(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,a=window.wp.element,n=window.wp.apiFetch;var l=e.n(n);const r=window.wp.i18n;function c(){return window.agenticDashboard||{}}function i(e,t){let a=`${c().adminUrl||""}admin.php?page=${e}`;return t&&(a+=t),a}function o(e){return Number(e||0).toLocaleString()}function s({value:e,label:a,href:n}){return(0,t.createElement)("div",{className:"agentic-metric"},(0,t.createElement)("div",{className:"agentic-metric-value"},e),(0,t.createElement)("div",{className:"agentic-metric-label"},n?(0,t.createElement)("a",{href:n},a):a))}function u(){const e=!!c().isPro,[n,u]=(0,a.useState)("week"),[d,m]=(0,a.useState)(null),[g,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=!1;const t=()=>{l()({path:`agentic/v1/dashboard-stats?period=${n}`}).then(t=>{e||(m(t),b(!1))}).catch(()=>{e||b(!0)})};t();const a=setInterval(t,3e4);return()=>{e=!0,clearInterval(a)}},[n]);const v=d?.activity||{},_=d?.agents||{},E=i(e?"agentic-costs":"agentic-audit-log");return(0,t.createElement)(a.Fragment,null,(0,t.createElement)("div",{className:"agentic-card-header agentic-flex-between"},(0,t.createElement)("h2",null,(0,r.__)("Activity","agent-builder")),(0,t.createElement)("div",{className:"agentic-period-toggle"},(0,t.createElement)("button",{type:"button",className:"button button-small"+("week"===n?" button-primary":""),onClick:()=>u("week")},(0,r.__)("Week","agent-builder")),(0,t.createElement)("button",{type:"button",className:"button button-small"+("month"===n?" button-primary":""),onClick:()=>u("month")},(0,r.__)("Month","agent-builder")))),g&&(0,t.createElement)("p",{className:"agentic-status-error"},(0,r.__)("Could not load activity.","agent-builder")),(0,t.createElement)("div",{className:"agentic-metrics-grid"},(0,t.createElement)(s,{value:o(v.actions),label:(0,r.__)("Total Actions","agent-builder"),href:i("agentic-audit-log")}),(0,t.createElement)(s,{value:o(v.tokens),label:(0,r.__)("Tokens Used","agent-builder"),href:E}),Number(v.cost)>0&&(0,t.createElement)(s,{value:"$"+Number(v.cost).toFixed(4),label:e?(0,r.__)("Est. Cost","agent-builder"):(0,r.__)("Estimated Usage","agent-builder"),href:E}),(0,t.createElement)(s,{value:o(_.active),label:(0,r.__)("Active Agents","agent-builder"),href:i("agentic-agents")}),(0,t.createElement)(s,{value:o(_.uploaded),label:(0,r.__)("Uploaded Agents","agent-builder"),href:i("agentic-agents")}),(0,t.createElement)(s,{value:o(_.user_created),label:(0,r.__)("User-Created Agents","agent-builder"),href:i("agentic-agents")}),(0,t.createElement)(s,{value:o(_.community),label:(0,r.__)("Community Agents","agent-builder"),href:"https://agentic-plugin.com/community-agents/"})))}document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("agentic-dashboard-activity-root");e&&(0,a.createRoot)(e).render((0,t.createElement)(u,null))})})();