@qwanyx/stack 0.2.16 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,6 +94,16 @@ export declare class MailClient {
94
94
  body: string;
95
95
  seen: boolean;
96
96
  } | null>;
97
+ /**
98
+ * Get a specific attachment from an email
99
+ * Returns base64-encoded content for download
100
+ */
101
+ getAttachment(accountId: string, uid: number, attachmentIndex: number, folder?: string): Promise<{
102
+ filename: string;
103
+ content_type: string;
104
+ size: number;
105
+ data: string;
106
+ } | null>;
97
107
  /**
98
108
  * Get email with client-side parsing using postal-mime
99
109
  * This handles CID embedded images by converting them to base64 data URIs
package/dist/index.cjs.js CHANGED
@@ -22,10 +22,10 @@ ${s}
22
22
  `}function mt(o){let e=[];if(o.from&&e.push(`<div class="postal-email-header-key">From</div><div class="postal-email-header-value">${yt(o.from)}</div>`),o.subject&&e.push(`<div class="postal-email-header-key">Subject</div><div class="postal-email-header-value postal-email-header-subject">${se(o.subject)}</div>`),o.date){let u={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},s=typeof Intl>"u"?o.date:new Intl.DateTimeFormat("default",u).format(new Date(o.date));e.push(`<div class="postal-email-header-key">Date</div><div class="postal-email-header-value postal-email-header-date" data-date="${se(o.date)}">${se(s)}</div>`)}return o.to&&o.to.length&&e.push(`<div class="postal-email-header-key">To</div><div class="postal-email-header-value">${Ke(o.to)}</div>`),o.cc&&o.cc.length&&e.push(`<div class="postal-email-header-key">Cc</div><div class="postal-email-header-value">${Ke(o.cc)}</div>`),o.bcc&&o.bcc.length&&e.push(`<div class="postal-email-header-key">Bcc</div><div class="postal-email-header-value">${Ke(o.bcc)}</div>`),`<div class="postal-email-header">${e.length?'<div class="postal-email-header-row">':""}${e.join(`</div>
23
23
  <div class="postal-email-header-row">`)}${e.length?"</div>":""}</div>`}function sr(o,e){let r=!1,u="text",s,n=[],t={address:[],comment:[],group:[],text:[],textWasQuoted:[]},i,l,c=!1;for(i=0,l=o.length;i<l;i++){let d=o[i],p=i?o[i-1]:null;if(d.type==="operator")switch(d.value){case"<":u="address",c=!1;break;case"(":u="comment",c=!1;break;case":":u="group",r=!0,c=!1;break;case'"':c=!c,u="text";break;default:u="text",c=!1;break}else d.value&&(u==="address"&&(d.value=d.value.replace(/^[^<]*<\s*/,"")),p&&p.noBreak&&t[u].length?(t[u][t[u].length-1]+=d.value,u==="text"&&c&&(t.textWasQuoted[t.textWasQuoted.length-1]=!0)):(t[u].push(d.value),u==="text"&&t.textWasQuoted.push(c)))}if(!t.text.length&&t.comment.length&&(t.text=t.comment,t.comment=[]),r){t.text=t.text.join(" ");let d=[];t.group.length&&Be(t.group.join(","),{_depth:e+1}).forEach(m=>{m.group?d=d.concat(m.group):d.push(m)}),n.push({name:Ce(t.text||s&&s.name),group:d})}else{if(!t.address.length&&t.text.length){for(i=t.text.length-1;i>=0;i--)if(!t.textWasQuoted[i]&&t.text[i].match(/^[^@\s]+@[^@\s]+$/)){t.address=t.text.splice(i,1),t.textWasQuoted.splice(i,1);break}let d=function(p){return t.address.length?p:(t.address=[p.trim()]," ")};if(!t.address.length)for(i=t.text.length-1;i>=0&&!(!t.textWasQuoted[i]&&(t.text[i]=t.text[i].replace(/\s*\b[^@\s]+@[^\s]+\b\s*/,d).trim(),t.address.length));i--);}if(!t.text.length&&t.comment.length&&(t.text=t.comment,t.comment=[]),t.address.length>1&&(t.text=t.text.concat(t.address.splice(1))),t.text=t.text.join(" "),t.address=t.address.join(" "),!t.address&&/^=\?[^=]+?=$/.test(t.text.trim())){const d=Be(Ce(t.text));if(d&&d.length)return d}if(!t.address&&r)return[];s={address:t.address||t.text||"",name:Ce(t.text||t.address||"")},s.address===s.name&&((s.address||"").match(/@/)?s.name="":s.address=""),n.push(s)}return n}class ar{constructor(e){this.str=(e||"").toString(),this.operatorCurrent="",this.operatorExpecting="",this.node=null,this.escaped=!1,this.list=[],this.operators={'"':'"',"(":")","<":">",",":"",":":";",";":""}}tokenize(){let e=[];for(let r=0,u=this.str.length;r<u;r++){let s=this.str.charAt(r),n=r<u-1?this.str.charAt(r+1):null;this.checkChar(s,n)}return this.list.forEach(r=>{r.value=(r.value||"").toString().trim(),r.value&&e.push(r)}),e}checkChar(e,r){if(!this.escaped){if(e===this.operatorExpecting){this.node={type:"operator",value:e},r&&![" "," ","\r",`
24
24
  `,",",";"].includes(r)&&(this.node.noBreak=!0),this.list.push(this.node),this.node=null,this.operatorExpecting="",this.escaped=!1;return}else if(!this.operatorExpecting&&e in this.operators){this.node={type:"operator",value:e},this.list.push(this.node),this.node=null,this.operatorExpecting=this.operators[e],this.escaped=!1;return}else if(['"',"'"].includes(this.operatorExpecting)&&e==="\\"){this.escaped=!0;return}}this.node||(this.node={type:"text",value:""},this.list.push(this.node)),e===`
25
- `&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const nr=50;function Be(o,e){e=e||{};let r=e._depth||0;if(r>nr)return[];let s=new ar(o).tokenize(),n=[],t=[],i=[];if(s.forEach(l=>{l.type==="operator"&&(l.value===","||l.value===";")?(t.length&&n.push(t),t=[]):t.push(l)}),t.length&&n.push(t),n.forEach(l=>{l=sr(l,r),l.length&&(i=i.concat(l))}),e.flatten){let l=[],c=d=>{d.forEach(p=>{if(p.group)return c(p.group);l.push(p)})};return c(i),l}return i}function ir(o){for(var e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=new Uint8Array(o),s=u.byteLength,n=s%3,t=s-n,i,l,c,d,p,m=0;m<t;m=m+3)p=u[m]<<16|u[m+1]<<8|u[m+2],i=(p&16515072)>>18,l=(p&258048)>>12,c=(p&4032)>>6,d=p&63,e+=r[i]+r[l]+r[c]+r[d];return n==1?(p=u[t],i=(p&252)>>2,l=(p&3)<<4,e+=r[i]+r[l]+"=="):n==2&&(p=u[t]<<8|u[t+1],i=(p&64512)>>10,l=(p&1008)>>4,c=(p&15)<<2,e+=r[i]+r[l]+r[c]+"="),e}const or=256,lr=2*1024*1024;class _e{static parse(e,r){return new _e(r).parse(e)}constructor(e){this.options=e||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||or,maxHeadersSize:this.options.maxHeadersSize||lr},this.root=this.currentNode=new pt({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(e,r){let u=this.boundaries;if(u.length&&e.length>2&&e[0]===45&&e[1]===45)for(let s=u.length-1;s>=0;s--){let n=u[s];if(e.length!==n.value.length+2&&e.length!==n.value.length+4)continue;let t=e.length===n.value.length+4;if(t&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let i=!0;for(let l=0;l<n.value.length;l++)if(e[l+2]!==n.value[l]){i=!1;break}if(i)return t?(await n.node.finalize(),this.currentNode=n.node.parentNode||this.root):(await n.node.finalizeChildNodes(),this.currentNode=new pt({postalMime:this,parentNode:n.node,...this.mimeOptions})),r?this.finalize():void 0}if(this.currentNode.feed(e),r)return this.finalize()}readLine(){let e=this.readPos,r=this.readPos,u=()=>({bytes:new Uint8Array(this.buf,e,r-e),done:this.readPos>=this.av.length});for(;this.readPos<this.av.length;){const s=this.av[this.readPos++];if(s!==13&&s!==10&&(r=this.readPos),s===10)return u()}return u()}async processNodeTree(){let e={},r=new Set,u=this.textMap=new Map,s=this.forceRfc822Attachments(),n=async(t,i,l)=>{if(i=i||!1,l=l||!1,t.contentType.multipart)t.contentType.multipart==="alternative"?i=t:t.contentType.multipart==="related"&&(l=t);else if(this.isInlineMessageRfc822(t)&&!s){const c=new _e;t.subMessage=await c.parse(t.content),u.has(t)||u.set(t,{});let d=u.get(t);(t.subMessage.text||!t.subMessage.html)&&(d.plain=d.plain||[],d.plain.push({type:"subMessage",value:t.subMessage}),r.add("plain")),t.subMessage.html&&(d.html=d.html||[],d.html.push({type:"subMessage",value:t.subMessage}),r.add("html")),c.textMap&&c.textMap.forEach((p,m)=>{u.set(m,p)});for(let p of t.subMessage.attachments||[])this.attachments.push(p)}else if(this.isInlineTextNode(t)){let c=t.contentType.parsed.value.substr(t.contentType.parsed.value.indexOf("/")+1),d=i||t;u.has(d)||u.set(d,{});let p=u.get(d);p[c]=p[c]||[],p[c].push({type:"text",value:t.getTextContent()}),r.add(c)}else if(t.content){const c=t.contentDisposition.parsed.params.filename||t.contentType.parsed.params.name||null,d={filename:c?Ce(c):null,mimeType:t.contentType.parsed.value,disposition:t.contentDisposition.parsed.value||null};switch(l&&t.contentId&&(d.related=!0),t.contentDescription&&(d.description=t.contentDescription),t.contentId&&(d.contentId=t.contentId),t.contentType.parsed.value){case"text/calendar":case"application/ics":{t.contentType.parsed.params.method&&(d.method=t.contentType.parsed.params.method.toString().toUpperCase().trim());const p=t.getTextContent().replace(/\r?\n/g,`
25
+ `&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const nr=50;function Be(o,e){e=e||{};let r=e._depth||0;if(r>nr)return[];let s=new ar(o).tokenize(),n=[],t=[],i=[];if(s.forEach(l=>{l.type==="operator"&&(l.value===","||l.value===";")?(t.length&&n.push(t),t=[]):t.push(l)}),t.length&&n.push(t),n.forEach(l=>{l=sr(l,r),l.length&&(i=i.concat(l))}),e.flatten){let l=[],c=d=>{d.forEach(p=>{if(p.group)return c(p.group);l.push(p)})};return c(i),l}return i}function ir(o){for(var e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=new Uint8Array(o),s=u.byteLength,n=s%3,t=s-n,i,l,c,d,p,m=0;m<t;m=m+3)p=u[m]<<16|u[m+1]<<8|u[m+2],i=(p&16515072)>>18,l=(p&258048)>>12,c=(p&4032)>>6,d=p&63,e+=r[i]+r[l]+r[c]+r[d];return n==1?(p=u[t],i=(p&252)>>2,l=(p&3)<<4,e+=r[i]+r[l]+"=="):n==2&&(p=u[t]<<8|u[t+1],i=(p&64512)>>10,l=(p&1008)>>4,c=(p&15)<<2,e+=r[i]+r[l]+r[c]+"="),e}const or=256,lr=2*1024*1024;class Re{static parse(e,r){return new Re(r).parse(e)}constructor(e){this.options=e||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||or,maxHeadersSize:this.options.maxHeadersSize||lr},this.root=this.currentNode=new pt({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(e,r){let u=this.boundaries;if(u.length&&e.length>2&&e[0]===45&&e[1]===45)for(let s=u.length-1;s>=0;s--){let n=u[s];if(e.length!==n.value.length+2&&e.length!==n.value.length+4)continue;let t=e.length===n.value.length+4;if(t&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let i=!0;for(let l=0;l<n.value.length;l++)if(e[l+2]!==n.value[l]){i=!1;break}if(i)return t?(await n.node.finalize(),this.currentNode=n.node.parentNode||this.root):(await n.node.finalizeChildNodes(),this.currentNode=new pt({postalMime:this,parentNode:n.node,...this.mimeOptions})),r?this.finalize():void 0}if(this.currentNode.feed(e),r)return this.finalize()}readLine(){let e=this.readPos,r=this.readPos,u=()=>({bytes:new Uint8Array(this.buf,e,r-e),done:this.readPos>=this.av.length});for(;this.readPos<this.av.length;){const s=this.av[this.readPos++];if(s!==13&&s!==10&&(r=this.readPos),s===10)return u()}return u()}async processNodeTree(){let e={},r=new Set,u=this.textMap=new Map,s=this.forceRfc822Attachments(),n=async(t,i,l)=>{if(i=i||!1,l=l||!1,t.contentType.multipart)t.contentType.multipart==="alternative"?i=t:t.contentType.multipart==="related"&&(l=t);else if(this.isInlineMessageRfc822(t)&&!s){const c=new Re;t.subMessage=await c.parse(t.content),u.has(t)||u.set(t,{});let d=u.get(t);(t.subMessage.text||!t.subMessage.html)&&(d.plain=d.plain||[],d.plain.push({type:"subMessage",value:t.subMessage}),r.add("plain")),t.subMessage.html&&(d.html=d.html||[],d.html.push({type:"subMessage",value:t.subMessage}),r.add("html")),c.textMap&&c.textMap.forEach((p,m)=>{u.set(m,p)});for(let p of t.subMessage.attachments||[])this.attachments.push(p)}else if(this.isInlineTextNode(t)){let c=t.contentType.parsed.value.substr(t.contentType.parsed.value.indexOf("/")+1),d=i||t;u.has(d)||u.set(d,{});let p=u.get(d);p[c]=p[c]||[],p[c].push({type:"text",value:t.getTextContent()}),r.add(c)}else if(t.content){const c=t.contentDisposition.parsed.params.filename||t.contentType.parsed.params.name||null,d={filename:c?Ce(c):null,mimeType:t.contentType.parsed.value,disposition:t.contentDisposition.parsed.value||null};switch(l&&t.contentId&&(d.related=!0),t.contentDescription&&(d.description=t.contentDescription),t.contentId&&(d.contentId=t.contentId),t.contentType.parsed.value){case"text/calendar":case"application/ics":{t.contentType.parsed.params.method&&(d.method=t.contentType.parsed.params.method.toString().toUpperCase().trim());const p=t.getTextContent().replace(/\r?\n/g,`
26
26
  `).replace(/\n*$/,`
27
27
  `);d.content=fe.encode(p);break}default:d.content=t.content}this.attachments.push(d)}for(let c of t.childNodes)await n(c,i,l)};await n(this.root,!1,[]),u.forEach(t=>{r.forEach(i=>{if(e[i]||(e[i]=[]),t[i])t[i].forEach(l=>{switch(l.type){case"text":e[i].push(l.value);break;case"subMessage":switch(i){case"html":e[i].push(mt(l.value));break;case"plain":e[i].push(gt(l.value));break}break}});else{let l;switch(i){case"html":l="plain";break;case"plain":l="html";break}(t[l]||[]).forEach(c=>{switch(c.type){case"text":switch(i){case"html":e[i].push(tr(c.value));break;case"plain":e[i].push(rr(c.value));break}break;case"subMessage":switch(i){case"html":e[i].push(mt(c.value));break;case"plain":e[i].push(gt(c.value));break}break}})}})}),Object.keys(e).forEach(t=>{e[t]=e[t].join(`
28
- `)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,r=u=>{u.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(u.contentType.parsed.value)&&(e=!0);for(let s of u.childNodes)r(s)};return r(this.root),e}async resolveStream(e){let r=0,u=[];const s=e.getReader();for(;;){const{done:i,value:l}=await s.read();if(i)break;u.push(l),r+=l.length}const n=new Uint8Array(r);let t=0;for(let i of u)n.set(i,t),t+=i.length;return n}async parse(e){var s,n;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=fe.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await Oe(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const t=this.readLine();await this.processLine(t.bytes,t.done)}await this.processNodeTree();const r={headers:this.root.headers.map(t=>({key:t.key,value:t.value})).reverse()};for(const t of["from","sender"]){const i=this.root.headers.find(l=>l.key===t);if(i&&i.value){const l=Be(i.value);l&&l.length&&(r[t]=l[0])}}for(const t of["delivered-to","return-path"]){const i=this.root.headers.find(l=>l.key===t);if(i&&i.value){const l=Be(i.value);if(l&&l.length&&l[0].address){const c=t.replace(/\-(.)/g,(d,p)=>p.toUpperCase());r[c]=l[0].address}}}for(const t of["to","cc","bcc","reply-to"]){const i=this.root.headers.filter(c=>c.key===t);let l=[];if(i.filter(c=>c&&c.value).map(c=>Be(c.value)).forEach(c=>l=l.concat(c||[])),l&&l.length){const c=t.replace(/\-(.)/g,(d,p)=>p.toUpperCase());r[c]=l}}for(const t of["subject","message-id","in-reply-to","references"]){const i=this.root.headers.find(l=>l.key===t);if(i&&i.value){const l=t.replace(/\-(.)/g,(c,d)=>d.toUpperCase());r[l]=Ce(i.value)}}let u=this.root.headers.find(t=>t.key==="date");if(u){let t=new Date(u.value);!t||t.toString()==="Invalid Date"?t=u.value:t=t.toISOString(),r.date=t}switch((s=this.textContent)!=null&&s.html&&(r.html=this.textContent.html),(n=this.textContent)!=null&&n.plain&&(r.text=this.textContent.plain),r.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let i of r.attachments||[])i!=null&&i.content&&(i.content=ir(i.content),i.encoding="base64");break;case"utf8":let t=new TextDecoder("utf8");for(let i of r.attachments||[])i!=null&&i.content&&(i.content=t.decode(i.content),i.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return r}}class xt{constructor(e){ye(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,r,u={}){const s={coprocessor:e,method:r,system_id:this.config.system_id,params:{user_id:this.config.system_id,...u}};try{const n=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!n.ok){const i=await n.text();throw new Error(`API error (${n.status}): ${i}`)}const t=await n.json();if(!t.success&&t.error)throw new Error(t.error);return t.result}catch(n){throw console.error("API call failed:",n),n}}async callMail(e,r={}){return this.callCoprocessor("mail",e,r)}async callEmail(e,r={}){return this.callCoprocessor("email",e,r)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,r=20,u){return this.callMail("list_emails",{account_id:e,limit:r,folder:u})}async deleteEmails(e,r,u=!0){return this.callMail("delete_emails",{account_id:e,uids:r,expunge:u})}async imapExec(e,r){return this.callMail("imap_exec",{account_id:e,commands:r})}async trashEmails(e,r){const u=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const s of u){const n=["SELECT INBOX",...r.map(l=>`UID MOVE ${l} ${s}`)],i=(await this.imapExec(e,n)).responses.filter(l=>l.ok&&l.command==="UID MOVE").length;if(i>0)return{success:!0,moved:i}}return{success:!1,moved:0}}async archiveEmails(e,r){const u=["SELECT INBOX",...r.map(t=>`UID STORE ${t} +FLAGS (\\Deleted)`),"EXPUNGE"],n=(await this.imapExec(e,u)).responses.filter(t=>t.ok&&t.command==="UID STORE").length;return{success:n>0,archived:n}}async listFolders(e){const u=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return u!=null&&u.ok&&u.folders?{success:!0,folders:u.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,r="INBOX",u=20){const s=await this.imapExec(e,[`SELECT ${r}`,"FETCH 1:* (UID INTERNALDATE)"]),n=s.responses.find(D=>D.command==="SELECT");if(!(n!=null&&n.ok))throw new Error(`Failed to select folder: ${(n==null?void 0:n.error)||"Unknown error"}`);const t=s.responses.find(D=>D.command==="FETCH");if(!(t!=null&&t.ok)||!t.messages)return{account:{id:e,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:[]};const l=[...t.messages].sort((D,w)=>{const k=D.internalDate?new Date(D.internalDate).getTime():0;return(w.internalDate?new Date(w.internalDate).getTime():0)-k}).slice(0,u).map(D=>D.uid).filter(Boolean);if(l.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:[]};const d=(await this.imapExec(e,[`SELECT ${r}`,`UID FETCH ${l.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(D=>D.command==="UID FETCH");if(!(d!=null&&d.ok)||!d.messages)throw new Error(`Failed to fetch details: ${(d==null?void 0:d.error)||"Unknown error"}`);const p=new Map;for(const D of d.messages)D.uid&&p.set(D.uid,D);const m=l.map(D=>{var U,g,F,y,N;const w=p.get(D);if(!w)return null;const k=((U=w.flags)==null?void 0:U.some(P=>P.includes("Seen")))||!1,M=((F=(g=w.envelope)==null?void 0:g.from)==null?void 0:F.email)||"Unknown",O=((y=w.envelope)==null?void 0:y.subject)||"(No subject)",B=((N=w.envelope)==null?void 0:N.date)||"";return{uid:D,from:M,subject:O,date:B,seen:k}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:m}}async getEmail(e,r,u="INBOX"){return this.callMail("get_email",{account_id:e,uid:r,folder:u})}async getEmailParsed(e,r,u="INBOX"){var w,k,M,O;const n=(await this.imapExec(e,[`SELECT "${u}"`,`UID FETCH ${r} (FLAGS BODY[])`])).responses.find(B=>B.command==="UID FETCH");if(!(n!=null&&n.ok)||!((w=n.messages)!=null&&w[0]))return console.error("Failed to fetch raw email:",n==null?void 0:n.error),null;const t=n.messages[0],i=t.body||t.raw;if(!i)return console.error("No raw email content in response"),null;const c=await new _e().parse(i),d=new Map;for(const B of c.attachments||[])if(B.contentId){const U=this.contentToBase64(B.content),g=`data:${B.mimeType};base64,${U}`,F=B.contentId.replace(/^<|>$/g,"");d.set(F,g),d.set(`<${F}>`,g)}let p=c.html||"";p&&d.size>0&&(p=p.replace(/src=["']cid:([^"']+)["']/gi,(B,U)=>{const g=d.get(U)||d.get(`<${U}>`);return g?`src="${g}"`:B}));const m=((k=t.flags)==null?void 0:k.some(B=>B.toLowerCase().includes("seen")))||!1,D=((M=c.from)==null?void 0:M.address)||((O=c.from)==null?void 0:O.name)||"Unknown";return{uid:r,from:D,subject:c.subject||"(No subject)",date:c.date||"",body:p||c.text||"",html:p,text:c.text||"",seen:m,attachments:(c.attachments||[]).map(B=>({filename:B.filename||"attachment",mimeType:B.mimeType||"application/octet-stream",size:this.getContentSize(B.content)}))}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const r=e instanceof Uint8Array?e:new Uint8Array(e);let u="";for(let s=0;s<r.byteLength;s++)u+=String.fromCharCode(r[s]);return btoa(u)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const r={to:e.to,subject:e.subject,body:e.body};return e.html&&(r.html=e.html),e.from&&(r.from=e.from),e.smtpConfig&&(r.smtp_config=e.smtpConfig),this.callEmail("send",r)}}const Xe="qwanyx_auth_token",Ze="qwanyx_refresh_token";class vt{static setToken(e){typeof window<"u"&&localStorage.setItem(Xe,e)}static getToken(){return typeof window<"u"?localStorage.getItem(Xe):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Xe),localStorage.removeItem(Ze))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(Ze,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Ze):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}}class Et{constructor(e){ye(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const r=new URLSearchParams;Object.entries(e).forEach(([s,n])=>{n!=null&&r.append(s,String(n))});const u=r.toString();return u?`?${u}`:""}async request(e,r={}){const{method:u="GET",headers:s={},body:n,params:t}=r,i=`${this.config.baseUrl}/${e}${this.buildQueryString(t)}`,l={...this.config.headers,...vt.getAuthHeader(),...s},c={method:u,headers:l};n&&u!=="GET"&&(c.body=JSON.stringify(n));try{const d=new AbortController,p=setTimeout(()=>d.abort(),this.config.timeout),m=await fetch(i,{...c,signal:d.signal});if(clearTimeout(p),!m.ok){const D=await m.json().catch(()=>({message:m.statusText}));throw new Error(D.message||`HTTP ${m.status}`)}return await m.json()}catch(d){throw d instanceof Error?d:new Error("An unexpected error occurred")}}async get(e,r){return this.request(e,{method:"GET",params:r})}async post(e,r,u){return this.request(e,{method:"POST",body:r,params:u})}async put(e,r,u){return this.request(e,{method:"PUT",body:r,params:u})}async patch(e,r,u){return this.request(e,{method:"PATCH",body:r,params:u})}async delete(e,r){return this.request(e,{method:"DELETE",params:r})}setBaseUrl(e){this.config.baseUrl=e}getBaseUrl(){return this.config.baseUrl}}let Le=null;function cr(o){return Le=new Et(o),Le}function rt(){if(!Le)throw new Error("API client not initialized. Call initializeApiClient() first.");return Le}function wt(o,e,r={}){const{enabled:u=!0,refetchOnMount:s=!0,onSuccess:n,onError:t}=r,[i,l]=x.useState(null),[c,d]=x.useState(u),[p,m]=x.useState(null),D=x.useCallback(async()=>{if(u){d(!0),m(null);try{const k=await rt().get(o,e);l(k),n==null||n(k)}catch(w){const k=w instanceof Error?w:new Error("Unknown error");m(k),t==null||t(k)}finally{d(!1)}}},[o,JSON.stringify(e),u,n,t]);return x.useEffect(()=>{s&&D()},[D,s]),{data:i,loading:c,error:p,refetch:D}}function dr(o,e="POST",r={}){const{onSuccess:u,onError:s}=r,[n,t]=x.useState(null),[i,l]=x.useState(!1),[c,d]=x.useState(null),p=x.useCallback(async D=>{l(!0),d(null);try{const w=rt();let k;switch(e){case"POST":k=await w.post(o,D);break;case"PUT":k=await w.put(o,D);break;case"PATCH":k=await w.patch(o,D);break;case"DELETE":k=await w.delete(o);break;default:throw new Error(`Unsupported method: ${e}`)}return t(k),u==null||u(k,D),k}catch(w){const k=w instanceof Error?w:new Error("Unknown error");return d(k),s==null||s(k,D),null}finally{l(!1)}},[o,e,u,s]),m=x.useCallback(()=>{t(null),d(null),l(!1)},[]);return{data:n,loading:i,error:c,mutate:p,reset:m}}var tt={exports:{}},xe={};/**
28
+ `)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,r=u=>{u.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(u.contentType.parsed.value)&&(e=!0);for(let s of u.childNodes)r(s)};return r(this.root),e}async resolveStream(e){let r=0,u=[];const s=e.getReader();for(;;){const{done:i,value:l}=await s.read();if(i)break;u.push(l),r+=l.length}const n=new Uint8Array(r);let t=0;for(let i of u)n.set(i,t),t+=i.length;return n}async parse(e){var s,n;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=fe.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await Oe(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const t=this.readLine();await this.processLine(t.bytes,t.done)}await this.processNodeTree();const r={headers:this.root.headers.map(t=>({key:t.key,value:t.value})).reverse()};for(const t of["from","sender"]){const i=this.root.headers.find(l=>l.key===t);if(i&&i.value){const l=Be(i.value);l&&l.length&&(r[t]=l[0])}}for(const t of["delivered-to","return-path"]){const i=this.root.headers.find(l=>l.key===t);if(i&&i.value){const l=Be(i.value);if(l&&l.length&&l[0].address){const c=t.replace(/\-(.)/g,(d,p)=>p.toUpperCase());r[c]=l[0].address}}}for(const t of["to","cc","bcc","reply-to"]){const i=this.root.headers.filter(c=>c.key===t);let l=[];if(i.filter(c=>c&&c.value).map(c=>Be(c.value)).forEach(c=>l=l.concat(c||[])),l&&l.length){const c=t.replace(/\-(.)/g,(d,p)=>p.toUpperCase());r[c]=l}}for(const t of["subject","message-id","in-reply-to","references"]){const i=this.root.headers.find(l=>l.key===t);if(i&&i.value){const l=t.replace(/\-(.)/g,(c,d)=>d.toUpperCase());r[l]=Ce(i.value)}}let u=this.root.headers.find(t=>t.key==="date");if(u){let t=new Date(u.value);!t||t.toString()==="Invalid Date"?t=u.value:t=t.toISOString(),r.date=t}switch((s=this.textContent)!=null&&s.html&&(r.html=this.textContent.html),(n=this.textContent)!=null&&n.plain&&(r.text=this.textContent.plain),r.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let i of r.attachments||[])i!=null&&i.content&&(i.content=ir(i.content),i.encoding="base64");break;case"utf8":let t=new TextDecoder("utf8");for(let i of r.attachments||[])i!=null&&i.content&&(i.content=t.decode(i.content),i.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return r}}class xt{constructor(e){ye(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,r,u={}){const s={coprocessor:e,method:r,system_id:this.config.system_id,params:{user_id:this.config.system_id,...u}};try{const n=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!n.ok){const i=await n.text();throw new Error(`API error (${n.status}): ${i}`)}const t=await n.json();if(!t.success&&t.error)throw new Error(t.error);return t.result}catch(n){throw console.error("API call failed:",n),n}}async callMail(e,r={}){return this.callCoprocessor("mail",e,r)}async callEmail(e,r={}){return this.callCoprocessor("email",e,r)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,r=20,u){return this.callMail("list_emails",{account_id:e,limit:r,folder:u})}async deleteEmails(e,r,u=!0){return this.callMail("delete_emails",{account_id:e,uids:r,expunge:u})}async imapExec(e,r){return this.callMail("imap_exec",{account_id:e,commands:r})}async trashEmails(e,r){const u=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const s of u){const n=["SELECT INBOX",...r.map(l=>`UID MOVE ${l} ${s}`)],i=(await this.imapExec(e,n)).responses.filter(l=>l.ok&&l.command==="UID MOVE").length;if(i>0)return{success:!0,moved:i}}return{success:!1,moved:0}}async archiveEmails(e,r){const u=["SELECT INBOX",...r.map(t=>`UID STORE ${t} +FLAGS (\\Deleted)`),"EXPUNGE"],n=(await this.imapExec(e,u)).responses.filter(t=>t.ok&&t.command==="UID STORE").length;return{success:n>0,archived:n}}async listFolders(e){const u=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return u!=null&&u.ok&&u.folders?{success:!0,folders:u.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,r="INBOX",u=20){const s=await this.imapExec(e,[`SELECT ${r}`,"FETCH 1:* (UID INTERNALDATE)"]),n=s.responses.find(D=>D.command==="SELECT");if(!(n!=null&&n.ok))throw new Error(`Failed to select folder: ${(n==null?void 0:n.error)||"Unknown error"}`);const t=s.responses.find(D=>D.command==="FETCH");if(!(t!=null&&t.ok)||!t.messages)return{account:{id:e,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:[]};const l=[...t.messages].sort((D,w)=>{const k=D.internalDate?new Date(D.internalDate).getTime():0;return(w.internalDate?new Date(w.internalDate).getTime():0)-k}).slice(0,u).map(D=>D.uid).filter(Boolean);if(l.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:[]};const d=(await this.imapExec(e,[`SELECT ${r}`,`UID FETCH ${l.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(D=>D.command==="UID FETCH");if(!(d!=null&&d.ok)||!d.messages)throw new Error(`Failed to fetch details: ${(d==null?void 0:d.error)||"Unknown error"}`);const p=new Map;for(const D of d.messages)D.uid&&p.set(D.uid,D);const m=l.map(D=>{var U,g,F,y,N;const w=p.get(D);if(!w)return null;const k=((U=w.flags)==null?void 0:U.some(P=>P.includes("Seen")))||!1,M=((F=(g=w.envelope)==null?void 0:g.from)==null?void 0:F.email)||"Unknown",O=((y=w.envelope)==null?void 0:y.subject)||"(No subject)",B=((N=w.envelope)==null?void 0:N.date)||"";return{uid:D,from:M,subject:O,date:B,seen:k}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:m}}async getEmail(e,r,u="INBOX"){return this.callMail("get_email",{account_id:e,uid:r,folder:u})}async getAttachment(e,r,u,s="INBOX"){return this.callMail("get_attachment",{account_id:e,uid:r,attachment_index:u,folder:s})}async getEmailParsed(e,r,u="INBOX"){var w,k,M,O;const n=(await this.imapExec(e,[`SELECT "${u}"`,`UID FETCH ${r} (FLAGS BODY[])`])).responses.find(B=>B.command==="UID FETCH");if(!(n!=null&&n.ok)||!((w=n.messages)!=null&&w[0]))return console.error("Failed to fetch raw email:",n==null?void 0:n.error),null;const t=n.messages[0],i=t.body||t.raw;if(!i)return console.error("No raw email content in response"),null;const c=await new Re().parse(i),d=new Map;for(const B of c.attachments||[])if(B.contentId){const U=this.contentToBase64(B.content),g=`data:${B.mimeType};base64,${U}`,F=B.contentId.replace(/^<|>$/g,"");d.set(F,g),d.set(`<${F}>`,g)}let p=c.html||"";p&&d.size>0&&(p=p.replace(/src=["']cid:([^"']+)["']/gi,(B,U)=>{const g=d.get(U)||d.get(`<${U}>`);return g?`src="${g}"`:B}));const m=((k=t.flags)==null?void 0:k.some(B=>B.toLowerCase().includes("seen")))||!1,D=((M=c.from)==null?void 0:M.address)||((O=c.from)==null?void 0:O.name)||"Unknown";return{uid:r,from:D,subject:c.subject||"(No subject)",date:c.date||"",body:p||c.text||"",html:p,text:c.text||"",seen:m,attachments:(c.attachments||[]).map(B=>({filename:B.filename||"attachment",mimeType:B.mimeType||"application/octet-stream",size:this.getContentSize(B.content)}))}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const r=e instanceof Uint8Array?e:new Uint8Array(e);let u="";for(let s=0;s<r.byteLength;s++)u+=String.fromCharCode(r[s]);return btoa(u)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const r={to:e.to,subject:e.subject,body:e.body};return e.html&&(r.html=e.html),e.from&&(r.from=e.from),e.smtpConfig&&(r.smtp_config=e.smtpConfig),this.callEmail("send",r)}}const Xe="qwanyx_auth_token",Ze="qwanyx_refresh_token";class vt{static setToken(e){typeof window<"u"&&localStorage.setItem(Xe,e)}static getToken(){return typeof window<"u"?localStorage.getItem(Xe):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Xe),localStorage.removeItem(Ze))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(Ze,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Ze):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}}class Et{constructor(e){ye(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const r=new URLSearchParams;Object.entries(e).forEach(([s,n])=>{n!=null&&r.append(s,String(n))});const u=r.toString();return u?`?${u}`:""}async request(e,r={}){const{method:u="GET",headers:s={},body:n,params:t}=r,i=`${this.config.baseUrl}/${e}${this.buildQueryString(t)}`,l={...this.config.headers,...vt.getAuthHeader(),...s},c={method:u,headers:l};n&&u!=="GET"&&(c.body=JSON.stringify(n));try{const d=new AbortController,p=setTimeout(()=>d.abort(),this.config.timeout),m=await fetch(i,{...c,signal:d.signal});if(clearTimeout(p),!m.ok){const D=await m.json().catch(()=>({message:m.statusText}));throw new Error(D.message||`HTTP ${m.status}`)}return await m.json()}catch(d){throw d instanceof Error?d:new Error("An unexpected error occurred")}}async get(e,r){return this.request(e,{method:"GET",params:r})}async post(e,r,u){return this.request(e,{method:"POST",body:r,params:u})}async put(e,r,u){return this.request(e,{method:"PUT",body:r,params:u})}async patch(e,r,u){return this.request(e,{method:"PATCH",body:r,params:u})}async delete(e,r){return this.request(e,{method:"DELETE",params:r})}setBaseUrl(e){this.config.baseUrl=e}getBaseUrl(){return this.config.baseUrl}}let Le=null;function cr(o){return Le=new Et(o),Le}function rt(){if(!Le)throw new Error("API client not initialized. Call initializeApiClient() first.");return Le}function wt(o,e,r={}){const{enabled:u=!0,refetchOnMount:s=!0,onSuccess:n,onError:t}=r,[i,l]=x.useState(null),[c,d]=x.useState(u),[p,m]=x.useState(null),D=x.useCallback(async()=>{if(u){d(!0),m(null);try{const k=await rt().get(o,e);l(k),n==null||n(k)}catch(w){const k=w instanceof Error?w:new Error("Unknown error");m(k),t==null||t(k)}finally{d(!1)}}},[o,JSON.stringify(e),u,n,t]);return x.useEffect(()=>{s&&D()},[D,s]),{data:i,loading:c,error:p,refetch:D}}function dr(o,e="POST",r={}){const{onSuccess:u,onError:s}=r,[n,t]=x.useState(null),[i,l]=x.useState(!1),[c,d]=x.useState(null),p=x.useCallback(async D=>{l(!0),d(null);try{const w=rt();let k;switch(e){case"POST":k=await w.post(o,D);break;case"PUT":k=await w.put(o,D);break;case"PATCH":k=await w.patch(o,D);break;case"DELETE":k=await w.delete(o);break;default:throw new Error(`Unsupported method: ${e}`)}return t(k),u==null||u(k,D),k}catch(w){const k=w instanceof Error?w:new Error("Unknown error");return d(k),s==null||s(k,D),null}finally{l(!1)}},[o,e,u,s]),m=x.useCallback(()=>{t(null),d(null),l(!1)},[]);return{data:n,loading:i,error:c,mutate:p,reset:m}}var tt={exports:{}},xe={};/**
29
29
  * @license React
30
30
  * react-jsx-runtime.production.min.js
31
31
  *
@@ -41,21 +41,21 @@ ${s}
41
41
  *
42
42
  * This source code is licensed under the MIT license found in the
43
43
  * LICENSE file in the root directory of this source tree.
44
- */var At;function pr(){return At||(At=1,process.env.NODE_ENV!=="production"&&function(){var o=x,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),w=Symbol.iterator,k="@@iterator";function M(a){if(a===null||typeof a!="object")return null;var h=w&&a[w]||a[k];return typeof h=="function"?h:null}var O=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function B(a){{for(var h=arguments.length,A=new Array(h>1?h-1:0),E=1;E<h;E++)A[E-1]=arguments[E];U("error",a,A)}}function U(a,h,A){{var E=O.ReactDebugCurrentFrame,_=E.getStackAddendum();_!==""&&(h+="%s",A=A.concat([_]));var L=A.map(function(q){return String(q)});L.unshift("Warning: "+h),Function.prototype.apply.call(console[a],console,L)}}var g=!1,F=!1,y=!1,N=!1,P=!1,T;T=Symbol.for("react.module.reference");function R(a){return!!(typeof a=="string"||typeof a=="function"||a===u||a===n||P||a===s||a===c||a===d||N||a===D||g||F||y||typeof a=="object"&&a!==null&&(a.$$typeof===m||a.$$typeof===p||a.$$typeof===t||a.$$typeof===i||a.$$typeof===l||a.$$typeof===T||a.getModuleId!==void 0))}function v(a,h,A){var E=a.displayName;if(E)return E;var _=h.displayName||h.name||"";return _!==""?A+"("+_+")":A}function H(a){return a.displayName||"Context"}function z(a){if(a==null)return null;if(typeof a.tag=="number"&&B("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case u:return"Fragment";case r:return"Portal";case n:return"Profiler";case s:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case i:var h=a;return H(h)+".Consumer";case t:var A=a;return H(A._context)+".Provider";case l:return v(a,a.render,"ForwardRef");case p:var E=a.displayName||null;return E!==null?E:z(a.type)||"Memo";case m:{var _=a,L=_._payload,q=_._init;try{return z(q(L))}catch{return null}}}return null}var j=Object.assign,G=0,J,pe,he,ke,ge,V,te;function ae(){}ae.__reactDisabledLog=!0;function Pe(){{if(G===0){J=console.log,pe=console.info,he=console.warn,ke=console.error,ge=console.group,V=console.groupCollapsed,te=console.groupEnd;var a={configurable:!0,enumerable:!0,value:ae,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}G++}}function Ue(){{if(G--,G===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},a,{value:J}),info:j({},a,{value:pe}),warn:j({},a,{value:he}),error:j({},a,{value:ke}),group:j({},a,{value:ge}),groupCollapsed:j({},a,{value:V}),groupEnd:j({},a,{value:te})})}G<0&&B("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var me=O.ReactCurrentDispatcher,De;function ne(a,h,A){{if(De===void 0)try{throw Error()}catch(_){var E=_.stack.trim().match(/\n( *(at )?)/);De=E&&E[1]||""}return`
45
- `+De+a}}var Ae=!1,ie;{var Ie=typeof WeakMap=="function"?WeakMap:Map;ie=new Ie}function Fe(a,h){if(!a||Ae)return"";{var A=ie.get(a);if(A!==void 0)return A}var E;Ae=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var L;L=me.current,me.current=null,Pe();try{if(h){var q=function(){throw Error()};if(Object.defineProperty(q.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(q,[])}catch(Q){E=Q}Reflect.construct(a,[],q)}else{try{q.call()}catch(Q){E=Q}a.call(q.prototype)}}else{try{throw Error()}catch(Q){E=Q}a()}}catch(Q){if(Q&&E&&typeof Q.stack=="string"){for(var S=Q.stack.split(`
44
+ */var At;function pr(){return At||(At=1,process.env.NODE_ENV!=="production"&&function(){var o=x,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),w=Symbol.iterator,k="@@iterator";function M(a){if(a===null||typeof a!="object")return null;var h=w&&a[w]||a[k];return typeof h=="function"?h:null}var O=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function B(a){{for(var h=arguments.length,A=new Array(h>1?h-1:0),E=1;E<h;E++)A[E-1]=arguments[E];U("error",a,A)}}function U(a,h,A){{var E=O.ReactDebugCurrentFrame,R=E.getStackAddendum();R!==""&&(h+="%s",A=A.concat([R]));var L=A.map(function(q){return String(q)});L.unshift("Warning: "+h),Function.prototype.apply.call(console[a],console,L)}}var g=!1,F=!1,y=!1,N=!1,P=!1,T;T=Symbol.for("react.module.reference");function _(a){return!!(typeof a=="string"||typeof a=="function"||a===u||a===n||P||a===s||a===c||a===d||N||a===D||g||F||y||typeof a=="object"&&a!==null&&(a.$$typeof===m||a.$$typeof===p||a.$$typeof===t||a.$$typeof===i||a.$$typeof===l||a.$$typeof===T||a.getModuleId!==void 0))}function v(a,h,A){var E=a.displayName;if(E)return E;var R=h.displayName||h.name||"";return R!==""?A+"("+R+")":A}function H(a){return a.displayName||"Context"}function z(a){if(a==null)return null;if(typeof a.tag=="number"&&B("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case u:return"Fragment";case r:return"Portal";case n:return"Profiler";case s:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case i:var h=a;return H(h)+".Consumer";case t:var A=a;return H(A._context)+".Provider";case l:return v(a,a.render,"ForwardRef");case p:var E=a.displayName||null;return E!==null?E:z(a.type)||"Memo";case m:{var R=a,L=R._payload,q=R._init;try{return z(q(L))}catch{return null}}}return null}var j=Object.assign,G=0,J,pe,he,ke,ge,V,te;function ae(){}ae.__reactDisabledLog=!0;function Pe(){{if(G===0){J=console.log,pe=console.info,he=console.warn,ke=console.error,ge=console.group,V=console.groupCollapsed,te=console.groupEnd;var a={configurable:!0,enumerable:!0,value:ae,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}G++}}function Ue(){{if(G--,G===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},a,{value:J}),info:j({},a,{value:pe}),warn:j({},a,{value:he}),error:j({},a,{value:ke}),group:j({},a,{value:ge}),groupCollapsed:j({},a,{value:V}),groupEnd:j({},a,{value:te})})}G<0&&B("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var me=O.ReactCurrentDispatcher,De;function ne(a,h,A){{if(De===void 0)try{throw Error()}catch(R){var E=R.stack.trim().match(/\n( *(at )?)/);De=E&&E[1]||""}return`
45
+ `+De+a}}var Ae=!1,ie;{var Ie=typeof WeakMap=="function"?WeakMap:Map;ie=new Ie}function Fe(a,h){if(!a||Ae)return"";{var A=ie.get(a);if(A!==void 0)return A}var E;Ae=!0;var R=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var L;L=me.current,me.current=null,Pe();try{if(h){var q=function(){throw Error()};if(Object.defineProperty(q.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(q,[])}catch(Q){E=Q}Reflect.construct(a,[],q)}else{try{q.call()}catch(Q){E=Q}a.call(q.prototype)}}else{try{throw Error()}catch(Q){E=Q}a()}}catch(Q){if(Q&&E&&typeof Q.stack=="string"){for(var S=Q.stack.split(`
46
46
  `),W=E.stack.split(`
47
47
  `),I=S.length-1,$=W.length-1;I>=1&&$>=0&&S[I]!==W[$];)$--;for(;I>=1&&$>=0;I--,$--)if(S[I]!==W[$]){if(I!==1||$!==1)do if(I--,$--,$<0||S[I]!==W[$]){var X=`
48
- `+S[I].replace(" at new "," at ");return a.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",a.displayName)),typeof a=="function"&&ie.set(a,X),X}while(I>=1&&$>=0);break}}}finally{Ae=!1,me.current=L,Ue(),Error.prepareStackTrace=_}var de=a?a.displayName||a.name:"",ue=de?ne(de):"";return typeof a=="function"&&ie.set(a,ue),ue}function $e(a,h,A){return Fe(a,!1)}function Me(a){var h=a.prototype;return!!(h&&h.isReactComponent)}function oe(a,h,A){if(a==null)return"";if(typeof a=="function")return Fe(a,Me(a));if(typeof a=="string")return ne(a);switch(a){case c:return ne("Suspense");case d:return ne("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case l:return $e(a.render);case p:return oe(a.type,h,A);case m:{var E=a,_=E._payload,L=E._init;try{return oe(L(_),h,A)}catch{}}}return""}var re=Object.prototype.hasOwnProperty,Te={},Se=O.ReactDebugCurrentFrame;function le(a){if(a){var h=a._owner,A=oe(a.type,a._source,h?h.type:null);Se.setExtraStackFrame(A)}else Se.setExtraStackFrame(null)}function ze(a,h,A,E,_){{var L=Function.call.bind(re);for(var q in a)if(L(a,q)){var S=void 0;try{if(typeof a[q]!="function"){var W=Error((E||"React class")+": "+A+" type `"+q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[q]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}S=a[q](h,q,E,A,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(I){S=I}S&&!(S instanceof Error)&&(le(_),B("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",E||"React class",A,q,typeof S),le(null)),S instanceof Error&&!(S.message in Te)&&(Te[S.message]=!0,le(_),B("Failed %s type: %s",A,S.message),le(null))}}}var Ge=Array.isArray;function b(a){return Ge(a)}function C(a){{var h=typeof Symbol=="function"&&Symbol.toStringTag,A=h&&a[Symbol.toStringTag]||a.constructor.name||"Object";return A}}function Y(a){try{return K(a),!1}catch{return!0}}function K(a){return""+a}function ee(a){if(Y(a))return B("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",C(a)),K(a)}var Z=O.ReactCurrentOwner,He={key:!0,ref:!0,__self:!0,__source:!0},be,je;function Ct(a){if(re.call(a,"ref")){var h=Object.getOwnPropertyDescriptor(a,"ref").get;if(h&&h.isReactWarning)return!1}return a.ref!==void 0}function Bt(a){if(re.call(a,"key")){var h=Object.getOwnPropertyDescriptor(a,"key").get;if(h&&h.isReactWarning)return!1}return a.key!==void 0}function kt(a,h){typeof a.ref=="string"&&Z.current}function Ft(a,h){{var A=function(){be||(be=!0,B("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",h))};A.isReactWarning=!0,Object.defineProperty(a,"key",{get:A,configurable:!0})}}function Tt(a,h){{var A=function(){je||(je=!0,B("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",h))};A.isReactWarning=!0,Object.defineProperty(a,"ref",{get:A,configurable:!0})}}var St=function(a,h,A,E,_,L,q){var S={$$typeof:e,type:a,key:h,ref:A,props:q,_owner:L};return S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(S,"_self",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.defineProperty(S,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function jt(a,h,A,E,_){{var L,q={},S=null,W=null;A!==void 0&&(ee(A),S=""+A),Bt(h)&&(ee(h.key),S=""+h.key),Ct(h)&&(W=h.ref,kt(h,_));for(L in h)re.call(h,L)&&!He.hasOwnProperty(L)&&(q[L]=h[L]);if(a&&a.defaultProps){var I=a.defaultProps;for(L in I)q[L]===void 0&&(q[L]=I[L])}if(S||W){var $=typeof a=="function"?a.displayName||a.name||"Unknown":a;S&&Ft(q,$),W&&Tt(q,$)}return St(a,S,W,_,E,Z.current,q)}}var Ve=O.ReactCurrentOwner,ut=O.ReactDebugCurrentFrame;function ce(a){if(a){var h=a._owner,A=oe(a.type,a._source,h?h.type:null);ut.setExtraStackFrame(A)}else ut.setExtraStackFrame(null)}var We;We=!1;function Qe(a){return typeof a=="object"&&a!==null&&a.$$typeof===e}function st(){{if(Ve.current){var a=z(Ve.current.type);if(a)return`
48
+ `+S[I].replace(" at new "," at ");return a.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",a.displayName)),typeof a=="function"&&ie.set(a,X),X}while(I>=1&&$>=0);break}}}finally{Ae=!1,me.current=L,Ue(),Error.prepareStackTrace=R}var de=a?a.displayName||a.name:"",ue=de?ne(de):"";return typeof a=="function"&&ie.set(a,ue),ue}function $e(a,h,A){return Fe(a,!1)}function Me(a){var h=a.prototype;return!!(h&&h.isReactComponent)}function oe(a,h,A){if(a==null)return"";if(typeof a=="function")return Fe(a,Me(a));if(typeof a=="string")return ne(a);switch(a){case c:return ne("Suspense");case d:return ne("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case l:return $e(a.render);case p:return oe(a.type,h,A);case m:{var E=a,R=E._payload,L=E._init;try{return oe(L(R),h,A)}catch{}}}return""}var re=Object.prototype.hasOwnProperty,Te={},Se=O.ReactDebugCurrentFrame;function le(a){if(a){var h=a._owner,A=oe(a.type,a._source,h?h.type:null);Se.setExtraStackFrame(A)}else Se.setExtraStackFrame(null)}function ze(a,h,A,E,R){{var L=Function.call.bind(re);for(var q in a)if(L(a,q)){var S=void 0;try{if(typeof a[q]!="function"){var W=Error((E||"React class")+": "+A+" type `"+q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[q]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}S=a[q](h,q,E,A,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(I){S=I}S&&!(S instanceof Error)&&(le(R),B("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",E||"React class",A,q,typeof S),le(null)),S instanceof Error&&!(S.message in Te)&&(Te[S.message]=!0,le(R),B("Failed %s type: %s",A,S.message),le(null))}}}var Ge=Array.isArray;function b(a){return Ge(a)}function C(a){{var h=typeof Symbol=="function"&&Symbol.toStringTag,A=h&&a[Symbol.toStringTag]||a.constructor.name||"Object";return A}}function Y(a){try{return K(a),!1}catch{return!0}}function K(a){return""+a}function ee(a){if(Y(a))return B("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",C(a)),K(a)}var Z=O.ReactCurrentOwner,He={key:!0,ref:!0,__self:!0,__source:!0},be,je;function Ct(a){if(re.call(a,"ref")){var h=Object.getOwnPropertyDescriptor(a,"ref").get;if(h&&h.isReactWarning)return!1}return a.ref!==void 0}function Bt(a){if(re.call(a,"key")){var h=Object.getOwnPropertyDescriptor(a,"key").get;if(h&&h.isReactWarning)return!1}return a.key!==void 0}function kt(a,h){typeof a.ref=="string"&&Z.current}function Ft(a,h){{var A=function(){be||(be=!0,B("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",h))};A.isReactWarning=!0,Object.defineProperty(a,"key",{get:A,configurable:!0})}}function Tt(a,h){{var A=function(){je||(je=!0,B("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",h))};A.isReactWarning=!0,Object.defineProperty(a,"ref",{get:A,configurable:!0})}}var St=function(a,h,A,E,R,L,q){var S={$$typeof:e,type:a,key:h,ref:A,props:q,_owner:L};return S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(S,"_self",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.defineProperty(S,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function jt(a,h,A,E,R){{var L,q={},S=null,W=null;A!==void 0&&(ee(A),S=""+A),Bt(h)&&(ee(h.key),S=""+h.key),Ct(h)&&(W=h.ref,kt(h,R));for(L in h)re.call(h,L)&&!He.hasOwnProperty(L)&&(q[L]=h[L]);if(a&&a.defaultProps){var I=a.defaultProps;for(L in I)q[L]===void 0&&(q[L]=I[L])}if(S||W){var $=typeof a=="function"?a.displayName||a.name||"Unknown":a;S&&Ft(q,$),W&&Tt(q,$)}return St(a,S,W,R,E,Z.current,q)}}var Ve=O.ReactCurrentOwner,ut=O.ReactDebugCurrentFrame;function ce(a){if(a){var h=a._owner,A=oe(a.type,a._source,h?h.type:null);ut.setExtraStackFrame(A)}else ut.setExtraStackFrame(null)}var We;We=!1;function Qe(a){return typeof a=="object"&&a!==null&&a.$$typeof===e}function st(){{if(Ve.current){var a=z(Ve.current.type);if(a)return`
49
49
 
50
50
  Check the render method of \``+a+"`."}return""}}function qt(a){return""}var at={};function Nt(a){{var h=st();if(!h){var A=typeof a=="string"?a:a.displayName||a.name;A&&(h=`
51
51
 
52
- Check the top-level render call using <`+A+">.")}return h}}function nt(a,h){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var A=Nt(h);if(at[A])return;at[A]=!0;var E="";a&&a._owner&&a._owner!==Ve.current&&(E=" It was passed a child from "+z(a._owner.type)+"."),ce(a),B('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',A,E),ce(null)}}function it(a,h){{if(typeof a!="object")return;if(b(a))for(var A=0;A<a.length;A++){var E=a[A];Qe(E)&&nt(E,h)}else if(Qe(a))a._store&&(a._store.validated=!0);else if(a){var _=M(a);if(typeof _=="function"&&_!==a.entries)for(var L=_.call(a),q;!(q=L.next()).done;)Qe(q.value)&&nt(q.value,h)}}}function Rt(a){{var h=a.type;if(h==null||typeof h=="string")return;var A;if(typeof h=="function")A=h.propTypes;else if(typeof h=="object"&&(h.$$typeof===l||h.$$typeof===p))A=h.propTypes;else return;if(A){var E=z(h);ze(A,a.props,"prop",E,a)}else if(h.PropTypes!==void 0&&!We){We=!0;var _=z(h);B("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_||"Unknown")}typeof h.getDefaultProps=="function"&&!h.getDefaultProps.isReactClassApproved&&B("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _t(a){{for(var h=Object.keys(a.props),A=0;A<h.length;A++){var E=h[A];if(E!=="children"&&E!=="key"){ce(a),B("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),ce(null);break}}a.ref!==null&&(ce(a),B("Invalid attribute `ref` supplied to `React.Fragment`."),ce(null))}}var ot={};function lt(a,h,A,E,_,L){{var q=R(a);if(!q){var S="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var W=qt();W?S+=W:S+=st();var I;a===null?I="null":b(a)?I="array":a!==void 0&&a.$$typeof===e?(I="<"+(z(a.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):I=typeof a,B("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",I,S)}var $=jt(a,h,A,_,L);if($==null)return $;if(q){var X=h.children;if(X!==void 0)if(E)if(b(X)){for(var de=0;de<X.length;de++)it(X[de],a);Object.freeze&&Object.freeze(X)}else B("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else it(X,a)}if(re.call(h,"key")){var ue=z(a),Q=Object.keys(h).filter(function($t){return $t!=="key"}),Ye=Q.length>0?"{key: someKey, "+Q.join(": ..., ")+": ...}":"{key: someKey}";if(!ot[ue+Ye]){var It=Q.length>0?"{"+Q.join(": ..., ")+": ...}":"{}";B(`A props object containing a "key" prop is being spread into JSX:
52
+ Check the top-level render call using <`+A+">.")}return h}}function nt(a,h){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var A=Nt(h);if(at[A])return;at[A]=!0;var E="";a&&a._owner&&a._owner!==Ve.current&&(E=" It was passed a child from "+z(a._owner.type)+"."),ce(a),B('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',A,E),ce(null)}}function it(a,h){{if(typeof a!="object")return;if(b(a))for(var A=0;A<a.length;A++){var E=a[A];Qe(E)&&nt(E,h)}else if(Qe(a))a._store&&(a._store.validated=!0);else if(a){var R=M(a);if(typeof R=="function"&&R!==a.entries)for(var L=R.call(a),q;!(q=L.next()).done;)Qe(q.value)&&nt(q.value,h)}}}function _t(a){{var h=a.type;if(h==null||typeof h=="string")return;var A;if(typeof h=="function")A=h.propTypes;else if(typeof h=="object"&&(h.$$typeof===l||h.$$typeof===p))A=h.propTypes;else return;if(A){var E=z(h);ze(A,a.props,"prop",E,a)}else if(h.PropTypes!==void 0&&!We){We=!0;var R=z(h);B("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",R||"Unknown")}typeof h.getDefaultProps=="function"&&!h.getDefaultProps.isReactClassApproved&&B("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Rt(a){{for(var h=Object.keys(a.props),A=0;A<h.length;A++){var E=h[A];if(E!=="children"&&E!=="key"){ce(a),B("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),ce(null);break}}a.ref!==null&&(ce(a),B("Invalid attribute `ref` supplied to `React.Fragment`."),ce(null))}}var ot={};function lt(a,h,A,E,R,L){{var q=_(a);if(!q){var S="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var W=qt();W?S+=W:S+=st();var I;a===null?I="null":b(a)?I="array":a!==void 0&&a.$$typeof===e?(I="<"+(z(a.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):I=typeof a,B("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",I,S)}var $=jt(a,h,A,R,L);if($==null)return $;if(q){var X=h.children;if(X!==void 0)if(E)if(b(X)){for(var de=0;de<X.length;de++)it(X[de],a);Object.freeze&&Object.freeze(X)}else B("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else it(X,a)}if(re.call(h,"key")){var ue=z(a),Q=Object.keys(h).filter(function($t){return $t!=="key"}),Ye=Q.length>0?"{key: someKey, "+Q.join(": ..., ")+": ...}":"{key: someKey}";if(!ot[ue+Ye]){var It=Q.length>0?"{"+Q.join(": ..., ")+": ...}":"{}";B(`A props object containing a "key" prop is being spread into JSX:
53
53
  let props = %s;
54
54
  <%s {...props} />
55
55
  React keys must be passed directly to JSX without using spread:
56
56
  let props = %s;
57
- <%s key={someKey} {...props} />`,Ye,ue,It,ue),ot[ue+Ye]=!0}}return a===u?_t($):Rt($),$}}function Lt(a,h,A){return lt(a,h,A,!0)}function Ot(a,h,A){return lt(a,h,A,!1)}var Pt=Ot,Ut=Lt;ve.Fragment=u,ve.jsx=Pt,ve.jsxs=Ut}()),ve}process.env.NODE_ENV==="production"?tt.exports=fr():tt.exports=pr();var f=tt.exports;class Re{static filter(e,r){return e.filter(r)}static filterBy(e,r,u){return e.filter(s=>s[r]===u)}static filterByFields(e,r){return e.filter(u=>Object.entries(r).every(([s,n])=>u[s]===n))}static sort(e,r,u="asc"){return[...e].sort((s,n)=>{const t=s[r],i=n[r];if(t===i)return 0;let l=0;return t>i&&(l=1),t<i&&(l=-1),u==="asc"?l:-l})}static search(e,r,u){if(!r.trim())return e;const s=r.toLowerCase();return e.filter(n=>u.some(t=>{const i=n[t];return i==null?!1:String(i).toLowerCase().includes(s)}))}static paginate(e,r,u){const s=(r-1)*u,n=s+u;return{data:e.slice(s,n),total:e.length,page:r,totalPages:Math.ceil(e.length/u)}}static groupBy(e,r){return e.reduce((u,s)=>{const n=String(s[r]);return u[n]||(u[n]=[]),u[n].push(s),u},{})}static unique(e,r){const u=e.map(s=>s[r]);return[...new Set(u)]}static countBy(e,r){return e.reduce((u,s)=>{const n=String(s[r]);return u[n]=(u[n]||0)+1,u},{})}static pipe(e,r){return r.reduce((u,s)=>s(u),e)}}function hr({endpoint:o,params:e,layout:r="list",title:u,emptyMessage:s="No items found",renderItem:n,keyExtractor:t=(k,M)=>k.id||k._id||String(M),searchable:i=!1,searchFields:l=[],searchPlaceholder:c="Search...",filters:d=[],pageSize:p=20,onItemClick:m,onRefresh:D,theme:w={}}){const{data:k,loading:M,error:O,refetch:B}=wt(o,e),[U,g]=x.useState(""),[F,y]=x.useState({}),[N,P]=x.useState(1),T=x.useMemo(()=>{if(!k)return{data:[],total:0,totalPages:0};let j=k;return i&&U&&l.length>0&&(j=Re.search(j,U,l)),Object.keys(F).length>0&&(j=Re.filterByFields(j,F)),Re.paginate(j,N,p)},[k,U,F,N,p,i,l]);x.useEffect(()=>{P(1)},[U,F]);const R=()=>{g(""),y({}),P(1),B(),D==null||D()},v={background:w.background||"#ffffff",cardBackground:w.cardBackground||"#f9fafb",text:w.text||"#111827",textSecondary:w.textSecondary||"#6b7280",border:w.border||"#e5e7eb",primary:w.primary||"#3b82f6"},z=n||(j=>f.jsxs("div",{style:{padding:"16px",cursor:m?"pointer":"default"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:v.text},children:j.title||j.name||j.label||"Untitled"}),j.description&&f.jsx("div",{style:{fontSize:"13px",color:v.textSecondary,marginTop:"4px"},children:j.description})]}));return M&&!k?f.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:v.textSecondary},children:"Loading..."}):O?f.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[f.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),f.jsx("div",{style:{fontSize:"14px"},children:O.message}),f.jsx("button",{onClick:R,style:{marginTop:"16px",padding:"8px 16px",background:v.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):f.jsxs("div",{style:{background:v.background,borderRadius:"12px",overflow:"hidden"},children:[(u||i||d.length>0)&&f.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${v.border}`},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:i||d.length>0?"12px":"0"},children:[u&&f.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:v.text},children:u}),f.jsx("button",{onClick:R,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",color:v.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),i&&f.jsx("input",{type:"text",placeholder:c,value:U,onChange:j=>g(j.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${v.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),f.jsx("div",{style:{display:r==="grid"?"grid":"flex",flexDirection:r==="list"?"column":void 0,gridTemplateColumns:r==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:r==="list"?"0":"16px",padding:r==="list"?"0":"16px"},children:T.data.length===0?f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:s}):T.data.map((j,G)=>f.jsx("div",{onClick:()=>m==null?void 0:m(j),style:{background:v.cardBackground,borderRadius:r==="list"?"0":"8px",borderBottom:r==="list"?`1px solid ${v.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:J=>{m&&(J.currentTarget.style.background=v.border)},onMouseLeave:J=>{J.currentTarget.style.background=v.cardBackground},children:z(j,G)},t(j,G)))}),T.totalPages>1&&f.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${v.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f.jsxs("div",{style:{fontSize:"13px",color:v.textSecondary},children:["Page ",N," of ",T.totalPages]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>P(j=>Math.max(1,j-1)),disabled:N===1,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===1?"not-allowed":"pointer",opacity:N===1?.5:1},children:"Previous"}),f.jsx("button",{onClick:()=>P(j=>Math.min(T.totalPages,j+1)),disabled:N===T.totalPages,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===T.totalPages?"not-allowed":"pointer",opacity:N===T.totalPages?.5:1},children:"Next"})]})]})]})}function gr({item:o,onClick:e,title:r=t=>t.title||t.name||t.label||"Untitled",subtitle:u=t=>t.description||t.subtitle||"",image:s=t=>t.image||t.thumbnail||t.photo,badge:n=t=>t.badge||t.tag||t.type}){const t=r(o),i=u(o),l=s(o),c=n(o);return f.jsxs("div",{onClick:e,className:`
57
+ <%s key={someKey} {...props} />`,Ye,ue,It,ue),ot[ue+Ye]=!0}}return a===u?Rt($):_t($),$}}function Lt(a,h,A){return lt(a,h,A,!0)}function Ot(a,h,A){return lt(a,h,A,!1)}var Pt=Ot,Ut=Lt;ve.Fragment=u,ve.jsx=Pt,ve.jsxs=Ut}()),ve}process.env.NODE_ENV==="production"?tt.exports=fr():tt.exports=pr();var f=tt.exports;class _e{static filter(e,r){return e.filter(r)}static filterBy(e,r,u){return e.filter(s=>s[r]===u)}static filterByFields(e,r){return e.filter(u=>Object.entries(r).every(([s,n])=>u[s]===n))}static sort(e,r,u="asc"){return[...e].sort((s,n)=>{const t=s[r],i=n[r];if(t===i)return 0;let l=0;return t>i&&(l=1),t<i&&(l=-1),u==="asc"?l:-l})}static search(e,r,u){if(!r.trim())return e;const s=r.toLowerCase();return e.filter(n=>u.some(t=>{const i=n[t];return i==null?!1:String(i).toLowerCase().includes(s)}))}static paginate(e,r,u){const s=(r-1)*u,n=s+u;return{data:e.slice(s,n),total:e.length,page:r,totalPages:Math.ceil(e.length/u)}}static groupBy(e,r){return e.reduce((u,s)=>{const n=String(s[r]);return u[n]||(u[n]=[]),u[n].push(s),u},{})}static unique(e,r){const u=e.map(s=>s[r]);return[...new Set(u)]}static countBy(e,r){return e.reduce((u,s)=>{const n=String(s[r]);return u[n]=(u[n]||0)+1,u},{})}static pipe(e,r){return r.reduce((u,s)=>s(u),e)}}function hr({endpoint:o,params:e,layout:r="list",title:u,emptyMessage:s="No items found",renderItem:n,keyExtractor:t=(k,M)=>k.id||k._id||String(M),searchable:i=!1,searchFields:l=[],searchPlaceholder:c="Search...",filters:d=[],pageSize:p=20,onItemClick:m,onRefresh:D,theme:w={}}){const{data:k,loading:M,error:O,refetch:B}=wt(o,e),[U,g]=x.useState(""),[F,y]=x.useState({}),[N,P]=x.useState(1),T=x.useMemo(()=>{if(!k)return{data:[],total:0,totalPages:0};let j=k;return i&&U&&l.length>0&&(j=_e.search(j,U,l)),Object.keys(F).length>0&&(j=_e.filterByFields(j,F)),_e.paginate(j,N,p)},[k,U,F,N,p,i,l]);x.useEffect(()=>{P(1)},[U,F]);const _=()=>{g(""),y({}),P(1),B(),D==null||D()},v={background:w.background||"#ffffff",cardBackground:w.cardBackground||"#f9fafb",text:w.text||"#111827",textSecondary:w.textSecondary||"#6b7280",border:w.border||"#e5e7eb",primary:w.primary||"#3b82f6"},z=n||(j=>f.jsxs("div",{style:{padding:"16px",cursor:m?"pointer":"default"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:v.text},children:j.title||j.name||j.label||"Untitled"}),j.description&&f.jsx("div",{style:{fontSize:"13px",color:v.textSecondary,marginTop:"4px"},children:j.description})]}));return M&&!k?f.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:v.textSecondary},children:"Loading..."}):O?f.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[f.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),f.jsx("div",{style:{fontSize:"14px"},children:O.message}),f.jsx("button",{onClick:_,style:{marginTop:"16px",padding:"8px 16px",background:v.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):f.jsxs("div",{style:{background:v.background,borderRadius:"12px",overflow:"hidden"},children:[(u||i||d.length>0)&&f.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${v.border}`},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:i||d.length>0?"12px":"0"},children:[u&&f.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:v.text},children:u}),f.jsx("button",{onClick:_,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",color:v.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),i&&f.jsx("input",{type:"text",placeholder:c,value:U,onChange:j=>g(j.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${v.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),f.jsx("div",{style:{display:r==="grid"?"grid":"flex",flexDirection:r==="list"?"column":void 0,gridTemplateColumns:r==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:r==="list"?"0":"16px",padding:r==="list"?"0":"16px"},children:T.data.length===0?f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:s}):T.data.map((j,G)=>f.jsx("div",{onClick:()=>m==null?void 0:m(j),style:{background:v.cardBackground,borderRadius:r==="list"?"0":"8px",borderBottom:r==="list"?`1px solid ${v.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:J=>{m&&(J.currentTarget.style.background=v.border)},onMouseLeave:J=>{J.currentTarget.style.background=v.cardBackground},children:z(j,G)},t(j,G)))}),T.totalPages>1&&f.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${v.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f.jsxs("div",{style:{fontSize:"13px",color:v.textSecondary},children:["Page ",N," of ",T.totalPages]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>P(j=>Math.max(1,j-1)),disabled:N===1,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===1?"not-allowed":"pointer",opacity:N===1?.5:1},children:"Previous"}),f.jsx("button",{onClick:()=>P(j=>Math.min(T.totalPages,j+1)),disabled:N===T.totalPages,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===T.totalPages?"not-allowed":"pointer",opacity:N===T.totalPages?.5:1},children:"Next"})]})]})]})}function gr({item:o,onClick:e,title:r=t=>t.title||t.name||t.label||"Untitled",subtitle:u=t=>t.description||t.subtitle||"",image:s=t=>t.image||t.thumbnail||t.photo,badge:n=t=>t.badge||t.tag||t.type}){const t=r(o),i=u(o),l=s(o),c=n(o);return f.jsxs("div",{onClick:e,className:`
58
58
  flex items-center gap-4 p-4 border-b border-gray-200
59
59
  hover:bg-gray-50 transition-colors
60
60
  ${e?"cursor-pointer":""}
61
- `,children:[l&&f.jsx("div",{className:"flex-shrink-0",children:f.jsx("img",{src:l,alt:t,className:"w-16 h-16 object-cover rounded-lg"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 truncate",children:t}),c&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:c})]}),i&&f.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:i})]}),e&&f.jsx("div",{className:"flex-shrink-0 text-gray-400",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function mr({item:o,onClose:e,title:r=n=>n.title||n.name||n.label||"Detail",image:u=n=>n.image||n.thumbnail||n.photo,fields:s=[]}){if(!o)return null;const n=r(o),t=u(o);return f.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[f.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[f.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:n}),e&&f.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"p-6",children:[t&&f.jsx("div",{className:"mb-6",children:f.jsx("img",{src:t,alt:n,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&f.jsx("div",{className:"space-y-4",children:s.map((i,l)=>{const c=i.value(o);return c==null||c===""?null:f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:i.label}),f.jsx("div",{className:"text-base text-gray-900",children:typeof c=="object"?JSON.stringify(c,null,2):String(c)})]},l)})}),s.length===0&&f.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(o,null,2)})]}),e&&f.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:f.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Dr={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function Ar({nodes:o,cardCount:e=2,minInterval:r=1e3,maxInterval:u=3e3,onCardClick:s,cardSize:n="medium",className:t=""}){const i=Math.min(Math.max(e,1),5),[l,c]=x.useState([]),[d,p]=x.useState([]),[m,D]=x.useState(Array(i).fill(!1)),[w,k]=x.useState(Array(i).fill(!1)),M=x.useRef([]),O=x.useCallback(y=>{const N=o.filter(T=>!y.includes(T._id));if(N.length===0)return null;const P=Math.floor(Math.random()*N.length);return N[P]},[o]),B=x.useCallback(()=>Math.random()*(u-r)+r,[r,u]);x.useEffect(()=>{if(o.length===0){c([]),p([]);return}const y=[],N=[],P=[];for(let T=0;T<i&&T<o.length;T++){const R=O(P);R&&(y.push(R),P.push(R._id))}for(let T=0;T<y.length;T++){const R=[y[T]._id,...y.filter((H,z)=>z!==T).map(H=>H._id)],v=O(R);v?N.push(v):N.push(y[T])}c(y),p(N)},[o,i,O]);const U=x.useCallback(y=>{const N=B(),P=setTimeout(()=>{D(T=>{const R=[...T];return R[y]=!R[y],R}),setTimeout(()=>{k(T=>{const R=[...T];return R[y]=!R[y],R}),setTimeout(()=>{const T=!w[y];T&&c(R=>{const v=[...R];return v[y]=d[y],v}),p(R=>{const v=[...R],z=[(T?d[y]:l[y])._id,...l.filter((G,J)=>J!==y).map(G=>G._id),...R.filter((G,J)=>J!==y).map(G=>G._id)],j=O(z);return j&&(v[y]=j),v}),setTimeout(()=>{U(y)},150)},200)},150)},N);M.current[y]=P},[B,O,l,d,w]),g=x.useRef(!1);x.useEffect(()=>{if(!(l.length===0||o.length<=1)&&!g.current){g.current=!0;for(let y=0;y<l.length;y++)U(y);return()=>{M.current.forEach(y=>clearTimeout(y)),M.current=[],g.current=!1}}},[l.length,o.length]);const F=y=>{s&&s(y)};return o.length===0?f.jsx("div",{className:`flex items-center justify-center p-8 ${t}`,children:f.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):l.length===0?f.jsx("div",{className:`flex items-center justify-center p-8 ${t}`,children:f.jsx("p",{className:"text-gray-500",children:"Loading..."})}):f.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${t}`,children:l.map((y,N)=>{const P=d[N],T=w[N];return f.jsx("div",{className:`relative ${Dr[n]}`,style:{perspective:"1000px"},onClick:()=>F(T?P:y),children:f.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${m[N]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[f.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:T?0:1},children:f.jsxs("div",{style:{transform:m[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[f.jsx("img",{src:y.data.image,alt:y.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:y.title})})]})}),P&&f.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:T?1:0},children:f.jsxs("div",{style:{transform:m[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[f.jsx("img",{src:P.data.image,alt:P.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:P.title})})]})})]})},`slot-${N}`)})})}function Ne(o){if(!o)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return o.replace(e,(r,u,s,n)=>{try{if(s.toUpperCase()==="B"){const t=atob(n);return decodeURIComponent(escape(t))}else if(s.toUpperCase()==="Q"){const t=n.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(i,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(t))}}catch(t){console.warn("MIME decode error:",t)}return r}).replace(/\s+/g," ").trim()}const br={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function yr({baseUrl:o,systemId:e,accountId:r,limit:u=30,folder:s,selectable:n=!0,showDetail:t=!1,emptyMessage:i="No emails",autoLoad:l=!0,onSelect:c,onSelectionChange:d,onDelete:p,onError:m,onLoad:D,renderItem:w,renderDetail:k,renderActions:M,renderEmpty:O,renderLoading:B,theme:U={}}){const g={...br,...U},[F,y]=x.useState([]),[N,P]=x.useState(!1),[T,R]=x.useState(null),[v,H]=x.useState(new Set),[z,j]=x.useState(null),[G,J]=x.useState(null),[pe,he]=x.useState(null),[ke,ge]=x.useState(!1),V=x.useMemo(()=>e?new xt({baseUrl:o,system_id:e}):null,[o,e]),te=x.useCallback(async()=>{if(V){P(!0),R(null);try{const b=await V.listEmails(r,u,s);b!=null&&b.messages&&(y(b.messages),D==null||D(b.messages))}catch(b){const C=b instanceof Error?b:new Error("Failed to fetch emails");R(C.message),m==null||m(C)}P(!1)}},[V,r,u,s,m,D]);x.useEffect(()=>{l&&te()},[l,te]),x.useEffect(()=>{te()},[s]);const ae=x.useCallback(async b=>{if(V){J(b),he(null),ge(!0);try{const C=await V.getEmailParsed(r,b.uid,s||"INBOX");C!=null&&C.body&&he(C.body)}catch(C){console.error("Failed to fetch email body:",C)}ge(!1)}},[V,r,s]),Pe=x.useCallback(b=>{c==null||c(b),t&&ae(b)},[c,t,ae]),Ue=x.useCallback((b,C,Y)=>{if(!n){c==null||c(b),t&&ae(b);return}const K=b.uid;if(Y.shiftKey&&z!==null){const ee=Math.min(z,C),Z=Math.max(z,C),He=F.slice(ee,Z+1).map(je=>je.uid),be=new Set(He);H(be),d==null||d(Array.from(be))}else if(Y.ctrlKey||Y.metaKey)H(ee=>{const Z=new Set(ee);return Z.has(K)?Z.delete(K):Z.add(K),d==null||d(Array.from(Z)),Z}),j(C);else{const ee=new Set([K]);H(ee),j(C),d==null||d(Array.from(ee))}},[n,z,F,v,c,d,t]),me=x.useCallback(async()=>{if(!(!V||v.size===0))try{const b=await V.trashEmails(r,Array.from(v));if(console.log("Trash result:",b),b.success&&b.moved>0){y(Y=>Y.filter(K=>!v.has(K.uid)));const C=Array.from(v);H(new Set),p==null||p(C)}else R("Failed to move emails to trash")}catch(b){const C=b instanceof Error?b:new Error("Trash failed");console.error("Trash error:",C),R(C.message),m==null||m(C)}},[V,r,v,p,m]),De=x.useCallback(async()=>{if(!(!V||v.size===0))try{const b=await V.archiveEmails(r,Array.from(v));if(console.log("Archive result:",b),b.success&&b.archived>0){y(Y=>Y.filter(K=>!v.has(K.uid)));const C=Array.from(v);H(new Set),p==null||p(C)}else R("Failed to archive emails")}catch(b){const C=b instanceof Error?b:new Error("Archive failed");console.error("Archive error:",C),R(C.message),m==null||m(C)}},[V,r,v,p,m]),ne=x.useCallback(()=>{if(v.size===F.length)H(new Set),d==null||d([]);else{const b=new Set(F.map(C=>C.uid));H(b),d==null||d(Array.from(b))}},[F,v.size,d]),Ae=x.useCallback(()=>{H(new Set),d==null||d([])},[d]),ie={delete:me,archive:De,refresh:te,selectAll:ne,clearSelection:Ae},Ie=b=>{if(!b)return"";const C=new Date(b),Y=new Date;return C.toDateString()===Y.toDateString()?C.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):C.toLocaleDateString([],{month:"short",day:"numeric"})},Fe=(b,C)=>f.jsx("div",{style:{padding:"12px 16px",background:C?g.selectedBackground:b.seen?g.cardBackground:g.unreadBackground,borderBottom:`1px solid ${g.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:b.seen?400:600,color:g.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Ne(b.from).split("@")[0]}),f.jsx("div",{style:{fontSize:"14px",fontWeight:b.seen?400:500,color:b.seen?g.textSecondary:g.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Ne(b.subject)||"(No subject)"})]}),f.jsx("div",{style:{fontSize:"12px",color:g.textSecondary,flexShrink:0},children:Ie(b.date)})]})}),$e=b=>f.jsxs("div",{style:{padding:"24px"},children:[f.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:g.text},children:Ne(b.subject)||"(No subject)"}),f.jsxs("div",{style:{fontSize:"14px",color:g.textSecondary,marginBottom:"16px"},children:["From: ",Ne(b.from)," • ",new Date(b.date).toLocaleString()]}),ke?f.jsx("div",{style:{fontSize:"14px",color:g.textSecondary},children:"Loading..."}):pe?f.jsx("div",{style:{fontSize:"14px",color:g.text},dangerouslySetInnerHTML:{__html:pe}}):f.jsx("div",{style:{fontSize:"14px",color:g.textSecondary},children:"No content available"})]}),Me=(b,C)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:g.cardBackground,borderBottom:`1px solid ${g.border}`},children:[f.jsx("button",{onClick:C.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:g.text},children:b.length===F.length?"Deselect All":"Select All"}),b.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{style:{fontSize:"13px",color:g.textSecondary},children:[b.length," selected"]}),f.jsx("button",{onClick:C.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),f.jsx("button",{onClick:C.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{onClick:C.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),oe=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:g.textSecondary},children:i}),re=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:g.textSecondary},children:"Loading..."}),Te=w||Fe,Se=k||$e,le=M||Me,ze=O||oe,Ge=B||re;return N&&F.length===0?f.jsx("div",{style:{background:g.background,width:"100%",height:"100%"},children:Ge()}):f.jsxs("div",{style:{display:"flex",background:g.background,width:"100%",height:"100%"},children:[f.jsxs("div",{style:{flex:t&&G?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:t&&G?`1px solid ${g.border}`:"none",overflow:"hidden"},children:[n&&le(Array.from(v),ie),T&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:g.danger,fontSize:"14px",borderBottom:`1px solid ${g.border}`},children:T}),f.jsx("div",{style:{flex:1,overflowY:"auto"},children:F.length===0?ze():F.map((b,C)=>f.jsx("div",{onClick:Y=>Ue(b,C,Y),onDoubleClick:()=>Pe(b),children:Te(b,v.has(b.uid))},b.uid))})]}),t&&G&&f.jsx("div",{style:{flex:1,overflowY:"auto"},children:Se(G)})]})}function xr({items:o,renderItem:e,onSelectionChange:r,onCurrentChange:u,onAction:s,actions:n=[],emptyMessage:t="No items",showSelectAll:i=!0,className:l=""}){const[c,d]=x.useState(new Set),[p,m]=x.useState(-1),D=o.filter(g=>c.has(g.id)),w=p>=0&&p<D.length?D[p]:null,k=x.useCallback(g=>{d(F=>{const y=new Set(F);return y.has(g)?y.delete(g):y.add(g),r==null||r(Array.from(y)),y})},[r]),M=x.useCallback(()=>{if(c.size===o.length)d(new Set),m(-1),r==null||r([]);else{const g=new Set(o.map(F=>F.id));d(g),o.length>0&&(m(0),u==null||u(o[0],0)),r==null||r(o.map(F=>F.id))}},[o,c.size,r,u]),O=x.useCallback(()=>{if(D.length===0)return;const g=p<=0?D.length-1:p-1;m(g),u==null||u(D[g],g)},[D,p,u]),B=x.useCallback(()=>{if(D.length===0)return;const g=p>=D.length-1?0:p+1;m(g),u==null||u(D[g],g)},[D,p,u]),U=x.useCallback(g=>{s==null||s(g,D,w)},[s,D,w]);return x.useEffect(()=>{D.length===0?m(-1):p>=D.length?m(D.length-1):p<0&&D.length>0&&(m(0),u==null||u(D[0],0))},[D.length,p,u]),o.length===0?f.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${l}`,children:t}):f.jsxs("div",{className:`space-y-2 ${l}`,children:[f.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[i&&f.jsxs("button",{onClick:M,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[f.jsx("span",{className:"material-icons text-sm",children:c.size===o.length?"check_box":c.size>0?"indeterminate_check_box":"check_box_outline_blank"}),f.jsx("span",{children:c.size===o.length?"Deselect all":"Select all"})]}),c.size>0&&f.jsxs("span",{className:"text-neutral-400",children:["(",c.size," selected)"]})]}),D.length>1&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:O,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),f.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[p+1," / ",D.length]}),f.jsx("button",{onClick:B,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),f.jsx("div",{className:"space-y-1",children:o.map(g=>{const F=c.has(g.id),y=(w==null?void 0:w.id)===g.id;return f.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${y?"bg-blue-50 ring-1 ring-blue-200":F?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>k(g.id),children:[f.jsx("span",{className:`material-icons text-lg ${F?"text-blue-500":"text-neutral-300"}`,children:F?"check_box":"check_box_outline_blank"}),f.jsx("div",{className:"flex-1 min-w-0",children:e(g,F,y)})]},g.id)})}),n.length>0&&c.size>0&&f.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:n.map(g=>{var y;const F=((y=g.disabled)==null?void 0:y.call(g,D))??!1;return f.jsxs("button",{onClick:()=>U(g.id),disabled:F,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${F?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[g.icon&&f.jsx("span",{className:"material-icons text-sm",children:g.icon}),g.label]},g.id)})})]})}exports.AnimatedCardFlip=Ar;exports.ApiClient=Et;exports.AuthManager=vt;exports.Card=gr;exports.DataOperations=Re;exports.Detail=mr;exports.GraphClient=Gt;exports.Mail=yr;exports.MailClient=xt;exports.SelectableList=xr;exports.Stack=hr;exports.getApiClient=rt;exports.initializeApiClient=cr;exports.useMutation=dr;exports.useQuery=wt;
61
+ `,children:[l&&f.jsx("div",{className:"flex-shrink-0",children:f.jsx("img",{src:l,alt:t,className:"w-16 h-16 object-cover rounded-lg"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 truncate",children:t}),c&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:c})]}),i&&f.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:i})]}),e&&f.jsx("div",{className:"flex-shrink-0 text-gray-400",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function mr({item:o,onClose:e,title:r=n=>n.title||n.name||n.label||"Detail",image:u=n=>n.image||n.thumbnail||n.photo,fields:s=[]}){if(!o)return null;const n=r(o),t=u(o);return f.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[f.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[f.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:n}),e&&f.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"p-6",children:[t&&f.jsx("div",{className:"mb-6",children:f.jsx("img",{src:t,alt:n,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&f.jsx("div",{className:"space-y-4",children:s.map((i,l)=>{const c=i.value(o);return c==null||c===""?null:f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:i.label}),f.jsx("div",{className:"text-base text-gray-900",children:typeof c=="object"?JSON.stringify(c,null,2):String(c)})]},l)})}),s.length===0&&f.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(o,null,2)})]}),e&&f.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:f.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Dr={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function Ar({nodes:o,cardCount:e=2,minInterval:r=1e3,maxInterval:u=3e3,onCardClick:s,cardSize:n="medium",className:t=""}){const i=Math.min(Math.max(e,1),5),[l,c]=x.useState([]),[d,p]=x.useState([]),[m,D]=x.useState(Array(i).fill(!1)),[w,k]=x.useState(Array(i).fill(!1)),M=x.useRef([]),O=x.useCallback(y=>{const N=o.filter(T=>!y.includes(T._id));if(N.length===0)return null;const P=Math.floor(Math.random()*N.length);return N[P]},[o]),B=x.useCallback(()=>Math.random()*(u-r)+r,[r,u]);x.useEffect(()=>{if(o.length===0){c([]),p([]);return}const y=[],N=[],P=[];for(let T=0;T<i&&T<o.length;T++){const _=O(P);_&&(y.push(_),P.push(_._id))}for(let T=0;T<y.length;T++){const _=[y[T]._id,...y.filter((H,z)=>z!==T).map(H=>H._id)],v=O(_);v?N.push(v):N.push(y[T])}c(y),p(N)},[o,i,O]);const U=x.useCallback(y=>{const N=B(),P=setTimeout(()=>{D(T=>{const _=[...T];return _[y]=!_[y],_}),setTimeout(()=>{k(T=>{const _=[...T];return _[y]=!_[y],_}),setTimeout(()=>{const T=!w[y];T&&c(_=>{const v=[..._];return v[y]=d[y],v}),p(_=>{const v=[..._],z=[(T?d[y]:l[y])._id,...l.filter((G,J)=>J!==y).map(G=>G._id),..._.filter((G,J)=>J!==y).map(G=>G._id)],j=O(z);return j&&(v[y]=j),v}),setTimeout(()=>{U(y)},150)},200)},150)},N);M.current[y]=P},[B,O,l,d,w]),g=x.useRef(!1);x.useEffect(()=>{if(!(l.length===0||o.length<=1)&&!g.current){g.current=!0;for(let y=0;y<l.length;y++)U(y);return()=>{M.current.forEach(y=>clearTimeout(y)),M.current=[],g.current=!1}}},[l.length,o.length]);const F=y=>{s&&s(y)};return o.length===0?f.jsx("div",{className:`flex items-center justify-center p-8 ${t}`,children:f.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):l.length===0?f.jsx("div",{className:`flex items-center justify-center p-8 ${t}`,children:f.jsx("p",{className:"text-gray-500",children:"Loading..."})}):f.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${t}`,children:l.map((y,N)=>{const P=d[N],T=w[N];return f.jsx("div",{className:`relative ${Dr[n]}`,style:{perspective:"1000px"},onClick:()=>F(T?P:y),children:f.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${m[N]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[f.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:T?0:1},children:f.jsxs("div",{style:{transform:m[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[f.jsx("img",{src:y.data.image,alt:y.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:y.title})})]})}),P&&f.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:T?1:0},children:f.jsxs("div",{style:{transform:m[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[f.jsx("img",{src:P.data.image,alt:P.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:P.title})})]})})]})},`slot-${N}`)})})}function Ne(o){if(!o)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return o.replace(e,(r,u,s,n)=>{try{if(s.toUpperCase()==="B"){const t=atob(n);return decodeURIComponent(escape(t))}else if(s.toUpperCase()==="Q"){const t=n.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(i,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(t))}}catch(t){console.warn("MIME decode error:",t)}return r}).replace(/\s+/g," ").trim()}const br={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function yr({baseUrl:o,systemId:e,accountId:r,limit:u=30,folder:s,selectable:n=!0,showDetail:t=!1,emptyMessage:i="No emails",autoLoad:l=!0,onSelect:c,onSelectionChange:d,onDelete:p,onError:m,onLoad:D,renderItem:w,renderDetail:k,renderActions:M,renderEmpty:O,renderLoading:B,theme:U={}}){const g={...br,...U},[F,y]=x.useState([]),[N,P]=x.useState(!1),[T,_]=x.useState(null),[v,H]=x.useState(new Set),[z,j]=x.useState(null),[G,J]=x.useState(null),[pe,he]=x.useState(null),[ke,ge]=x.useState(!1),V=x.useMemo(()=>e?new xt({baseUrl:o,system_id:e}):null,[o,e]),te=x.useCallback(async()=>{if(V){P(!0),_(null);try{const b=await V.listEmails(r,u,s);b!=null&&b.messages&&(y(b.messages),D==null||D(b.messages))}catch(b){const C=b instanceof Error?b:new Error("Failed to fetch emails");_(C.message),m==null||m(C)}P(!1)}},[V,r,u,s,m,D]);x.useEffect(()=>{l&&te()},[l,te]),x.useEffect(()=>{te()},[s]);const ae=x.useCallback(async b=>{if(V){J(b),he(null),ge(!0);try{const C=await V.getEmailParsed(r,b.uid,s||"INBOX");C!=null&&C.body&&he(C.body)}catch(C){console.error("Failed to fetch email body:",C)}ge(!1)}},[V,r,s]),Pe=x.useCallback(b=>{c==null||c(b),t&&ae(b)},[c,t,ae]),Ue=x.useCallback((b,C,Y)=>{if(!n){c==null||c(b),t&&ae(b);return}const K=b.uid;if(Y.shiftKey&&z!==null){const ee=Math.min(z,C),Z=Math.max(z,C),He=F.slice(ee,Z+1).map(je=>je.uid),be=new Set(He);H(be),d==null||d(Array.from(be))}else if(Y.ctrlKey||Y.metaKey)H(ee=>{const Z=new Set(ee);return Z.has(K)?Z.delete(K):Z.add(K),d==null||d(Array.from(Z)),Z}),j(C);else{const ee=new Set([K]);H(ee),j(C),d==null||d(Array.from(ee))}},[n,z,F,v,c,d,t]),me=x.useCallback(async()=>{if(!(!V||v.size===0))try{const b=await V.trashEmails(r,Array.from(v));if(console.log("Trash result:",b),b.success&&b.moved>0){y(Y=>Y.filter(K=>!v.has(K.uid)));const C=Array.from(v);H(new Set),p==null||p(C)}else _("Failed to move emails to trash")}catch(b){const C=b instanceof Error?b:new Error("Trash failed");console.error("Trash error:",C),_(C.message),m==null||m(C)}},[V,r,v,p,m]),De=x.useCallback(async()=>{if(!(!V||v.size===0))try{const b=await V.archiveEmails(r,Array.from(v));if(console.log("Archive result:",b),b.success&&b.archived>0){y(Y=>Y.filter(K=>!v.has(K.uid)));const C=Array.from(v);H(new Set),p==null||p(C)}else _("Failed to archive emails")}catch(b){const C=b instanceof Error?b:new Error("Archive failed");console.error("Archive error:",C),_(C.message),m==null||m(C)}},[V,r,v,p,m]),ne=x.useCallback(()=>{if(v.size===F.length)H(new Set),d==null||d([]);else{const b=new Set(F.map(C=>C.uid));H(b),d==null||d(Array.from(b))}},[F,v.size,d]),Ae=x.useCallback(()=>{H(new Set),d==null||d([])},[d]),ie={delete:me,archive:De,refresh:te,selectAll:ne,clearSelection:Ae},Ie=b=>{if(!b)return"";const C=new Date(b),Y=new Date;return C.toDateString()===Y.toDateString()?C.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):C.toLocaleDateString([],{month:"short",day:"numeric"})},Fe=(b,C)=>f.jsx("div",{style:{padding:"12px 16px",background:C?g.selectedBackground:b.seen?g.cardBackground:g.unreadBackground,borderBottom:`1px solid ${g.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:b.seen?400:600,color:g.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Ne(b.from).split("@")[0]}),f.jsx("div",{style:{fontSize:"14px",fontWeight:b.seen?400:500,color:b.seen?g.textSecondary:g.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Ne(b.subject)||"(No subject)"})]}),f.jsx("div",{style:{fontSize:"12px",color:g.textSecondary,flexShrink:0},children:Ie(b.date)})]})}),$e=b=>f.jsxs("div",{style:{padding:"24px"},children:[f.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:g.text},children:Ne(b.subject)||"(No subject)"}),f.jsxs("div",{style:{fontSize:"14px",color:g.textSecondary,marginBottom:"16px"},children:["From: ",Ne(b.from)," • ",new Date(b.date).toLocaleString()]}),ke?f.jsx("div",{style:{fontSize:"14px",color:g.textSecondary},children:"Loading..."}):pe?f.jsx("div",{style:{fontSize:"14px",color:g.text},dangerouslySetInnerHTML:{__html:pe}}):f.jsx("div",{style:{fontSize:"14px",color:g.textSecondary},children:"No content available"})]}),Me=(b,C)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:g.cardBackground,borderBottom:`1px solid ${g.border}`},children:[f.jsx("button",{onClick:C.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:g.text},children:b.length===F.length?"Deselect All":"Select All"}),b.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{style:{fontSize:"13px",color:g.textSecondary},children:[b.length," selected"]}),f.jsx("button",{onClick:C.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),f.jsx("button",{onClick:C.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{onClick:C.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),oe=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:g.textSecondary},children:i}),re=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:g.textSecondary},children:"Loading..."}),Te=w||Fe,Se=k||$e,le=M||Me,ze=O||oe,Ge=B||re;return N&&F.length===0?f.jsx("div",{style:{background:g.background,width:"100%",height:"100%"},children:Ge()}):f.jsxs("div",{style:{display:"flex",background:g.background,width:"100%",height:"100%"},children:[f.jsxs("div",{style:{flex:t&&G?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:t&&G?`1px solid ${g.border}`:"none",overflow:"hidden"},children:[n&&le(Array.from(v),ie),T&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:g.danger,fontSize:"14px",borderBottom:`1px solid ${g.border}`},children:T}),f.jsx("div",{style:{flex:1,overflowY:"auto"},children:F.length===0?ze():F.map((b,C)=>f.jsx("div",{onClick:Y=>Ue(b,C,Y),onDoubleClick:()=>Pe(b),children:Te(b,v.has(b.uid))},b.uid))})]}),t&&G&&f.jsx("div",{style:{flex:1,overflowY:"auto"},children:Se(G)})]})}function xr({items:o,renderItem:e,onSelectionChange:r,onCurrentChange:u,onAction:s,actions:n=[],emptyMessage:t="No items",showSelectAll:i=!0,className:l=""}){const[c,d]=x.useState(new Set),[p,m]=x.useState(-1),D=o.filter(g=>c.has(g.id)),w=p>=0&&p<D.length?D[p]:null,k=x.useCallback(g=>{d(F=>{const y=new Set(F);return y.has(g)?y.delete(g):y.add(g),r==null||r(Array.from(y)),y})},[r]),M=x.useCallback(()=>{if(c.size===o.length)d(new Set),m(-1),r==null||r([]);else{const g=new Set(o.map(F=>F.id));d(g),o.length>0&&(m(0),u==null||u(o[0],0)),r==null||r(o.map(F=>F.id))}},[o,c.size,r,u]),O=x.useCallback(()=>{if(D.length===0)return;const g=p<=0?D.length-1:p-1;m(g),u==null||u(D[g],g)},[D,p,u]),B=x.useCallback(()=>{if(D.length===0)return;const g=p>=D.length-1?0:p+1;m(g),u==null||u(D[g],g)},[D,p,u]),U=x.useCallback(g=>{s==null||s(g,D,w)},[s,D,w]);return x.useEffect(()=>{D.length===0?m(-1):p>=D.length?m(D.length-1):p<0&&D.length>0&&(m(0),u==null||u(D[0],0))},[D.length,p,u]),o.length===0?f.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${l}`,children:t}):f.jsxs("div",{className:`space-y-2 ${l}`,children:[f.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[i&&f.jsxs("button",{onClick:M,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[f.jsx("span",{className:"material-icons text-sm",children:c.size===o.length?"check_box":c.size>0?"indeterminate_check_box":"check_box_outline_blank"}),f.jsx("span",{children:c.size===o.length?"Deselect all":"Select all"})]}),c.size>0&&f.jsxs("span",{className:"text-neutral-400",children:["(",c.size," selected)"]})]}),D.length>1&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:O,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),f.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[p+1," / ",D.length]}),f.jsx("button",{onClick:B,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),f.jsx("div",{className:"space-y-1",children:o.map(g=>{const F=c.has(g.id),y=(w==null?void 0:w.id)===g.id;return f.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${y?"bg-blue-50 ring-1 ring-blue-200":F?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>k(g.id),children:[f.jsx("span",{className:`material-icons text-lg ${F?"text-blue-500":"text-neutral-300"}`,children:F?"check_box":"check_box_outline_blank"}),f.jsx("div",{className:"flex-1 min-w-0",children:e(g,F,y)})]},g.id)})}),n.length>0&&c.size>0&&f.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:n.map(g=>{var y;const F=((y=g.disabled)==null?void 0:y.call(g,D))??!1;return f.jsxs("button",{onClick:()=>U(g.id),disabled:F,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${F?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[g.icon&&f.jsx("span",{className:"material-icons text-sm",children:g.icon}),g.label]},g.id)})})]})}exports.AnimatedCardFlip=Ar;exports.ApiClient=Et;exports.AuthManager=vt;exports.Card=gr;exports.DataOperations=_e;exports.Detail=mr;exports.GraphClient=Gt;exports.Mail=yr;exports.MailClient=xt;exports.SelectableList=xr;exports.Stack=hr;exports.getApiClient=rt;exports.initializeApiClient=cr;exports.useMutation=dr;exports.useQuery=wt;
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var zt = Object.defineProperty;
2
2
  var Gt = (o, e, r) => e in o ? zt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r;
3
3
  var ve = (o, e, r) => Gt(o, typeof e != "symbol" ? e + "" : e, r);
4
- import st, { useState as O, useCallback as H, useEffect as pe, useMemo as vt, useRef as ft } from "react";
4
+ import st, { useState as P, useCallback as H, useEffect as pe, useMemo as vt, useRef as ft } from "react";
5
5
  class yr {
6
6
  constructor(e) {
7
7
  ve(this, "config");
@@ -344,7 +344,7 @@ function Be(o) {
344
344
  }
345
345
  return e;
346
346
  }
347
- async function Oe(o) {
347
+ async function Pe(o) {
348
348
  if ("arrayBuffer" in o)
349
349
  return await o.arrayBuffer();
350
350
  const e = new FileReader();
@@ -453,7 +453,7 @@ class Qt {
453
453
  `);
454
454
  }
455
455
  finalize() {
456
- return Oe(new Blob(this.chunks, { type: "application/octet-stream" }));
456
+ return Pe(new Blob(this.chunks, { type: "application/octet-stream" }));
457
457
  }
458
458
  }
459
459
  class Yt {
@@ -468,7 +468,7 @@ class Yt {
468
468
  }
469
469
  }
470
470
  finalize() {
471
- return this.remainder && !/^=+$/.test(this.remainder) && this.chunks.push(rt(this.remainder)), Oe(new Blob(this.chunks, { type: "application/octet-stream" }));
471
+ return this.remainder && !/^=+$/.test(this.remainder) && this.chunks.push(rt(this.remainder)), Pe(new Blob(this.chunks, { type: "application/octet-stream" }));
472
472
  }
473
473
  }
474
474
  const gt = /^=[a-f0-9]{2}$/i, Jt = /(?==[a-f0-9]{2})/i, Kt = /=\r?\n/g, Xt = /=[a-fA-F0-9]?$/;
@@ -520,7 +520,7 @@ class Zt {
520
520
  this.decodeChunks(r);
521
521
  }
522
522
  finalize() {
523
- return this.remainder.length && (this.decodeChunks(this.remainder), this.remainder = ""), Oe(new Blob(this.chunks, { type: "application/octet-stream" }));
523
+ return this.remainder.length && (this.decodeChunks(this.remainder), this.remainder = ""), Pe(new Blob(this.chunks, { type: "application/octet-stream" }));
524
524
  }
525
525
  }
526
526
  class mt {
@@ -3380,7 +3380,7 @@ class Le {
3380
3380
  var s, n;
3381
3381
  if (this.started)
3382
3382
  throw new Error("Can not reuse parser, create a new PostalMime object");
3383
- for (this.started = !0, e && typeof e.getReader == "function" && (e = await this.resolveStream(e)), e = e || new ArrayBuffer(0), typeof e == "string" && (e = he.encode(e)), (e instanceof Blob || Object.prototype.toString.call(e) === "[object Blob]") && (e = await Oe(e)), e.buffer instanceof ArrayBuffer && (e = new Uint8Array(e).buffer), this.buf = e, this.av = new Uint8Array(e), this.readPos = 0; this.readPos < this.av.length; ) {
3383
+ for (this.started = !0, e && typeof e.getReader == "function" && (e = await this.resolveStream(e)), e = e || new ArrayBuffer(0), typeof e == "string" && (e = he.encode(e)), (e instanceof Blob || Object.prototype.toString.call(e) === "[object Blob]") && (e = await Pe(e)), e.buffer instanceof ArrayBuffer && (e = new Uint8Array(e).buffer), this.buf = e, this.av = new Uint8Array(e), this.readPos = 0; this.readPos < this.av.length; ) {
3384
3384
  const t = this.readLine();
3385
3385
  await this.processLine(t.bytes, t.done);
3386
3386
  }
@@ -3629,7 +3629,7 @@ class cr {
3629
3629
  var U, g, k, y, q;
3630
3630
  const E = p.get(D);
3631
3631
  if (!E) return null;
3632
- const B = ((U = E.flags) == null ? void 0 : U.some((P) => P.includes("Seen"))) || !1, M = ((k = (g = E.envelope) == null ? void 0 : g.from) == null ? void 0 : k.email) || "Unknown", L = ((y = E.envelope) == null ? void 0 : y.subject) || "(No subject)", C = ((q = E.envelope) == null ? void 0 : q.date) || "";
3632
+ const B = ((U = E.flags) == null ? void 0 : U.some((O) => O.includes("Seen"))) || !1, M = ((k = (g = E.envelope) == null ? void 0 : g.from) == null ? void 0 : k.email) || "Unknown", L = ((y = E.envelope) == null ? void 0 : y.subject) || "(No subject)", C = ((q = E.envelope) == null ? void 0 : q.date) || "";
3633
3633
  return { uid: D, from: M, subject: L, date: C, seen: B };
3634
3634
  }).filter(Boolean);
3635
3635
  return {
@@ -3648,6 +3648,18 @@ class cr {
3648
3648
  folder: u
3649
3649
  });
3650
3650
  }
3651
+ /**
3652
+ * Get a specific attachment from an email
3653
+ * Returns base64-encoded content for download
3654
+ */
3655
+ async getAttachment(e, r, u, s = "INBOX") {
3656
+ return this.callMail("get_attachment", {
3657
+ account_id: e,
3658
+ uid: r,
3659
+ attachment_index: u,
3660
+ folder: s
3661
+ });
3662
+ }
3651
3663
  /**
3652
3664
  * Get email with client-side parsing using postal-mime
3653
3665
  * This handles CID embedded images by converting them to base64 data URIs
@@ -3874,14 +3886,14 @@ class fr {
3874
3886
  return this.config.baseUrl;
3875
3887
  }
3876
3888
  }
3877
- let Pe = null;
3889
+ let Oe = null;
3878
3890
  function xr(o) {
3879
- return Pe = new fr(o), Pe;
3891
+ return Oe = new fr(o), Oe;
3880
3892
  }
3881
3893
  function Ct() {
3882
- if (!Pe)
3894
+ if (!Oe)
3883
3895
  throw new Error("API client not initialized. Call initializeApiClient() first.");
3884
- return Pe;
3896
+ return Oe;
3885
3897
  }
3886
3898
  function pr(o, e, r = {}) {
3887
3899
  const {
@@ -3889,7 +3901,7 @@ function pr(o, e, r = {}) {
3889
3901
  refetchOnMount: s = !0,
3890
3902
  onSuccess: n,
3891
3903
  onError: t
3892
- } = r, [i, l] = O(null), [c, d] = O(u), [p, m] = O(null), D = H(async () => {
3904
+ } = r, [i, l] = P(null), [c, d] = P(u), [p, m] = P(null), D = H(async () => {
3893
3905
  if (u) {
3894
3906
  d(!0), m(null);
3895
3907
  try {
@@ -3913,7 +3925,7 @@ function pr(o, e, r = {}) {
3913
3925
  };
3914
3926
  }
3915
3927
  function vr(o, e = "POST", r = {}) {
3916
- const { onSuccess: u, onError: s } = r, [n, t] = O(null), [i, l] = O(!1), [c, d] = O(null), p = H(
3928
+ const { onSuccess: u, onError: s } = r, [n, t] = P(null), [i, l] = P(!1), [c, d] = P(null), p = H(
3917
3929
  async (D) => {
3918
3930
  l(!0), d(null);
3919
3931
  try {
@@ -4017,10 +4029,10 @@ function gr() {
4017
4029
  R.unshift("Warning: " + h), Function.prototype.apply.call(console[a], console, R);
4018
4030
  }
4019
4031
  }
4020
- var g = !1, k = !1, y = !1, q = !1, P = !1, F;
4032
+ var g = !1, k = !1, y = !1, q = !1, O = !1, F;
4021
4033
  F = Symbol.for("react.module.reference");
4022
4034
  function N(a) {
4023
- return !!(typeof a == "string" || typeof a == "function" || a === u || a === n || P || a === s || a === c || a === d || q || a === D || g || k || y || typeof a == "object" && a !== null && (a.$$typeof === m || a.$$typeof === p || a.$$typeof === t || a.$$typeof === i || a.$$typeof === l || // This needs to include all possible module reference object
4035
+ return !!(typeof a == "string" || typeof a == "function" || a === u || a === n || O || a === s || a === c || a === d || q || a === D || g || k || y || typeof a == "object" && a !== null && (a.$$typeof === m || a.$$typeof === p || a.$$typeof === t || a.$$typeof === i || a.$$typeof === l || // This needs to include all possible module reference object
4024
4036
  // types supported by any Flight configuration anywhere since
4025
4037
  // we don't know which Flight build this will end up being used
4026
4038
  // with.
@@ -4569,13 +4581,13 @@ React keys must be passed directly to JSX without using spread:
4569
4581
  return a === u ? Lt($) : Rt($), $;
4570
4582
  }
4571
4583
  }
4572
- function Pt(a, h, A) {
4584
+ function Ot(a, h, A) {
4573
4585
  return dt(a, h, A, !0);
4574
4586
  }
4575
- function Ot(a, h, A) {
4587
+ function Pt(a, h, A) {
4576
4588
  return dt(a, h, A, !1);
4577
4589
  }
4578
- var Ut = Ot, It = Pt;
4590
+ var Ut = Pt, It = Ot;
4579
4591
  we.Fragment = u, we.jsx = Ut, we.jsxs = It;
4580
4592
  }()), we;
4581
4593
  }
@@ -4683,16 +4695,16 @@ function Er({
4683
4695
  onRefresh: D,
4684
4696
  theme: E = {}
4685
4697
  }) {
4686
- const { data: B, loading: M, error: L, refetch: C } = pr(o, e), [U, g] = O(""), [k, y] = O({}), [q, P] = O(1), F = vt(() => {
4698
+ const { data: B, loading: M, error: L, refetch: C } = pr(o, e), [U, g] = P(""), [k, y] = P({}), [q, O] = P(1), F = vt(() => {
4687
4699
  if (!B) return { data: [], total: 0, totalPages: 0 };
4688
4700
  let S = B;
4689
4701
  return i && U && l.length > 0 && (S = tt.search(S, U, l)), Object.keys(k).length > 0 && (S = tt.filterByFields(S, k)), tt.paginate(S, q, p);
4690
4702
  }, [B, U, k, q, p, i, l]);
4691
4703
  pe(() => {
4692
- P(1);
4704
+ O(1);
4693
4705
  }, [U, k]);
4694
4706
  const N = () => {
4695
- g(""), y({}), P(1), C(), D == null || D();
4707
+ g(""), y({}), O(1), C(), D == null || D();
4696
4708
  }, x = {
4697
4709
  background: E.background || "#ffffff",
4698
4710
  cardBackground: E.cardBackground || "#f9fafb",
@@ -4839,7 +4851,7 @@ function Er({
4839
4851
  /* @__PURE__ */ f.jsx(
4840
4852
  "button",
4841
4853
  {
4842
- onClick: () => P((S) => Math.max(1, S - 1)),
4854
+ onClick: () => O((S) => Math.max(1, S - 1)),
4843
4855
  disabled: q === 1,
4844
4856
  style: {
4845
4857
  padding: "6px 12px",
@@ -4855,7 +4867,7 @@ function Er({
4855
4867
  /* @__PURE__ */ f.jsx(
4856
4868
  "button",
4857
4869
  {
4858
- onClick: () => P((S) => Math.min(F.totalPages, S + 1)),
4870
+ onClick: () => O((S) => Math.min(F.totalPages, S + 1)),
4859
4871
  disabled: q === F.totalPages,
4860
4872
  style: {
4861
4873
  padding: "6px 12px",
@@ -4974,21 +4986,21 @@ function Br({
4974
4986
  cardSize: n = "medium",
4975
4987
  className: t = ""
4976
4988
  }) {
4977
- const i = Math.min(Math.max(e, 1), 5), [l, c] = O([]), [d, p] = O([]), [m, D] = O(Array(i).fill(!1)), [E, B] = O(Array(i).fill(!1)), M = ft([]), L = H((y) => {
4989
+ const i = Math.min(Math.max(e, 1), 5), [l, c] = P([]), [d, p] = P([]), [m, D] = P(Array(i).fill(!1)), [E, B] = P(Array(i).fill(!1)), M = ft([]), L = H((y) => {
4978
4990
  const q = o.filter((F) => !y.includes(F._id));
4979
4991
  if (q.length === 0) return null;
4980
- const P = Math.floor(Math.random() * q.length);
4981
- return q[P];
4992
+ const O = Math.floor(Math.random() * q.length);
4993
+ return q[O];
4982
4994
  }, [o]), C = H(() => Math.random() * (u - r) + r, [r, u]);
4983
4995
  pe(() => {
4984
4996
  if (o.length === 0) {
4985
4997
  c([]), p([]);
4986
4998
  return;
4987
4999
  }
4988
- const y = [], q = [], P = [];
5000
+ const y = [], q = [], O = [];
4989
5001
  for (let F = 0; F < i && F < o.length; F++) {
4990
- const N = L(P);
4991
- N && (y.push(N), P.push(N._id));
5002
+ const N = L(O);
5003
+ N && (y.push(N), O.push(N._id));
4992
5004
  }
4993
5005
  for (let F = 0; F < y.length; F++) {
4994
5006
  const N = [
@@ -5000,7 +5012,7 @@ function Br({
5000
5012
  c(y), p(q);
5001
5013
  }, [o, i, L]);
5002
5014
  const U = H((y) => {
5003
- const q = C(), P = setTimeout(() => {
5015
+ const q = C(), O = setTimeout(() => {
5004
5016
  D((F) => {
5005
5017
  const N = [...F];
5006
5018
  return N[y] = !N[y], N;
@@ -5026,7 +5038,7 @@ function Br({
5026
5038
  }, 200);
5027
5039
  }, 150);
5028
5040
  }, q);
5029
- M.current[y] = P;
5041
+ M.current[y] = O;
5030
5042
  }, [C, L, l, d, E]), g = ft(!1);
5031
5043
  pe(() => {
5032
5044
  if (!(l.length === 0 || o.length <= 1) && !g.current) {
@@ -5042,13 +5054,13 @@ function Br({
5042
5054
  s && s(y);
5043
5055
  };
5044
5056
  return o.length === 0 ? /* @__PURE__ */ f.jsx("div", { className: `flex items-center justify-center p-8 ${t}`, children: /* @__PURE__ */ f.jsx("p", { className: "text-gray-500", children: "No nodes available" }) }) : l.length === 0 ? /* @__PURE__ */ f.jsx("div", { className: `flex items-center justify-center p-8 ${t}`, children: /* @__PURE__ */ f.jsx("p", { className: "text-gray-500", children: "Loading..." }) }) : /* @__PURE__ */ f.jsx("div", { className: `flex gap-4 justify-center items-center flex-wrap ${t}`, children: l.map((y, q) => {
5045
- const P = d[q], F = E[q];
5057
+ const O = d[q], F = E[q];
5046
5058
  return /* @__PURE__ */ f.jsx(
5047
5059
  "div",
5048
5060
  {
5049
5061
  className: `relative ${mr[n]}`,
5050
5062
  style: { perspective: "1000px" },
5051
- onClick: () => k(F ? P : y),
5063
+ onClick: () => k(F ? O : y),
5052
5064
  children: /* @__PURE__ */ f.jsxs(
5053
5065
  "div",
5054
5066
  {
@@ -5089,7 +5101,7 @@ function Br({
5089
5101
  )
5090
5102
  }
5091
5103
  ),
5092
- P && /* @__PURE__ */ f.jsx(
5104
+ O && /* @__PURE__ */ f.jsx(
5093
5105
  "div",
5094
5106
  {
5095
5107
  className: "absolute inset-0 transition-opacity duration-200",
@@ -5108,12 +5120,12 @@ function Br({
5108
5120
  /* @__PURE__ */ f.jsx(
5109
5121
  "img",
5110
5122
  {
5111
- src: P.data.image,
5112
- alt: P.title,
5123
+ src: O.data.image,
5124
+ alt: O.title,
5113
5125
  className: "w-full h-full object-cover"
5114
5126
  }
5115
5127
  ),
5116
- /* @__PURE__ */ f.jsx("div", { className: "absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2", children: /* @__PURE__ */ f.jsx("p", { className: "text-white text-sm font-medium truncate", children: P.title }) })
5128
+ /* @__PURE__ */ f.jsx("div", { className: "absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2", children: /* @__PURE__ */ f.jsx("p", { className: "text-white text-sm font-medium truncate", children: O.title }) })
5117
5129
  ]
5118
5130
  }
5119
5131
  )
@@ -5181,9 +5193,9 @@ function kr({
5181
5193
  renderLoading: C,
5182
5194
  theme: U = {}
5183
5195
  }) {
5184
- const g = { ...Dr, ...U }, [k, y] = O([]), [q, P] = O(!1), [F, N] = O(null), [x, V] = O(/* @__PURE__ */ new Set()), [z, S] = O(null), [G, K] = O(null), [ge, me] = O(null), [Te, De] = O(!1), W = vt(() => e ? new cr({ baseUrl: o, system_id: e }) : null, [o, e]), re = H(async () => {
5196
+ const g = { ...Dr, ...U }, [k, y] = P([]), [q, O] = P(!1), [F, N] = P(null), [x, V] = P(/* @__PURE__ */ new Set()), [z, S] = P(null), [G, K] = P(null), [ge, me] = P(null), [Te, De] = P(!1), W = vt(() => e ? new cr({ baseUrl: o, system_id: e }) : null, [o, e]), re = H(async () => {
5185
5197
  if (W) {
5186
- P(!0), N(null);
5198
+ O(!0), N(null);
5187
5199
  try {
5188
5200
  const b = await W.listEmails(r, u, s);
5189
5201
  b != null && b.messages && (y(b.messages), D == null || D(b.messages));
@@ -5191,7 +5203,7 @@ function kr({
5191
5203
  const w = b instanceof Error ? b : new Error("Failed to fetch emails");
5192
5204
  N(w.message), m == null || m(w);
5193
5205
  }
5194
- P(!1);
5206
+ O(!1);
5195
5207
  }
5196
5208
  }, [W, r, u, s, m, D]);
5197
5209
  pe(() => {
@@ -5463,7 +5475,7 @@ function Fr({
5463
5475
  showSelectAll: i = !0,
5464
5476
  className: l = ""
5465
5477
  }) {
5466
- const [c, d] = O(/* @__PURE__ */ new Set()), [p, m] = O(-1), D = o.filter((g) => c.has(g.id)), E = p >= 0 && p < D.length ? D[p] : null, B = H((g) => {
5478
+ const [c, d] = P(/* @__PURE__ */ new Set()), [p, m] = P(-1), D = o.filter((g) => c.has(g.id)), E = p >= 0 && p < D.length ? D[p] : null, B = H((g) => {
5467
5479
  d((k) => {
5468
5480
  const y = new Set(k);
5469
5481
  return y.has(g) ? y.delete(g) : y.add(g), r == null || r(Array.from(y)), y;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/stack",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "Modern HyperCard for React - All-in-one data management (REST + Graph API + Auth + Hooks + UI)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",