import{r as l,j as t,G as O,w as U,i as W,d as H}from"./index-cd3b2402.js";function I({apiRoot:a,apiNamespace:p,isPremium:f=!1,planData:n}){const u=n?n.plan_name!=="free"||n.is_trial:f,v=(n==null?void 0:n.plan_name)==="enterprise",[x,S]=l.useState(""),[h,N]=l.useState("weekly"),[w,z]=l.useState("09:00"),[c,_]=l.useState(null),[k,L]=l.useState(!1),[$,m]=l.useState(null),[y,T]=l.useState(!1),[j,b]=l.useState(null),[R,A]=l.useState(""),[g,E]=l.useState("classic");l.useEffect(()=>{u&&(async()=>{var o;try{const e=await fetch(`${a}${p}/report-email`,{headers:{"X-WP-Nonce":((o=window.wpApiSettings)==null?void 0:o.nonce)||""}});if(e.ok){const i=await e.json();i.email&&S(i.email),i.template&&E(i.template),i.frequency&&N(i.frequency),i.send_time&&z(i.send_time),i.company_logo&&_(i.company_logo)}}catch(e){console.error("Error fetching report settings:",e)}})()},[u,a,p]);const P=async()=>{var s;if(!k){L(!0),m(null);try{const o=await fetch(`${a}${p}/report-email`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":((s=window.wpApiSettings)==null?void 0:s.nonce)||""},body:JSON.stringify({email:x,template:g,frequency:h,send_time:w,company_logo:c})});if(!o.ok)throw new Error(`Error: ${o.status}`);const e=await o.json();e.success?(O(h,g,!!c),U({has_email_reports:!!x}),m({type:"success",text:"Report settings saved successfully."})):m({type:"error",text:e.message||"Failed to save settings."})}catch(o){console.error("Error saving report settings:",o),m({type:"error",text:"Failed to save settings. Please try again."})}finally{L(!1),setTimeout(()=>{m(null)},3e3)}}},C=()=>{var o;if(!v)return;const s=(o=window.wp)==null?void 0:o.media({title:"Select Company Logo",button:{text:"Use this logo"},multiple:!1,library:{type:"image"}});s.on("select",()=>{const e=s.state().get("selection").first().toJSON();_({id:e.id,url:e.url})}),s.open()},q=()=>{_(null)},V=async s=>{var o;E(s);try{await fetch(`${a}${p}/report-email`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":((o=window.wpApiSettings)==null?void 0:o.nonce)||""},body:JSON.stringify({email:x,template:s,frequency:h,send_time:w,company_logo:c})})}catch(e){console.error("Error saving template:",e)}},F=async()=>{var s;if(!y){T(!0),b(null);try{const o=await fetch(`${a}${p}/send-report`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":((s=window.wpApiSettings)==null?void 0:s.nonce)||""}});if(!o.ok)throw new Error(`Error: ${o.status}`);const e=await o.json();e.success?b({type:"success",text:"Analytics report has been sent to your email."}):b({type:"error",text:e.message||"Failed to send analytics report."})}catch(o){console.error("Error sending report:",o),b({type:"error",text:"Failed to send analytics report. Please try again later."})}finally{T(!1),setTimeout(()=>{b(null)},5e3)}}};if(!u)return t.jsxs("div",{className:"wrap",children:[t.jsx("h1",{className:"text-2xl font-semibold text-gray-900 mb-4",children:"Analytics Reports"}),t.jsx("div",{className:"bg-white border border-gray-200 shadow-sm p-6 rounded-md",children:t.jsx("p",{className:"text-gray-600",children:"Analytics Reports is a premium feature. Please upgrade to access this functionality."})})]});const M={site_name:"My Website",week_range:"Jan 15 - Jan 21, 2024",company_logo:(c==null?void 0:c.url)||null,weekly_stats:[{bot_name:"ChatGPT",visits:1250},{bot_name:"Claude",visits:890},{bot_name:"Perplexity",visits:645},{bot_name:"Gemini",visits:432},{bot_name:"Grok",visits:321}],all_time_stats:[{bot_name:"ChatGPT",visits:15230},{bot_name:"Claude",visits:10890},{bot_name:"Perplexity",visits:7645},{bot_name:"Gemini",visits:5432},{bot_name:"Grok",visits:3321}],visibility_score:{score:72,total_visits:3538,unique_pages:24,breakdown:{frequency:{score:85,weight:25,label:"Crawl Frequency"},visit_type:{score:68,weight:20,label:"Visit Types"},visit_count:{score:75,weight:25,label:"Visit Volume"},page_status:{score:90,weight:15,label:"Page Health"},url_type:{score:55,weight:15,label:"URL Structure"}}}},r=s=>s>=75?"#22c55e":s>=50?"#eab308":"#ef4444",B=s=>{const o={classic:e=>`
        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <style>
              * { margin: 0; padding: 0; box-sizing: border-box; }
              body {
                font-family: Arial, sans-serif;
                line-height: 1.6;
                color: #333;
                max-width: 600px;
                margin: 0 auto;
                padding: 20px;
                background-color: #ffffff;
              }
              .header {
                background-color: #5d4066;
                color: white;
                padding: 20px;
                border-radius: 5px 5px 0 0;
                margin-bottom: 20px;
              }
              .header h1 { margin: 0 0 10px 0; font-size: 24px; }
              .header p { margin: 0; font-size: 14px; opacity: 0.9; }
              .summary {
                background-color: #f9f9f9;
                padding: 15px;
                border-radius: 5px;
                margin: 20px 0;
              }
              .summary h2 { margin: 0 0 10px 0; font-size: 18px; color: #333; }
              .summary p { margin: 0; font-size: 14px; color: #666; }
              .visibility-score-box {
                background-color: #ffffff;
                border-radius: 10px;
                padding: 20px;
                margin: 20px 0;
                color: #000000;
                text-align: center;
              }
              .visibility-score-box h2 { margin: 0 0 15px 0; font-size: 18px; font-weight: 500; }
              .score-circle {
                display: inline-block;
                width: 80px;
                height: 80px;
                border-radius: 50%;
                background: rgba(255,255,255,0.2);
                line-height: 80px;
                font-size: 32px;
                font-weight: bold;
                margin-bottom: 10px;
              }
              .score-details {
                display: flex;
                justify-content: space-around;
                margin-top: 15px;
                flex-wrap: wrap;
              }
              .score-item {
                text-align: center;
                padding: 5px 10px;
              }
              .score-item-label { font-size: 11px; opacity: 0.9; }
              .score-item-value { font-size: 16px; font-weight: bold; }
              .score-green { color: #22c55e; }
              .score-yellow { color: #eab308; }
              .score-red { color: #ef4444; }
              table {
                width: 100%;
                border-collapse: collapse;
                margin: 20px 0;
                background-color: white;
              }
              th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }
              th { background-color: #f5f5f5; font-weight: bold; }
              .bot-name { font-weight: bold; }
              .visits { font-weight: bold; color: #a070b0; }
              h3 { margin: 20px 0 10px 0; font-size: 16px; color: #333; }
              .footer {
                margin-top: 30px;
                padding-top: 20px;
                border-top: 1px solid #ddd;
                font-size: 12px;
                color: #666;
              }
            </style>
          </head>
          <body>
            <div class="header">
              ${e.company_logo?`
                <div style="margin-bottom: 15px;">
                  <img src="${e.company_logo}" alt="Company Logo" style="max-height: 50px; max-width: 150px; object-fit: contain;" />
                </div>
              `:""}
              <h1>LLM Bot Analytics Report</h1>
              <p>${e.site_name} - Week of ${e.week_range}</p>
            </div>
            <div class="visibility-score-box">
              <h2>AI Visibility Score</h2>
              <div class="score-circle" style="background-color: ${r(e.visibility_score.score)};">${e.visibility_score.score}</div>
              <div style="font-size: 14px; opacity: 0.9;">${e.visibility_score.total_visits.toLocaleString()} visits across ${e.visibility_score.unique_pages} pages</div>
              <div class="score-details">
                <div class="score-item">
                  <div class="score-item-value" style="color: ${r(e.visibility_score.breakdown.frequency.score)};">${e.visibility_score.breakdown.frequency.score}</div>
                  <div class="score-item-label">Frequency</div>
                </div>
                <div class="score-item">
                  <div class="score-item-value" style="color: ${r(e.visibility_score.breakdown.visit_type.score)};">${e.visibility_score.breakdown.visit_type.score}</div>
                  <div class="score-item-label">Visit Types</div>
                </div>
                <div class="score-item">
                  <div class="score-item-value" style="color: ${r(e.visibility_score.breakdown.visit_count.score)};">${e.visibility_score.breakdown.visit_count.score}</div>
                  <div class="score-item-label">Volume</div>
                </div>
                <div class="score-item">
                  <div class="score-item-value" style="color: ${r(e.visibility_score.breakdown.page_status.score)};">${e.visibility_score.breakdown.page_status.score}</div>
                  <div class="score-item-label">Health</div>
                </div>
                <div class="score-item">
                  <div class="score-item-value" style="color: ${r(e.visibility_score.breakdown.url_type.score)};">${e.visibility_score.breakdown.url_type.score}</div>
                  <div class="score-item-label">URL</div>
                </div>
              </div>
            </div>
            <div class="summary">
              <h2>Weekly Summary</h2>
              <p>This report shows LLM bot visits to your website during the week of ${e.week_range}.</p>
            </div>
            <h3>Bot Visits for the Week of ${e.week_range}</h3>
            <table>
              <tr><th>Bot Name</th><th>Visits</th></tr>
              ${e.weekly_stats.map(i=>`
                <tr>
                  <td class="bot-name">${i.bot_name}</td>
                  <td class="visits">${i.visits.toLocaleString()}</td>
                </tr>
              `).join("")}
            </table>
            <h3>All-Time Bot Visits</h3>
            <table>
              <tr><th>Bot Name</th><th>Total Visits</th></tr>
              ${e.all_time_stats.map(i=>`
                <tr>
                  <td class="bot-name">${i.bot_name}</td>
                  <td class="visits">${i.visits.toLocaleString()}</td>
                </tr>
              `).join("")}
            </table>
            <div class="footer">
              <p>This is an automated report generated by LLMagnet AI SEO Optimizer.</p>
            </div>
          </body>
        </html>
      `,minimal:e=>`
        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <style>
              * { margin: 0; padding: 0; box-sizing: border-box; }
              body {
                font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                line-height: 1.8;
                color: #2c3e50;
                max-width: 600px;
                margin: 0 auto;
                padding: 40px 20px;
                background-color: #f8f9fa;
              }
              .header {
                text-align: center;
                padding-bottom: 30px;
                border-bottom: 3px solid #2c3e50;
                margin-bottom: 30px;
              }
              .header h1 {
                font-size: 32px;
                font-weight: 300;
                color: #2c3e50;
                margin-bottom: 10px;
                letter-spacing: 2px;
              }
              .header p {
                font-size: 14px;
                color: #7f8c8d;
                text-transform: uppercase;
                letter-spacing: 1px;
              }
              .visibility-score {
                text-align: center;
                padding: 30px;
                margin: 30px 0;
                border: 2px solid #2c3e50;
              }
              .visibility-score h2 {
                font-size: 14px;
                font-weight: 400;
                text-transform: uppercase;
                letter-spacing: 2px;
                color: #7f8c8d;
                margin-bottom: 15px;
              }
              .visibility-score .score-value {
                font-size: 64px;
                font-weight: 200;
                color: #2c3e50;
                line-height: 1;
              }
              .visibility-score .score-meta {
                font-size: 12px;
                color: #95a5a6;
                margin-top: 10px;
              }
              .score-breakdown {
                display: flex;
                justify-content: space-between;
                margin-top: 20px;
                padding-top: 20px;
                border-top: 1px solid #ecf0f1;
              }
              .score-breakdown-item {
                text-align: center;
              }
              .score-breakdown-item .value {
                font-size: 20px;
                font-weight: 300;
                color: #2c3e50;
              }
              .score-breakdown-item .label {
                font-size: 10px;
                text-transform: uppercase;
                letter-spacing: 1px;
                color: #95a5a6;
              }
              .section {
                margin: 40px 0;
              }
              .section-title {
                font-size: 18px;
                font-weight: 400;
                color: #34495e;
                margin-bottom: 20px;
                text-transform: uppercase;
                letter-spacing: 1px;
                border-left: 4px solid #2c3e50;
                padding-left: 15px;
              }
              table {
                width: 100%;
                border-collapse: collapse;
                margin: 20px 0;
              }
              th {
                text-align: left;
                padding: 15px 0;
                border-bottom: 2px solid #2c3e50;
                font-weight: 400;
                font-size: 12px;
                text-transform: uppercase;
                letter-spacing: 1px;
                color: #7f8c8d;
              }
              td {
                padding: 15px 0;
                border-bottom: 1px solid #ecf0f1;
              }
              .bot-name {
                font-weight: 500;
                color: #2c3e50;
              }
              .visits {
                color: #34495e;
                font-size: 18px;
              }
              .footer {
                margin-top: 50px;
                padding-top: 30px;
                border-top: 1px solid #ecf0f1;
                text-align: center;
                font-size: 11px;
                color: #95a5a6;
                text-transform: uppercase;
                letter-spacing: 1px;
              }
            </style>
          </head>
          <body>
            <div class="header">
              ${e.company_logo?`
                <div style="margin-bottom: 20px; text-align: center;">
                  <img src="${e.company_logo}" alt="Company Logo" style="max-height: 40px; max-width: 120px; object-fit: contain;" />
                </div>
              `:""}
              <h1>LLM Bot Analytics</h1>
              <p>${e.site_name} • ${e.week_range}</p>
            </div>
            <div class="visibility-score">
              <h2>AI Visibility Score</h2>
              <div class="score-value" style="color: ${r(e.visibility_score.score)};">${e.visibility_score.score}</div>
              <div class="score-meta">${e.visibility_score.total_visits.toLocaleString()} visits • ${e.visibility_score.unique_pages} pages</div>
              <div class="score-breakdown">
                <div class="score-breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.frequency.score)};">${e.visibility_score.breakdown.frequency.score}</div>
                  <div class="label">Freq</div>
                </div>
                <div class="score-breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.visit_type.score)};">${e.visibility_score.breakdown.visit_type.score}</div>
                  <div class="label">Types</div>
                </div>
                <div class="score-breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.visit_count.score)};">${e.visibility_score.breakdown.visit_count.score}</div>
                  <div class="label">Vol</div>
                </div>
                <div class="score-breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.page_status.score)};">${e.visibility_score.breakdown.page_status.score}</div>
                  <div class="label">Health</div>
                </div>
                <div class="score-breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.url_type.score)};">${e.visibility_score.breakdown.url_type.score}</div>
                  <div class="label">URL</div>
                </div>
              </div>
            </div>
            <div class="section">
              <div class="section-title">Weekly Visits</div>
              <table>
                <tr>
                  <th>Bot</th>
                  <th style="text-align: right;">Visits</th>
                </tr>
                ${e.weekly_stats.map(i=>`
                  <tr>
                    <td class="bot-name">${i.bot_name}</td>
                    <td class="visits" style="text-align: right;">${i.visits.toLocaleString()}</td>
                  </tr>
                `).join("")}
              </table>
            </div>
            <div class="section">
              <div class="section-title">All-Time Total</div>
              <table>
                <tr>
                  <th>Bot</th>
                  <th style="text-align: right;">Total</th>
                </tr>
                ${e.all_time_stats.map(i=>`
                  <tr>
                    <td class="bot-name">${i.bot_name}</td>
                    <td class="visits" style="text-align: right;">${i.visits.toLocaleString()}</td>
                  </tr>
                `).join("")}
              </table>
            </div>
            <div class="footer">
              LLMagnet AI SEO Optimizer
            </div>
          </body>
        </html>
      `,gradient:e=>`
        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <style>
              * { margin: 0; padding: 0; box-sizing: border-box; }
              body {
                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
                line-height: 1.6;
                color: #1f2937;
                max-width: 600px;
                margin: 0 auto;
                background-color: #f3f4f6;
              }
              .email-wrap { background: #ffffff; border-radius: 12px; overflow: hidden; margin: 20px; }
              .header {
                background: linear-gradient(135deg, #301630 0%, #512756 20%, #000000 40%, #2B1434 60%, #E276F0 80%, #E7AFE7 100%);
                padding: 32px 28px;
                color: #ffffff;
                text-align: center;
              }
              .header img { max-height: 44px; max-width: 140px; margin-bottom: 16px; object-fit: contain; }
              .header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
              .header p  { font-size: 13px; opacity: 0.85; }
              .score-card {
                margin: -24px 24px 0;
                background: #ffffff;
                border-radius: 12px;
                box-shadow: 0 4px 24px rgba(0,0,0,0.08);
                padding: 24px;
                text-align: center;
                position: relative;
                z-index: 1;
              }
              .score-card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: #9ca3af; margin-bottom: 12px; }
              .score-number { font-size: 52px; font-weight: 800; line-height: 1; }
              .score-meta { font-size: 12px; color: #6b7280; margin-top: 8px; }
              .score-grid { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 18px; border-top: 1px solid #f3f4f6; }
              .score-grid-item { text-align: center; flex: 1; }
              .score-grid-item .val { font-size: 18px; font-weight: 700; }
              .score-grid-item .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #9ca3af; margin-top: 2px; }
              .section { padding: 28px 24px; }
              .section-title {
                font-size: 13px;
                font-weight: 700;
                text-transform: uppercase;
                letter-spacing: 1px;
                color: #a855f7;
                margin-bottom: 16px;
                display: flex;
                align-items: center;
                gap: 8px;
              }
              .section-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, #e9d5ff, transparent); }
              table { width: 100%; border-collapse: collapse; }
              th {
                text-align: left;
                padding: 10px 12px;
                font-size: 11px;
                text-transform: uppercase;
                letter-spacing: 0.5px;
                color: #9ca3af;
                border-bottom: 2px solid #f3f4f6;
              }
              td { padding: 12px; border-bottom: 1px solid #f9fafb; font-size: 14px; }
              .bot-name { font-weight: 600; color: #1f2937; }
              .visits { font-weight: 700; color: #7c3aed; text-align: right; }
              th:last-child { text-align: right; }
              .footer {
                background: #f9fafb;
                padding: 20px 24px;
                text-align: center;
                font-size: 11px;
                color: #9ca3af;
              }
              .footer a { color: #a855f7; text-decoration: none; }
            </style>
          </head>
          <body>
            <div class="email-wrap">
              <div class="header">
                ${e.company_logo?`<img src="${e.company_logo}" alt="Logo" />`:""}
                <h1>AI Visibility Report</h1>
                <p>${e.site_name} &mdash; ${e.week_range}</p>
              </div>

              <div class="score-card">
                <h2>Visibility Score</h2>
                <div class="score-number" style="color: ${r(e.visibility_score.score)};">
                  ${e.visibility_score.score}
                </div>
                <div class="score-meta">
                  ${e.visibility_score.total_visits.toLocaleString()} visits across ${e.visibility_score.unique_pages} pages
                </div>
                <div class="score-grid">
                  <div class="score-grid-item">
                    <div class="val" style="color:${r(e.visibility_score.breakdown.frequency.score)}">${e.visibility_score.breakdown.frequency.score}</div>
                    <div class="lbl">Freq</div>
                  </div>
                  <div class="score-grid-item">
                    <div class="val" style="color:${r(e.visibility_score.breakdown.visit_type.score)}">${e.visibility_score.breakdown.visit_type.score}</div>
                    <div class="lbl">Types</div>
                  </div>
                  <div class="score-grid-item">
                    <div class="val" style="color:${r(e.visibility_score.breakdown.visit_count.score)}">${e.visibility_score.breakdown.visit_count.score}</div>
                    <div class="lbl">Volume</div>
                  </div>
                  <div class="score-grid-item">
                    <div class="val" style="color:${r(e.visibility_score.breakdown.page_status.score)}">${e.visibility_score.breakdown.page_status.score}</div>
                    <div class="lbl">Health</div>
                  </div>
                  <div class="score-grid-item">
                    <div class="val" style="color:${r(e.visibility_score.breakdown.url_type.score)}">${e.visibility_score.breakdown.url_type.score}</div>
                    <div class="lbl">URL</div>
                  </div>
                </div>
              </div>

              <div class="section">
                <div class="section-title">Weekly Bot Visits</div>
                <table>
                  <tr><th>Bot</th><th>Visits</th></tr>
                  ${e.weekly_stats.map(i=>`
                    <tr>
                      <td class="bot-name">${i.bot_name}</td>
                      <td class="visits">${i.visits.toLocaleString()}</td>
                    </tr>
                  `).join("")}
                </table>
              </div>

              <div class="section" style="padding-top: 0;">
                <div class="section-title">All-Time Statistics</div>
                <table>
                  <tr><th>Bot</th><th>Total</th></tr>
                  ${e.all_time_stats.map(i=>`
                    <tr>
                      <td class="bot-name">${i.bot_name}</td>
                      <td class="visits">${i.visits.toLocaleString()}</td>
                    </tr>
                  `).join("")}
                </table>
              </div>

              <div class="footer">
                Powered by <a href="https://llmagnet.com">LLMagnet</a> AI SEO Optimizer
              </div>
            </div>
          </body>
        </html>
      `,professional:e=>`
        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <style>
              * { margin: 0; padding: 0; box-sizing: border-box; }
              body {
                font-family: Georgia, "Times New Roman", serif;
                line-height: 1.7;
                color: #1a1a1a;
                max-width: 650px;
                margin: 0 auto;
                padding: 30px;
                background-color: #ffffff;
                border: 1px solid #e0e0e0;
              }
              .letterhead {
                border-bottom: 3px solid #1a1a1a;
                padding-bottom: 20px;
                margin-bottom: 30px;
              }
              .letterhead h1 {
                font-size: 36px;
                font-weight: 400;
                color: #1a1a1a;
                margin-bottom: 5px;
                letter-spacing: 1px;
              }
              .letterhead .subtitle {
                font-size: 14px;
                color: #666;
                font-style: italic;
              }
              .date {
                text-align: right;
                margin-bottom: 30px;
                color: #666;
                font-size: 14px;
              }
              .intro {
                margin-bottom: 30px;
                font-size: 15px;
                line-height: 1.8;
                color: #333;
              }
              .visibility-section {
                background-color: #f8f8f8;
                border: 2px solid #1a1a1a;
                padding: 25px;
                margin: 30px 0;
              }
              .visibility-section h2 {
                font-size: 18px;
                font-weight: 400;
                color: #1a1a1a;
                margin-bottom: 20px;
                text-align: center;
              }
              .visibility-main {
                text-align: center;
                margin-bottom: 20px;
              }
              .visibility-main .score {
                font-size: 48px;
                font-weight: 600;
                color: #1a1a1a;
              }
              .visibility-main .score-label {
                font-size: 12px;
                color: #666;
                font-style: italic;
              }
              .visibility-breakdown {
                display: flex;
                justify-content: space-between;
                border-top: 1px solid #e0e0e0;
                padding-top: 15px;
              }
              .breakdown-item {
                text-align: center;
                flex: 1;
              }
              .breakdown-item .value {
                font-size: 18px;
                font-weight: 600;
                color: #1a1a1a;
              }
              .breakdown-item .label {
                font-size: 11px;
                color: #666;
              }
              .report-section {
                margin: 35px 0;
              }
              .report-section h2 {
                font-size: 22px;
                font-weight: 400;
                color: #1a1a1a;
                margin-bottom: 20px;
                border-bottom: 2px solid #1a1a1a;
                padding-bottom: 8px;
              }
              table {
                width: 100%;
                border-collapse: collapse;
                margin: 25px 0;
                font-size: 14px;
              }
              th {
                background-color: #1a1a1a;
                color: white;
                padding: 12px 15px;
                text-align: left;
                font-weight: 400;
                font-size: 13px;
                letter-spacing: 0.5px;
              }
              td {
                padding: 12px 15px;
                border-bottom: 1px solid #e0e0e0;
              }
              tr:last-child td { border-bottom: 2px solid #1a1a1a; }
              .bot-name {
                font-weight: 500;
                color: #1a1a1a;
              }
              .visits {
                font-weight: 600;
                color: #1a1a1a;
              }
              .closing {
                margin-top: 40px;
                font-size: 14px;
                line-height: 1.8;
                color: #333;
              }
              .signature {
                margin-top: 30px;
                padding-top: 20px;
                border-top: 1px solid #e0e0e0;
                font-size: 12px;
                color: #666;
                font-style: italic;
              }
            </style>
          </head>
          <body>
            <div class="letterhead">
              ${e.company_logo?`
                <div style="margin-bottom: 20px;">
                  <img src="${e.company_logo}" alt="Company Logo" style="max-height: 60px; max-width: 180px; object-fit: contain;" />
                </div>
              `:""}
              <h1>LLM Bot Analytics Report</h1>
              <div class="subtitle">${e.site_name}</div>
            </div>
            <div class="date">Week of ${e.week_range}</div>
            <div class="intro">
              Dear Administrator,<br><br>
              Please find below the comprehensive analytics report for LLM bot visits to your website. This report covers your AI Visibility Score, weekly performance metrics, and cumulative all-time statistics.
            </div>
            <div class="visibility-section">
              <h2>AI Visibility Score</h2>
              <div class="visibility-main">
                <div class="score" style="color: ${r(e.visibility_score.score)};">${e.visibility_score.score}</div>
                <div class="score-label">${e.visibility_score.total_visits.toLocaleString()} total visits across ${e.visibility_score.unique_pages} pages</div>
              </div>
              <div class="visibility-breakdown">
                <div class="breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.frequency.score)};">${e.visibility_score.breakdown.frequency.score}</div>
                  <div class="label">Frequency</div>
                </div>
                <div class="breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.visit_type.score)};">${e.visibility_score.breakdown.visit_type.score}</div>
                  <div class="label">Visit Types</div>
                </div>
                <div class="breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.visit_count.score)};">${e.visibility_score.breakdown.visit_count.score}</div>
                  <div class="label">Volume</div>
                </div>
                <div class="breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.page_status.score)};">${e.visibility_score.breakdown.page_status.score}</div>
                  <div class="label">Health</div>
                </div>
                <div class="breakdown-item">
                  <div class="value" style="color: ${r(e.visibility_score.breakdown.url_type.score)};">${e.visibility_score.breakdown.url_type.score}</div>
                  <div class="label">URL</div>
                </div>
              </div>
            </div>
            <div class="report-section">
              <h2>Weekly Performance Metrics</h2>
              <table>
                <tr>
                  <th>Bot Name</th>
                  <th style="text-align: right;">Visits</th>
                </tr>
                ${e.weekly_stats.map(i=>`
                  <tr>
                    <td class="bot-name">${i.bot_name}</td>
                    <td class="visits" style="text-align: right;">${i.visits.toLocaleString()}</td>
                  </tr>
                `).join("")}
              </table>
            </div>
            <div class="report-section">
              <h2>Cumulative Statistics</h2>
              <table>
                <tr>
                  <th>Bot Name</th>
                  <th style="text-align: right;">Total Visits</th>
                </tr>
                ${e.all_time_stats.map(i=>`
                  <tr>
                    <td class="bot-name">${i.bot_name}</td>
                    <td class="visits" style="text-align: right;">${i.visits.toLocaleString()}</td>
                  </tr>
                `).join("")}
              </table>
            </div>
            <div class="closing">
              Should you require any additional information or have questions regarding this report, please do not hesitate to contact us.
            </div>
            <div class="signature">
              Respectfully,<br>
              LLMagnet AI SEO Optimizer<br>
              Automated Reporting System
            </div>
          </body>
        </html>
      `};return o[s]||o.classic};return l.useEffect(()=>{const o=B(g)(M),e=new Blob([o],{type:"text/html"}),i=URL.createObjectURL(e);return A(i),()=>{URL.revokeObjectURL(i)}},[g,c,v]),t.jsx("div",{className:"wrap",style:{maxWidth:"1200px",margin:"auto",paddingTop:"1.5rem",paddingLeft:"1.5rem",paddingRight:"1.5rem"},children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"bg-white p-6",style:{boxShadow:"0px 5.4px 10.79px 0px rgba(0, 0, 0, 0.03)"},children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-6",children:"Email Report Settings"}),t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"report-email",className:"block text-base font-medium text-gray-800 mb-2",children:"Report Recipients"}),t.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Add multiple email addresses separated by commas (e.g., admin@example.com, team@example.com)"}),t.jsx("input",{id:"report-email",type:"text",value:x,onChange:s=>S(s.target.value),className:"w-full rounded border-solid bg-white px-3 py-2 text-sm !border !border-gray-300 focus:border-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-500",placeholder:"admin@example.com, team@example.com"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"report-frequency",className:"block text-base font-medium text-gray-800 mb-2",children:"Report Frequency"}),t.jsxs("select",{id:"report-frequency",value:h,onChange:s=>N(s.target.value),className:"w-full rounded border-solid bg-white px-3 py-2 text-sm !border !border-gray-300 focus:border-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-500",children:[t.jsx("option",{value:"daily",children:"Daily"}),t.jsx("option",{value:"weekly",children:"Weekly"}),t.jsx("option",{value:"monthly",children:"Monthly"}),t.jsx("option",{value:"quarterly",children:"Quarterly"})]})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"report-time",className:"block text-base font-medium text-gray-800 mb-2",children:"Send Time"}),t.jsx("input",{id:"report-time",type:"time",value:w,onChange:s=>z(s.target.value),className:"w-full rounded border-solid bg-white px-3 py-2 text-sm !border !border-gray-300 focus:border-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-500"})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("label",{className:"block text-base font-medium text-gray-800",children:"Company Logo"}),!v&&t.jsxs("a",{href:"/wp-admin/admin.php?page=llmagnet-ai-seo-optimizer-pricing",className:"inline-flex items-center gap-1 text-xs py-0.5 px-2 bg-gradient-to-r from-purple-500 to-pink-500 text-white rounded-full hover:opacity-90 hover:text-white transition-opacity no-underline",children:[t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Enterprise"]})]}),t.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Add your company logo to email reports. Available for Enterprise users only."}),v?t.jsx("div",{className:"flex items-center gap-4",children:c?t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-16 h-16 border border-gray-200 rounded-lg overflow-hidden bg-gray-50 flex items-center justify-center",children:t.jsx("img",{src:c.url,alt:"Company Logo",className:"max-w-full max-h-full object-contain"})}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("button",{onClick:C,className:"text-sm text-purple-600 hover:text-purple-700 font-medium",children:"Change Logo"}),t.jsx("button",{onClick:q,className:"text-sm text-red-500 hover:text-red-600",children:"Remove"})]})]}):t.jsxs("button",{onClick:C,className:"inline-flex items-center gap-2 px-4 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-600 hover:border-purple-400 hover:text-purple-600 transition-colors",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),"Select Logo"]})}):t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 bg-gray-50 rounded-lg border border-gray-200",children:[t.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),t.jsx("span",{className:"text-sm text-gray-500",children:"Upgrade to Enterprise to add your company logo"})]})]}),t.jsxs("div",{className:"pt-4",children:[t.jsx("button",{onClick:P,disabled:k,className:"inline-flex items-center px-6 py-2.5 text-sm font-medium rounded-lg text-white bg-gray-900 hover:bg-gray-800 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:k?"Saving...":"Save Settings"}),$&&t.jsx("p",{className:`mt-2 text-sm ${$.type==="success"?"text-green-600":"text-red-600"}`,children:$.text})]}),t.jsxs("div",{className:"border-t border-gray-100 pt-6",children:[t.jsx("h3",{className:"text-base font-medium text-gray-800 mb-2",children:"Send Report Now"}),t.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Send an analytics report immediately to the recipients above."}),t.jsxs("div",{className:"flex flex-col items-start",children:[t.jsx("button",{onClick:F,disabled:y,className:`inline-block px-6 py-3 bg-gray-900 text-white rounded-full font-medium hover:bg-gray-800 transition-colors ${y?"opacity-70 cursor-not-allowed":""}`,children:y?"Sending...":"Send Analytics Report Now"}),j&&t.jsx("div",{className:`mt-3 p-3 rounded text-sm ${j.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:j.text})]})]})]})]}),t.jsxs("div",{className:"bg-white p-6",style:{boxShadow:"0px 5.4px 10.79px 0px rgba(0, 0, 0, 0.03)"},children:[t.jsxs("div",{className:"flex justify-between items-center mb-6",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Email Template"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{htmlFor:"template-select",className:"text-sm text-gray-600",children:"Template:"}),t.jsxs("select",{id:"template-select",value:g,onChange:s=>V(s.target.value),className:"rounded border-solid bg-white px-3 py-1.5 text-sm !border !border-gray-300 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"classic",children:"Classic"}),t.jsx("option",{value:"minimal",children:"Minimal"}),t.jsx("option",{value:"gradient",children:"Gradient"}),t.jsx("option",{value:"professional",children:"Professional"})]})]})]}),t.jsx("div",{className:"rounded overflow-hidden bg-white border border-gray-200",style:{height:"600px"},children:R?t.jsx("iframe",{src:R,className:"w-full h-full border-0",title:"Email Preview",sandbox:"allow-same-origin",style:{minHeight:"600px"}}):t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx("p",{className:"text-gray-500",children:"Loading email preview..."})})})]})]})})}const d=window.llmagnetReportsData;W({analyticsData:d==null?void 0:d.analyticsData,planData:d==null?void 0:d.planData,isPremium:d==null?void 0:d.isPremium});H("Reports");function D(){var n;const a=window.llmagnetReportsData;if(!a)return t.jsx("div",{className:"p-4 text-red-600",children:"Reports data not found."});const p=((n=window.wpApiSettings)==null?void 0:n.root)||"",f="llm-analytics/v1";return t.jsx("div",{className:"llms-reports-react-app",style:{position:"relative",backgroundColor:"#F0F0F1"},children:t.jsx(I,{apiRoot:p,apiNamespace:f,isPremium:a.planData.plan_name!=="free"||a.planData.is_trial,planData:a.planData})})}export{D as ReportsApp};
