1import{aD as N,r as g,j as e,D as n,I as y,E as S,R as w,at as _,B as r,a as z,aE as C,a0 as M,F as h,W as b,V as v,a6 as m,Z as B}from"./index-YmoTp3IO.js";import{f as L,S as o,H as A,M as D}from"./TransactionDetail-DnWfBTu_.js";import{c as R}from"./palette-CR6Bj1EL.js";import{T as f}from"./triangle-alert-BmVUxX55.js";import{A as T}from"./arrow-right-tT1YJkeF.js";import"./tag-DPUlCbzC.js";import"./pencil-DPXV2Kqy.js";function H(){const{data:s,isLoading:t}=N(),l=(s==null?void 0:s.subscriptions)||[],[c,i]=g.useState(null);return e.jsxs("div",{children:[e.jsx("div",{className:"page-head",children:e.jsxs("div",{children:[e.jsx("h1",{children:"Subscriptions"}),e.jsx("p",{children:"Every recurring charge Lumino has detected automatically."})]})}),!t&&l.length>0&&e.jsxs("div",{className:"stat-grid",style:{marginBottom:20},children:[e.jsxs(n,{className:"hero-networth",children:[e.jsx("div",{className:"stat-label",children:"Monthly recurring"}),e.jsx("div",{className:"num stat-value",children:s==null?void 0:s.formatted_total_monthly})]}),e.jsxs(n,{children:[e.jsx("div",{className:"stat-label",children:"Active subscriptions"}),e.jsx("div",{className:"num stat-value",children:s==null?void 0:s.active_count})]}),e.jsxs(n,{children:[e.jsx("div",{className:"stat-label",children:"Price increases"}),e.jsx("div",{className:"num stat-value",style:{color:((s==null?void 0:s.price_increases_count)||0)>0?"var(--warn)":void 0},children:(s==null?void 0:s.price_increases_count)||0})]}),e.jsxs(n,{children:[e.jsx("div",{className:"stat-label",children:"Possibly forgotten"}),e.jsx("div",{className:"num stat-value",style:{color:((s==null?void 0:s.unused_count)||0)>0?"var(--neg)":void 0},children:(s==null?void 0:s.unused_count)||0})]})]}),t?e.jsx(n,{children:e.jsx(y,{h:280})}):l.length?e.jsx(n,{padded:!1,style:{overflow:"hidden"},children:e.jsx("div",{className:"bud-table-wrap",children:e.jsxs("table",{className:"bud-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:e.jsx("span",{className:"th-inner",children:"Subscription"})}),e.jsx("th",{className:"r",children:e.jsx("span",{className:"th-inner",children:"Cadence"})}),e.jsx("th",{className:"r",children:e.jsx("span",{className:"th-inner",children:"Amount"})}),e.jsx("th",{className:"r",children:e.jsx("span",{className:"th-inner",children:"Monthly"})}),e.jsx("th",{children:e.jsx("span",{className:"th-inner",children:"Status"})})]})}),e.jsx("tbody",{children:l.map(a=>e.jsx(W,{s:a,onOpen:()=>i(a)},a.stream_id))})]})})}):e.jsx(n,{children:e.jsx(S,{icon:e.jsx(w,{size:24}),title:"No recurring charges detected yet",desc:"Once Lumino spots a subscription or recurring bill in your transactions, it shows up here."})}),e.jsx(k,{sub:c,onClose:()=>i(null)})]})}function W({s,onOpen:t}){return e.jsxs("tr",{className:"bud-row",onClick:t,title:`Open ${s.label}`,children:[e.jsx("td",{children:e.jsxs("span",{className:"bud-cat",children:[e.jsx(_,{merchantLogoUrl:s.merchant_logo_url,category:s.category,name:s.label,size:30}),e.jsxs("span",{children:[e.jsxs("span",{className:"bud-cat-name",children:[s.label,s.occurrences>1&&` Ã${s.occurrences}`]}),e.jsx("span",{className:"bud-cat-sub",children:s.occurrences>1?`${s.occurrences} similar charges combined`:[s.bank_name,s.account_name].filter(Boolean).join(" · ")})]})]})}),e.jsx("td",{className:"r td-dim",style:{textTransform:"capitalize"},children:s.cadence.toLowerCase()}),e.jsx("td",{className:"r num",children:s.formatted_amount}),e.jsx("td",{className:"r num td-dim",children:s.formatted_monthly_amount||"â"}),e.jsx("td",{children:s.price_increased?e.jsxs(r,{tone:"warn",children:[e.jsx(f,{size:11})," +",s.pct_change,"%"]}):s.unused?e.jsxs(r,{tone:"neg",children:[s.days_since_last_charge,"d unused"]}):e.jsx(r,{tone:"pos",children:"Stable"})})]})}function k({sub:s,onClose:t}){var p,u;const l=z(),c=!!s,i=!!(s!=null&&s.merchant_name),a=C({merchant_name:(s==null?void 0:s.merchant_name)||void 0,transaction_name:(s==null?void 0:s.merchant_name)||void 0},c&&i),x=g.useMemo(()=>a.data?L(a.data.monthly_by_year):[],[a.data]),j=s?R(s.category||s.label):void 0;return e.jsx(M,{open:c,onClose:t,title:"Subscription",width:520,children:s&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",gap:14,alignItems:"center"},children:[e.jsx(_,{merchantLogoUrl:s.merchant_logo_url,category:s.category,name:s.label,size:52}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{className:"ellipsis",style:{fontWeight:600,fontSize:17},children:s.label}),e.jsx("div",{style:{fontSize:12.5,color:"var(--text-dim)",textTransform:"capitalize"},children:s.cadence.toLowerCase()})]}),s.price_increased?e.jsxs(r,{tone:"warn",children:[e.jsx(f,{size:11})," +",s.pct_change,"%"]}):s.unused?e.jsx(r,{tone:"neg",children:"Possibly forgotten"}):e.jsx(r,{tone:"pos",children:"Stable"})]}),e.jsxs("div",{className:"td-stats",children:[s.price_increased?e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Was",value:h(s.previous_amount||0)}),e.jsx(o,{label:"Now",value:h(s.amount),tone:"neg"})]}):e.jsx(o,{label:"Amount",value:s.formatted_amount}),e.jsx(o,{label:"Monthly",value:s.formatted_monthly_amount||"â"})]}),e.jsxs("div",{className:"td-meta",children:[(s.bank_name||s.account_name)&&e.jsxs("div",{className:"td-meta-row",children:[e.jsxs("span",{children:[e.jsx(b,{size:14})," Account"]}
1),e.jsx("span",{children:[s.bank_name,s.account_name].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"td-meta-row",children:[e.jsxs("span",{children:[e.jsx(v,{size:14})," Last charged"]}),e.jsx("span",{children:s.last_date?m(s.last_date):"â"})]}),e.jsxs("div",{className:"td-meta-row",children:[e.jsxs("span",{children:[e.jsx(v,{size:14})," Next expected"]}),e.jsx("span",{children:s.predicted_next_date?m(s.predicted_next_date):"â"})]})]}),i&&e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:13,fontWeight:600,marginBottom:10,display:"flex",alignItems:"center",gap:8},children:[e.jsx(A,{size:14,style:{color:j}})," Price history"]}),a.isLoading?e.jsx(y,{h:150}):x.length>1?e.jsx(D,{data:x,color:j}):e.jsx("div",{style:{fontSize:12.5,color:"var(--text-dim)"},children:"Not enough history to chart yet."}),!!((u=(p=a.data)==null?void 0:p.recent_transactions)!=null&&u.length)&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("div",{style:{fontSize:11.5,color:"var(--text-dim)",marginBottom:8},children:"Recent charges"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.data.recent_transactions.slice(0,6).map(d=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13,padding:"6px 0",borderBottom:"1px solid var(--border)"},children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:m(d.date)}),e.jsx("span",{className:"num",style:{fontWeight:600},children:h(Math.abs(d.amount))})]},d.id))})]}),e.jsx(B,{full:!0,variant:"outline",icon:e.jsx(T,{size:16}),style:{marginTop:16},onClick:()=>l(`/app/transactions?search=${encodeURIComponent(s.merchant_name)}`),children:"View all transactions"})]})]},s.stream_id)})}export{H 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.