PageSourceSearch

https://dwellversecrm-e3181.web.app/assets/scheduled-D9SS-eU5.js

js dwellversecrm-e3181.web.app collected 2026-10-03 12:22:01 UTC 11,029 bytes, 59 lines download raw bytes

1import{R as D,c as F,l as h,aj as f,h as w,b,f as p,a0 as A}from"./main-CJA6AarP.js";import{i as L,j as M,f as P,r as N}from"./fb-email-ClwVSn0v.js";import"https://www.gstatic.com/firebasejs/9.22.1/firebase-app.js";import"https://www.gstatic.com/firebasejs/9.22.1/firebase-auth.js";import"https://www.gstatic.com/firebasejs/9.22.1/firebase-firestore.js";import"https://www.gstatic.com/firebasejs/9.22.1/firebase-storage.js";import"https://www.gstatic.com/firebasejs/9.22.1/firebase-functions.js";let u=null,d="all";async function G(){var e,n;u=new AbortController;const{signal:t}=u;(e=document.getElementById("scheduledRefreshBtn"))==null||e.addEventListener("click",()=>c(),{signal:t}),(n=document.getElementById("scheduledHelpBtn"))==null||n.addEventListener("click",()=>D("Scheduled Emails",[{title:"What are Scheduled Emails?",body:"<p>When you compose an email and click the clock icon instead of Send, you can pick a future date and time. The email sits here until that time, then sends automatically.</p>"},{title:"Send Now / Cancel",body:"<p><strong>Send Now</strong> sends the email immediately. <strong>Cancel</strong> stops it from ever sending. <strong>Reschedule</strong> lets you change the time.</p>"}]),{signal:t}),await c()}function J(){u&&(u.abort(),u=null),d="all"}async function c(){var r,s;const t=document.getElementById("scheduledEmailsList");if(!t)return;const e=(r=F)==null?void 0:r.uid;if(!e){t.innerHTML=$("Sign in to view scheduled emails.");return}t.innerHTML='<div style="padding:2rem;text-align:center;color:rgba(255,255,255,0.3);">Loading scheduled emails...</div>';let n=[];try{n=await L(e)}catch(i){if(h.error("Failed to load scheduled emails:",i),(s=i.message)!=null&&s.includes("index")){t.innerHTML=$("The database index is still building. Please wait a minute and refresh.");return}}R(t,n)}function R(t,e){const n=e.filter(a=>a.status==="pending"||a.status==="processing"),r=e.filter(a=>a.status==="sent"),s=e.filter(a=>a.status==="failed"),i=e.filter(a=>a.status==="cancelled");let o=e;d==="pending"?o=n:d==="sent"?o=r:d==="failed"?o=s:d==="cancelled"&&(o=i);let l="";if(l+=`
2    <div style="display:flex;gap:8px;margin-bottom:1rem;flex-wrap:wrap;">
3        ${g("All",e.length,"all","#a78bfa")}
4        ${g("Queued",n.length,"pending","#f59e0b")}
5        ${g("Sent",r.length,"sent","#22c55e")}
6        ${g("Failed",s.length,"failed","#ef4444")}
7        ${g("Cancelled",i.length,"cancelled","#6b7280")}
8    </div>`,l+=`
9    <div class="vision-panel" style="padding:0;overflow:hidden;">
10        <table style="width:100%;border-collapse:collapse;font-size:0.82rem;">
11            <thead>
12                <tr style="background:rgba(255,255,255,0.04);border-bottom:2px solid rgba(255,255,255,0.08);">
13                    <th style="text-align:left;padding:10px 12px;font-weight:600;color:rgba(255,255,255,0.5);font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;">Status</th>
14                    <th style="text-align:left;padding:10px 12px;font-weight:600;color:rgba(255,255,255,0.5);font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;">To</th>
15                    <th style="text-align:left;padding:10px 12px;font-weight:600;color:rgba(255,255,255,0.5);font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;">Subject</th>
16                    <th style="text-align:left;padding:10px 12px;font-weight:600;color:rgba(255,255,255,0.5);font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;">Scheduled For</th>
17                    <th style="text-align:left;padding:10px 12px;font-weight:600;color:rgba(255,255,255,0.5);font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;">Created</th>
18                    <th style="text-align:right;padding:10px 12px;font-weight:600;color:rgba(255,255,255,0.5);font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;">Actions</th>
19                </tr>
20            </thead>
21            <tbody>`,o.length===0){const a=d==="all"?"No scheduled emails yet. Use the clock icon on the email composer to schedule one.":`No ${d} emails.`;l+=`
22            <tr>
23                <td colspan="6" style="padding:3rem 1rem;text-align:center;color:rgba(255,255,255,0.3);">
24                    <div style="font-size:1.5rem;margin-bottom:8px;">&#128235;</div>
25                    ${a}
26                </td>
27            </tr>`}for(const a of o){const E=f((a.to||"").split(",")[0]).substring(0,35),x=(a.to||"").split(",").length>1?` +${(a.to||"").split(",").length-1}`:"",v=f(a.subject||"(No subject)").substring(0,50),z=k(a.scheduledFor),T=k(a.createdAt),m=a.status||"pending",C=m==="pending",y={pending:'<span style="display:inline-block;padding:2px 8px;border-radius:4px;font-size:0.7rem;font-weight:600;background:rgba(245,158,11,0.15);color:#f59e0b;">Queued</span>',processing:'<span style="display:inline-block;padding:2px 8px;border-radius:4px;font-size:0.7rem;font-weight:600;background:rgba(59,130,246,0.15);color:#3b82f6;">Sending...</span>',sent:'<span style="display:inline-block;padding:2px 8px;border-radius:4px;font-size:0.7rem;font-weight:600;background:rgba(34,197,94,0.15);color:#22c55e;">Sent</span>',failed:'<span style="display:inline-block;padding:2px 8px;border-radius:4px;font-size:0.7rem;font-weight:600;background:rgba(239,68,68,0.15);color:#ef4444;">Failed</span>',cancelled:'<span style="display:inline-block;padding:2px 8px;border-radius:4px;font-size:0.7rem;font-weight:600;background:rgba(107,114,128,0.15);color:#6b7280;">Cancelled</span>'};l+=`
28            <tr style="border-bottom:1px solid rgba(255,255,255,0.04);transition:background 0.15s;" onmouseover="this.style.background='rgba(255,255,255,0.02)'" onmouseout="this.style.background='transparent'">
29                <td style="padding:10px 12px;">${y[m]||y.pending}</td>
30                <td style="padding:10px 12px;color:rgba(255,255,255,0.8);">${E}${x?`<span style="color:rgba(255,255,255,0.3);font-size:0.7rem;">${x}</span>`:""}</td>
31                <td style="padding:10px 12px;color:rgba(255,255,255,0.9);font-weight:500;">${v}</td>
32                <td style="padding:10px 12px;color:rgba(255,255,255,0.6);">${z}</td>
33                <td style="padding:10px 12px;color:rgba(255,255,255,0.4);font-size:0.75rem;">${T}</td>
34                <td style="padding:10px 12px;text-align:right;">
35                    ${C?`
36                        <button class="sched-send-now-btn" data-id="${a.id}" style="padding:3px 10px;font-size:0.7rem;background:rgba(34,197,94,0.1);color:#22c55e;border:1px solid rgba(34,197,94,0.2);border-radius:4px;cursor:pointer;margin-right:4px;">Send Now</button>
37                        <button class="sched-reschedule-btn" data-id="${a.id}" style="padding:3px 10px;font-size:0.7rem;background:rgba(255,255,255,0.04);color:rgba(255,255,255,0.6);border:1px solid rgba(255,255,255,0.1);border-radius:4px;cursor:pointer;margin-right:4px;">Reschedule</button>
38                        <button class="sched-cancel-btn" data-id="${a.id}" style="padding:3px 10px;font-size:0.7rem;background:rgba(239,68,68,0.1);color:#ef4444;border:1px solid rgba(239,68,68,0.2);border-radius:4px;cursor:pointer;">Cancel</button>
39                    `:""}
40                    ${m==="failed"?`<span style="font-size:0.65rem;color:#ef4444;" title="${f(a.errorMessage||"")}">${f((a.errorMessage||"").substring(0,30))}</span>`:""}
41                </td>
42            </tr>`}l+=`
43            </tbody>
44        </table>
45    </div>`,t.innerHTML=l,H(t),B(t)}function g(t,e,n,r){const s=d===n;return`<button class="sched-filter-btn" data-filter="${n}" style="
46        display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:8px;
47        font-size:0.78rem;font-weight:500;cursor:pointer;transition:all 0.15s;
48        background:${s?`${r}20`:"rgba(255,255,255,0.03)"};
49        color:${s?r:"rgba(255,255,255,0.5)"};
50        border:1px solid ${s?`${r}40`:"rgba(255,255,255,0.06)"};
51    ">
52        <span style="width:8px;height:8px;border-radius:50%;background:${r};"></span>
53        ${t} <strong>${e}</strong>
54    </button>`}function $(t){return`
55    <div style="padding:3rem;text-align:center;">
56        <div style="font-size:2.5rem;margin-bottom:12px;">&#128235;</div>
57        <p style="color:rgba(255,255,255,0.5);font-size:0.95rem;margin-bottom:8px;">${t}</p>
58        <p style="color:rgba(255,255,255,0.25);font-size:0.78rem;">Tip: Compose an email and click the &#128336; clock icon next to Send to schedule it.</p>
59    </div>`}function B(t){t.querySelectorAll(".sched-filter-btn").forEach(e=>{e.addEventListener("click",()=>{d=e.dataset.filter,c()})})}function H(t){t.querySelectorAll(".sched-send-now-btn").forEach(e=>{e.addEventListener("click",async n=>{n.stopPropagation();const{id:r}=e.dataset;if(await w("Send this email right now?","Send Now")){e.disabled=!0,e.textContent="Sending...";try{await M(r),b("Email will send within 1 minute","success"),await c()}catch(i){h.error("Send now failed:",i),p("Failed to send. Please try again."),e.disabled=!1,e.textContent="Send Now"}}})}),t.querySelectorAll(".sched-cancel-btn").forEach(e=>{e.addEventListener("click",async n=>{n.stopPropagation();const{id:r}=e.dataset;if(await w("Cancel this scheduled email? It will not be sent.","Cancel Email")){e.disabled=!0,e.textContent="Cancelling...";try{await P(r),b("Email cancelled","success"),await c()}catch(i){h.error("Cancel failed:",i),p("Failed to cancel."),e.disabled=!1,e.textContent="Cancel"}}})}),t.querySelectorAll(".sched-reschedule-btn").forEach(e=>{e.addEventListener("click",async n=>{n.stopPropagation();const{id:r}=e.dataset,s=await I();if(!s)return;const i=new Date(s);if(isNaN(i.getTime())){p("That date and time could not be understood. Please try again.");return}if(i<=new Date){p("The new send time must be in the future.");return}e.disabled=!0,e.textContent="Updating...";try{await N(r,i),b("Email rescheduled","success"),await c()}catch(o){h.error("Reschedule failed:",o),p("Failed to reschedule."),e.disabled=!1,e.textContent="Reschedule"}})})}function S(t){const e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}`}function I(){const t=document.getElementById("simpleModalInput"),e=t?t.type:"text",n=new Date,r=S(new Date(n.getTime()+3600*1e3));t&&(t.type="datetime-local",t.min=S(n));const s=()=>{t&&(t.type=e,t.removeAttribute("min"))};return new Promise(i=>{A("Reschedule Email","Pick a new send time:",r,o=>{s(),i(o||null)},()=>{s(),i(null)})})}function k(t){if(!t)return"-";let e;if(t.toDate?e=t.toDate():typeof t=="string"?e=new Date(t):t.seconds?e=new Date(t.seconds*1e3):e=new Date(t),isNaN(e.getTime()))return"-";const n=new Date,r=e-n,s=Math.abs(r),i=Math.round(s/6e4),o=Math.round(s/36e5);if(r>0&&i<60)return`in ${i}m`;if(r>0&&o<24)return`in ${o}h`;if(r<0&&i<60)return`${i}m ago`;if(r<0&&o<24)return`${o}h ago`;const l={month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};return e.getFullYear()!==n.getFullYear()&&(l.year="numeric"),e.toLocaleDateString("en-US",l)}export{J as destroy,G as init};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.