(()=>{"use strict";var e={364(e,n,t){var r=t(87),s=t(723),a=t(455),o=t.n(a),i=t(427),c=t(790);const l=window.fairPaymentsConnector?.currency||"EUR",d=e=>new Intl.NumberFormat("de-DE",{style:"currency",currency:l}).format(e??0),m=({value:e,max:n})=>{const t=n>0?Math.min(e/n*100,100):0,r=t>=100?"#d63638":t>=80?"#946800":"#007017";return(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{style:{background:"#ddd",borderRadius:"4px",overflow:"hidden",height:"12px"},children:(0,c.jsx)("div",{style:{width:`${t}%`,background:r,height:"100%",transition:"width 0.3s"}})}),(0,c.jsxs)("p",{style:{margin:"4px 0 0",color:r},children:[d(e)," / ",d(n)," (",Math.round(t),"%)"]})]})},p=({label:e,children:n})=>(0,c.jsxs)(i.Card,{children:[(0,c.jsx)(i.CardHeader,{children:(0,c.jsx)("h3",{style:{margin:0},children:e})}),(0,c.jsx)(i.CardBody,{children:n})]});t.d(n,["A",0,()=>{const[e,n]=(0,r.useState)(null),[t,a]=(0,r.useState)(!0),[l,h]=(0,r.useState)(null);(0,r.useEffect)(()=>{o()({path:"/fair-payments-connector/v1/dashboard/monthly-summary"}).then(e=>n(e)).catch(e=>h(e.message||(0,s.__)("Failed to load dashboard data.","fair-payments-connector"))).finally(()=>a(!1))},[]);const x=e?.month?new Date(e.month+"-01").toLocaleString("default",{month:"long",year:"numeric"}):"",y=e?.plan_breakdown?Object.entries(e.plan_breakdown):[],[u,...f]=y;return(0,c.jsx)("div",{className:"wrap fair-payments-connector-fee-dashboard-page",children:(0,c.jsxs)(i.__experimentalVStack,{spacing:4,children:[(0,c.jsxs)(i.__experimentalHStack,{justify:"space-between",align:"center",children:[(0,c.jsx)("h1",{style:{margin:0},children:(0,s.__)("Fee Dashboard","fair-payments-connector")}),x&&(0,c.jsx)("span",{style:{color:"#666"},children:x})]}),e?.testmode&&(0,c.jsx)(i.Notice,{status:"warning",isDismissible:!1,children:(0,s.__)("Test mode — these figures reflect test transactions only.","fair-payments-connector")}),l&&(0,c.jsx)(i.Notice,{status:"error",isDismissible:!0,onRemove:()=>h(null),children:l}),t&&(0,c.jsx)("div",{children:(0,c.jsx)(i.Spinner,{})}),!t&&e&&(0,c.jsxs)(i.__experimentalVStack,{spacing:4,children:[(0,c.jsx)(p,{label:(0,s.__)("Total payment volume this month","fair-payments-connector"),children:(0,c.jsx)("p",{style:{fontSize:"1.5em",margin:0},children:d(e.total_volume)})}),(0,c.jsx)(p,{label:(0,s.__)("Integration fees this month","fair-payments-connector"),children:(0,c.jsx)("p",{style:{fontSize:"1.5em",margin:0},children:d(e.total_fees)})}),(0,c.jsx)(p,{label:(0,s.__)("Monthly fee cap","fair-payments-connector"),children:(0,c.jsxs)(i.__experimentalVStack,{spacing:2,children:[(0,c.jsx)(m,{value:e.total_fees,max:e.fee_cap}),(0,c.jsxs)("p",{style:{margin:0,color:"#666"},children:[d(e.cap_remaining)," ",(0,s.__)("remaining","fair-payments-connector")]})]})}),y.length>0&&(0,c.jsx)(p,{label:(0,s.__)("Active plan","fair-payments-connector"),children:(0,c.jsxs)(i.__experimentalVStack,{spacing:1,children:[u&&(0,c.jsxs)("p",{style:{margin:0},children:[(0,c.jsx)("strong",{children:u[0]})," (",d(u[1]),")"]}),f.map(([e,n])=>(0,c.jsxs)("p",{style:{margin:0},children:["+ ",e," (+",d(n),")"]},e))]})})]})]})})}])},790(e){e.exports=window.ReactJSXRuntime},455(e){e.exports=window.wp.apiFetch},427(e){e.exports=window.wp.components},490(e){e.exports=window.wp.domReady},87(e){e.exports=window.wp.element},723(e){e.exports=window.wp.i18n}};const n={};function t(r){const s=n[r];if(void 0!==s)return s.exports;const a=n[r]={exports:{}};return e[r](a,a.exports,t),a.exports}t.n=e=>{const n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},t.d=(e,n)=>{if(Array.isArray(n))for(var r=0;r<n.length;){var s=n[r++],a=n[r++];t.o(e,s)?0===a&&r++:0===a?Object.defineProperty(e,s,{enumerable:!0,value:n[r++]}):Object.defineProperty(e,s,{enumerable:!0,get:a})}else for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})},t.o=(e,n)=>Object.hasOwn(e,n);var r=t(490),s=t.n(r),a=t(87),o=t(364),i=t(790);s()(()=>{const e=document.getElementById("fair-payments-connector-fee-dashboard-root");e&&(0,a.createRoot)(e).render((0,i.jsx)(o.A,{}))})})();
//# sourceMappingURL=index.js.map