PageSourceSearch

https://notaryeveryday.ai/assets/index-BxKl1DOK.js

js notaryeveryday.ai collected 2026-10-05 12:20:49 UTC 87,484 bytes, 18 lines download raw bytes

1import{j as e}from"./react-pdf-Cq6GPVDG.js";import{r as i,a as Tt}from"./react-router-BFySgQvb.js";import{dR as hs,u as We,ba as ps,v as Ae,J as gs,be as fs,dS as js,a as te,t as bt,B as ie,c as Z,dT as Q,x as V,y as ne,dU as we,ca as vt,bw as ys,ce as ft,bx as pe,cD as je,cc as re,cd as ae,dV as bs,cb as vs,dW as Ns,dX as Ss,dY as ws,by as Cs,dZ as Es,d_ as Ts}from"./index-maVJ-geo.js";import{N as It,a as Rt}from"./NotaryMileageModal-CfgF-EBV.js";import{b as Is,a0 as Rs,v as ks,C as ct,x as Ds,a2 as Ps,a3 as Ms,az as _s,ag as As,a as he,L as _e,G as Re,P as de,ad as Me,aA as Be,ao as Le,D as Ve,F as ze,aB as Ue,a9 as $s,a6 as He,T as dt,af as jt,g as Fs,aC as Os,S as Ls,X as Bs,aD as Vs,k as zs,I as Us,aE as Hs,aF as Ys,e as Ws}from"./icons-DcQvN3ix.js";import{d as Nt,e as St,S as Ks,g as Gs,A as $e,B as wt,R as qs,C as st,f as le,T as Xs}from"./bootstrap-CPno1dha.js";import{h as Js}from"./html2pdf-DN6Wo7ID.js";import{C as ue,b as at,d as nt,a as xe}from"./card-Cc2PDGT4.js";import{B as ke}from"./badge-cWU89HkI.js";import{S as Zs,I as mt,L as Fe}from"./separator-DJFybvQa.js";import{u as Qs,c as ea}from"./index-CrgCrsmn.js";import{c as kt,R as ta,V as sa,A as aa,C as na,a as ra}from"./index-96IvcO2O.js";import"./pdfjs-CC5_zlEF.js";import"./react-core-9HpXahQi.js";import"./calendar-ui-BTeGO8Ej.js";import"./ckeditor-Chjiymov.js";import"./dates-fns-DyoRc1Ct.js";import"./pdf-gen-CK9OQt9R.js";import"./markdown-DFjncyPT.js";import"./axios-4nCoxB4W.js";import"./@react-pdf-C0gzRH8D.js";import"./animation-CbTzt0YB.js";import"./react-select-creatable.esm-6ZHLBdD-.js";import"./useStateManager-7e1e8489.esm-DvPWzAV4.js";import"./forms-74xxAriz.js";import"./tiptap-core-M6Q8ouaR.js";const la=({data:o,taxYear:t,userName:s})=>{const a=i.useRef(null),[n,l]=i.useState(!1),[r,c]=i.useState(!1),[d,m]=i.useState(!1),x={totalIncome:o?.income?.total||0,totalExpenses:o?.expenses?.total||0,netIncome:(o?.income?.total||0)-(o?.expenses?.total||0),mileageDeduction:o?.mileage?.totalDeduction||0,totalMiles:o?.mileage?.totalMiles||0},g=u=>{const T=Number(u)||0;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(T)},v=u=>new Intl.NumberFormat("en-US").format(Math.round(u)),b=x.totalIncome>0?Math.round(x.netIncome/x.totalIncome*100):0,f=async()=>{if(a.current){m(!0);try{const u=await hs(a.current,{backgroundColor:"#0a0a0a",scale:2,useCORS:!0,logging:!1}),T=document.createElement("a");T.download=`my-${t}-money-recap.png`,T.href=u.toDataURL("image/png"),T.click()}catch(u){console.error("Error saving image:",u)}finally{m(!1)}}},h=()=>{const u=`💰 My ${t} Business Recap
2
3📈 Revenue: ${g(x.totalIncome)}
4💸 Expenses: ${g(x.totalExpenses)}
5✨ Net Profit: ${g(x.netIncome)}
6🚗 Miles: ${v(x.totalMiles)}
7
8#NotaryLife #SmallBusiness #SideHustle`;navigator.clipboard.writeText(u).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},p=()=>{navigator.clipboard.writeText(window.location.href).then(()=>{c(!0),setTimeout(()=>c(!1),2e3)})},C=()=>{const u=`💰 Just checked my ${t} business recap!
9
10📈 ${g(x.totalIncome)} revenue
11✨ ${g(x.netIncome)} profit
12🚗 ${v(x.totalMiles)} miles driven
13
14#NotaryLife #SmallBusiness #Entrepreneur`;window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(u)}`,"_blank")},S=()=>{`${t}${g(x.netIncome)}${b}`,window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(window.location.href)}`,"_blank")},E=(o?.expenses?.categories||[]).sort((u,T)=>(T.amount||0)-(u.amount||0)).slice(0,4);return e.jsxs("div",{className:"share-tab",children:[e.jsxs("div",{className:"share-hero",children:[e.jsx("div",{className:"hero-icon",children:e.jsx(Is,{size:24})}),e.jsx("h2",{children:"Share Your Wins ✨"}),e.jsx("p",{children:"flex your financial progress on the timeline"})]}),e.jsx("div",{className:"share-card-wrapper",children:e.jsxs("div",{ref:a,className:"share-card",children:[e.jsxs("div",{className:"card-header",children:[e.jsxs("div",{className:"card-badge",children:[e.jsx(Rs,{size:14}),e.jsxs("span",{children:[t," RECAP"]})]}),e.jsxs("div",{className:"user-tag",children:["@",s||"notary_boss"]})]}),e.jsxs("div",{className:"card-title",children:[e.jsx("h3",{children:"my money wrapped"}),e.jsx("p",{children:"independent notary szn 💼"})]}),e.jsxs("div",{className:"stats-grid",children:[e.jsxs("div",{className:"stat-item revenue",children:[e.jsx("div",{className:"stat-emoji",children:"📈"}),e.jsxs("div",{className:"stat-content",children:[e.jsx("span",{className:"stat-label",children:"Revenue"}),e.jsx("span",{className:"stat-value",children:g(x.totalIncome)})]})]}),e.jsxs("div",{className:"stat-item expenses",children:[e.jsx("div",{className:"stat-emoji",children:"💸"}),e.jsxs("div",{className:"stat-content",children:[e.jsx("span",{className:"stat-label",children:"Spent"}),e.jsx("span",{className:"stat-value",children:g(x.totalExpenses)})]})]}),e.jsxs("div",{className:"stat-item profit",children:[e.jsx("div",{className:"stat-emoji",children:"✨"}),e.jsxs("div",{className:"stat-content",children:[e.jsx("span",{className:"stat-label",children:"Profit"}),e.jsx("span",{className:"stat-value green",children:g(x.netIncome)})]})]}),e.jsxs("div",{className:"stat-item miles",children:[e.jsx("div",{className:"stat-emoji",children:"🚗"}),e.jsxs("div",{className:"stat-content",children:[e.jsx("span",{className:"stat-label",children:"Miles"}),e.jsx("span",{className:"stat-value",children:v(x.totalMiles)})]})]})]}),E.length>0&&e.jsxs("div",{className:"mini-chart",children:[e.jsx("div",{className:"chart-title",children:"where it went 👇"}),e.jsx("div",{className:"chart-bars",children:E.map((u,T)=>{const D=x.totalExpenses>0?Math.round(u.amount/x.totalExpenses*100):0;return e.jsxs("div",{className:"bar-item",children:[e.jsxs("div",{className:"bar-label",children:[e.jsx("span",{className:"bar-name",children:u.name}),e.jsxs("span",{className:"bar-percent",children:[D,"%"]})]}),e.jsx("div",{className:"bar-track",children:e.jsx("div",{className:"bar-fill",style:{width:`${Math.min(D,100)}%`}})})]},T)})})]}),e.jsxs("div",{className:"profit-badge",children:[e.jsxs("div",{className:"profit-ring",children:[e.jsxs("svg",{viewBox:"0 0 36 36",children:[e.jsx("path",{className:"ring-bg",d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"}),e.jsx("path",{className:"ring-fill",strokeDasharray:`${Math.max(0,b)}, 100`,d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"})]}),e.jsxs("span",{className:"ring-text",children:[b,"%"]})]}),e.jsxs("div",{className:"profit-label",children:[e.jsx("span",{children:"profit margin"}),e.jsx("span",{className:"profit-vibe",children:b>=30?"🔥 killing it":b>=15?"💪 solid":"📈 room to grow"})]})]}),e.jsx("div",{className:"card-footer",children:e.jsx("span",{className:"watermark",children:"notaryeveryday.com"})})]})}),e.jsxs("div",{className:"share-actions",children:[e.jsx("button",{className:"action-btn save",onClick:f,disabled:d,children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"spinner"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ks,{size:20}),"Save to Photos"]})}),e.jsx("button",{className:"action-btn copy",onClick:h,children:n?e.jsxs(e.Fragment,{children:[e.jsx(ct,{size:20}),"Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ds,{size:20}),"Copy Stats"]})})]}),e.jsxs("div",{className:"social-grid",children:[e.jsx("h4",{children:"Share the vibes ✌️"}),e.jsxs("div",{className:"social-buttons",children:[e.jsxs("button",{className:"social-btn twitter",onClick:C,children:[e.jsx(Ps,{size:22}),e.jsx("span",{children:"X / Twitter"})]}),e.jsxs("button",{className:"social-btn linkedin",onClick:S,children:[e.jsx(Ms,{size:22}),e.jsx("span",{children:"LinkedIn"})]}),e.jsxs("button",{className:"social-btn instagram",onClick:f,children:[e.jsx(_s,{size:22}),e.jsx("span",{children:"Story"})]}),e.jsxs("button",{className:"social-btn link",onClick:p,children:[r?e.jsx(ct,{size:22}):e.jsx(As,{size:22}),e.jsx("span",{children:r?"Copied!":"Copy Link"})]})]})]}),e.jsxs("div",{className:"share-tips",children:[e.jsx("h4",{children:"pro tips 💡"}),e.jsxs("ul",{children:[e.jsx("li",{children:"📸 Save the image and upload to IG Stories"}),e.jsx("li",{children:"🐦 Tweet your wins to connect with other notaries"}),e.jsx("li",{children:"💼 Share on LinkedIn to build your professional brand"}),e.jsx("li",{children:"📊 Track monthly to see your growth over time"})]})]})]})},oa=()=>{const{user:o,endpoint:t}=We(),[s,a]=i.useState(null),[n,l]=i.useState([]),[r,c]=i.useState(null),[d,m]=i.useState(null),[x,g]=i.useState(!0),[v,b]=i.useState(null),f=o?.user_account?.notary_id;i.useEffect(()=>{if(!f)return;(async()=>{try{g(!0);const T=await te.get(`/api/stripe/notary/${f}/stripe-earnings`);a(T.data);const D=await te.get(`/api/stripe/notary/${f}/payout-history`);l(D.data.payouts||[]);const P=await te.get(`/api/stripe/notary/${f}/stripe-status`);c(P.data);const $=await te.get(`/api/stripe/notary/${f}/ytd-earnings`);m($.data),g(!1)}catch(T){console.error("Error fetching earnings data:",T),b("Failed to load earnings data"),g(!1)}})()},[f]);const h=async()=>
14{try{console.log("[Stripe Connect] Initiating onboarding for notary:",f);const u=await te.post(`/api/stripe/notary/${f}/connect-stripe`);console.log("[Stripe Connect] API Response:",{status:u.status,hasOnboardingUrl:!!u.data?.onboardingUrl,data:u.data}),u.data.onboardingUrl?(console.log("[Stripe Connect] Redirecting to:",u.data.onboardingUrl),window.location.href=u.data.onboardingUrl):(console.error("[Stripe Connect] No onboardingUrl in response:",u.data),ie.error("Failed to generate Stripe onboarding link. Please try again."))}catch(u){console.error("[Stripe Connect] Error initiating Stripe Connect:",{message:u.message,status:u.response?.status,statusText:u.response?.statusText,data:u.response?.data,headers:u.response?.headers,code:u.code,config:{url:u.config?.url,method:u.config?.method}});const T=u.response?.data?.error||u.message||"An error occurred";ie.error(`Failed to initiate Stripe Connect: ${T}`)}},p=u=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(u||0),C=u=>u?new Date(u).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"N/A",S=()=>r?.connected?r?.onboardingComplete?e.jsxs(le,{color:"success",children:[e.jsx(he,{icon:Ae,className:"me-1"}),"Active"]}):r?.onboardingStatus?.requirements?.currently_due?.length>0?e.jsxs(le,{color:"warning",children:[e.jsx(he,{icon:bt,className:"me-1"}),"Action Required"]}):e.jsxs(le,{color:"info",children:[e.jsx(he,{icon:Ae,className:"me-1"}),"Pending Verification"]}):e.jsxs(le,{color:"warning",children:[e.jsx(he,{icon:bt,className:"me-1"}),"Setup Required"]}),E=u=>{switch(u){case"PAID":return e.jsx(le,{color:"success",children:"Paid"});case"PENDING":return e.jsx(le,{color:"warning",children:"Pending"});case"FAILED":return e.jsx(le,{color:"danger",children:"Failed"});default:return e.jsx(le,{color:"secondary",children:u})}};return x?e.jsx(Nt,{className:"earnings-payouts-card","data-testid":"earnings-loading",children:e.jsxs(St,{className:"text-center",children:[e.jsx(Ks,{color:"primary"}),e.jsx("p",{className:"mt-2",children:"Loading earnings data..."})]})}):e.jsxs(Nt,{className:"earnings-payouts-card","data-testid":"earnings-payouts-card",children:[e.jsx(Gs,{children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("h5",{className:"mb-0",children:[e.jsx(he,{icon:ps,className:"me-2"}),"Earnings & Payouts"]}),S()]})}),e.jsxs(St,{children:[v&&e.jsx($e,{color:"danger",children:v}),r?.connected?e.jsxs(e.Fragment,{children:[r?.connected&&!r?.onboardingComplete&&e.jsxs($e,{color:"warning",className:"mb-4","data-testid":"incomplete-onboarding-alert",children:[e.jsx("strong",{children:"Complete Payout Setup"}),e.jsx("p",{className:"mb-2",children:"Additional information is required to activate payouts for your account."}),e.jsxs(wt,{color:"primary",size:"sm",onClick:h,"data-testid":"continue-setup-button",children:[e.jsx(he,{icon:Ae,className:"me-2"}),"Continue Setup"]})]}),e.jsxs(qs,{className:"earnings-summary mb-4","data-testid":"earnings-summary",children:[e.jsx(st,{md:4,children:e.jsxs("div",{className:"earnings-card","data-testid":"current-cycle-card",children:[e.jsx("div",{className:"earnings-label",children:"Current Cycle Earnings"}),e.jsx("div",{className:"earnings-amount","data-testid":"current-cycle-amount",children:p(s?.currentCycleEarnings)}),e.jsxs("div",{className:"earnings-meta",children:[s?.orderCount||0," orders completed",s?.cycleStartDate&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsxs("small",{children:["Cycle: ",C(s.cycleStartDate)," - ",C(s.cycleEndDate)]})]})]})]})}),e.jsx(st,{md:4,children:e.jsxs("div",{className:"earnings-card","data-testid":"next-payout-card",children:[e.jsx("div",{className:"earnings-label",children:"Next Payout Date"}),e.jsxs("div",{className:"earnings-date","data-testid":"next-payout-date",children:[e.jsx(he,{icon:gs,className:"me-2"}),C(s?.nextPayoutDate)]}),e.jsx("div",{className:"earnings-meta",children:"T+5 (5 business days after cycle ends)"})]})}),e.jsx(st,{md:4,children:e.jsxs("div",{className:"earnings-card","data-testid":"ytd-earnings-card",children:[e.jsxs("div",{className:"earnings-label",children:["YTD Earnings (",d?.year||new Date().getFullYear(),")"]}),e.jsx("div",{className:"earnings-amount","data-testid":"ytd-earnings-amount",children:p(d?.grossEarnings||s?.ytdEarnings)}),e.jsxs("div",{className:"earnings-meta",children:[d?.orderCount||0," orders completed"]}),d&&e.jsx("div",{className:"mt-2",children:d.will1099BeIssued?e.jsx(le,{color:"info",children:"1099-NEC will be issued"}):e.jsx(le,{color:"secondary",children:"Below $600 threshold"})})]})})]}),e.jsxs("div",{className:"payout-history","data-testid":"payout-history-section",children:[e.jsx("h6",{className:"mb-3",children:"Recent Payouts"}),n.length===0?e.jsx($e,{color:"light",className:"mb-0","data-testid":"empty-payout-history",children:"No payout history yet. Complete orders to receive your first payout!"}):e.jsxs(Xs,{striped:!0,responsive:!0,className:"payout-history-table","data-testid":"payout-history-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Payout Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Orders"}),e.jsx("th",{children:"Details"}),e.jsx("th",{children:"Method"}),e.jsx("th",{children:"Status"})]})}),e.jsx("tbody",{children:n.map((u,T)=>e.jsxs("tr",{children:[e.jsx("td",{children:C(u.payoutDate)}),e.jsx("td",{className:"amount",children:p(u.amount)}),e.jsx("td",{children:u.orderCount}
14),e.jsx("td",{children:u.payoutMethod==="stripe"?e.jsxs("span",{children:[C(u.cycleStartDate)," - ",C(u.cycleEndDate)]}):e.jsxs("span",{className:"text-muted",children:[u.fileNumber?`#${u.fileNumber}`:`Order #${u.orderId}`,u.signerName&&` - ${u.signerName}`]})}),e.jsx("td",{children:u.payoutMethod==="stripe"?e.jsxs(le,{color:"primary",className:"d-flex align-items-center gap-1",style:{width:"fit-content"},children:[e.jsx(he,{icon:fs,size:"sm"}),"Stripe"]}):e.jsxs(le,{color:"secondary",className:"d-flex align-items-center gap-1",style:{width:"fit-content"},children:[e.jsx(he,{icon:js,size:"sm"}),"Manual"]})}),e.jsx("td",{children:E(u.status)})]},T))})]})]})]}):e.jsxs($e,{color:"info",className:"mb-0","data-testid":"setup-required-alert",children:[e.jsx("h6",{children:"Setup Required"}),e.jsx("p",{children:"Connect your bank account to receive automated payouts for completed orders. Payouts are processed T+5 (5 business days after billing cycle ends)."}),e.jsxs(wt,{color:"primary",onClick:h,"data-testid":"setup-payout-button",children:[e.jsx(he,{icon:Ae,className:"me-2"}),"Setup Payout Account"]})]})]})]})},oe=o=>{const t=Number(o)||0;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(t)},rt=o=>o?new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—",hn=()=>{const{endpoint:o,user:t}=We(),s=t?.user_account?.notary_id,[a,n]=i.useState("overview"),[l,r]=i.useState(!0),[c,d]=i.useState(new Date().getFullYear()),[m,x]=i.useState(null),[g,v]=i.useState([]),[b,f]=i.useState([]),[h,p]=i.useState(!1),[C,S]=i.useState(!1),[E,u]=i.useState(null),[T,D]=i.useState(null),[P,$]=i.useState(!1),F=i.useCallback(async()=>{if(s){r(!0);try{const[j,O,ee]=await Promise.all([te.get(`/api/notary-accounting/notaries/${s}/profit-loss?taxYear=${c}`),te.get(`/api/notary-expenses/notaries/${s}/expenses?taxYear=${c}`),te.get(`/api/notary-mileage/notaries/${s}/mileage?taxYear=${c}`)]);j.data.success&&x(j.data.data),O.data.success&&v(O.data.data||[]),ee.data.success&&f(ee.data.data||[])}catch(j){console.error("Error fetching data:",j),ie.error("Failed to load accounting data")}finally{r(!1)}}},[o,s,c]);i.useEffect(()=>{F()},[F]);const U=(j="expense")=>{u({category_type:j}),p(!0),$(!1)},q=j=>{u(j),p(!0)},J=async j=>{if(window.confirm("Are you sure you want to delete this entry?"))try{await te.delete(`/api/notary-expenses/expenses/${j}`),ie.success("Entry deleted"),F()}catch{ie.error("Failed to delete entry")}},H=()=>{D(null),S(!0),$(!1)},W=j=>{D(j),S(!0)},w=async j=>{if(window.confirm("Are you sure you want to delete this mileage record?"))try{await te.delete(`/api/notary-mileage/mileage/${j}`),ie.success("Mileage deleted"),F()}catch{ie.error("Failed to delete mileage")}},I=()=>{const j=g.map(R=>({Date:rt(R.expense_date),Category:R.category_name,Type:R.category_type,Amount:R.amount,Vendor:R.vendor_name||"",Notes:R.notes||""})),O=Object.keys(j[0]||{}).join(","),ee=j.map(R=>Object.values(R).join(",")),se=[O,...ee].join(`
15`),N=new Blob([se],{type:"text/csv"}),A=window.URL.createObjectURL(N),y=document.createElement("a");y.href=A,y.download=`accounting-${c}.csv`,y.click(),window.URL.revokeObjectURL(A),ie.success("Export downloaded")},k=m?.summary||{totalIncome:0,totalExpenses:0,netIncome:0},_=b.reduce((j,O)=>({miles:j.miles+(parseFloat(O.mileage)||0),amount:j.amount+(parseFloat(O.tax_deduction)||parseFloat(O.mileage)*.7||0)}),{miles:0,amount:0}),L=new Date().getFullYear(),Y=Array.from({length:L-2020},(j,O)=>L-O);return l?e.jsx("div",{className:"accounting-minimal",children:e.jsxs("div",{className:"loading-screen",children:[e.jsx(_e,{className:"spinner"}),e.jsx("p",{children:"Loading your finances..."})]})}):e.jsxs("div",{className:"accounting-minimal",children:[e.jsxs("header",{className:"header",children:[e.jsxs("div",{className:"header-left",children:[e.jsx("h1",{children:"Earnings"}),e.jsx("select",{value:c,onChange:j=>d(Number(j.target.value)),className:"year-select",children:Y.map(j=>e.jsx("option",{value:j,children:j},j))})]}),e.jsxs("div",{className:"header-actions",children:[e.jsxs("button",{className:"btn-secondary",onClick:I,children:[e.jsx(Re,{size:16}),"Export"]}),e.jsxs("div",{className:"dropdown-container",children:[e.jsxs("button",{className:"btn-primary",onClick:()=>$(!P),children:[e.jsx(de,{size:18}),"Add Entry"]}),P&&e.jsxs("div",{className:"add-entry-menu",children:[e.jsxs("button",{onClick:()=>U("income"),children:[e.jsx(Me,{size:16}),"Add Income"]}),e.jsxs("button",{onClick:()=>U("expense"),children:[e.jsx(Be,{size:16}),"Add Expense"]}),e.jsxs("button",{onClick:H,children:[e.jsx(Le,{size:16}),"Add Mileage"]})]})]})]})]}),e.jsxs("div",{className:"stats-row",children:[e.jsxs("div",{className:"stat-card income",children:[e.jsx("div",{className:"stat-icon",children:e.jsx(Me,{size:20})}),e.jsxs("div",{className:"stat-content",children:[e.jsx("span",{className:"stat-label",children:"Income"}),e.jsx("span",{className:"stat-value",children:oe(k.totalIncome)})]})]}),e.jsxs("div",{className:"stat-card expense",children:[e.jsx("div",{className:"stat-icon",children:e.jsx(Be,{size:20})}),e.jsxs("div",{className:"stat-content",children:[e.jsx("span",{className:"stat-label",children:"Expenses"}),e.jsx("span",{className:"stat-value",children:oe(k.totalExpenses)})]})]}),e.jsxs("div",{className:"stat-card profit",children:[e.jsx("div",{className:"stat-icon",children:e.jsx(Ve,{size:20})}),e.jsxs("div",{className:"stat-content",children:[e.jsx("span",{className:"stat-label",children:"Net Profit"}),e.jsx("span",{className:`stat-value ${k.netIncome>=0?"positive":"negative"}`,children:oe(k.netIncome)})]})]})]}),e.jsx("nav",{className:"tabs",children:[{id:"overview",label:"Overview",icon:ze},{id:"expenses",label:"Expenses",icon:Ue},{id:"mileage",label:"Mileage",icon:Le},{id:"payouts",label:"Payouts",icon:Ve},{id:"share",label:"Share",icon:$s,highlight:!0}].map(j=>e.jsxs("button",{className:`tab ${a===j.id?"active":""} ${j.highlight?"highlight":""}`,onClick:()=>n(j.id),children:[e.jsx(j.icon,{size:18}),j.label]},j.id))}),e.jsxs("div",{className:"content",children:[a==="overview"&&e.jsxs("div",{className:"overview-content",children:[e.jsxs("section",{className:"section",children:[e.jsxs("div",{className:"section-header",children:[e.jsx("h2",{children:"Income"}),e.jsx("span",{className:"section-total positive",children:oe(k.totalIncome)})]}),e.jsxs("div",{className:"category-list",children:[m?.income?.categories?.map((j,O)=>e.jsxs("div",{className:"category-item",children:[e.jsx("span",{className:"category-name",children:j.name}),e.jsx("span",{className:"category-amount",children:oe(j.amount)})]},O)),(!m?.income?.categories||m.income.categories.length===0)&&e.jsx("p",{className:"empty-text",children:"No income recorded"})]})]}),e.jsxs("section",{className:"section",children:[e.jsxs("div",{className:"section-header",children:[e.jsx("h2",{children:"Expenses"}),e.jsx("span",{className:"section-total negative",children:oe(k.totalExpenses)})]}),e.jsxs("div",{className:"category-list",children:[m?.expenses?.categories?.map((j,O)=>e.jsxs("div",{className:"category-item",children:[e.jsx("span",{className:"category-name",children:j.name}),e.jsx("span",{className:"category-amount",children:oe(j.amount)})]},O)),(!m?.expenses?.categories||m.expenses.categories.length===0)&&e.jsx("p",{className:"empty-text",children:"No expenses recorded"})]})]}),e.jsxs("section",{className:"section tax-section",children:[e.jsx("div",{className:"section-header",children:e.jsx("h2",{children:"Tax Summary"})}),e.jsxs("div",{className:"tax-grid",children:[e.jsxs("div",{className:"tax-item",children:[e.jsx("span",{className:"tax-label",children:"Self-Employment Tax Basis"}),e.jsx("span",{className:"tax-value",children:oe(m?.summary?.selfEmploymentTaxableIncome||0)})]}),e.jsxs("div",{className:"tax-item",children:[e.jsx("span",{className:"tax-label",children:"Eligible Notarial Fees"}),e.jsx("span",{className:"tax-value",children:oe(m?.summary?.eligibleNotarialFees||0)})]})]}),e.jsx("p",{className:"tax-note",children:"* Notarial fees are exempt from self-employment tax. See IRS Publication 334."})]})]}),a==="expenses"&&e.jsxs("div",{className:"expenses-content",children:[e.jsxs("div",{className:"list-header",children:[e.jsxs("span",{children:[g.length," entries"]}),e.jsxs("div",{className:"list-actions",children:[e.jsxs("button",{className:"btn-secondary",onClick:I,children:[e.jsx(Re,{size:16}),"Export"]}),e.jsxs("button",{className:"btn-secondary",onClick:()=>U("income"),children:[e.jsx(de,{size:16}),"Income"]}),e.jsxs("button",{className:"btn-primary",onClick:()=>U("expense"),children:[e.jsx(de,{size:16}),"Expense"]})]})]}),e.jsxs("div",{className:"expense-list",children:[g.map(j=>e.jsxs("div",{className:"expense-row",children:[e.jsxs("div",{className:"expense-main",children:[e.jsx("span",{className:"expense-date",children:rt(j.expense_date)}),e.jsx("span",{className:"expense-category",children:j.category_name}),e.jsx("span",{className:`expense-type ${j.category_type}`,children:j.category_type}),j.vendor_name&&e.jsx("span",{className:"expense-vendor",children:j.vendor_name})]}),e.jsxs("div",{className:"expense-right",children:[e.jsxs("span",{className:`expense-amount ${j.category_type==="income"?"positive":"negative"}`,children:[j.category_type==="income"?"+":"-",oe(j.amount)]}),e.jsxs("div",{className:"row-actions",children:[e.jsx("button",{className:"icon-btn",onClick:()=>q(j),title:"Edit",children:e.jsx(He,{size:14})}),e.jsx("button",{className:"icon-btn danger",onClick:()=>J(j.id),title:"Delete",children:e.jsx(dt,{size:14})})]})]})]},j.id)),g.length===0&&e.jsxs("div",{className:"empty-state",children:[e.jsx(Ue,{size:48}),e.jsx("h3",{children:"No expenses yet"}),e.jsx("p",{children:"Start tracking your business expenses"}),e.jsxs("button",{className:"btn-primary",onClick:()=>U("expense"),children:[e.jsx(de,{size:18}),"Add Expense"]})]})]})]}),a==="mileage"&&e.jsxs("div",{className:"mileage-content",children:[e.jsxs("div",{className:"mileage-summary",children:[e.jsxs("div",{className:"mileage-stat",children:[e.jsx("span",{className:"mileage-label",children:"Total Miles"}),e.jsxs("span",{className:"mileage-value",children:[_.miles.toFixed(1)," mi"]})]}),e.jsxs("div",{className:"mileage-stat",children:[e.jsx("span",{className:"mileage-label",children:"Deduction"}),e.jsx("span",{className:"mileage-value positive",children:oe(_.amount)})]}),e.jsxs("div",{className:"mileage-stat",children:[e.jsx("span",{className:"mileage-label",children:"IRS Rate"}),e.jsx("span",{className:"mileage-value",children:"$0.70/mi"})]})]}),e.jsxs("div",{className:"list-header",children:[e.jsxs("span",{children:[b.length," trips"]}),e.jsxs("button",{className:"btn-primary",onClick:H,children:[e.jsx(de,{size:16}
15),"Add Trip"]})]}),e.jsxs("div",{className:"mileage-list",children:[b.map(j=>{const O=parseFloat(j.mileage)||0,ee=parseFloat(j.tax_deduction)||O*.7;return e.jsxs("div",{className:"mileage-row",children:[e.jsxs("div",{className:"mileage-main",children:[e.jsx("span",{className:"mileage-date",children:rt(j.mileage_date)}),e.jsx("span",{className:"mileage-desc",children:j.notes||"Business trip"}),j.reimbursed&&e.jsx("span",{className:"reimbursed-badge",children:"Reimbursed"}),j.order_id&&e.jsxs("a",{href:`/admin/orders/${j.order_id}`,className:"order-link",children:["#",j.order_id]})]}),e.jsxs("div",{className:"mileage-right",children:[e.jsxs("span",{className:"miles",children:[O.toFixed(1)," mi"]}),e.jsx("span",{className:"deduction",children:oe(ee)}),e.jsxs("div",{className:"row-actions",children:[e.jsx("button",{className:"icon-btn",onClick:()=>W(j),title:"Edit",children:e.jsx(He,{size:14})}),e.jsx("button",{className:"icon-btn danger",onClick:()=>w(j.id),title:"Delete",children:e.jsx(dt,{size:14})})]})]})]},j.id)}),b.length===0&&e.jsxs("div",{className:"empty-state",children:[e.jsx(Le,{size:48}),e.jsx("h3",{children:"No mileage logged"}),e.jsx("p",{children:"Track your business travel for tax deductions"}),e.jsxs("button",{className:"btn-primary",onClick:H,children:[e.jsx(de,{size:18}),"Add Trip"]})]})]})]}),a==="share"&&e.jsx(la,{data:{income:{total:k.totalIncome,categories:m?.income?.categories||[]},expenses:{total:k.totalExpenses,categories:m?.expenses?.categories||[]},mileage:{totalMiles:_.miles,totalDeduction:_.amount}},taxYear:c,userName:t?.user_account?.first_name?.toLowerCase()||"notary"}),a==="payouts"&&e.jsx(oa,{})]}),P&&e.jsx("div",{className:"dropdown-overlay",onClick:()=>$(!1)}),e.jsx(It,{isOpen:h,toggle:()=>{p(!1),u(null),F()},expenseToEdit:E,notaryId:s,endpoint:o,categoryType:E?.category_type||"expense",onUpdateSuccess:F}),e.jsx(Rt,{isOpen:C,toggle:()=>{S(!1),D(null),F()},mileageRecord:T,notaryId:s,endpoint:o,onSuccess:F})]})},Ct=o=>{const t=Z.c(29),{category:s,isExpanded:a,onToggle:n,type:l,details:r}=o,d=(l===void 0?"income":l)==="income";let m;t[0]!==a?(m=a?e.jsx(jt,{className:"h-4 w-4 text-gray-400"}):e.jsx(Fs,{className:"h-4 w-4 text-gray-400"}),t[0]=a,t[1]=m):m=t[1];let x;t[2]!==s.name?(x=e.jsx("span",{className:"font-medium text-gray-900",children:s.name}),t[2]=s.name,t[3]=x):x=t[3];const g=s.count===1?"item":"items";let v;t[4]!==s.count||t[5]!==g?(v=e.jsxs(ke,{variant:"secondary",className:"text-xs",children:[s.count," ",g]}),t[4]=s.count,t[5]=g,t[6]=v):v=t[6];let b;t[7]!==m||t[8]!==x||t[9]!==v?(b=e.jsxs("div",{className:"flex items-center gap-3",children:[m,x,v]}),t[7]=m,t[8]=x,t[9]=v,t[10]=b):b=t[10];const f=d?"text-emerald-600":"text-rose-600";let h;t[11]!==f?(h=V("font-semibold tabular-nums",f),t[11]=f,t[12]=h):h=t[12];const p=parseFloat(s.amount);let C;t[13]!==p?(C=Q(p),t[13]=p,t[14]=C):C=t[14];let S;t[15]!==C||t[16]!==h?(S=e.jsx("span",{className:h,children:C}),t[15]=C,t[16]=h,t[17]=S):S=t[17];let E;t[18]!==n||t[19]!==S||t[20]!==b?(E=e.jsxs("button",{onClick:n,className:"w-full px-4 py-3 flex items-center justify-between hover:bg-gray-50/50 transition-colors",children:[b,S]}),t[18]=n,t[19]=S,t[20]=b,t[21]=E):E=t[21];let u;t[22]!==r||t[23]!==a||t[24]!==d?(u=a&&r&&e.jsx("div",{className:"bg-gray-50/50 px-4 py-3 pl-11",children:e.jsx("div",{className:"space-y-2",children:r.map((D,P)=>e.jsxs("div",{className:"flex items-center justify-between text-sm py-1",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-gray-500 tabular-nums w-24",children:we(D.date)}),e.jsx("span",{className:"text-gray-700",children:D.vendor||D.type||D.notes||"—"}),D.orderId&&e.jsxs(ke,{variant:"outline",className:"text-xs",children:["Order #",D.orderId]})]}),e.jsx("span",{className:V("font-medium tabular-nums",d?"text-emerald-600":"text-rose-600"),children:Q(parseFloat(D.amount))})]},P))})}),t[22]=r,t[23]=a,t[24]=d,t[25]=u):u=t[25];let T;return t[26]!==E||t[27]!==u?(T=e.jsxs("div",{className:"border-b border-gray-100 last:border-b-0",children:[E,u]}),t[26]=E,t[27]=u,t[28]=T):T=t[28],T},lt=o=>{const t=Z.c(22),{title:s,amount:a,type:n,icon:l}=o;let r,c,d,m;if(t[0]!==l||t[1]!==a||t[2]!==s||t[3]!==n){const h={income:{bg:"bg-emerald-50",border:"border-emerald-200",text:"text-emerald-700",iconBg:"bg-emerald-100"},expense:{bg:"bg-rose-50",border:"border-rose-200",text:"text-rose-700",iconBg:"bg-rose-100"},net:{bg:a>=0?"bg-blue-50":"bg-amber-50",border:a>=0?"border-blue-200":"border-amber-200",text:a>=0?"text-blue-700":"text-amber-700",iconBg:a>=0?"bg-blue-100":"bg-amber-100"}}[n];m=V("rounded-xl p-4 border",h.bg,h.border),c="flex items-center justify-between";let p;t[8]!==s?(p=e.jsx("span",{className:"font-medium text-gray-700",children:s}
15),t[8]=s,t[9]=p):p=t[9],d=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:V("p-2 rounded-lg",h.iconBg),children:e.jsx(l,{className:V("h-5 w-5",h.text)})}),p]}),r=V("text-xl font-bold tabular-nums",h.text),t[0]=l,t[1]=a,t[2]=s,t[3]=n,t[4]=r,t[5]=c,t[6]=d,t[7]=m}else r=t[4],c=t[5],d=t[6],m=t[7];let x;t[10]!==a?(x=Q(a),t[10]=a,t[11]=x):x=t[11];let g;t[12]!==r||t[13]!==x?(g=e.jsx("span",{className:r,children:x}),t[12]=r,t[13]=x,t[14]=g):g=t[14];let v;t[15]!==c||t[16]!==d||t[17]!==g?(v=e.jsxs("div",{className:c,children:[d,g]}),t[15]=c,t[16]=d,t[17]=g,t[18]=v):v=t[18];let b;return t[19]!==m||t[20]!==v?(b=e.jsx("div",{className:m,children:v}),t[19]=m,t[20]=v,t[21]=b):b=t[21],b},pn=o=>{const t=Z.c(72),{data:s,loading:a,taxYear:n,taxQuarter:l}=o,[r,c]=i.useState(null),[d,m]=i.useState(null);let x;t[0]!==l||t[1]!==n?(x=()=>{const y=document.getElementById("profit-loss-report");if(!y)return;const R={margin:10,filename:`profit-loss-${n}${l?`-Q${l}`:""}.pdf`,image:{type:"jpeg",quality:.98},html2canvas:{scale:2,useCORS:!0},jsPDF:{unit:"mm",format:"a4",orientation:"portrait"}};Js().set(R).from(y).save()},t[0]=l,t[1]=n,t[2]=x):x=t[2];const g=x;let v;t[3]!==s?(v=(y,R)=>{const K=R===void 0?!0:R;if(!s)return[];const M=K?s.income.details:s.expenses.details,z=Object.keys(M).find(ge=>ge.toLowerCase()===y.toLowerCase());if(!z)return[];const G=M[z];return z.toLowerCase()==="signings"&&G.allPayments?G.allPayments:Array.isArray(G)?G:[]},t[3]=s,t[4]=v):v=t[4];const b=v;if(a){let y;return t[5]===Symbol.for("react.memo_cache_sentinel")?(y=e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(_e,{className:"h-8 w-8 animate-spin text-gray-400 mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading report data..."})]}),t[5]=y):y=t[5],y}if(!s){let y;return t[6]===Symbol.for("react.memo_cache_sentinel")?(y=e.jsx(ue,{children:e.jsxs(xe,{className:"py-16 text-center",children:[e.jsx(ze,{className:"h-12 w-12 mx-auto text-gray-300 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No Data Available"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto",children:"No profit & loss data found for the selected period. Try adjusting your filters or add some transactions."})]})}),t[6]=y):y=t[6],y}const{summary:f,income:h,expenses:p,period:C}=s;let S;t[7]===Symbol.for("react.memo_cache_sentinel")?(S=e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Profit & Loss Statement"}),t[7]=S):S=t[7];const E=C?.description||`${n}${l?` Q${l}`:""}`;let u;t[8]!==E?(u=e.jsxs("div",{children:[S,e.jsx("p",{className:"text-sm text-muted-foreground",children:E})]}),t[8]=E,t[9]=u):u=t[9];let T;t[10]===Symbol.for("react.memo_cache_sentinel")?(T=e.jsx(Re,{className:"h-4 w-4"}),t[10]=T):T=t[10];let D;t[11]!==g?(D=e.jsxs(ne,{onClick:g,variant:"outline",size:"sm",className:"gap-2",children:[T,"Export PDF"]}),t[11]=g,t[12]=D):D=t[12];let P;t[13]!==u||t[14]!==D?(P=e.jsxs("div",{className:"flex items-center justify-between",children:[u,D]}),t[13]=u,t[14]=D,t[15]=P):P=t[15];let $;t[16]!==f.totalIncome?($=e.jsx(lt,{title:"Total Income",amount:f.totalIncome,type:"income",icon:Me}),t[16]=f.totalIncome,t[17]=$):$=t[17];let F;t[18]!==f.totalExpenses?(F=e.jsx(lt,{title:"Total Expenses",amount:f.totalExpenses,type:"expense",icon:Be}),t[18]=f.totalExpenses,t[19]=F):F=t[19];let U;t[20]!==f.netIncome?(U=e.jsx(lt,{title:"Net Income",amount:f.netIncome,type:"net",icon:Ve}),t[20]=f.netIncome,t[21]=U):U=t[21];let q;t[22]!==F||t[23]!==U||t[24]!==$?(q=e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[$,F,U]}),t[22]=F,t[23]=U,t[24]=$,t[25]=q):q=t[25];let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"Income"]}),t[26]=J):J=t[26];let H;t[27]!==f.totalIncome?(H=Q(f.totalIncome),t[27]=f.totalIncome,t[28]=H):H=t[28];let W;t[29]!==H?(W=e.jsx(at,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[J,e.jsx("span",{className:"text-lg font-bold text-emerald-600 tabular-nums",children:H})]})}),t[29]=H,t[30]=W):W=t[30];let w;if(t[31]!==r||t[32]!==b||t[33]!==h.categories){let y;t[35]!==r||t[36]!==b?(y=(R,K)=>e.jsx(Ct,{category:R,type:"income",isExpanded:r===R.name,onToggle:()=>c(r===R.name?null:R.name),details:b(R.name,!0)},K),t[35]=r,t[36]=b,t[37]=y):y=t[37],w=h.categories.map(y),t[31]=r,t[32]=b,t[33]=h.categories,t[34]=w}else w=t[34];let I;t[38]!==w?(I=e.jsx(xe,{className:"pt-0",children:e.jsx("div",{className:"border rounded-lg overflow-hidden",children:w})}),t[38]=w,t[39]=I):I=t[39];let k;t[40]!==W||t[41]!==I?(k=e.jsxs(ue,{children:[W,I]}),t[40]=W,t[41]=I,t[42]=k):k=t[42];let _;t[43]===Symbol.for("react.memo_cache_sentinel")?(_=e.jsxs(nt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-rose-500"}),"Expenses"]}),t[43]=_):_=t[43];let L;t[44]!==f.totalExpenses?(L=Q(f.totalExpenses),t[44]=f.totalExpenses,t[45]=L):L=t[45];let Y;t[46]!==L?(Y=e.jsx(at,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[_,e.jsx("span",{className:"text-lg font-bold text-rose-600 tabular-nums",children:L})]})}),t[46]=L,t[47]=Y):Y=t[47];let j;if(t[48]!==d||t[49]!==p.categories||t[50]!==b){let y;t[52]!==d||t[53]!==b?(y=(R,K)=>e.jsx(Ct,{category:R,type:"expense",isExpanded:d===R.name,onToggle:()=>m(d===R.name?null:R.name),details:b(R.name,!1)},K),t[52]=d,t[53]=b,t[54]=y):y=t[54],j=p.categories.map(y),t[48]=d,t[49]=p.categories,t[50]=b,t[51]=j}else j=t[51];let O;t[55]!==j?(O=e.jsx(xe,{className:"pt-0",children:e.jsx("div",{className:"border rounded-lg overflow-hidden",children:j})}),t[55]=j,t[56]=O):O=t[56];let ee;t[57]!==Y||t[58]!==O?(ee=e.jsxs(ue,{children:[Y,O]}),t[57]=Y,t[58]=O,t[59]=ee):ee=t[59];let se;t[60]!==f.eligibleNotarialFees||t[61]!==f.netIncome||t[62]!==f.selfEmploymentTaxableIncome?(se=f.netIncome>0&&e.jsxs(ue,{className:"bg-slate-50 border-slate-200",children:[e.jsx(at,{className:"pb-3",children:e.jsx(nt,{className:"text-base",children:"Tax Information"})}),e.jsxs(xe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"Eligible Notarial Fees*"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Portion not subject to self-employment tax"})]}),e.jsx("span",{className:"text-lg font-semibold text-blue-600 tabular-nums",children:Q(f.eligibleNotarialFees||0)})]}),e.jsx(Zs,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"Subject to SE Tax"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Income subject to self-employment tax"})]}),e.jsx("span",{className:"text-lg font-semibold text-amber-600 tabular-nums",children:Q(f.selfEmploymentTaxableIncome||0)})]}),e.jsx("p",{className:"text-xs text-muted-foreground italic pt-2 border-t",children:"*This is the portion of your Net Income that is NOT subject to self-employment tax. See IRS Publication 334 - Notary Public."})]})]}),t[60]=f.eligibleNotarialFees,t[61]=f.netIncome,t[62]=f.selfEmploymentTaxableIncome,t[63]=se):se=t[63];let N;t[64]!==k||t[65]!==ee||t[66]!==se?(N=e.jsxs("div",{id:"profit-loss-report",className:"space-y-6",children:[k,ee,se]}
vendor: 6,550 bytes, line 15
15),t[64]=k,t[65]=ee,t[66]=se,t[67]=N):N=t[67];let A;return t[68]!==q||t[69]!==N||t[70]!==P?(A=e.jsxs("div",{className:"space-y-6",children:[P,q,N]}),t[68]=q,t[69]=N,t[70]=P,t[71]=A):A=t[71],A};function Et(o,[t,s]){return Math.min(s,Math.max(t,o))}function ia(o){const t=i.useRef({value:o,previous:o});return i.useMemo(()=>(t.current.value!==o&&(t.current.previous=t.current.value,t.current.value=o),t.current.previous),[o])}var ca=[" ","Enter","ArrowUp","ArrowDown"],da=[" ","Enter"],Ce="Select",[Ke,Ge,ma]=ea(Ce),[De]=ys(Ce,[ma,kt]),qe=kt(),[ua,ye]=De(Ce),[xa,ha]=De(Ce),Dt=o=>{const{__scopeSelect:t,children:s,open:a,defaultOpen:n,onOpenChange:l,value:r,defaultValue:c,onValueChange:d,dir:m,name:x,autoComplete:g,disabled:v,required:b,form:f}=o,h=qe(t),[p,C]=i.useState(null),[S,E]=i.useState(null),[u,T]=i.useState(!1),D=Qs(m),[P,$]=vt({prop:a,defaultProp:n??!1,onChange:l,caller:Ce}),[F,U]=vt({prop:r,defaultProp:c,onChange:d,caller:Ce}),q=i.useRef(null),J=p?f||!!p.closest("form"):!0,[H,W]=i.useState(new Set),w=Array.from(H).map(I=>I.props.value).join(";");return e.jsx(ta,{...h,children:e.jsxs(ua,{required:b,scope:t,trigger:p,onTriggerChange:C,valueNode:S,onValueNodeChange:E,valueNodeHasChildren:u,onValueNodeHasChildrenChange:T,contentId:ft(),value:F,onValueChange:U,open:P,onOpenChange:$,dir:D,triggerPointerDownPosRef:q,disabled:v,children:[e.jsx(Ke.Provider,{scope:t,children:e.jsx(xa,{scope:o.__scopeSelect,onNativeOptionAdd:i.useCallback(I=>{W(k=>new Set(k).add(I))},[]),onNativeOptionRemove:i.useCallback(I=>{W(k=>{const _=new Set(k);return _.delete(I),_})},[]),children:s})}),J?e.jsxs(ts,{"aria-hidden":!0,required:b,tabIndex:-1,name:x,autoComplete:g,value:F,onChange:I=>U(I.target.value),disabled:v,form:f,children:[F===void 0?e.jsx("option",{value:""}):null,Array.from(H)]},w):null]})})};Dt.displayName=Ce;var Pt="SelectTrigger",Mt=i.forwardRef((o,t)=>{const{__scopeSelect:s,disabled:a=!1,...n}=o,l=qe(s),r=ye(Pt,s),c=r.disabled||a,d=pe(t,r.onTriggerChange),m=Ge(s),x=i.useRef("touch"),[g,v,b]=as(h=>{const p=m().filter(E=>!E.disabled),C=p.find(E=>E.value===r.value),S=ns(p,h,C);S!==void 0&&r.onValueChange(S.value)}),f=h=>{c||(r.onOpenChange(!0),b()),h&&(r.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return e.jsx(aa,{asChild:!0,...l,children:e.jsx(re.button,{type:"button",role:"combobox","aria-controls":r.contentId,"aria-expanded":r.open,"aria-required":r.required,"aria-autocomplete":"none",dir:r.dir,"data-state":r.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":ss(r.value)?"":void 0,...n,ref:d,onClick:ae(n.onClick,h=>{h.currentTarget.focus(),x.current!=="mouse"&&f(h)}),onPointerDown:ae(n.onPointerDown,h=>{x.current=h.pointerType;const p=h.target;p.hasPointerCapture(h.pointerId)&&p.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(f(h),h.preventDefault())}),onKeyDown:ae(n.onKeyDown,h=>{const p=g.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&v(h.key),!(p&&h.key===" ")&&ca.includes(h.key)&&(f(),h.preventDefault())})})})});Mt.displayName=Pt;var _t="SelectValue",At=i.forwardRef((o,t)=>{const{__scopeSelect:s,className:a,style:n,children:l,placeholder:r="",...c}=o,d=ye(_t,s),{onValueNodeHasChildrenChange:m}=d,x=l!==void 0,g=pe(t,d.onValueNodeChange);return je(()=>{m(x)},[m,x]),e.jsx(re.span,{...c,ref:g,style:{pointerEvents:"none"},children:ss(d.value)?e.jsx(e.Fragment,{children:r}):l})});At.displayName=_t;var pa="SelectIcon",$t=i.forwardRef((o,t)=>{const{__scopeSelect:s,children:a,...n}=o;return e.jsx(re.span,{"aria-hidden":!0,...n,ref:t,children:a||"▼"})});$t.displayName=pa;var ga="SelectPortal",Ft=o=>e.jsx(bs,{asChild:!0,...o});Ft.displayName=ga;var Ee="SelectContent",Ot=i.forwardRef((o,t)=>{const s=ye(Ee,o.__scopeSelect),[a,n]=i.useState();if(je(()=>{n(new DocumentFragment)},[]),!s.open){const l=a;return l?Tt.createPortal(e.jsx(Lt,{scope:o.__scopeSelect,children:e.jsx(Ke.Slot,{scope:o.__scopeSelect,children:e.jsx("div",{children:o.children})})}),l):null}return e.jsx(Bt,{...o,ref:t})});Ot.displayName=Ee;var ce=10,[Lt,be]=De(Ee),fa="SelectContentImpl",ja=Cs("SelectContent.RemoveScroll"),Bt=i.forwardRef((o,t)=>{const{__scopeSelect:s,position:a="item-aligned",onCloseAutoFocus:n,onEscapeKeyDown:l,onPointerDownOutside:r,side:c,sideOffset:d,align:m,alignOffset:x,arrowPadding:g,collisionBoundary:v,collisionPadding:b,sticky:f,hideWhenDetached:h,avoidCollisions:p,...C}=o,S=ye(Ee,s),[E,u]=i.useState(null),[T,D]=i.useState(null),P=pe(t,y=>u(y)),[$,F]=i.useState(null),[U,q]=i.useState(null),J=Ge(s),[H,W]=i.useState(!1),w=i.useRef(!1);i.useEffect(()=>{if(E)return Ns(E)},[E]),Ss();const I=i.useCallback(y=>{const[R,...K]=J().map(G=>G.ref.current),[M]=K.slice(-1),z=document.activeElement;for(const G of y)if(G===z||(G?.scrollIntoView({block:"nearest"}),G===R&&T&&(T.scrollTop=0),G===M&&T&&(T.scrollTop=T.scrollHeight),G?.focus(),document.activeElement!==z))return},[J,T]),k=i.useCallback(()=>I([$,E]),[I,$,E]);i.useEffect(()=>{H&&k()},[H,k]);const{onOpenChange:_,triggerPointerDownPosRef:L}=S;i.useEffect(()=>{if(E){let y={x:0,y:0};const R=M=>{y={x:Math.abs(Math.round(M.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(M.pageY)-(L.current?.y??0))}},K=M=>{y.x<=10&&y.y<=10?M.preventDefault():E.contains(M.target)||_(!1),document.removeEventListener("pointermove",R),L.current=null};return L.current!==null&&(document.addEventListener("pointermove",R),document.addEventListener("pointerup",K,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",K,{capture:!0})}}},[E,_,L]),i.useEffect(()=>{const y=()=>_(!1);return window.addEventListener("blur",y),window.addEventListener("resize",y),()=>{window.removeEventListener("blur",y),window.removeEventListener("resize",y)}},[_]);const[Y,j]=as(y=>{const R=J().filter(z=>!z.disabled),K=R.find(z=>z.ref.current===document.activeElement),M=ns(R,y,K);M&&setTimeout(()=>M.ref.current.focus())}),O=i.useCallback((y,R,K)=>{const M=!w.current&&!K;(S.value!==void 0&&S.value===R||M)&&(F(y),M&&(w.current=!0))},[S.value]),ee=i.useCallback(()=>E?.focus(),[E]),se=i.useCallback((y,R,K)=>{const M=!w.current&&!K;(S.value!==void 0&&S.value===R||M)&&q(y)},[S.value]),N=a==="popper"?ut:Vt,A=N===ut?{side:c,sideOffset:d,align:m,alignOffset:x,arrowPadding:g,collisionBoundary:v,collisionPadding:b,sticky:f,hideWhenDetached:h,avoidCollisions:p}:{};return e.jsx(Lt,{scope:s,content:E,viewport:T,onViewportChange:D,itemRefCallback:O,selectedItem:$,onItemLeave:ee,itemTextRefCallback:se,focu
vendor: 8,287 bytes, line 15
15sSelectedItem:k,selectedItemText:U,position:a,isPositioned:H,searchRef:Y,children:e.jsx(ws,{as:ja,allowPinchZoom:!0,children:e.jsx(Es,{asChild:!0,trapped:S.open,onMountAutoFocus:y=>{y.preventDefault()},onUnmountAutoFocus:ae(n,y=>{S.trigger?.focus({preventScroll:!0}),y.preventDefault()}),children:e.jsx(Ts,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:r,onFocusOutside:y=>y.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(N,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:y=>y.preventDefault(),...C,...A,onPlaced:()=>W(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:ae(C.onKeyDown,y=>{const R=y.ctrlKey||y.altKey||y.metaKey;if(y.key==="Tab"&&y.preventDefault(),!R&&y.key.length===1&&j(y.key),["ArrowUp","ArrowDown","Home","End"].includes(y.key)){let M=J().filter(z=>!z.disabled).map(z=>z.ref.current);if(["ArrowUp","End"].includes(y.key)&&(M=M.slice().reverse()),["ArrowUp","ArrowDown"].includes(y.key)){const z=y.target,G=M.indexOf(z);M=M.slice(G+1)}setTimeout(()=>I(M)),y.preventDefault()}})})})})})})});Bt.displayName=fa;var ya="SelectItemAlignedPosition",Vt=i.forwardRef((o,t)=>{const{__scopeSelect:s,onPlaced:a,...n}=o,l=ye(Ee,s),r=be(Ee,s),[c,d]=i.useState(null),[m,x]=i.useState(null),g=pe(t,P=>x(P)),v=Ge(s),b=i.useRef(!1),f=i.useRef(!0),{viewport:h,selectedItem:p,selectedItemText:C,focusSelectedItem:S}=r,E=i.useCallback(()=>{if(l.trigger&&l.valueNode&&c&&m&&h&&p&&C){const P=l.trigger.getBoundingClientRect(),$=m.getBoundingClientRect(),F=l.valueNode.getBoundingClientRect(),U=C.getBoundingClientRect();if(l.dir!=="rtl"){const z=U.left-$.left,G=F.left-z,ge=P.left-G,ve=P.width+ge,Qe=Math.max(ve,$.width),et=window.innerWidth-ce,tt=Et(G,[ce,Math.max(ce,et-Qe)]);c.style.minWidth=ve+"px",c.style.left=tt+"px"}else{const z=$.right-U.right,G=window.innerWidth-F.right-z,ge=window.innerWidth-P.right-G,ve=P.width+ge,Qe=Math.max(ve,$.width),et=window.innerWidth-ce,tt=Et(G,[ce,Math.max(ce,et-Qe)]);c.style.minWidth=ve+"px",c.style.right=tt+"px"}const q=v(),J=window.innerHeight-ce*2,H=h.scrollHeight,W=window.getComputedStyle(m),w=parseInt(W.borderTopWidth,10),I=parseInt(W.paddingTop,10),k=parseInt(W.borderBottomWidth,10),_=parseInt(W.paddingBottom,10),L=w+I+H+_+k,Y=Math.min(p.offsetHeight*5,L),j=window.getComputedStyle(h),O=parseInt(j.paddingTop,10),ee=parseInt(j.paddingBottom,10),se=P.top+P.height/2-ce,N=J-se,A=p.offsetHeight/2,y=p.offsetTop+A,R=w+I+y,K=L-R;if(R<=se){const z=q.length>0&&p===q[q.length-1].ref.current;c.style.bottom="0px";const G=m.clientHeight-h.offsetTop-h.offsetHeight,ge=Math.max(N,A+(z?ee:0)+G+k),ve=R+ge;c.style.height=ve+"px"}else{const z=q.length>0&&p===q[0].ref.current;c.style.top="0px";const ge=Math.max(se,w+h.offsetTop+(z?O:0)+A)+K;c.style.height=ge+"px",h.scrollTop=R-se+h.offsetTop}c.style.margin=`${ce}px 0`,c.style.minHeight=Y+"px",c.style.maxHeight=J+"px",a?.(),requestAnimationFrame(()=>b.current=!0)}},[v,l.trigger,l.valueNode,c,m,h,p,C,l.dir,a]);je(()=>E(),[E]);const[u,T]=i.useState();je(()=>{m&&T(window.getComputedStyle(m).zIndex)},[m]);const D=i.useCallback(P=>{P&&f.current===!0&&(E(),S?.(),f.current=!1)},[E,S]);return e.jsx(va,{scope:s,contentWrapper:c,shouldExpandOnScrollRef:b,onScrollButtonChange:D,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:u},children:e.jsx(re.div,{...n,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...n.style}})})})});Vt.displayName=ya;var ba="SelectPopperPosition",ut=i.forwardRef((o,t)=>{const{__scopeSelect:s,align:a="start",collisionPadding:n=ce,...l}=o,r=qe(s);return e.jsx(na,{...r,...l,ref:t,align:a,collisionPadding:n,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ut.displayName=ba;var[va,yt]=De(Ee,{}),xt="SelectViewport",zt=i.forwardRef((o,t)=>{const{__scopeSelect:s,nonce:a,...n}=o,l=be(xt,s),r=yt(xt,s),c=pe(t,l.onViewportChange),d=i.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(Ke.Slot,{scope:s,children:e.jsx(re.div,{"data-radix-select-viewport":"",role:"presentation",...n,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...n.style},onScroll:ae(n.onScroll,m=>{const x=m.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:v}=r;if(v?.current&&g){const b=Math.abs(d.current-x.scrollTop);if(b>0){const f=window.innerHeight-ce*2,h=parseFloat(g.style.minHeight),p=parseFloat(g.style.height),C=Math.max(h,p);if(C<f){const S=C+b,E=Math.min(f,S),u=S-E;g.style.height=E+"px",g.style.bottom==="0px"&&(x.scrollTop=u>0?u:0,g.style.justifyContent="flex-end")}}}d.current=x.scrollTop})})})]})});zt.displayName=xt;var Ut="SelectGroup",[Na,Sa]=De(Ut),wa=i.forwardRef((o,t)=>{const{__scopeSelect:s,...a}=o,n=ft();return e.jsx(Na,{scope:s,id:n,children:e.jsx(re.div,{role:"group","aria-labelledby":n,...a,ref:t})})});wa.displayName=Ut;var Ht="SelectLabel",Yt=i.forwardRef((o,t)=>{const{__scopeSelect:s,...a}=o,n=Sa(Ht,s);return e.jsx(re.div,{id:n.id,...a,ref:t})});Yt.displayName=Ht;var Ye="SelectItem",[Ca,Wt]=De(Ye),Kt=i.forwardRef((o,t)=>{const{__scopeSelect:s,value:a,disabled:n=!1,textValue:l,...r}=o,c=ye(Ye,s),d=be(Ye,s),m=c.value===a,[x,g]=i.useState(l??""),[v,b]=i.useState(!1),f=pe(t,S=>d.itemRefCallback?.(S,a,n)),h=ft(),p=i.useRef("touch"),C=()=>{n||(c.onValueChange(a),c.onOpenChange(!1))};if(a==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(Ca,{scope:s,value:a,disabled:n,textId:h,isSelected:m,onItemTextChange:i.useCallback(S=>{g(E=>E||(S?.textContent??"").trim())},[]),children:e.jsx(Ke.ItemSlot,{scope:s,value:a,disabled:n,textValue:x,children:e.jsx(re.div,{role:"option","aria-labelledby":h,"data-highlighted":v?"":void 0,"aria-selected":m&&v,"data-state":m?"checked":"unchecked","aria-disabled":n||void 0,"data-disabled":n?"":void 0,tabIndex:n?void 0:-1,...r,ref:f,onFocus:ae(r.onFocus,()=>b(!0)),onBlur:ae(r.onBlur,()=>b(!1)),onClick:ae(r.onClick,()=>{p.current!=="mouse"&&C()}),onPointerUp:ae(r.onPointerUp,()=>{p.current==="mouse"&&C()}),onPointerDown:ae(r.onPointerDown,S=>{p.current=S.pointerType}),onPointerMove:ae(r.onPointerMove,S=>{p.current=S.pointerType,n?d.onItemLeave?.():p.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(r.onPointerLeave,S=>{S.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:ae(r.onKeyDown,S=>{d.searchRef?.current!==""&&S.key===" "||(da.includes(S.key)&&C(),S.key===" "&&S.preventDefault())})})})})});Kt.displayName=Ye;var Pe="SelectItemText",Gt=i.forwardRef((o,t)=>{const{__scopeSelect:s,className:a,style:n,...l}=o,r=ye(Pe,s),c=be(Pe,s),d=Wt(Pe,s),m=ha(Pe,s),[x,g]=i.useState(null),v=pe(t,C=>g(C),d.onItemTextChange,C=>c.itemTextRefCallback?.(C,d.value,d.disabled)),b=x?.textContent,f=i.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:b},d.value),[d.disabled,d.value,b]),{onNativeOptionAdd:h,onNativeOptionRemove:p}=m;return je(()=>(h(f),()=>p(f)),[h,p,f]),e.jsxs(e.Fragment,{children:[e.jsx(re.span,{id:d.textId,...l,ref:v}),d.isSelected&&r.valueNode&&!r.valueNodeHasChildren?Tt.createPortal(l.children,r.valueNode):null]})});Gt.displayName=Pe;var qt="SelectItemIndicator",Xt=i.forwardRef((o,t)=>{const{__scopeSelect:s,...a}=o;return Wt(qt,s).isSelected?e.jsx(re.span,{"aria-hidden":!0,...a,ref:t}):null});Xt.displayName=qt;var ht="SelectScrollUpButton",Jt=i.forwardRef((o,t)=>{const s=be(ht,o.__scopeSelect),a=yt(ht,o.__scopeSelect),[n,l]=i.useState(!1),r=pe(t,a.onScrollButtonChange);return je(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollTop>0;
vendor: 3,461 bytes, line 15
15l(m)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),n?e.jsx(Qt,{...o,ref:r,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Jt.displayName=ht;var pt="SelectScrollDownButton",Zt=i.forwardRef((o,t)=>{const s=be(pt,o.__scopeSelect),a=yt(pt,o.__scopeSelect),[n,l]=i.useState(!1),r=pe(t,a.onScrollButtonChange);return je(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollHeight-d.clientHeight,x=Math.ceil(d.scrollTop)<m;l(x)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),n?e.jsx(Qt,{...o,ref:r,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Zt.displayName=pt;var Qt=i.forwardRef((o,t)=>{const{__scopeSelect:s,onAutoScroll:a,...n}=o,l=be("SelectScrollButton",s),r=i.useRef(null),c=Ge(s),d=i.useCallback(()=>{r.current!==null&&(window.clearInterval(r.current),r.current=null)},[]);return i.useEffect(()=>()=>d(),[d]),je(()=>{c().find(x=>x.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),e.jsx(re.div,{"aria-hidden":!0,...n,ref:t,style:{flexShrink:0,...n.style},onPointerDown:ae(n.onPointerDown,()=>{r.current===null&&(r.current=window.setInterval(a,50))}),onPointerMove:ae(n.onPointerMove,()=>{l.onItemLeave?.(),r.current===null&&(r.current=window.setInterval(a,50))}),onPointerLeave:ae(n.onPointerLeave,()=>{d()})})}),Ea="SelectSeparator",es=i.forwardRef((o,t)=>{const{__scopeSelect:s,...a}=o;return e.jsx(re.div,{"aria-hidden":!0,...a,ref:t})});es.displayName=Ea;var gt="SelectArrow",Ta=i.forwardRef((o,t)=>{const{__scopeSelect:s,...a}=o,n=qe(s),l=ye(gt,s),r=be(gt,s);return l.open&&r.position==="popper"?e.jsx(ra,{...n,...a,ref:t}):null});Ta.displayName=gt;var Ia="SelectBubbleInput",ts=i.forwardRef(({__scopeSelect:o,value:t,...s},a)=>{const n=i.useRef(null),l=pe(a,n),r=ia(t);return i.useEffect(()=>{const c=n.current;if(!c)return;const d=window.HTMLSelectElement.prototype,x=Object.getOwnPropertyDescriptor(d,"value").set;if(r!==t&&x){const g=new Event("change",{bubbles:!0});x.call(c,t),c.dispatchEvent(g)}},[r,t]),e.jsx(re.select,{...s,style:{...sa,...s.style},ref:l,defaultValue:t})});ts.displayName=Ia;function ss(o){return o===""||o===void 0}function as(o){const t=vs(o),s=i.useRef(""),a=i.useRef(0),n=i.useCallback(r=>{const c=s.current+r;t(c),(function d(m){s.current=m,window.clearTimeout(a.current),m!==""&&(a.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),l=i.useCallback(()=>{s.current="",window.clearTimeout(a.current)},[]);return i.useEffect(()=>()=>window.clearTimeout(a.current),[]),[s,n,l]}function ns(o,t,s){const n=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,l=s?o.indexOf(s):-1;let r=Ra(o,Math.max(l,0));n.length===1&&(r=r.filter(m=>m!==s));const d=r.find(m=>m.textValue.toLowerCase().startsWith(n.toLowerCase()));return d!==s?d:void 0}function Ra(o,t){return o.map((s,a)=>o[(t+a)%o.length])}var ka=Dt,rs=Mt,Da=At,Pa=$t,Ma=Ft,ls=Ot,_a=zt,os=Yt,is=Kt,Aa=Gt,$a=Xt,cs=Jt,ds=Zt,ms=es;const Te=ka,Ie=Da,Ne=i.forwardRef((o,t)=>{const s=Z.c(12);let a,n,l;s[0]!==o?({className:n,children:a,...l}=o,s[0]=o,s[1]=a,s[2]=n,s[3]=l):(a=s[1],n=s[2],l=s[3]);let r;s[4]!==n?(r=V("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
15ing-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",n),s[4]=n,s[5]=r):r=s[5];let c;s[6]===Symbol.for("react.memo_cache_sentinel")?(c=e.jsx(Pa,{asChild:!0,children:e.jsx(jt,{className:"h-4 w-4 opacity-50"})}),s[6]=c):c=s[6];let d;return s[7]!==a||s[8]!==l||s[9]!==t||s[10]!==r?(d=e.jsxs(rs,{ref:t,className:r,...l,children:[a,c]}),s[7]=a,s[8]=l,s[9]=t,s[10]=r,s[11]=d):d=s[11],d});Ne.displayName=rs.displayName;const us=i.forwardRef((o,t)=>{const s=Z.c(10);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("flex cursor-default items-center justify-center py-1",a),s[3]=a,s[4]=l):l=s[4];let r;s[5]===Symbol.for("react.memo_cache_sentinel")?(r=e.jsx(Os,{className:"h-4 w-4"}),s[5]=r):r=s[5];let c;return s[6]!==n||s[7]!==t||s[8]!==l?(c=e.jsx(cs,{ref:t,className:l,...n,children:r}),s[6]=n,s[7]=t,s[8]=l,s[9]=c):c=s[9],c});us.displayName=cs.displayName;const xs=i.forwardRef((o,t)=>{const s=Z.c(10);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("flex cursor-default items-center justify-center py-1",a),s[3]=a,s[4]=l):l=s[4];let r;s[5]===Symbol.for("react.memo_cache_sentinel")?(r=e.jsx(jt,{className:"h-4 w-4"}),s[5]=r):r=s[5];let c;return s[6]!==n||s[7]!==t||s[8]!==l?(c=e.jsx(ds,{ref:t,className:l,...n,children:r}),s[6]=n,s[7]=t,s[8]=l,s[9]=c):c=s[9],c});xs.displayName=ds.displayName;const Se=i.forwardRef((o,t)=>{const s=Z.c(21);let a,n,l,r;s[0]!==o?({className:n,children:a,position:r,...l}=o,s[0]=o,s[1]=a,s[2]=n,s[3]=l,s[4]=r):(a=s[1],n=s[2],l=s[3],r=s[4]);const c=r===void 0?"popper":r,d=c==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1";let m;s[5]!==n||s[6]!==d?(m=V("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",d,n),s[5]=n,s[6]=d,s[7]=m):m=s[7];let x;s[8]===Symbol.for("react.memo_cache_sentinel")?(x=e.jsx(us,{}),s[8]=x):x=s[8];const g=c==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]";let v;s[9]!==g?(v=V("p-1",g),s[9]=g,s[10]=v):v=s[10];let b;s[11]!==a||s[12]!==v?(b=e.jsx(_a,{className:v,children:a}),s[11]=a,s[12]=v,s[13]=b):b=s[13];let f;s[14]===Symbol.for("react.memo_cache_sentinel")?(f=e.jsx(xs,{}),s[14]=f):f=s[14];let h;return s[15]!==c||s[16]!==l||s[17]!==t||s[18]!==m||s[19]!==b?(h=e.jsx(Ma,{children:e.jsxs(ls,{ref:t,className:m,position:c,...l,children:[x,b,f]})}),s[15]=c,s[16]=l,s[17]=t,s[18]=m,s[19]=b,s[20]=h):h=s[20],h});Se.displayName=ls.displayName;const Fa=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("py-1.5 pl-8 pr-2 text-sm font-semibold",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx(os,{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});Fa.displayName=os.displayName;const me=i.forwardRef((o,t)=>{const s=Z.c(14);let a,n,l;s[0]!==o?({className:n,children:a,...l}=o,s[0]=o,s[1]=a,s[2]=n,s[3]=l):(a=s[1],n=s[2],l=s[3]);let r;s[4]!==n?(r=V("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),s[4]=n,s[5]=r):r=s[5];let c;s[6]===Symbol.for("react.memo_cache_sentinel")?(c=e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx($a,{children:e.jsx(ct,{className:"h-4 w-4"})})}),s[6]=c):c=s[6];let d;s[7]!==a?(d=e.jsx(Aa,{children:a}),s[7]=a,s[8]=d):d=s[8];let m;return s[9]!==l||s[10]!==t||s[11]!==r||s[12]!==d?(m=e.jsxs(is,{ref:t,className:r,...l,children:[c,d]}
15),s[9]=l,s[10]=t,s[11]=r,s[12]=d,s[13]=m):m=s[13],m});me.displayName=is.displayName;const Oa=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("-mx-1 my-1 h-px bg-muted",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx(ms,{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});Oa.displayName=ms.displayName;const Xe=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("w-full caption-bottom text-sm",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:l,...n})}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});Xe.displayName="Table";const Je=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("[&_tr]:border-b",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("thead",{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});Je.displayName="TableHeader";const Ze=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("[&_tr:last-child]:border-0",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("tbody",{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});Ze.displayName="TableBody";const La=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("tfoot",{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});La.displayName="TableFooter";const fe=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("tr",{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});fe.displayName="TableRow";const X=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("th",{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});X.displayName="TableHead";const B=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("p-4 align-middle [&:has([role=checkbox])]:pr-0",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("td",{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});B.displayName="TableCell";const Ba=i.forwardRef((o,t)=>{const s=Z.c(9);let a,n;s[0]!==o?({className:a,...n}=o,s[0]=o,s[1]=a,s[2]=n):(a=s[1],n=s[2]);let l;s[3]!==a?(l=V("mt-4 text-sm text-muted-foreground",a),s[3]=a,s[4]=l):l=s[4];let r;return s[5]!==n||s[6]!==t||s[7]!==l?(r=e.jsx("caption",{ref:t,className:l,...n}),s[5]=n,s[6]=t,s[7]=l,s[8]=r):r=s[8],r});Ba.displayName="TableCaption";const ot=o=>{const t=Z.c(17),{label:s,value:a,icon:n,variant:l}=o,r=l===void 0?"default":l;let c;t[0]!==r?(c=V("rounded-xl p-4",{default:"bg-gray-50 text-gray-900",income:"bg-emerald-50 text-emerald-700",expense:"bg-rose-50 text-rose-700"}[r]),t[0]=r,t[1]=c):c=t[1];let d;t[2]!==n?(d=n&&e.jsx(n,{className:"h-5 w-5 opacity-70"}),t[2]=n,t[3]=d):d=t[3];let m;t[4]!==s?(m=e.jsx("p",{className:"text-xs font-medium opacity-70",children:s}),t[4]=s,t[5]=m):m=t[5];let x;t[6]!==a?(x=e.jsx("p",{className:"text-lg font-bold tabular-nums",children:a}),t[6]=a,t[7]=x):x=t[7];let g;t[8]!==m||t[9]!==x?(g=e.jsxs("div",{children:[m,x]}),t[8]=m,t[9]=x,t[10]=g):g=t[10];let v;t[11]!==d||t[12]!==g?(v=e.jsxs("div",{className:"flex items-center gap-3",children:[d,g]}),t[11]=d,t[12]=g,t[13]=v):v=t[13];let b;return t[14]!==c||t[15]!==v?(b=e.jsx("div",{className:c,children:v}),t[14]=c,t[15]=v,t[16]=b):b=t[16],b},gn=()=>{const{endpoint:o,user:t}=We(),s=t?.user_account?.notary_id,[a,n]=i.useState([]),[l,r]=i.useState(!1),[c,d]=i.useState(new Date().getFullYear().toString()),[m,x]=i.useState("all"),[g,v]=i.useState("all"),[b,f]=i.useState(""),[h,p]=i.useState(""),[C,S]=i.useState([]),[E,u]=i.useState([]),[T,D]=i.useState([]),[P,$]=i.useState(!1),[F,U]=i.useState("expense"),[q,J]=i.useState(null),H=i.useCallback(async()=>
15{if(s)try{r(!0);let N=`/api/notary-expenses/notaries/${s}/expenses?taxYear=${c}`;m&&m!=="all"&&(N+=`&categoryId=${m}`);const A=await te.get(N);A.data.success&&n(A.data.data)}catch(N){console.error("Error fetching expenses:",N),ie.error("Failed to load expenses")}finally{r(!1)}},[o,s,c,m]),W=i.useCallback(async()=>{if(s)try{const N=await te.get(`/api/notary-expenses/notaries/${s}/expense-categories`);N.data.success&&S(N.data.data)}catch(N){console.error("Error fetching categories:",N)}},[o,s]),w=i.useCallback(async()=>{if(s)try{const N=await te.get(`/api/notary-vendors/notary/${s}`);u(N.data.map(A=>({value:A.vendor_name,label:A.vendor_name})))}catch(N){console.error("Error fetching vendors:",N)}},[o,s]),I=i.useCallback(async()=>{if(s)try{const N=await te.get("/api/orders/notary/all",{params:{notaryId:s}});D(N.data||[])}catch(N){console.error("Error fetching orders:",N)}},[o,s]);i.useEffect(()=>{s&&(H(),W(),w(),I())},[s,H,W,w,I]);const k=a.filter(N=>{const A=h?N.vendor?.toLowerCase().includes(h.toLowerCase())||N.notes?.toLowerCase().includes(h.toLowerCase())||N.category_name?.toLowerCase().includes(h.toLowerCase()):!0,y=!g||g==="all"?!0:N.category_type===g,R=b?N.vendor?.toLowerCase().includes(b.toLowerCase()):!0;return A&&y&&R}),_=k.reduce((N,A)=>{const y=parseFloat(A.amount);return A.category_type==="income"?N.income+=y:N.expense+=y,N},{income:0,expense:0}),L=()=>{d(new Date().getFullYear().toString()),x("all"),v("all"),f(""),p("")},Y=()=>{if(k.length===0)return;const A=[["Date","Category","Type","Amount","Vendor","Notes","Order ID"].join(",")];k.forEach(M=>{A.push([we(M.expense_date),M.category_name,M.category_type||"expense",parseFloat(M.amount).toFixed(2),M.vendor||"",M.notes||"",M.order_id||""].join(","))});const y=new Blob([A.join(`
16`)],{type:"text/csv;charset=utf-8;"}),R=URL.createObjectURL(y),K=document.createElement("a");K.href=R,K.download=`expenses-${c}.csv`,K.click()},j=N=>{U(N),J(null),$(!0)},O=N=>{J(N),U(N.category_type||"expense"),$(!0)},ee=N=>N?T.find(A=>A.order_id?.toString()===N?.toString()):null,se=Array.from({length:5},(N,A)=>{const y=new Date().getFullYear()-A;return{value:y.toString(),label:y.toString()}});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(ot,{label:"Total Income",value:Q(_.income),icon:Me,variant:"income"}),e.jsx(ot,{label:"Total Expenses",value:Q(_.expense),icon:Be,variant:"expense"}),e.jsx(ot,{label:"Net",value:Q(_.income-_.expense),icon:Ue,variant:_.income-_.expense>=0?"income":"expense"})]}),e.jsx(ue,{children:e.jsx(xe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 mb-1.5 block",children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ls,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(mt,{placeholder:"Search expenses...",value:h,onChange:N=>p(N.target.value),className:"pl-9"})]})]}),e.jsxs("div",{className:"w-32",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 mb-1.5 block",children:"Year"}),e.jsxs(Te,{value:c,onValueChange:d,children:[e.jsx(Ne,{children:e.jsx(Ie,{})}),e.jsx(Se,{children:se.map(N=>e.jsx(me,{value:N.value,children:N.label},N.value))})]})]}),e.jsxs("div",{className:"w-36",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 mb-1.5 block",children:"Type"}),e.jsxs(Te,{value:g,onValueChange:v,children:[e.jsx(Ne,{children:e.jsx(Ie,{placeholder:"All Types"})}),e.jsxs(Se,{children:[e.jsx(me,{value:"all",children:"All Types"}),e.jsx(me,{value:"expense",children:"Expense"}),e.jsx(me,{value:"income",children:"Income"})]})]})]}),e.jsxs("div",{className:"w-40",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 mb-1.5 block",children:"Category"}),e.jsxs(Te,{value:m,onValueChange:x,children:[e.jsx(Ne,{children:e.jsx(Ie,{placeholder:"All Categories"})}),e.jsxs(Se,{children:[e.jsx(me,{value:"all",children:"All Categories"}),C.map(N=>e.jsx(me,{value:N.id.toString(),children:N.category_name},N.id))]})]})]}),e.jsxs(ne,{variant:"ghost",size:"sm",onClick:L,className:"gap-1",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Clear"]})]})})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[k.length," ",k.length===1?"entry":"entries"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ne,{variant:"outline",size:"sm",onClick:Y,className:"gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Export"]}),e.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>j("income"),className:"gap-2 text-emerald-600 border-emerald-200 hover:bg-emerald-50",children:[e.jsx(de,{className:"h-4 w-4"}),"Add Income"]}),e.jsxs(ne,{size:"sm",onClick:()=>j("expense"),className:"gap-2 bg-gray-900 hover:bg-gray-800",children:[e.jsx(de,{className:"h-4 w-4"}),"Add Expense"]})]})]}),e.jsx(ue,{children:e.jsx(xe,{className:"p-0",children:l?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(_e,{className:"h-6 w-6 animate-spin text-gray-400"})}):k.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(Ue,{className:"h-12 w-12 mx-auto text-gray-300 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No entries found"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Start tracking your income and expenses"}),e.jsxs(ne,{onClick:()=>j("expense"),size:"sm",className:"gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),"Add Entry"]})]}):e.jsxs(Xe,{children:[e.jsx(Je,{children:e.jsxs(fe,{className:"bg-gray-50/50",children:[e.jsx(X,{children:"Date"}),e.jsx(X,{children:"Category"}),e.jsx(X,{children:"Type"}),e.jsx(X,{className:"text-right",children:"Amount"}),e.jsx(X,{children:"Vendor"}),e.jsx(X,{children:"Notes"}),e.jsx(X,{children:"Order"}),e.jsx(X,{className:"text-right",children:"Actions"})]})}),e.jsx(Ze,{children:k.map((N,A)=>
16{const y=ee(N.order_id),R=N.category_type==="income";return e.jsxs(fe,{children:[e.jsx(B,{className:"font-medium tabular-nums",children:we(N.expense_date)}),e.jsx(B,{children:N.category_name}),e.jsx(B,{children:e.jsx(ke,{variant:R?"default":"secondary",className:V("text-xs",R?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-rose-100 text-rose-700 border-rose-200"),children:N.category_type||"expense"})}),e.jsx(B,{className:V("text-right font-semibold tabular-nums",R?"text-emerald-600":"text-rose-600"),children:Q(parseFloat(N.amount))}),e.jsx(B,{className:"text-gray-600",children:N.vendor||"—"}),e.jsx(B,{className:"text-gray-500 max-w-[200px] truncate",children:N.notes||"—"}),e.jsx(B,{children:N.order_id?e.jsx("a",{href:`/admin/orders/${N.order_id}`,className:"text-blue-600 hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:y?.file_number||`#${N.order_id}`}):"—"}),e.jsx(B,{className:"text-right",children:e.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>O(N),className:"h-8 w-8 p-0",children:e.jsx(He,{className:"h-4 w-4"})})})]},N.id||A)})})]})})}),e.jsx(It,{isOpen:P,toggle:()=>$(!1),orderId:null,notaryId:s,endpoint:o,expenseToEdit:q,onUpdateSuccess:H,categoryType:F})]})},Oe=o=>{const t=Z.c(22),{label:s,value:a,subValue:n,icon:l,variant:r}=o,c=r===void 0?"default":r;let d,m;if(t[0]!==c){const C={default:"bg-white border",highlight:"bg-gradient-to-br from-blue-50 to-blue-100/50 border-blue-200",success:"bg-gradient-to-br from-emerald-50 to-emerald-100/50 border-emerald-200",warning:"bg-gradient-to-br from-amber-50 to-amber-100/50 border-amber-200"};d=ue,m=V("transition-all duration-200",C[c]),t[0]=c,t[1]=d,t[2]=m}else d=t[1],m=t[2];let x;t[3]!==s?(x=e.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-1",children:s}),t[3]=s,t[4]=x):x=t[4];let g;t[5]!==a?(g=e.jsx("p",{className:"text-2xl font-bold tracking-tight",children:a}),t[5]=a,t[6]=g):g=t[6];let v;t[7]!==n?(v=n&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:n}),t[7]=n,t[8]=v):v=t[8];let b;t[9]!==x||t[10]!==g||t[11]!==v?(b=e.jsxs("div",{children:[x,g,v]}),t[9]=x,t[10]=g,t[11]=v,t[12]=b):b=t[12];let f;t[13]!==l?(f=l&&e.jsx("div",{className:"p-2.5 rounded-xl bg-white/80 shadow-sm",children:e.jsx(l,{className:"h-5 w-5 text-gray-600"})}),t[13]=l,t[14]=f):f=t[14];let h;t[15]!==b||t[16]!==f?(h=e.jsx(xe,{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between",children:[b,f]})}),t[15]=b,t[16]=f,t[17]=h):h=t[17];let p;return t[18]!==d||t[19]!==m||t[20]!==h?(p=e.jsx(d,{className:m,children:h}),t[18]=d,t[19]=m,t[20]=h,t[21]=p):p=t[21],p},fn=()=>{const{endpoint:o,user:t}=We(),s=t?.user_account?.notary_id,[a,n]=i.useState([]),[l,r]=i.useState(!1),[c,d]=i.useState(.7),[m,x]=i.useState(!0),g=new Date().getFullYear(),[v,b]=i.useState(g.toString()),[f,h]=i.useState(`${g}-01-01`),[p,C]=i.useState(`${g}-12-31`),[S,E]=i.useState(!1),[u,T]=i.useState(null),[D,P]=i.useState({totalMiles:0,totalAmount:0,reimbursedMiles:0,reimbursedAmount:0,nonReimbursedMiles:0,nonReimbursedAmount:0}),$=i.useCallback(async(w=g)=>{try{const I=await te.get(`/api/notary-mileage/mileage-rate/fiscal-year/${w}`);I.data.success&&I.data.data&&d(Number(I.data.data.rate))}catch(I){console.error("Error fetching mileage rate:",I)}},[o,g]),F=i.useCallback(async()=>{if(s)try{r(!0);let w=`/api/notary-mileage/notaries/${s}/mileage`;const I=new URLSearchParams;f&&I.append("startDate",f),p&&I.append("endDate",p),m||I.append("reimbursed","false"),I.toString()&&(w+=`?${I.toString()}`);const k=await te.get(w);k.data.success&&(n(k.data.data),U(k.data.data))}catch(w){console.error("Error fetching mileage data:",w),ie.error("Failed to load mileage data")}finally{r(!1)}},[o,s,f,p,m]),U=w=>{const I=w.reduce((k,_)=>{const L=parseFloat(_.mileage)||0,Y=parseFloat(_.mileage_rate)||c,j=parseFloat(_.tax_deduction)||L*Y;return k.totalMiles+=L,k.totalAmount+=j,_.reimbursed?(k.reimbursedMiles+=L,k.reimbursedAmount+=j):(k.nonReimbursedMiles+=L,k.nonReimbursedAmount+=j),k},{totalMiles:0,totalAmount:0,reimbursedMiles:0,reimbursedAmount:0,nonReimbursedMiles:0,nonReimbursedAmount:0});P(I)},q=w=>{b(w),w&&(h(`${w}-01-01`),C(`${w}-12-31`),$(parseInt(w)))};i.useEffect(()=>{s&&(F(),$(parseInt(v)))},[s,F,$,v]);const J=async w=>{if(window.confirm("Are you sure you want to delete this mileage record?"))try{(await te.delete(`/api/notary-accounting/mileage/${w}`)).data.success&&(ie.success("Mileage deleted successfully"),F())}catch(I){console.error("Error deleting mileage:",I),ie.error("Failed to delete mileage")}},H=()=>
16{if(a.length===0)return;const I=[["Date","Miles","Amount","Description","Order ID","Reimbursed"].join(",")];a.forEach(Y=>{I.push([we(Y.mileage_date),Y.mileage,(parseFloat(Y.tax_deduction)||parseFloat(Y.mileage)*c).toFixed(2),Y.notes||"",Y.order_id||"",Y.reimbursed?"Yes":"No"].join(","))}),I.push(""),I.push(`Total,${D.totalMiles.toFixed(1)},${D.totalAmount.toFixed(2)}`),I.push(`Reimbursed,${D.reimbursedMiles.toFixed(1)},${D.reimbursedAmount.toFixed(2)}`),I.push(`Non-Reimbursed,${D.nonReimbursedMiles.toFixed(1)},${D.nonReimbursedAmount.toFixed(2)}`);const k=new Blob([I.join(`
17`)],{type:"text/csv;charset=utf-8;"}),_=URL.createObjectURL(k),L=document.createElement("a");L.href=_,L.download=`mileage-${v}.csv`,L.click()},W=Array.from({length:8},(w,I)=>{const k=g-I;return{value:k.toString(),label:k.toString()}});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Oe,{label:`IRS Rate (${v})`,value:`$${c.toFixed(2)}/mi`,icon:Ve,variant:"highlight"}),e.jsx(Oe,{label:"Total Miles",value:`${D.totalMiles.toFixed(1)} mi`,subValue:Q(D.totalAmount),icon:Vs,variant:"default"}),e.jsx(Oe,{label:"Reimbursed",value:Q(D.reimbursedAmount),subValue:`${D.reimbursedMiles.toFixed(1)} miles`,icon:zs,variant:"success"}),e.jsx(Oe,{label:"Non-Reimbursed",value:Q(D.nonReimbursedAmount),subValue:`${D.nonReimbursedMiles.toFixed(1)} miles`,icon:Us,variant:"warning"})]}),e.jsx(ue,{children:e.jsx(xe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"w-32",children:[e.jsx(Fe,{className:"text-xs font-medium text-gray-500 mb-1.5 block",children:"Tax Year"}),e.jsxs(Te,{value:v,onValueChange:q,children:[e.jsx(Ne,{children:e.jsx(Ie,{})}),e.jsx(Se,{children:W.map(w=>e.jsx(me,{value:w.value,children:w.label},w.value))})]})]}),e.jsxs("div",{className:"w-40",children:[e.jsx(Fe,{className:"text-xs font-medium text-gray-500 mb-1.5 block",children:"Start Date"}),e.jsx(mt,{type:"date",value:f,onChange:w=>h(w.target.value)})]}),e.jsxs("div",{className:"w-40",children:[e.jsx(Fe,{className:"text-xs font-medium text-gray-500 mb-1.5 block",children:"End Date"}),e.jsx(mt,{type:"date",value:p,onChange:w=>C(w.target.value)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"showReimbursed",checked:m,onChange:w=>x(w.target.checked),className:"rounded border-gray-300"}),e.jsx(Fe,{htmlFor:"showReimbursed",className:"text-sm",children:"Show Reimbursed"})]}),e.jsxs(ne,{onClick:F,variant:"secondary",size:"sm",className:"gap-2",children:[e.jsx(Hs,{className:"h-4 w-4"}),"Apply"]})]})})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.length," ",a.length===1?"record":"records"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ne,{variant:"outline",size:"sm",onClick:H,className:"gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Export"]}),e.jsxs(ne,{size:"sm",onClick:()=>{T(null),E(!0)},className:"gap-2 bg-gray-900 hover:bg-gray-800",children:[e.jsx(de,{className:"h-4 w-4"}),"Add Mileage"]})]})]}),e.jsx(ue,{children:e.jsx(xe,{className:"p-0",children:l?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(_e,{className:"h-6 w-6 animate-spin text-gray-400"})}):a.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(Le,{className:"h-12 w-12 mx-auto text-gray-300 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No mileage records"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Start tracking your business mileage for tax deductions"}),e.jsxs(ne,{onClick:()=>{T(null),E(!0)},size:"sm",className:"gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),"Add Mileage"]})]}):e.jsxs(Xe,{children:[e.jsx(Je,{children:e.jsxs(fe,{className:"bg-gray-50/50",children:[e.jsx(X,{children:"Date"}),e.jsx(X,{className:"text-right",children:"Miles"}),e.jsx(X,{className:"text-right",children:"Amount"}),e.jsx(X,{children:"Description"}),e.jsx(X,{children:"Order"}),e.jsx(X,{children:"Status"}),e.jsx(X,{className:"text-right",children:"Actions"})]})}),e.jsxs(Ze,{children:[a.map(w=>{const I=parseFloat(w.tax_deduction)||parseFloat(w.mileage)*c;return e.jsxs(fe,{className:V(w.reimbursed&&"bg-emerald-50/30"),children:[e.jsx(B,{className:"font-medium tabular-nums",children:we(w.mileage_date)}),e.jsxs(B,{className:"text-right tabular-nums",children:[w.mileage," mi"]}),e.jsx(B,{className:"text-right font-semibold tabular-nums text-blue-600",children:Q(I)}),e.jsx(B,{className:"text-gray-600 max-w-[200px] truncate",children:w.notes||"—"}),e.jsx(B,{children:w.order_id?e.jsxs("a",{href:`/admin/orders/${w.order_id}`,className:"text-blue-600 hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:["#",w.order_id]}):"—"}),e.jsx(B,{children:e.jsx(ke,{variant:w.reimbursed?"default":"secondary",className:V("text-xs",w.reimbursed?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-gray-100 text-gray-600"),children:w.reimbursed?"Reimbursed":"Pending"})}),e.jsx(B,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>{T(w),E(!0)},className:"h-8 w-8 p-0",children:e.jsx(He,{className:"h-4 w-4"})}),e.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>J(w.id),className:"h-8 w-8 p-0 text-rose-600 hover:text-rose-700 hover:bg-rose-50",children:e.jsx(dt,{className:"h-4 w-4"})})]})})]},w.id)}),e.jsxs(fe,{className:"bg-gray-50 font-semibold",children:[e.jsx(B,{children:"Total"}),e.jsxs(B,{className:"text-right tabular-nums",children:[D.totalMiles.toFixed(1)," mi"]}),e.jsx(B,{className:"text-right tabular-nums text-blue-600",children:Q(D.totalAmount)}),e.jsx(B,{colSpan:4})]})]})]})})}),e.jsx(Rt,{isOpen:S,toggle:()=>E(!1),notaryId:s,endpoint:o,editMode:!!u,mileageRecord:u,onSuccess:F})]})},it=o=>{const t=Z.c(12),{label:s,value:a,icon:n}=o;let l;t[0]!==n?(l=n&&e.jsx("div",{className:"p-2 rounded-lg bg-white shadow-sm",children:e.jsx(n,{className:"h-4 w-4 text-slate-600"})}),t[0]=n,t[1]=l):l=t[1];let r;t[2]!==s?(r=e.jsx("p",{className:"text-xs font-medium text-slate-500",children:s}),t[2]=s,t[3]=r):r=t[3];let c;t[4]!==a?(c=e.jsx("p",{className:"text-lg font-bold text-slate-900 tabular-nums",children:a}),t[4]=a,t[5]=c):c=t[5];let d;t[6]!==r||t[7]!==c?(d=e.jsxs("div",{children:[r,c]}),t[6]=r,t[7]=c,t[8]=d):d=t[8];let m;return t[9]!==l||t[10]!==d?(m=e.jsx("div",{className:"bg-gradient-to-br from-slate-50 to-slate-100/50 rounded-xl p-4 border border-slate-200",children:e.jsxs("div",{className:"flex items-center gap-3",children:[l,d]})}),t[9]=l,t[10]=d,t[11]=m):m=t[11],m},jn=({endpoint:o,notaryId:t})=>{const[s,a]=i.useState(!1),[n,l]=i.useState([]),[r,c]=i.useState(new Date().getFullYear().toString()),[d,m]=i.useState("all"),[x,g]=i.useState({totalSales:0,totalOrders:0,avgOrderValue:0}),v=i.useCallback(async()=>
17{if(t)try{a(!0);let p=`/api/notary-accounting/notaries/${t}/sales-report?year=${r}`;d&&d!=="all"&&(p+=`&month=${d}`);const C=await te.get(p);if(C.data.success){const S=C.data.data||[];l(S);const E=S.reduce((D,P)=>D+parseFloat(P.amount||0),0),u=S.length,T=u>0?E/u:0;g({totalSales:E,totalOrders:u,avgOrderValue:T})}}catch(p){console.error("Error fetching sales data:",p),l([]),g({totalSales:0,totalOrders:0,avgOrderValue:0})}finally{a(!1)}},[o,t,r,d]);i.useEffect(()=>{t&&v()},[t,v]);const b=()=>{if(n.length===0)return;const C=[["Date","Order ID","Client","Service Type","Amount","Status"].join(",")];n.forEach(T=>{C.push([we(T.date),T.order_id||"",T.client_name||"",T.service_type||"",parseFloat(T.amount||0).toFixed(2),T.status||""].join(","))});const S=new Blob([C.join(`
18`)],{type:"text/csv;charset=utf-8;"}),E=URL.createObjectURL(S),u=document.createElement("a");u.href=E,u.download=`sales-report-${r}${d?`-${d}`:""}.csv`,u.click()},f=Array.from({length:5},(p,C)=>{const S=new Date().getFullYear()-C;return{value:S.toString(),label:S.toString()}}),h=[{value:"1",label:"January"},{value:"2",label:"February"},{value:"3",label:"March"},{value:"4",label:"April"},{value:"5",label:"May"},{value:"6",label:"June"},{value:"7",label:"July"},{value:"8",label:"August"},{value:"9",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(it,{label:"Total Sales",value:Q(x.totalSales),icon:Me}),e.jsx(it,{label:"Total Orders",value:x.totalOrders.toString(),icon:ze}),e.jsx(it,{label:"Avg Order Value",value:Q(x.avgOrderValue),icon:Ys})]}),e.jsx(ue,{children:e.jsx(xe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ws,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Te,{value:r,onValueChange:c,children:[e.jsx(Ne,{className:"w-32",children:e.jsx(Ie,{})}),e.jsx(Se,{children:f.map(p=>e.jsx(me,{value:p.value,children:p.label},p.value))})]})]}),e.jsxs(Te,{value:d,onValueChange:m,children:[e.jsx(Ne,{className:"w-40",children:e.jsx(Ie,{placeholder:"All Months"})}),e.jsxs(Se,{children:[e.jsx(me,{value:"all",children:"All Months"}),h.map(p=>e.jsx(me,{value:p.value,children:p.label},p.value))]})]}),e.jsx(ne,{onClick:v,variant:"secondary",size:"sm",children:"Generate Report"}),e.jsx("div",{className:"flex-1"}),e.jsxs(ne,{variant:"outline",size:"sm",onClick:b,disabled:n.length===0,className:"gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Export"]})]})})}),e.jsx(ue,{children:e.jsx(xe,{className:"p-0",children:s?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(_e,{className:"h-6 w-6 animate-spin text-gray-400"})}):n.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(ze,{className:"h-12 w-12 mx-auto text-gray-300 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No Sales Data"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto",children:"No sales records found for the selected period. Complete some orders to see your sales report."})]}):e.jsxs(Xe,{children:[e.jsx(Je,{children:e.jsxs(fe,{className:"bg-gray-50/50",children:[e.jsx(X,{children:"Date"}),e.jsx(X,{children:"Order ID"}),e.jsx(X,{children:"Client"}),e.jsx(X,{children:"Service"}),e.jsx(X,{className:"text-right",children:"Amount"}),e.jsx(X,{children:"Status"})]})}),e.jsxs(Ze,{children:[n.map((p,C)=>e.jsxs(fe,{children:[e.jsx(B,{className:"font-medium tabular-nums",children:we(p.date)}),e.jsx(B,{children:p.order_id?e.jsxs("a",{href:`/admin/orders/${p.order_id}`,className:"text-blue-600 hover:underline",target:"_blank",rel:"noopener noreferrer",children:["#",p.order_id]}):"—"}),e.jsx(B,{children:p.client_name||"—"}),e.jsx(B,{children:e.jsx(ke,{variant:"secondary",className:"text-xs",children:p.service_type||"Signing"})}),e.jsx(B,{className:"text-right font-semibold tabular-nums text-emerald-600",children:Q(parseFloat(p.amount||0))}),e.jsx(B,{children:e.jsx(ke,{variant:"secondary",className:V("text-xs",p.status==="completed"?"bg-emerald-100 text-emerald-700":p.status==="pending"?"bg-amber-100 text-amber-700":"bg-gray-100 text-gray-600"),children:p.status||"—"})})]},p.order_id||C)),e.jsxs(fe,{className:"bg-gray-50 font-semibold",children:[e.jsx(B,{colSpan:4,children:"Total"}),e.jsx(B,{className:"text-right tabular-nums text-emerald-600",children:Q(x.totalSales)}),e.jsx(B,{})]})]})]})})})]})};export{hn as AccountingDashboard,gn as ExpensesTab,fn as MileageTab,pn as ProfitLossReport,jn as SalesReportTab};

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.