1import{j as s}from"./index-BjgQbuaZ.js";import{u as $,N as D,U as m}from"./Owner-B5rPLC5p.js";function p(t,n,e=2){if(typeof t!="number"||!Number.isFinite(t))return"â";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:n||"USD",minimumFractionDigits:e,maximumFractionDigits:e}).format(t/100)}catch{return`${(t/100).toFixed(e)} ${n}`}}const S=t=>typeof t=="number"&&Number.isFinite(t)?new Intl.NumberFormat("en-US").format(Math.round(t)):"â",c=t=>typeof t=="number"&&Number.isFinite(t);function M(t){const n=t?new Date(t):new Date;return Number.isNaN(n.getTime())?"":n.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}function F(t){const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleDateString("en-GB",{day:"numeric",month:"short"})+", "+n.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}function L(t,n){if(!c(t)||!c(n)||n===0)return null;const e=(t-n)/Math.abs(n)*100;return{pct:e,up:e>=0}}const f=260,g=62;function T({series:t}){const n=t.map(x=>x.cents).filter(x=>Number.isFinite(x));if(n.length<2)return null;const e=Math.max(...n),h=Math.min(...n),u=e-h||1,d=6,i=x=>x/(t.length-1)*f,r=x=>
1d+(1-(x-h)/u)*(g-d*2),N=t.map((x,o)=>`${o?"L":"M"}${i(o).toFixed(1)} ${r(x.cents).toFixed(1)}`).join(" "),a=`${N} L${f} ${g} L0 ${g} Z`,b=t[t.length-1];return s.jsxs("svg",{className:"st-spark",viewBox:`0 0 ${f} ${g}`,width:f,height:g,role:"img","aria-label":"Gross volume over the reported window",preserveAspectRatio:"none",children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"st-spark-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--sk-accent)",stopOpacity:"0.16"}),s.jsx("stop",{offset:"100%",stopColor:"var(--sk-accent)",stopOpacity:"0"})]})}),s.jsx("path",{d:a,fill:"url(#st-spark-fill)"}),s.jsx("path",{d:N,fill:"none",stroke:"var(--sk-accent)",strokeWidth:"1.6",strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}),s.jsx("circle",{cx:i(t.length-1),cy:r(b.cents),r:"2.6",fill:"var(--sk-accent)"})]})}function R({available:t,required:n,short:e}){const h=Math.max(t,n)*1.08||1,u=Math.max(0,Math.min(100,t/h*100)),d=Math.max(0,Math.min(100,n/h*100));return s.jsxs("div",{className:e?"st-meter st-meter-short":"st-meter",children:[s.jsxs("div",{className:"st-meter-track",children:[s.jsx("div",{className:"st-meter-fill",style:{width:`${u}%`}}),s.jsx("div",{className:"st-meter-notch",style:{left:`${d}%`}})]}),s.jsxs("div",{className:"st-meter-legend",children:[s.jsx("span",{className:"st-meter-key st-meter-key-fill",children:"balance on hand"}),s.jsx("span",{className:"st-meter-key st-meter-key-notch",children:"required (owed + threshold)"})]})]})}const q={succeeded:"ok",paid:"ok",active:"ok",available:"ok",pending:"wait",processing:"wait",in_transit:"wait",failed:"bad",canceled:"bad",cancelled:"bad",refunded:"note",disputed:"note",info:"flat"};function A({status:t,label:n}){const e=q[t.toLowerCase()]??"note";return s.jsxs("span",{className:`st-pill st-pill-${e}`,children:[(n??t).replace(/_/g," "),e==="flat"?null:s.jsx("svg",{className:"st-pill-dot",viewBox:"0 0 8 8",width:"8",height:"8","aria-hidden":"true",children:s.jsx("circle",{cx:"4",cy:"4",r:"2.5",fill:"currentColor"})})]})}function B({e:t,currency:n}){const e=t.status==="info";return s.jsxs("tr",{children:[s.jsx("td",{className:"st-td-amt",children:e?s.jsx("span",{className:"st-td-none",children:"â"}):p(t.amountCents,n)}),s.jsx("td",{className:"st-td-pill",children:s.jsx(A,{status:t.status,label:e?t.kind.replace(/\./g," · "):void 0})}),s.jsx("td",{className:"st-td-desc",children:t.label}),s.jsx("td",{className:"st-td-when",children:F(t.at)})]})}function G(t){const n=new Date(t);if(Number.isNaN(n.getTime()))return t;const e=d=>`${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`,h=new Date,u=new Date(h.getTime()-864e5);return e(n)===e(h)?"Today":e(n)===e(u)?"Yesterday":n.toLocaleDateString("en-GB",{day:"numeric",month:"long"})}function P(t){const n=[];for(const e of t){const h=e.at?G(e.at):"Undated",u=n[n.length-1];u&&u.day===h?u.rows.push(e):n.push({day:h,rows:[e]})}return n}const U=25;function E(){return s.jsxs("div",{className:"st-skel","aria-hidden":"true",children:[s.jsx("div",{className:"st-band st-band-4",children:[0,1,2,3].map(t=>s.jsxs("div",{className:"st-col",children:[s.jsx("span",{className:"st-skel-bar st-skel-k"}),s.jsx("span",{className:"st-skel-bar st-skel-v"}),s.jsx("span",{className:"st-skel-bar st-skel-s"})]},t))}),s.jsxs("div",{className:"st-card",children:[s.jsx("span",{className:"st-skel-bar st-skel-h"}),[0,1,2,3].map(t=>s.jsx("span",{className:"st-skel-bar st-skel-row"},t))]})]})}function K({api:t}={}){var w,C;const n=(t==null?void 0:t.useOwnerApi)??$,{data:e,loading:h,error:u}=n("/stripe"),d=l=>{var j;return s.jsxs("div",{className:"skin-stripe",children:[s.jsxs("header",{className:"st-top",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"st-title",children:"Today"}),s.jsx("p",{className:"st-subtitle",children:M(e==null?void 0:e.fetchedAt)})]}),s.jsxs("div",{className:"st-top-right",children:[s.jsx("span",{className:"st-range",children:((j=e==null?void 0:e.grossVolume)==null?void 0:j.label)??"Last 30 days"}),s.jsx("span",{className:"st-attrib",children:"styled after Stripe"})]})]}),l]})};if(h&&!e)return d(s.jsx(E,{}));if(u)return d(s.jsx("div",{className:"st-card st-hollow",children:s.jsx(m,{reason:u})}));if(!e)return d(s.jsx("div",{className:"st-card st-hollow",children:s.jsx(m,{reason:"the backend returned nothing"})}));if(!e.enabled)return d(s.jsxs("div",{className:"st-card st-keys",children:[s.jsx("h3",{className:"st-card-head",children:"Connect this account"}),s.jsx("div",{className:"st-needskeys",children:s.jsx(D,{keys:e.needsKeys??[],product:"Stripe"})}),e.error?s.jsxs("p",{className:"st-keys-err",children:["Last attempt: ",e.error]}):null]}));const i=e.currency||"USD",r=e.grossVolume,N=L((r==null?void 0:r.totalCents)??null,(r==null?void 0:r.previousCents)??null),a=e.float,b=(a==null?void 0:a.state)==="short",x=(a==null?void 0:a.state)==="tight",o=(l,j)=>{var k;return((k=e.unavailable)==null?void 0:k[l])??e.error??j}
1,v=[...e.events??[]].sort((l,j)=>{const k=l.at?new Date(l.at).getTime():0;return(j.at?new Date(j.at).getTime():0)-k}),y=v.slice(0,U);return d(s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"st-band st-band-4",children:[s.jsxs("div",{className:"st-col",children:[s.jsx("p",{className:"st-k",children:"Balance"}),c(e.balanceCents)?s.jsx("p",{className:"st-v",children:p(e.balanceCents,i)}):s.jsx(m,{reason:o("balanceCents","no Stripe balance read")}),s.jsx("p",{className:"st-sub",children:"available in the platform account"})]}),s.jsxs("div",{className:"st-col",children:[s.jsx("p",{className:"st-k",children:"Pending"}),c(e.pendingCents)?s.jsx("p",{className:"st-v",children:p(e.pendingCents,i)}):s.jsx(m,{reason:o("pendingCents","the balance read returns available funds only")}),s.jsx("p",{className:"st-sub",children:"settling, not yet available"})]}),s.jsxs("div",{className:"st-col",children:[s.jsx("p",{className:"st-k",children:"Payouts owed to users"}),c(e.owedNowCents)?s.jsx("p",{className:"st-v",children:p(e.owedNowCents,i)}):s.jsx(m,{reason:o("owedNowCents","cashback ledger not read")}),s.jsx("p",{className:"st-sub",children:"cleared cashback, awaiting payout"})]}),s.jsxs("div",{className:"st-col",children:[s.jsx("p",{className:"st-k",children:"Subscriptions"}),c(e.activeSubs)?s.jsx("p",{className:"st-v",children:S(e.activeSubs)}):s.jsx(m,{reason:o("activeSubs","no subscription list read")}),c(e.mrrCents)?s.jsxs("p",{className:"st-sub",children:[p(e.mrrCents,i)," MRR"]}):s.jsx(m,{reason:o("mrrCents","no subscriptions read")})]})]}),s.jsxs("div",{className:"st-quiet-row",children:[s.jsxs("section",{className:"st-card st-quiet",children:[s.jsxs("div",{className:"st-card-top",children:[s.jsx("h3",{className:"st-card-head",children:"Gross volume"}),s.jsx("span",{className:"st-card-side",children:(r==null?void 0:r.label)??"Last 30 days"})]}),c(r==null?void 0:r.totalCents)?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"st-v st-v-2",children:p(r.totalCents,i,2)}),N?s.jsxs("span",{className:N.up?"st-delta st-delta-up":"st-delta st-delta-down",children:[N.up?"â²":"â¼"," ",Math.abs(N.pct).toFixed(1),"%",s.jsx("span",{className:"st-delta-vs",children:"vs previous period"})]}):s.jsx("span",{className:"st-delta st-delta-none",children:"no comparable previous period"}),r.series&&r.series.length>1?s.jsx(T,{series:r.series}):s.jsx("div",{className:"st-spark-missing",children:s.jsx(m,{reason:o("grossVolume.series","no daily series recorded yet")})})]}):s.jsx(m,{reason:o("grossVolume.totalCents","Stripe balance transactions not read")})]}),s.jsxs("section",{className:"st-card st-quiet",children:[s.jsxs("div",{className:"st-card-top",children:[s.jsx("h3",{className:"st-card-head",children:"Connect Express"}),s.jsx("span",{className:"st-pill st-pill-flat",children:((w=e.connect)==null?void 0:w.status)??"unknown"})]}),(C=e.connect)!=null&&C.detail?s.jsx("p",{className:"st-note st-note-tight",children:e.connect.detail}):s.jsx("p",{className:"st-note st-note-tight",children:"Cashback payouts run through Connect once Stripe enables it."})]})]}),s.jsxs("section",{className:b?"st-card st-float st-float-alarm":"st-card st-float",children:[s.jsxs("div",{className:"st-card-top",children:[s.jsx("h3",{className:"st-card-head",children:"Cashback float"}),s.jsx("span",{className:`st-pill st-pill-${b?"bad":x?"warn":(a==null?void 0:a.state)==="ok"?"ok":"note"}`,children:b?"short":x?"tight":(a==null?void 0:a.state)==="ok"?"healthy":"unknown"})]}),s.jsxs("div",{className:"st-float-grid",children:[s.jsxs("div",{children:[s.jsx("p",{className:"st-k",children:"Must be in Stripe"}),c(a==null?void 0:a.requiredCents)?s.jsx("p",{className:"st-v st-v-2",children:p(a.requiredCents,i)}):s.jsx(m,{reason:o("float.requiredCents","cashback ledger not read")})]}),s.jsxs("div",{children:[s.jsx("p",{className:"st-k",children:"On hand"}),c(a==null?void 0:a.availableCents)?s.jsx("p",{className:"st-v st-v-2",children:p(a.availableCents,i)}):s.jsx(m,{reason:o("float.availableCents","no Stripe balance read")})]}),s.jsxs("div",{children:[s.jsx("p",{className:"st-k",children:"Safety threshold"}),c(a==null?void 0:a.thresholdCents)?s.jsx("p",{className:"st-v st-v-2",children:p(a.thresholdCents,i)}):s.jsx(m,{reason:o("float.thresholdCents","no threshold configured")})]})]}),c(a==null?void 0:a.availableCents)&&c(a==null?void 0:a.requiredCents)&&!(a.availableCents===0&&a.requiredCents===0)?s.jsx(R,{available:a.availableCents,required:a.requiredCents,short:b}):null,b?s.jsx("p",{className:"st-alarm",children:"Cleared cashback exceeds the Stripe balance. Top the platform account up before the next payout run, or payouts will fail."}):s.jsxs("p",{className:"st-note",children:["The float is the money that must sit in Stripe to cover cashback already cleared. Network commissions clear over a 30â90 day window, so it is topped up ahead of them.",(a==null?void 0:a.availableCents)===0&&(a==null?void 0:a.requiredCents)===0?" Nothing is owed and nothing is held yet, so there is no meter to draw.":""]})]}),s.jsxs("section",{className:"st-card",children:[s.jsxs("div",{className:"st-card-top",children:[s.jsx("h3",{className:"st-card-head",children:"Subscriptions"}),s.jsx("span",{className:"st-card-side",children:c(e.mrrCents)?`${p(e.mrrCents,i)} MRR`:"MRR unread"})]}),e.tiers&&e.tiers.length?s.jsx("div",{className:"st-tiles",children:e.tiers.map(l=>s.jsxs("div",{className:"st-tile",children:[s.jsx("p",{className:"st-tile-n",children:S(l.count)}),s.jsx("p",{className:"st-tile-k",children:l.label}),s.jsx("p",{className:"st-tile-m",children:c(l.mrrCents)?`${p(l.mrrCents,i,0)} / mo`:s.jsx("span",{className:"st-tile-none",children:"not measured"})}),c(l.unitCents)&&l.unitCents>0?s.jsxs("p",{className:"st-tile-u",children:[p(l.unitCents,i)," each"]}):null]},l.id))}):s.jsx("p",{className:"st-note st-note-tight",children:o("tiers","no subscription products have been created on this account yet")})]}),s.jsxs("section",{className:"st-card st-card-flush",children:[s.jsxs("div",{className:"st-card-top",children:[s.jsx("h3",{className:"st-card-head",children:"Recent events"}),v.length?s.jsx("span",{className:"st-card-side",children:y.length===v.length?`${v.length} ${v.length===1?"event":"events"}`:`${y.length} of ${v.length} events`}):null]}),y.length?s.jsxs("table",{className:"st-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"st-td-amt",children:"Amount"}),s.jsx("th",{className:"st-td-pill",children:"Status"}),s.jsx("th",{className:"st-td-desc",children:"Description"}),s.jsx("th",{className:"st-td-when",children:"Date"})]})}
1),P(y).map(l=>s.jsxs("tbody",{children:[s.jsx("tr",{className:"st-daysep",children:s.jsx("th",{className:"st-day",colSpan:4,scope:"colgroup",children:l.day})}),l.rows.map(j=>s.jsx(B,{e:j,currency:i},j.id))]},l.day))]}):s.jsx("div",{className:"st-card-body",children:s.jsx(m,{reason:o("events","no events read from Stripe")})})]})]}))}export{K as default};
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.