PageSourceSearch

https://cridergpt.com/assets/CalculatorPanel-BTNti6iJ.js

js cridergpt.com collected 2026-09-24 14:40:54 UTC 127,153 bytes, 12 lines download raw bytes

1import{f as fe,r as N,j as e,C as P,b as U,c as L,e as E,y as h,a6 as f,B as i,D as X,E as B,G as O,H,J as G,N as z,n as ye,T as Q,ah as W,ee as Ce,ef as be,eg as Fe,eh as Se,ad as le,a1 as Y,a2 as K,a3 as $,a4 as M,h as xe,dn as $e,Y as Ae,dz as Me,da as Re,dc as Pe,dd as Te,de as De,df as Ve,dg as Ie,di as Ee,z as Ue,ek as se,el as J}from"./index-CgMUx9S8.js";import{T as Le,a as ze,b as pe,c as ae,d as qe,e as te}from"./table-Cmv5jBDh.js";import{R as ne,L as we,C as de,X as ue,Y as me,T as re,a as he,b as ee,P as Be,c as Oe,d as He,B as Ge,e as je}from"./PieChart-CXHMNF_1.js";import{P as We}from"./pen-6XNGl-Xy.js";import"./findIndex-Z_qbMyQx.js";import"./linear-BZ5GqTV4.js";import"./init-Dmth1JHB.js";import"./defaultLocale-C4B-KCzX.js";import"./time-CzOnMm8f.js";import"./band-CquvqAHh.js";import"./ordinal-DILIJJjt.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Je=fe("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ye=fe("Dice1",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);function Ke(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(0),[u,j]=N.useState([]),x=()=>{const l=parseFloat(r),F=parseFloat(n)/100/12,t=parseFloat(d)*12;if(l&&F&&t){const o=l*(F*Math.pow(1+F,t))/(Math.pow(1+F,t)-1);T(o);const c=[];let m=l;for(let p=1;p<=t;p++){const a=m*F,s=o-a;m-=s,c.push({payment:p,principalPayment:s,interestPayment:a,remainingBalance:Math.max(0,m)})}j(c)}},b=u.slice(0,60).map((l,F)=>({month:F+1,principal:l.principalPayment,interest:l.interestPayment,balance:l.remainingBalance})),v=l=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(l);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Loan/Mortgage Calculator"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"principal",children:"Principal Amount ($)"}),e.jsx(f,{id:"principal",type:"number",value:r,onChange:l=>k(l.target.value),placeholder:"200000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"rate",children:"Annual Interest Rate (%)"}),e.jsx(f,{id:"rate",type:"number",step:"0.01",value:n,onChange:l=>S(l.target.value),placeholder:"5.5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"term",children:"Loan Term (years)"}),e.jsx(f,{id:"term",type:"number",value:d,onChange:l=>R(l.target.value),placeholder:"30"})]})]}),e.jsx(i,{onClick:x,className:"w-full",children:"Calculate Loan"}),C>0&&e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Results"}),e.jsxs("p",{className:"text-2xl font-bold text-primary",children:["Monthly Payment: ",v(C)]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Total Interest: ",v(C*parseFloat(d)*12-parseFloat(r))]})]})]})]}),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Payment Breakdown Chart (First 5 Years)"})}),e.jsx(E,{children:e.jsx(ne,{width:"100%",height:300,children:e.jsxs(we,{data:b,children:[e.jsx(de,{strokeDasharray:"3 3"}),e.jsx(ue,{dataKey:"month"}),e.jsx(me,{}),e.jsx(re,{formatter:l=>v(Number(l))}),e.jsx(he,{}),e.jsx(ee,{type:"monotone",dataKey:"principal",stroke:"#8884d8",name:"Principal"}),e.jsx(ee,{type:"monotone",dataKey:"interest",stroke:"#82ca9d",name:"Interest"}),e.jsx(ee,{type:"monotone",dataKey:"balance",stroke:"#ffc658",name:"Remaining Balance"})]})})})]}),e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Amortization Schedule (First 12 Payments)"})}),e.jsx(E,{children:e.jsxs(Le,{children:[e.jsx(ze,{children:e.jsxs(pe,{children:[e.jsx(ae,{children:"Payment #"}),e.jsx(ae,{children:"Principal"}),e.jsx(ae,{children:"Interest"}),e.jsx(ae,{children:"Remaining Balance"})]})}),e.jsx(qe,{children:u.slice(0,12).map((l,F)=>e.jsxs(pe,{children:[e.jsx(te,{children:l.payment}),e.jsx(te,{children:v(l.principalPayment)}),e.jsx(te,{children:v(l.interestPayment)}),e.jsx(te,{children:v(l.remainingBalance)})]},F))})]})})]})]})]})}function _e(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(null),x=()=>{const v=parseFloat(r)||0,l=parseFloat(n)||0,F=parseFloat(d)/100,t=parseFloat(C);if(F&&t){const o=[];let c=v,m=v;for(let s=1;s<=t;s++){for(let y=1;y<=12;y++)c+=l,m+=l,c*=1+F/12;o.push({year:s,totalValue:c,totalContributions:m,totalInterest:c-m})}const p=c,a=p-m;j({futureValue:p,totalContributions:m,totalInterest:a,yearlyData:o})}},b=v=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(v);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Investment Calculator"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"initial",children:"Initial Investment ($)"}),e.jsx(f,{id:"initial",type:"number",value:r,onChange:v=>k(v.target.value),placeholder:"10000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"monthly",children:"Monthly Contribution ($)"}),e.jsx(f,{id:"monthly",type:"number",value:n,onChange:v=>S(v.target.value),placeholder:"500"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"return",children:"Expected Annual Return (%)"}),e.jsx(f,{id:"return",type:"number",step:"0.01",value:d,onChange:v=>R(v.target.value),placeholder:"7"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"horizon",children:"Time Horizon (years)"}),e.jsx(f,{id:"horizon",type:"number",value:C,onChange:v=>T(v.target.value),placeholder:"20"})]})]}),e.jsx(i,{onClick:x,className:"w-full",children:"Calculate Investment"}),u&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-green-50 border border-green-200 p-4 rounded-lg",children:[e.jsx("h3",{className:"text-lg font-semibold text-green-800",children:"Future Value"}),e.jsx("p",{className:"text-2xl font-bold text-green-900",children:b(u.futureValue)})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 p-4 rounded-lg",children:[e.jsx("h3",{className:"text-lg font-semibold text-blue-800",children:"Total Contributions"}),e.jsx("p",{className:"text-2xl font-bold text-blue-900",children:b(u.totalContributions)})]}),e.jsxs("div",{className:"bg-purple-50 border border-purple-200 p-4 rounded-lg",children:[e.jsx("h3",{className:"text-lg font-semibold text-purple-800",children:"Total Interest"}),e.jsx("p",{className:"text-2xl font-bold text-purple-900",children:b(u.totalInterest)})]})]})]})]}),u&&e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Investment Growth Chart"})}),e.jsx(E,{children:e.jsx(ne,{width:"100%",height:400,children:e.jsxs(we,{data:u.yearlyData,children:[e.jsx(de,{strokeDasharray:"3 3"}),e.jsx(ue,{dataKey:"year"}),e.jsx(me,{}),e.jsx(re,{formatter:v=>b(Number(v))}),e.jsx(he,{}),e.jsx(ee,{type:"monotone",dataKey:"totalValue",stroke:"#8884d8",name:"Total Value",strokeWidth:2}),e.jsx(ee,{type:"monotone",dataKey:"totalContributions",stroke:"#82ca9d",name:"Contributions"}),e.jsx(ee,{type:"monotone",dataKey:"totalInterest",stroke:"#ffc658",name:"Interest Earned"})]})})})]})]})}const ce=["Food & Dining","Transportation","Housing","Utilities","Entertainment","Healthcare","Shopping","Education","Travel","Other"],ge=["#0088FE","#00C49F","#FFBB28","#FF8042","#8884D8","#82CA9D","#FFC658","#FF7C7C","#8DD1E1","#D084D0"];function Ze(){const[r,k]=N.useState([]),[n,S]=N.useState([]),[d,R]=N.useState({category:"",amount:"",description:""}),[C,T]=N.useState({category:"",limit:""});N.useEffect(()=>{const t=localStorage.getItem("budget-expenses"),o=localStorage.getItem("budget-limits");t&&k(JSON.parse(t)),o&&S(JSON.parse(o))},[]);const u=()=>{if(!d.category||!d.amount){W.error("Please fill in all required fields");return}const t={id:Date.now().toString(),category:d.category,amount:parseFloat(d.amount),description:d.description,date:new Date().toISOString().split("T")[0]},o=[...r,t];k(o),localStorage.setItem("budget-expenses",JSON.stringify(o)),x(o),R({category:"",amount:"",description:""}),W.success("Expense added successfully")},j=()=>
11{if(!C.category||!C.limit){W.error("Please fill in all required fields");return}const t=n.findIndex(c=>c.category===C.category);let o;if(t>=0)o=[...n],o[t].limit=parseFloat(C.limit);else{const c={category:C.category,limit:parseFloat(C.limit),spent:0};o=[...n,c]}S(o),localStorage.setItem("budget-limits",JSON.stringify(o)),x(r,o),T({category:"",limit:""}),W.success("Budget updated successfully")},x=(t=r,o=n)=>{const c=o.map(m=>({...m,spent:t.filter(p=>p.category===m.category).reduce((p,a)=>p+a.amount,0)}));S(c),localStorage.setItem("budget-limits",JSON.stringify(c))},b=t=>{const o=r.filter(c=>c.id!==t);k(o),localStorage.setItem("budget-expenses",JSON.stringify(o)),x(o),W.success("Expense removed")},v=async()=>{try{const t=new Ce;let o=await be(t);t.setFontSize(18),t.setTextColor(0,0,0),t.text("Budget & Expense Report",20,o),o+=10,t.setFontSize(12),t.text(`Generated on: ${new Date().toLocaleDateString()}`,20,o),o+=15,t.setFontSize(16),t.text("Budget Overview",20,o),o+=15,n.forEach(c=>{t.setFontSize(12),t.text(`${c.category}:`,20,o),t.text(`Budget: $${c.limit.toFixed(2)}`,80,o),t.text(`Spent: $${c.spent.toFixed(2)}`,130,o),t.text(`Remaining: $${(c.limit-c.spent).toFixed(2)}`,170,o),o+=8}),o+=10,o>200&&(t.addPage(),o=30),t.setFontSize(16),t.text("Recent Expenses",20,o),o+=15,r.slice(-10).forEach(c=>{t.setFontSize(10),t.text(`${c.date} - ${c.category}`,20,o),t.text(`$${c.amount.toFixed(2)}`,120,o),t.text(c.description||"N/A",150,o),o+=6,o>270&&(t.addPage(),o=30)}),Fe(t),await Se(t),t.save("CriderGPT_Budget_Report.pdf"),W.success("Budget report exported successfully")}catch(t){console.error("PDF export error:",t),W.error("Failed to export PDF")}},l=ce.map(t=>{const c=r.filter(m=>m.category===t).reduce((m,p)=>m+p.amount,0);return{name:t,value:c}}).filter(t=>t.value>0),F=n.map(t=>({category:t.category,budget:t.limit,spent:t.spent,remaining:Math.max(0,t.limit-t.spent)}));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{children:[e.jsx(U,{children:e.jsxs(L,{className:"flex items-center justify-between",children:["Add New Expense",e.jsxs(i,{onClick:v,variant:"outline",size:"sm",children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Export PDF"]})]})}),e.jsx(E,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"expense-category",children:"Category"}),e.jsxs(B,{value:d.category,onValueChange:t=>R({...d,category:t}),children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select category"})}),e.jsx(G,{children:ce.map(t=>e.jsx(z,{value:t,children:t},t))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"expense-amount",children:"Amount ($)"}),e.jsx(f,{id:"expense-amount",type:"number",step:"0.01",value:d.amount,onChange:t=>R({...d,amount:t.target.value}),placeholder:"0.00"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"expense-description",children:"Description"}),e.jsx(f,{id:"expense-description",value:d.description,onChange:t=>R({...d,description:t.target.value}),placeholder:"Optional description"})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(i,{onClick:u,className:"w-full",children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Add Expense"]})})]})})]}),e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Set Budget Limits"})}),e.jsx(E,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"budget-category",children:"Category"}),e.jsxs(B,{value:C.category,onValueChange:t=>T({...C,category:t}),children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select category"})}),e.jsx(G,{children:ce.map(t=>e.jsx(z,{value:t,children:t},t))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"budget-limit",children:"Monthly Limit ($)"}),e.jsx(f,{id:"budget-limit",type:"number",step:"0.01",value:C.limit,onChange:t=>T({...C,limit:t.target.value}),placeholder:"0.00"})]}),e.jsx("div",{className:"flex items-end",children:e.jsx(i,{onClick:j,className:"w-full",children:"Set Budget"})})]})})]}),n.length>0&&e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Budget Overview"})}),e.jsx(E,{children:e.jsx("div",{className:"space-y-4",children:n.map((t,o)=>{const c=t.spent/t.limit*100,m=t.spent>t.limit;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-medium",children:t.category}),e.jsxs("span",{className:`text-sm ${m?"text-red-600":"text-green-600"}`,children:["$",t.spent.toFixed(2)," / $",t.limit.toFixed(2)]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:e.jsx("div",{className:`h-2 rounded-full ${m?"bg-red-500":"bg-green-500"}`,style:{width:`${Math.min(100,c)}%`}})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.toFixed(1),"% used",m&&` (Over by $${(t.spent-t.limit).toFixed(2)})`]})]},o)})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.length>0&&e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Expense Breakdown"})}),e.jsx(E,{children:e.jsx(ne,{width:"100%",height:300,children:e.jsxs(Be,{children:[e.jsx(Oe,{data:l,cx:"50%",cy:"50%",labelLine:!1,label:({name:t,percent:o})=>`${t}: ${(o*100).toFixed(0)}%`,outerRadius:80,fill:"#8884d8",dataKey:"value",children:l.map((t,o)=>e.jsx(He,{fill:ge[o%ge.length]},`cell-${o}`))}),e.jsx(re,{formatter:t=>`$${Number(t).toFixed(2)}`})]})})})]}),F.length>0&&e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Budget vs Spending"})}),e.jsx(E,{children:e.jsx(ne,{width:"100%",height:300,children:e.jsxs(Ge,{data:F,children:[e.jsx(de,{strokeDasharray:"3 3"}),e.jsx(ue,{dataKey:"category"}),e.jsx(me,{}),e.jsx(re,{formatter:t=>`$${Number(t).toFixed(2)}`}),e.jsx(he,{}),e.jsx(je,{dataKey:"budget",fill:"#8884d8",name:"Budget"}),e.jsx(je,{dataKey:"spent",fill:"#82ca9d",name:"Spent"})]})})})]})]}),e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Recent Expenses"})}),e.jsx(E,{children:e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No expenses recorded yet"}):r.slice().reverse().slice(0,10).map(t=>e.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.category}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[t.description," • ",t.date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-bold",children:["$",t.amount.toFixed(2)]}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>b(t.id),children:e.jsx(Q,{className:"h-4 w-4"})})]})]},t.id))})})]})]})}const ve=[{code:"USD",name:"US Dollar"},{code:"EUR",name:"Euro"}
11,{code:"GBP",name:"British Pound"},{code:"JPY",name:"Japanese Yen"},{code:"CAD",name:"Canadian Dollar"},{code:"AUD",name:"Australian Dollar"},{code:"CHF",name:"Swiss Franc"},{code:"CNY",name:"Chinese Yuan"}];function Xe(){const[r,k]=N.useState(""),[n,S]=N.useState("USD"),[d,R]=N.useState("EUR"),[C,T]=N.useState(null),[u,j]=N.useState(null),[x,b]=N.useState(!1),v=async()=>{if(!(!r||!n||!d)){b(!0);try{const F={"USD-EUR":.85,"USD-GBP":.73,"USD-JPY":110,"USD-CAD":1.25,"USD-AUD":1.35,"USD-CHF":.92,"USD-CNY":6.45,"EUR-USD":1.18,"GBP-USD":1.37,"JPY-USD":.0091,"CAD-USD":.8,"AUD-USD":.74,"CHF-USD":1.09,"CNY-USD":.155},t=`${n}-${d}`;let o=F[t];if(!o){const c=F[`${n}-USD`]||1,m=F[`USD-${d}`]||1;o=c*m}n===d&&(o=1),j(o||1),T(parseFloat(r)*(o||1))}catch(F){console.error("Error fetching exchange rate:",F),j(1),T(parseFloat(r))}finally{b(!1)}}},l=(F,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(F);return e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Currency Converter"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"amount",children:"Amount"}),e.jsx(f,{id:"amount",type:"number",step:"0.01",value:r,onChange:F=>k(F.target.value),placeholder:"100"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"from",children:"From"}),e.jsxs(B,{value:n,onValueChange:S,children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsx(G,{children:ve.map(F=>e.jsxs(z,{value:F.code,children:[F.code," - ",F.name]},F.code))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"to",children:"To"}),e.jsxs(B,{value:d,onValueChange:R,children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsx(G,{children:ve.map(F=>e.jsxs(z,{value:F.code,children:[F.code," - ",F.name]},F.code))})]})]})]}),e.jsx(i,{onClick:v,className:"w-full",disabled:x,children:x?"Converting...":"Convert Currency"}),C!==null&&u!==null&&e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-2",children:[e.jsx("div",{className:"text-center",children:e.jsxs("p",{className:"text-lg",children:[e.jsx("span",{className:"font-semibold",children:l(parseFloat(r),n)}),e.jsx("span",{className:"mx-2",children:"="}),e.jsx("span",{className:"font-bold text-2xl text-primary",children:l(C,d)})]})}),e.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:["Exchange Rate: 1 ",n," = ",u.toFixed(4)," ",d]})]}),e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:"* Exchange rates are for demonstration purposes only"})]})]})}function Qe(){const[r,k]=N.useState([]),[n,S]=N.useState({name:"",targetAmount:"",currentAmount:"",monthlyContribution:"",targetDate:""});N.useEffect(()=>{const x=localStorage.getItem("savings-goals");x&&k(JSON.parse(x))},[]);const d=x=>{localStorage.setItem("savings-goals",JSON.stringify(x)),k(x)},R=()=>{if(n.name&&n.targetAmount&&n.currentAmount!==""&&n.monthlyContribution&&n.targetDate){const x={name:n.name,targetAmount:parseFloat(n.targetAmount),currentAmount:parseFloat(n.currentAmount),monthlyContribution:parseFloat(n.monthlyContribution),targetDate:n.targetDate};d([...r,x]),S({name:"",targetAmount:"",currentAmount:"",monthlyContribution:"",targetDate:""})}},C=(x,b)=>{const v=[...r];v[x].currentAmount=parseFloat(b)||0,d(v)},T=x=>{const b=r.filter((v,l)=>l!==x);d(b)},u=x=>{const b=x.targetAmount-x.currentAmount;if(b<=0)return"Goal achieved!";const v=Math.ceil(b/x.monthlyContribution),l=new Date;return l.setMonth(l.getMonth()+v),`Projected completion: ${l.toLocaleDateString()}`},j=x=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(x);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Add Savings Goal"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"goal-name",children:"Goal Name"}),e.jsx(f,{id:"goal-name",value:n.name,onChange:x=>S({...n,name:x.target.value}),placeholder:"Emergency Fund"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"target-amount",children:"Target Amount ($)"}),e.jsx(f,{id:"target-amount",type:"number",value:n.targetAmount,onChange:x=>S({...n,targetAmount:x.target.value}),placeholder:"10000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"current-amount",children:"Current Amount ($)"}),e.jsx(f,{id:"current-amount",type:"number",value:n.currentAmount,onChange:x=>S({...n,currentAmount:x.target.value}),placeholder:"2500"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"monthly-contribution",children:"Monthly Contribution ($)"}),e.jsx(f,{id:"monthly-contribution",type:"number",value:n.monthlyContribution,onChange:x=>S({...n,monthlyContribution:x.target.value}),placeholder:"500"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(h,{htmlFor:"target-date",children:"Target Date"}),e.jsx(f,{id:"target-date",type:"date",value:n.targetDate,onChange:x=>S({...n,targetDate:x.target.value})})]})]}),e.jsx(i,{onClick:R,className:"w-full",children:"Add Savings Goal"})]})]}),r.map((x,b)=>{const v=Math.min(x.currentAmount/x.targetAmount*100,100),l=x.currentAmount>=x.targetAmount;return e.jsxs(P,{className:l?"border-green-500":"",children:[e.jsx(U,{className:"pb-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx(L,{className:"text-lg",children:x.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Target: ",j(x.targetAmount)," by ",new Date(x.targetDate).toLocaleDateString()]})]}),e.jsx(i,{variant:"outline",size:"sm",onClick:()=>T(b),children:"Remove"})]})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-2",children:[e.jsx("span",{children:"Progress"}),e.jsxs("span",{children:[v.toFixed(1),"%"]})]}),e.jsx(le,{value:v,className:"h-3"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:"Current Amount"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(f,{type:"number",value:x.currentAmount,onChange:F=>C(b,F.target.value),className:"text-sm"})})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:"Remaining"}),e.jsx("p",{className:"font-semibold p-2",children:j(Math.max(0,x.targetAmount-x.currentAmount))})]})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:"Monthly Contribution"}),e.jsx("p",{className:"font-semibold",children:j(x.monthlyContribution)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:u(x)}),l&&e.jsx("div",{className:"bg-green-50 border border-green-200 p-3 rounded-lg",children:e.jsx("p",{className:"text-green-800 font-semibold",children:"🎉 Congratulations! Goal achieved!"})})]})]},b)}),r.length===0&&e.jsx(P,{children:e.jsx(E,{className:"text-center py-8",children:e.jsx("p",{className:"text-muted-foreground",children:"No savings goals yet. Add your first goal above!"})})})]})}function es(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(null),x=()=>{const l=parseFloat(r),F=parseFloat(n),t=parseFloat(d),o=parseFloat(C);if(l>0){const c=F/(l*12)*100,m=t/l*100,p=o/l*100;j({debtToIncomeRatio:c,savingsRate:m,expenseRatio:p})}},b=(l,F)=>{switch(F){case"debt":return l<=20?{status:"Excellent",color:"text-green-600",description:"Very low debt burden"}:l<=36?{status:"Good",color:"text-blue-600",description:"Manageable debt level"}:l<=50?{status:"Fair",color:"text-yellow-600",description:"Consider debt reduction"}:{status:"High Risk",color:"text-red-600",description:"Urgent debt reduction needed"};case"savings":return l>=20?{status:"Excellent",color:"text-green-600",description:"Strong savings habit"}:l>=15?{status:"Good",color:"text-blue-600",description:"Good savings rate"}:l>=10?{status:"Fair",color:"text-yellow-600",description:"Consider increasing savings"}:{status:"Low",color:"text-red-600",description:"Increase savings rate"};case"expenses":return l<=50?{status:"Excellent",color:"text-green-600",description:"Very efficie
11nt spending"}:l<=70?{status:"Good",color:"text-blue-600",description:"Reasonable expense ratio"}:l<=80?{status:"Fair",color:"text-yellow-600",description:"Room for optimization"}:{status:"High",color:"text-red-600",description:"Review and reduce expenses"};default:return{status:"",color:"",description:""}}},v=l=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(l);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Financial Ratio Analysis"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"monthly-income",children:"Monthly Income ($)"}),e.jsx(f,{id:"monthly-income",type:"number",value:r,onChange:l=>k(l.target.value),placeholder:"5000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"total-debt",children:"Total Debt ($)"}),e.jsx(f,{id:"total-debt",type:"number",value:n,onChange:l=>S(l.target.value),placeholder:"25000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"monthly-savings",children:"Monthly Savings ($)"}),e.jsx(f,{id:"monthly-savings",type:"number",value:d,onChange:l=>R(l.target.value),placeholder:"750"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"monthly-expenses",children:"Monthly Expenses ($)"}),e.jsx(f,{id:"monthly-expenses",type:"number",value:C,onChange:l=>T(l.target.value),placeholder:"3500"})]})]}),e.jsx(i,{onClick:x,className:"w-full",children:"Calculate Financial Ratios"})]})]}),u&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs(P,{children:[e.jsx(U,{className:"pb-3",children:e.jsx(L,{className:"text-lg",children:"Debt-to-Income Ratio"})}),e.jsx(E,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-center",children:e.jsxs("span",{className:"text-3xl font-bold",children:[u.debtToIncomeRatio.toFixed(1),"%"]})}),e.jsx(le,{value:Math.min(u.debtToIncomeRatio,100),className:"h-2"}),e.jsxs("div",{className:`text-center ${b(u.debtToIncomeRatio,"debt").color}`,children:[e.jsx("p",{className:"font-semibold",children:b(u.debtToIncomeRatio,"debt").status}),e.jsx("p",{className:"text-xs",children:b(u.debtToIncomeRatio,"debt").description})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("p",{children:"Ideal: <20%"}),e.jsx("p",{children:"Good: 20-36%"}),e.jsx("p",{children:"Caution: >36%"})]})]})})]}),e.jsxs(P,{children:[e.jsx(U,{className:"pb-3",children:e.jsx(L,{className:"text-lg",children:"Savings Rate"})}),e.jsx(E,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-center",children:e.jsxs("span",{className:"text-3xl font-bold",children:[u.savingsRate.toFixed(1),"%"]})}),e.jsx(le,{value:Math.min(u.savingsRate,100),className:"h-2"}),e.jsxs("div",{className:`text-center ${b(u.savingsRate,"savings").color}`,children:[e.jsx("p",{className:"font-semibold",children:b(u.savingsRate,"savings").status}),e.jsx("p",{className:"text-xs",children:b(u.savingsRate,"savings").description})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("p",{children:"Excellent: >20%"}),e.jsx("p",{children:"Good: 15-20%"}),e.jsx("p",{children:"Minimum: 10-15%"})]})]})})]}),e.jsxs(P,{children:[e.jsx(U,{className:"pb-3",children:e.jsx(L,{className:"text-lg",children:"Expense Ratio"})}),e.jsx(E,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-center",children:e.jsxs("span",{className:"text-3xl font-bold",children:[u.expenseRatio.toFixed(1),"%"]})}),e.jsx(le,{value:Math.min(u.expenseRatio,100),className:"h-2"}),e.jsxs("div",{className:`text-center ${b(u.expenseRatio,"expenses").color}`,children:[e.jsx("p",{className:"font-semibold",children:b(u.expenseRatio,"expenses").status}),e.jsx("p",{className:"text-xs",children:b(u.expenseRatio,"expenses").description})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("p",{children:"Excellent: <50%"}),e.jsx("p",{children:"Good: 50-70%"}),e.jsx("p",{children:"Review: >70%"})]})]})})]})]}),u&&e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Financial Health Summary"})}),e.jsx(E,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:"Monthly Income"}),e.jsx("p",{className:"font-semibold",children:v(parseFloat(r))})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:"Annual Income"}),e.jsx("p",{className:"font-semibold",children:v(parseFloat(r)*12)})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:"Monthly Savings"}),e.jsx("p",{className:"font-semibold",children:v(parseFloat(d))})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:"Annual Savings"}),e.jsx("p",{className:"font-semibold",children:v(parseFloat(d)*12)})]})]}),e.jsxs("div",{className:"bg-muted p-3 rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:"Financial Recommendations:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground mt-1 space-y-1",children:[u.debtToIncomeRatio>36&&e.jsx("li",{children:"• Consider debt consolidation or aggressive debt payoff"}),u.savingsRate<15&&e.jsx("li",{children:"• Increase savings rate to at least 15% of income"}),u.expenseRatio>70&&e.jsx("li",{children:"• Review and reduce monthly expenses"}),u.debtToIncomeRatio<=20&&u.savingsRate>=15&&e.jsx("li",{children:"• Great financial health! Consider investment opportunities"})]})]})]})})]})]})}function ss(){const[r,k]=N.useState([]);N.useEffect(()=>{const j=localStorage.getItem("calculation-history");j&&k(JSON.parse(j))},[]);const n=()=>{k([]),localStorage.removeItem("calculation-history"),W.success("Calculation history cleared")},S=j=>{const x=r.filter(b=>b.id!==j);k(x),localStorage.setItem("calculation-history",JSON.stringify(x)),W.success("Entry removed")},d=j=>{const x=`${j.type.toUpperCase()} Calculation (${j.timestamp})
12${JSON.stringify(j.results,null,2)}`;navigator.clipboard.writeText(x),W.success("Copied to clipboard")},R=async()=>{try{const j=new Ce;let x=await be(j);j.setFontSize(18),j.setTextColor(0,0,0),j.text("Financial Calculation History",20,x),x+=10,j.setFontSize(12),j.text(`Generated on: ${new Date().toLocaleDateString()}`,20,x),x+=15,r.forEach((b,v)=>{x>250&&(j.addPage(),x=30),j.setFontSize(14),j.text(`${v+1}. ${b.type.toUpperCase()} - ${b.timestamp}`,20,x),x+=10,j.setFontSize(10);const l=JSON.stringify(b.results,null,2),F=j.splitTextToSize(l,170);j.text(F,25,x),x+=F.length*4+10}),Fe(j),await Se(j),j.save("CriderGPT_Financial_Calculations.pdf"),W.success("PDF exp
12orted successfully")}catch(j){console.error("PDF export error:",j),W.error("Failed to export PDF")}},C=j=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(j),T=j=>{switch(j.type){case"loan":return e.jsxs("div",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Principal:"})," ",C(j.inputs.principal)]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Rate:"})," ",j.inputs.interestRate,"%"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Term:"})," ",j.inputs.loanTerm," years"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Monthly Payment:"})," ",C(j.results.monthlyPayment)]})]});case"investment":return e.jsxs("div",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Initial:"})," ",C(j.inputs.initialInvestment)]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Monthly:"})," ",C(j.inputs.monthlyContribution)]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Return:"})," ",j.inputs.annualReturn,"%"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Future Value:"})," ",C(j.results.futureValue)]})]});case"currency":return e.jsxs("div",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Amount:"})," ",j.inputs.amount," ",j.inputs.fromCurrency]}),e.jsxs("p",{children:[e.jsx("strong",{children:"To:"})," ",j.inputs.toCurrency]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Result:"})," ",C(j.results.convertedAmount)," ",j.inputs.toCurrency]})]});case"ratio":return e.jsxs("div",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Income:"})," ",C(j.inputs.income),"/month"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Debt-to-Income:"})," ",j.results.debtToIncomeRatio.toFixed(1),"%"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Savings Rate:"})," ",j.results.savingsRate.toFixed(1),"%"]})]});default:return e.jsxs("p",{children:["Basic calculation result: ",j.results.result||"N/A"]})}},u=j=>r.filter(x=>x.type===j);return e.jsx("div",{className:"space-y-6",children:e.jsxs(P,{children:[e.jsxs(U,{className:"flex flex-row items-center justify-between",children:[e.jsx(L,{children:"Calculation History"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(i,{variant:"outline",onClick:R,children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Export PDF"]}),e.jsxs(i,{variant:"destructive",onClick:n,children:[e.jsx(Q,{className:"h-4 w-4 mr-2"}),"Clear All"]})]})]}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"all",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-6",children:[e.jsx($,{value:"all",children:"All"}),e.jsx($,{value:"loan",children:"Loan"}),e.jsx($,{value:"investment",children:"Investment"}),e.jsx($,{value:"currency",children:"Currency"}),e.jsx($,{value:"ratio",children:"Ratios"}),e.jsx($,{value:"basic",children:"Basic"})]}),e.jsx(M,{value:"all",className:"mt-4",children:e.jsx("div",{className:"space-y-3",children:r.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No calculation history yet"}):r.slice().reverse().map(j=>e.jsx(P,{className:"p-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-xs bg-primary text-primary-foreground px-2 py-1 rounded",children:j.type.toUpperCase()}),e.jsx("span",{className:"text-xs text-muted-foreground",children:j.timestamp})]}),T(j)]}),e.jsxs("div",{className:"flex gap-1 ml-4",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>d(j),children:e.jsx(xe,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>S(j.id),children:e.jsx(Q,{className:"h-4 w-4"})})]})]})},j.id))})}),["loan","investment","currency","ratio","basic"].map(j=>e.jsx(M,{value:j,className:"mt-4",children:e.jsx("div",{className:"space-y-3",children:u(j).length===0?e.jsxs("p",{className:"text-muted-foreground text-center py-8",children:["No ",j," calculations yet"]}):u(j).slice().reverse().map(x=>e.jsx(P,{className:"p-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:x.timestamp}),T(x)]}),e.jsxs("div",{className:"flex gap-1 ml-4",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>d(x),children:e.jsx(xe,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>S(x.id),children:e.jsx(Q,{className:"h-4 w-4"})})]})]})},x.id))})},j))]})})]})})}const oe=[{value:"tax",label:"Tax Rate"},{value:"tip",label:"Tip Percentage"},{value:"interest",label:"Interest Rate"},{value:"discount",label:"Discount Percentage"},{value:"other",label:"Other"}],Ne=[{id:"1",name:"Standard Tax",type:"tax",value:8.25,description:"Default sales tax rate"},{id:"2",name:"Good Service Tip",type:"tip",value:18,description:"Standard tip for good service"},{id:"3",name:"Great Service Tip",type:"tip",value:20,description:"Tip for exceptional service"},{id:"4",name:"Mortgage Rate",type:"interest",value:6.5,description:"Current mortgage interest rate"},{id:"5",name:"Standard Discount",type:"discount",value:10,description:"Common retail discount"}];function as(){const[r,k]=N.useState(Ne),[n,S]=N.useState(null),[d,R]=N.useState({name:"",type:"other",value:"",description:""});N.useEffect(()=>
12{const l=localStorage.getItem("financial-presets");l&&k(JSON.parse(l))},[]);const C=l=>{localStorage.setItem("financial-presets",JSON.stringify(l)),k(l)},T=()=>{if(d.name&&d.value){const l={id:Date.now().toString(),name:d.name,type:d.type,value:parseFloat(d.value),description:d.description};C([...r,l]),R({name:"",type:"other",value:"",description:""}),W.success("Preset added successfully")}},u=(l,F)=>{const t=r.map(o=>o.id===l?{...o,...F}:o);C(t),S(null),W.success("Preset updated successfully")},j=l=>{const F=r.filter(t=>t.id!==l);C(F),W.success("Preset removed")},x=l=>{navigator.clipboard.writeText(l.value.toString()),W.success(`${l.name} (${l.value}%) copied to clipboard`)},b=()=>{C(Ne),W.success("Reset to default presets")},v=l=>{switch(l){case"tax":return"bg-red-100 text-red-800";case"tip":return"bg-green-100 text-green-800";case"interest":return"bg-blue-100 text-blue-800";case"discount":return"bg-purple-100 text-purple-800";default:return"bg-gray-100 text-gray-800"}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Add New Preset"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"preset-name",children:"Preset Name"}),e.jsx(f,{id:"preset-name",value:d.name,onChange:l=>R({...d,name:l.target.value}),placeholder:"My Custom Rate"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"preset-type",children:"Type"}),e.jsxs(B,{value:d.type,onValueChange:l=>R({...d,type:l}),children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsx(G,{children:oe.map(l=>e.jsx(z,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"preset-value",children:"Value (%)"}),e.jsx(f,{id:"preset-value",type:"number",step:"0.01",value:d.value,onChange:l=>R({...d,value:l.target.value}),placeholder:"15.5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"preset-description",children:"Description (Optional)"}),e.jsx(f,{id:"preset-description",value:d.description,onChange:l=>R({...d,description:l.target.value}),placeholder:"Brief description"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{onClick:T,className:"flex-1",children:"Add Preset"}),e.jsx(i,{variant:"outline",onClick:b,children:"Reset to Defaults"})]})]})]}),e.jsxs(P,{children:[e.jsx(U,{children:e.jsx(L,{children:"Your Presets"})}),e.jsxs(E,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(l=>{var F;return e.jsx(P,{className:"p-4",children:n===l.id?e.jsx(ts,{preset:l,onSave:t=>u(l.id,t),onCancel:()=>S(null)}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:l.name}),e.jsx("span",{className:`text-xs px-2 py-1 rounded ${v(l.type)}`,children:(F=oe.find(t=>t.value===l.type))==null?void 0:F.label})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>S(l.id),children:e.jsx(We,{className:"h-3 w-3"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>j(l.id),children:e.jsx(Q,{className:"h-3 w-3"})})]})]}),e.jsx("div",{className:"text-center py-3",children:e.jsxs("span",{className:"text-2xl font-bold text-primary",children:[l.value,"%"]})}),l.description&&e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:l.description}),e.jsx(i,{variant:"outline",size:"sm",className:"w-full",onClick:()=>x(l),children:"Apply & Copy"})]})},l.id)})}),r.length===0&&e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-muted-foreground",children:"No presets yet. Add your first preset above!"})})]})]})]})}function ts({preset:r,onSave:k,onCancel:n}){const[S,d]=N.useState({name:r.name,type:r.type,value:r.value.toString(),description:r.description}),R=()=>{k({name:S.name,type:S.type,value:parseFloat(S.value),description:S.description})};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{value:S.name,onChange:C=>d({...S,name:C.target.value}),placeholder:"Preset name"}),e.jsxs(B,{value:S.type,onValueChange:C=>d({...S,type:C}),children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsx(G,{children:oe.map(C=>e.jsx(z,{value:C.value,children:C.label},C.value))})]}),e.jsx(f,{type:"number",step:"0.01",value:S.value,onChange:C=>d({...S,value:C.target.value}),placeholder:"Value"}),e.jsx(f,{value:S.description,onChange:C=>d({...S,description:C.target.value}),placeholder:"Description"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(i,{size:"sm",onClick:R,children:[e.jsx($e,{className:"h-3 w-3 mr-1"}),"Save"]}),e.jsxs(i,{size:"sm",variant:"outline",onClick:n,children:[e.jsx(Ae,{className:"h-3 w-3 mr-1"}),"Cancel"]})]})]})}function ls(){return e.jsxs(P,{className:"w-full",children:[e.jsx(U,{children:e.jsx(L,{className:"text-center",children:"Advanced Financial Calculator"})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"loan",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4 lg:grid-cols-8",children:[e.jsx($,{value:"loan",children:"Loan"}),e.jsx($,{value:"investment",children:"Investment"}),e.jsx($,{value:"budget",children:"Budget"}),e.jsx($,{value:"currency",children:"Currency"}),e.jsx($,{value:"savings",children:"Savings"}),e.jsx($,{value:"ratios",children:"Ratios"}),e.jsx($,{value:"history",children:"History"}),e.jsx($,{value:"presets",children:"Presets"})]}),e.jsx(M,{value:"loan",className:"mt-6",children:e.jsx(Ke,{})}),e.jsx(M,{value:"investment",className:"mt-6",children:e.jsx(_e,{})}),e.jsx(M,{value:"budget",className:"mt-6",children:e.jsx(Ze,{})}),e.jsx(M,{value:"currency",className:"mt-6",children:e.jsx(Xe,{})}),e.jsx(M,{value:"savings",className:"mt-6",children:e.jsx(Qe,{})}),e.jsx(M,{value:"ratios",className:"mt-6",children:e.jsx(es,{})}),e.jsx(M,{value:"history",className:"mt-6",children:e.jsx(ss,{})}),e.jsx(M,{value:"presets",className:"mt-6",children:e.jsx(as,{})})]})})]})}function ns(){const[r,k]=N.useState("0"),[n,S]=N.useState(null),[d,R]=N.useState(null),[C,T]=N.useState(!1),[u,j]=N.useState(0),[x,b]=N.useState(!1),{plan:v,isActive:l}=Me(),F=l&&(v==="plus"||v==="pro"),t=I=>{C?(k(I),T(!1)):k(r==="0"?I:r+I)},o=()=>{C?(k("0."),T(!1)):r.indexOf(".")===-1&&k(r+".")},c=()=>{k("0"),S(null),R(null),T(!1)},m=I=>{const D=parseFloat(r);if(n===null)S(D);else if(d){const _=p(n||0,D,d);k(String(_)),S(_)}T(!0),R(I)},p=(I,D,q)=>{switch(q){case"+":return I+D;case"-":return I-D;case"×":return I*D;case"÷":return I/D;case"^":return Math.pow(I,D);case"%":return I%D;default:return D}},a=I=>
12{if(!F&&["sin","cos","tan","log","ln","sqrt","^"].includes(I)){b(!0);return}const D=parseFloat(r);let q;switch(I){case"sin":q=Math.sin(D*Math.PI/180);break;case"cos":q=Math.cos(D*Math.PI/180);break;case"tan":q=Math.tan(D*Math.PI/180);break;case"log":q=Math.log10(D);break;case"ln":q=Math.log(D);break;case"sqrt":q=Math.sqrt(D);break;case"1/x":q=1/D;break;case"x²":q=D*D;break;case"±":q=-D;break;case"tax":q=D*.0825;break;case"discount":q=D*.1;break;case"tip15":q=D*.15;break;case"tip20":q=D*.2;break;case"compound":q=D*Math.pow(1.05,1);break;default:return}k(String(q)),T(!0)},s=()=>{const I=parseFloat(r);if(n!==null&&d){const D=p(n,I,d);k(String(D)),S(null),R(null),T(!0)}},y=()=>{j(parseFloat(r))},w=()=>{k(String(u)),T(!0)},g=()=>{j(0)},A=()=>{j(u+parseFloat(r))},V=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(I);return e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full max-w-2xl mx-auto",children:[e.jsx(U,{children:e.jsx(L,{className:"text-center",children:"Advanced Calculator"})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"basic",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4",children:[e.jsx($,{value:"basic",children:"Basic"}),e.jsxs($,{value:"scientific",children:["Scientific ",!F&&e.jsx("span",{className:"ml-1",children:"🔒"})]}),e.jsx($,{value:"money",children:"Money & Finance"}),e.jsx($,{value:"advanced-financial",children:"Advanced Financial"})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg mb-4 text-right",children:e.jsx("div",{className:"text-3xl font-mono font-bold overflow-hidden",children:r})}),e.jsx(M,{value:"basic",className:"space-y-2",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsx(i,{variant:"outline",onClick:c,className:"h-12",children:"C"}),e.jsx(i,{variant:"outline",onClick:()=>m("%"),className:"h-12",children:"%"}),e.jsx(i,{variant:"outline",onClick:()=>a("±"),className:"h-12",children:"±"}),e.jsx(i,{variant:"destructive",onClick:()=>m("÷"),className:"h-12",children:"÷"}),e.jsx(i,{onClick:()=>t("7"),className:"h-12",children:"7"}),e.jsx(i,{onClick:()=>t("8"),className:"h-12",children:"8"}),e.jsx(i,{onClick:()=>t("9"),className:"h-12",children:"9"}),e.jsx(i,{variant:"destructive",onClick:()=>m("×"),className:"h-12",children:"×"}),e.jsx(i,{onClick:()=>t("4"),className:"h-12",children:"4"}),e.jsx(i,{onClick:()=>t("5"),className:"h-12",children:"5"}),e.jsx(i,{onClick:()=>t("6"),className:"h-12",children:"6"}),e.jsx(i,{variant:"destructive",onClick:()=>m("-"),className:"h-12",children:"-"}),e.jsx(i,{onClick:()=>t("1"),className:"h-12",children:"1"}),e.jsx(i,{onClick:()=>t("2"),className:"h-12",children:"2"}),e.jsx(i,{onClick:()=>t("3"),className:"h-12",children:"3"}),e.jsx(i,{variant:"destructive",onClick:()=>m("+"),className:"h-12",children:"+"}),e.jsx(i,{onClick:()=>t("0"),className:"h-12 col-span-2",children:"0"}),e.jsx(i,{onClick:o,className:"h-12",children:"."}),e.jsx(i,{variant:"default",onClick:s,className:"h-12 bg-primary",children:"="})]})}),e.jsxs(M,{value:"scientific",className:"space-y-2",children:[!F&&e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-3 mb-4",children:e.jsxs("p",{className:"text-sm text-yellow-800",children:["🔒 Scientific functions require Plus or Pro plan.",e.jsx(i,{variant:"link",className:"p-0 h-auto text-yellow-800 underline",onClick:()=>{b(!0),setTimeout(()=>window.location.hash="#payment",100)},children:"Upgrade now"})]})}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-2",children:[e.jsx(i,{variant:"secondary",onClick:g,className:"h-10 text-xs",children:"MC"}),e.jsx(i,{variant:"secondary",onClick:w,className:"h-10 text-xs",children:"MR"}),e.jsx(i,{variant:"secondary",onClick:A,className:"h-10 text-xs",children:"M+"}),e.jsx(i,{variant:"secondary",onClick:y,className:"h-10 text-xs",children:"MS"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[e.jsx(i,{variant:"outline",onClick:()=>a("sin"),className:"h-10 text-xs",disabled:!F,children:"sin"}),e.jsx(i,{variant:"outline",onClick:()=>a("cos"),className:"h-10 text-xs",disabled:!F,children:"cos"}),e.jsx(i,{variant:"outline",onClick:()=>a("tan"),className:"h-10 text-xs",disabled:!F,children:"tan"}),e.jsx(i,{variant:"outline",onClick:c,className:"h-10",children:"C"}),e.jsx(i,{variant:"destructive",onClick:()=>m("÷"),className:"h-10",children:"÷"}),e.jsx(i,{variant:"outline",onClick:()=>a("log"),className:"h-10 text-xs",disabled:!F,children:"log"}),e.jsx(i,{variant:"outline",onClick:()=>a("ln"),className:"h-10 text-xs",disabled:!F,children:"ln"}),e.jsx(i,{variant:"outline",onClick:()=>m("^"),className:"h-10 text-xs",disabled:!F,children:"x^y"}),e.jsx(i,{onClick:()=>t("7"),className:"h-10",children:"7"}),e.jsx(i,{onClick:()=>t("8"),className:"h-10",children:"8"}),e.jsx(i,{variant:"outline",onClick:()=>a("sqrt"),className:"h-10 text-xs",disabled:!F,children:"√"}),e.jsx(i,{variant:"outline",onClick:()=>a("x²"),className:"h-10 text-xs",children:"x²"}),e.jsx(i,{variant:"outline",onClick:()=>a("1/x"),className:"h-10 text-xs",children:"1/x"}),e.jsx(i,{onClick:()=>t("9"),className:"h-10",children:"9"}),e.jsx(i,{variant:"destructive",onClick:()=>m("×"),className:"h-10",children:"×"}),e.jsx(i,{variant:"outline",onClick:()=>t("("),className:"h-10",children:"("}),e.jsx(i,{variant:"outline",onClick:()=>t(")"),className:"h-10",children:")"}),e.jsx(i,{variant:"outline",onClick:()=>m("%"),className:"h-10",children:"%"}),e.jsx(i,{onClick:()=>t("4"),className:"h-10",children:"4"}),e.jsx(i,{onClick:()=>t("5"),className:"h-10",children:"5"}),e.jsx(i,{onClick:()=>t("6"),className:"h-10",children:"6"}),e.jsx(i,{variant:"destructive",onClick:()=>m("-"),className:"h-10",children:"-"}),e.jsx(i,{onClick:()=>t("1"),className:"h-10",children:"1"}),e.jsx(i,{onClick:()=>t("2"),className:"h-10",children:"2"}),e.jsx(i,{onClick:()=>t("3"),className:"h-10",children:"3"}),e.jsx(i,{variant:"destructive",onClick:()=>m("+"),className:"h-10",children:"+"}),e.jsx(i,{variant:"outline",onClick:()=>a("±"),className:"h-10",children:"±"}),e.jsx(i,{onClick:()=>t("0"),className:"h-10",children:"0"}),e.jsx(i,{onClick:o,className:"h-10",children:"."}),e.jsx(i,{variant:"default",onClick:s,className:"h-10 bg-primary",children:"="})]})]}),e.jsxs(M,{value:"money",className:"space-y-2",children:[e.jsx("div",{className:"bg-green-50 border border-green-200 rounded-lg p-3 mb-4",children:e.jsx("p",{className:"text-sm text-green-800",children:"💰 Financial calculations for budgeting, taxes, and money management"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx(i,{variant:"outline",onClick:()=>a("tax"),className:"h-10 text-xs",children:"Tax (8.25%)"}),e.jsx(i,{variant:"outline",onClick:()=>a("tip15"),className:"h-10 text-xs",children:"Tip 15%"}),e.jsx(i,{variant:"outline",onClick:()=>a("tip20"),className:"h-10 text-xs",children:"Tip 20%"}),e.jsx(i,{variant:"outline",onClick:()=>a("discount"),className:"h-10 text-xs",children:"Discount 10%"}),e.jsx(i,{variant:"outline",onClick:()=>a("compound"),className:"h-10 text-xs",children:"Interest 5%"}),e.jsx(i,{variant:"outline",onClick:c,className:"h-10 text-xs",children:"Clear"})]}),e.jsxs("div",{className:"bg-muted p-2 rounded text-center mb-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Currency: "}),e.jsx("span",{className:"font-semibold",children:V(parseFloat(r)||0)})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsx(i,{variant:"outline",onClick:c,className:"h-12",children:"C"}),e.jsx(i,{variant:"outline",onClick:()=>m("%"),className:"h-12",children:"%"}),e.jsx(i,{variant:"outline",onClick:()=>a("±"),className:"h-12",children:"±"}),e.jsx(i,{variant:"destructive",onClick:()=>m("÷"),className:"h-12",children:"÷"}),e.jsx(i,{onClick:()=>t("7"),className:"h-12",children:"7"}),e.jsx(i,{onClick:()=>t("8"),className:"h-12",children:"8"}),e.jsx(i,{onClick:()=>t("9"),className:"h-12",children:"9"}),e.jsx(i,{variant:"destructive",onClick:()=>m("×"),className:"h-12",children:"×"}),e.jsx(i,{onClick:()=>t("4"),className:"h-12",children:"4"}),e.jsx(i,{onClick:()=>t("5"),className:"h-12",children:"5"}),e.jsx(i,{onClick:()=>t("6"),className:"h-12",children:"6"}),e.jsx(i,{variant:"destructive",onClick:()=>m("-"),className:"h-12",children:"-"}),e.jsx(i,{onClick:()=>t("1"),className:"h-12",children:"1"}),e.jsx(i,{onClick:()=>t("2"),className:"h-12",children:"2"}),e.jsx(i,{onClick:()=>t("3"),className:"h-12",children:"3"}),e.jsx(i,{variant:"destructive",onClick:()=>m("+"),className:"h-12",children:"+"}),e.jsx(i,{onClick:()=>t("0"),className:"h-12 col-span-2",children:"0"}),e.jsx(i,{onClick:o,className:"h-12",children:"."}),e.jsx(i,{variant:"default",onClick:s,className:"h-12 bg-primary",children:"="})]})]}),e.jsx(M,{value:"advanced-financial",className:"mt-6",children:e.jsx(ls,{})})]})})]}),e.jsx(Re,{open:x,onOpenChange:b,children:e.jsxs(Pe,{children:[e.jsxs(Te,{children:[e.jsx(De,{children:"Upgrade Required"}),e.jsx(Ve,{children:"Scientific calculator functions are available with Plus or Pro plans. Upgrade now to unlock advanced mathematical functions including trigonometry, logarithms, and more."})]}),e.jsx(Ie,{children:e.jsx(Ee,{onClick:()=>{b(!1),window.location.hash="#payment"},children:"Upgrade Now"})})]})})]})}function rs(){const[r,k]=N.useState("mig"),[n,S]=N.useState(""),[d,R]=N.useState("steel"),[C,T]=N.useState("dc"),[u,j]=N.useState(""),[x,b]=N.useState(""),[v,l]=N.useState(null),F=()=>{const a=parseFloat(n);if(isNaN(a)||a<=0)return{recommendations:["Please enter a valid positive thickness value"]};let s=a*40,y=18+(s-80)*.04;s<80&&(s=80,y=18);let w=s;d==="aluminum"?(w=s*1.25,y+=2):d==="stainless"&&(w=s*.95,y-=.5);
12const g=Math.max(150,w*2.2),A=Math.max(15,Math.min(35,a*8+10)),V=Math.max(8,18-a*1.5),I=y*w*60/(V*1e3),D=[`Use ${C.toUpperCase()} current with ${C==="dc"?"electrode positive":"standard polarity"}`,`Wire diameter: ${a<=2?'0.030"':a<=4?'0.035"':a<=8?'0.045"':'1/16"'} recommended`,`Joint preparation: ${a>6?"Bevel edges for full penetration":a>3?"Square butt or fillet joint":"No prep needed for thin material"}`,d==="aluminum"?"Use push technique and aluminum-specific wire":"Push or pull technique acceptable",`Gas: ${d==="aluminum"?"100% Argon":d==="stainless"?"Tri-mix (Ar/He/CO2)":"75/25 Argon/CO2"}`,I>2.5?"High heat input - consider preheating and interpass temperature control":"Standard heat input range"];return{amperage:Math.round(w),voltage:Math.round(y*10)/10,wireSpeed:Math.round(g),gasFlow:Math.round(A),travelSpeed:Math.round(V*10)/10,heatInput:Math.round(I*1e3)/1e3,recommendations:D}},t=()=>{const a=parseFloat(n);if(isNaN(a)||a<=0)return{recommendations:["Please enter a valid positive thickness value"]};let s=a*35;d==="aluminum"?C==="ac"?s=a*25:s=a*30:d==="stainless"&&(s=a*30);const y=C==="ac"?12+s*.025:10+s*.02,w=Math.max(8,Math.min(25,a*4+5)),g=Math.max(3,12-a*1.8),A=y*s*60/(g*1e3),V=[`Use ${C.toUpperCase()} current`,d==="aluminum"?"AC current recommended for aluminum (cleaning action)":"DC electrode negative (DCEN) for steel/stainless",`Tungsten electrode: ${d==="aluminum"?"Pure tungsten or AC-specific (green/red tip)":C==="dc"?"2% Thoriated (red) or Lanthanated (blue)":"AC tungsten"}`,`Tungsten diameter: ${a<=1.5?'1/16"':a<=3?'3/32"':a<=6?'1/8"':'5/32"'}`,`Filler rod: ${a<=1?'1/16"':a<=3?'3/32"':'1/8"'} diameter`,"Maintain tight arc length (tungsten diameter distance)",`Gas: ${d==="aluminum"||d==="stainless"?"100% Argon":"100% Argon or Argon/Hydrogen mix"}`,A>1.5?"Monitor heat buildup - use backing bars or heat sinks":"Good heat input for penetration"];return{amperage:Math.round(s),voltage:Math.round(y*10)/10,gasFlow:Math.round(w),travelSpeed:Math.round(g*10)/10,heatInput:Math.round(A*1e3)/1e3,recommendations:V}},o=()=>{const a=parseFloat(n);if(isNaN(a)||a<=0)return{recommendations:["Please enter a valid positive thickness value"]};const s=Math.max(80,a*35+15),y=22+s*.035,w=Math.max(4,10-a*.8),g=y*s*60/(w*1e3);let A='1/8"';a<=2?A='5/64"':a<=4?A='3/32"':a<=8?A='1/8"':A='5/32"';const V=[`Use ${C.toUpperCase()} current`,`Electrode size: ${A} recommended for ${a}mm material`,C==="dc"?"DCEP (electrode positive) for better penetration":"AC suitable for general welding",`Electrode type: ${d==="steel"?"E7018 (low hydrogen) or E6013 (general purpose)":d==="stainless"?"E308L-16 or E316L-16":"Consult electrode manufacturer"}`,"Maintain arc length equal to electrode diameter",`Root opening: ${a>6?"2-3mm with backing":a>3?"1-2mm":"Tight fit-up"}`,`Preheat: ${a>25?"150-200°C recommended":a>12?"100°C may be beneficial":"No preheat required"}`,g>2?"High heat input - monitor interpass temperature":"Acceptable heat input"];return{amperage:Math.round(s),voltage:Math.round(y*10)/10,travelSpeed:Math.round(w*10)/10,heatInput:Math.round(g*1e3)/1e3,recommendations:V}},c=()=>{const a=parseFloat(u),s=parseFloat(x);if(isNaN(a)&&isNaN(s))return{recommendations:["Please enter at least one value (voltage or amperage)"]};if(!isNaN(a)&&a<0)return{recommendations:["Voltage cannot be negative"]};if(!isNaN(s)&&s<0)return{recommendations:["Amperage cannot be negative"]};if(!isNaN(a)&&isNaN(s)){const y=C==="ac"?Math.max(20,(a-15)/.04):Math.max(20,(a-12)/.035),w=y*1.5;return{voltage:a,amperage:Math.round((y+w)/2),recommendations:[`For ${a}V, typical amperage range: ${Math.round(y)}-${Math.round(w)}A`,`Suggested amperage: ${Math.round((y+w)/2)}A`,`Power range: ${Math.round(a*y)}-${Math.round(a*w)}W`,`${C.toUpperCase()} characteristics applied`]}}else if(isNaN(a)&&!isNaN(s)){const y=C==="ac"?15+s*.04:12+s*.035;return{amperage:s,voltage:Math.round(y*10)/10,recommendations:[`For ${s}A, calculated voltage: ${y.toFixed(1)}V`,`Power: ${Math.round(y*s)}W`,`${C.toUpperCase()} voltage-current relationship`,s>200?"High amperage - ensure adequate machine capacity":"Standard amperage range"]}}else{const y=a*s,w=C==="dc"?.85:.75;return{amperage:s,voltage:a,recommendations:[`Power: ${Math.round(y)}
12W`,`Estimated arc efficiency: ${(w*100).toFixed(0)}%`,`Actual power to arc: ${Math.round(y*w)}W`,y>8e3?"High power - industrial welding application":y>3e3?"Medium power - suitable for structural work":"Light power - suitable for sheet metal",`${C.toUpperCase()} welding parameters`]}}},m=()=>{let a;switch(r){case"mig":a=F();break;case"tig":a=t();break;case"stick":a=o();break;case"voltage":a=c();break;default:a={recommendations:["Please select a welding type"]}}l(a)},p=()=>{S(""),j(""),b(""),l(null)};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsx(L,{className:"text-center",children:"Professional Welding Calculator"})}),e.jsx(E,{children:e.jsxs(Y,{value:r,onValueChange:k,className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4",children:[e.jsx($,{value:"mig",children:"MIG/GMAW"}),e.jsx($,{value:"tig",children:"TIG/GTAW"}),e.jsx($,{value:"stick",children:"Stick/SMAW"}),e.jsx($,{value:"voltage",children:"Parameters"})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"currentType",children:"Current Type"}),e.jsxs(B,{value:C,onValueChange:T,children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsxs(G,{children:[e.jsx(z,{value:"dc",children:"DC (Direct Current)"}),e.jsx(z,{value:"ac",children:"AC (Alternating Current)"})]})]})]}),r!=="voltage"&&e.jsxs("div",{children:[e.jsx(h,{htmlFor:"materialType",children:"Material Type"}),e.jsxs(B,{value:d,onValueChange:R,children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsxs(G,{children:[e.jsx(z,{value:"steel",children:"Carbon Steel"}),e.jsx(z,{value:"stainless",children:"Stainless Steel"}),e.jsx(z,{value:"aluminum",children:"Aluminum"})]})]})]})]}),e.jsx(M,{value:"mig",className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(h,{htmlFor:"thickness-mig",children:"Material Thickness (mm)"}),e.jsx(f,{id:"thickness-mig",type:"number",step:"0.1",min:"0.5",max:"50",value:n,onChange:a=>S(a.target.value),placeholder:"Enter thickness (0.5-50mm)"})]})}),e.jsx(M,{value:"tig",className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(h,{htmlFor:"thickness-tig",children:"Material Thickness (mm)"}),e.jsx(f,{id:"thickness-tig",type:"number",step:"0.1",min:"0.2",max:"25",value:n,onChange:a=>S(a.target.value),placeholder:"Enter thickness (0.2-25mm)"})]})}),e.jsx(M,{value:"stick",className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(h,{htmlFor:"thickness-stick",children:"Material Thickness (mm)"}),e.jsx(f,{id:"thickness-stick",type:"number",step:"0.5",min:"2",max:"100",value:n,onChange:a=>S(a.target.value),placeholder:"Enter thickness (2-100mm)"})]})}),e.jsxs(M,{value:"voltage",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"voltage-input",children:"Voltage (V)"}),e.jsx(f,{id:"voltage-input",type:"number",step:"0.1",min:"10",max:"50",value:u,onChange:a=>j(a.target.value),placeholder:"10-50V"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"amperage-input",children:"Amperage (A)"}),e.jsx(f,{id:"amperage-input",type:"number",step:"1",min:"20",max:"500",value:x,onChange:a=>b(a.target.value),placeholder:"20-500A"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter voltage, amperage, or both to analyze welding parameters"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{onClick:m,className:"flex-1",disabled:r!=="voltage"&&!n||r==="voltage"&&!u&&!x,children:"Calculate Parameters"}),e.jsx(i,{variant:"outline",onClick:p,children:"Reset"})]}),v&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Welding Parameters"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[v.amperage&&e.jsxs("div",{className:"text-center p-3 bg-background rounded-lg border",children:[e.jsxs("div",{className:"text-2xl font-bold text-primary",children:[v.amperage,"A"]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Amperage"})]}),v.voltage&&e.jsxs("div",{className:"text-center p-3 bg-background rounded-lg border",children:[e.jsxs("div",{className:"text-2xl font-bold text-primary",children:[v.voltage,"V"]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Voltage"})]}),v.wireSpeed&&e.jsxs("div",{className:"text-center p-3 bg-background rounded-lg border",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:v.wireSpeed}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Wire Speed (IPM)"})]}),v.gasFlow&&e.jsxs("div",{className:"text-center p-3 bg-background rounded-lg border",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:v.gasFlow}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Gas Flow (CFH)"})]}),v.travelSpeed&&e.jsxs("div",{className:"text-center p-3 bg-background rounded-lg border",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:v.travelSpeed}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Travel Speed (IPM)"})]}),v.heatInput&&e.jsxs("div",{className:"text-center p-3 bg-background rounded-lg border",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:v.heatInput}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Heat Input (kJ/in)"})]})]}),v.recommendations&&v.recommendations.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-3",children:"Setup Recommendations:"}),e.jsx("ul",{className:"space-y-2",children:v.recommendations.map((a,s)=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-start",children:[e.jsx("span",{className:"mr-2 mt
12-0.5",children:"•"}),e.jsx("span",{children:a})]},s))})]})]})]})]})]})})]})}function is(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState(""),[v,l]=N.useState(null),F=()=>{const p=parseFloat(r),a=parseFloat(x);if(isNaN(p)||isNaN(a)||p<=0||a<=0){l({recommendations:["Please enter valid positive force and radius values"]});return}const s=p*a;l({result:s,unit:"N⋅m",calculations:{"Force (N)":p,"Radius (m)":a,"Torque (N⋅m)":s},recommendations:["Torque = Force × Radius",`Applied force: ${p} N at distance ${a} m`,s>100?"High torque - ensure proper safety measures":"Standard torque range","Always use proper torque wrench for precision work"]})},t=()=>{const p=parseFloat(r),a=parseFloat(n),s=parseFloat(d);if(isNaN(p)||isNaN(a)||isNaN(s)||p<=0||a<=0||s<=0){l({recommendations:["Please enter valid positive values for force, distance, and time"]});return}const y=p*a,w=y/s;l({result:w,unit:"W",calculations:{"Force (N)":p,"Distance (m)":a,"Time (s)":s,"Work (J)":y,"Power (W)":w},recommendations:["Power = Work ÷ Time = (Force × Distance) ÷ Time",`Work done: ${y.toFixed(2)} J over ${s} seconds`,w>1e3?"High power output - consider cooling requirements":"Standard power range",w<100?"Low power - suitable for precision work":""].filter(Boolean)})},o=()=>{const p=parseFloat(C),a=parseFloat(u);if(isNaN(p)||isNaN(a)||p<=0){l({recommendations:["Please enter valid positive mass and acceleration values"]});return}const s=p*a;l({result:s,unit:"N",calculations:{"Mass (kg)":p,"Acceleration (m/s²)":a,"Force (N)":s},recommendations:["Force = Mass × Acceleration (Newton's Second Law)",`Object mass: ${p} kg with acceleration: ${a} m/s²`,s>1e3?"High force - ensure structural integrity":"Standard force range",a===9.81?"Standard gravity acceleration detected":""].filter(Boolean)})},c=()=>{const p=parseFloat(n),a=parseFloat(d);if(isNaN(p)||isNaN(a)||a<=0){l({recommendations:["Please enter valid distance and positive time values"]});return}const s=p/a,y=parseFloat(u);let w=s,g={"Distance (m)":p,"Time (s)":a,"Average Velocity (m/s)":s};isNaN(y)||(w=s+y*a,g={...g,"Acceleration (m/s²)":y,"Final Velocity (m/s)":w}),l({result:w,unit:"m/s",calculations:g,recommendations:["Velocity = Distance ÷ Time",isNaN(y)?"Constant velocity calculation":"Final Velocity = Initial Velocity + (Acceleration × Time)",`Average speed: ${s.toFixed(2)} m/s`,w>50?"High velocity - consider safety factors":"Safe velocity range",Math.abs(w-s)>10?"Significant acceleration effect detected":""].filter(Boolean)})},m=()=>{k(""),S(""),R(""),T(""),j(""),b(""),l(null)};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsx(L,{className:"text-center",children:"Mechanics Calculator"})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"torque",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4",children:[e.jsx($,{value:"torque",children:"Torque"}),e.jsx($,{value:"power",children:"Power"}),e.jsx($,{value:"force",children:"Force"}),e.jsx($,{value:"velocity",children:"Velocity"})]}),e.jsxs(M,{value:"torque",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"force-torque",children:"Force (N)"}),e.jsx(f,{id:"force-torque",type:"number",step:"0.1",min:"0",value:r,onChange:p=>k(p.target.value),placeholder:"Enter force in Newtons"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"radius",children:"Radius/Lever Arm (m)"}),e.jsx(f,{id:"radius",type:"number",step:"0.01",min:"0",value:x,onChange:p=>b(p.target.value),placeholder:"Enter radius in meters"})]})]}),e.jsx(i,{onClick:F,className:"w-full",children:"Calculate Torque"})]}),e.jsxs(M,{value:"power",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"force-power",children:"Force (N)"}),e.jsx(f,{id:"force-power",type:"number",step:"0.1",min:"0",value:r,onChange:p=>k(p.target.value),placeholder:"Enter force"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"distance-power",children:"Distance (m)"}),e.jsx(f,{id:"distance-power",type:"number",step:"0.1",value:n,onChange:p=>S(p.target.value),placeholder:"Enter distance"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"time-power",children:"Time (s)"}),e.jsx(f,{id:"time-power",type:"number",step:"0.1",min:"0.01",value:d,onChange:p=>R(p.target.value),placeholder:"Enter time"})]})]}),e.jsx(i,{onClick:t,className:"w-full",children:"Calculate Power"})]}),e.jsxs(M,{value:"force",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"mass",children:"Mass (kg)"}),e.jsx(f,{id:"mass",type:"number",step:"0.1",min:"0",value:C,onChange:p=>T(p.target.value),placeholder:"Enter mass in kg"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"acceleration-force",children:"Acceleration (m/s²)"}),e.jsx(f,{id:"acceleration-force",type:"number",step:"0.1",value:u,onChange:p=>j(p.target.value),placeholder:"Enter acceleration (use 9.81 for gravity)"})]})]}),e.jsx(i,{onClick:o,className:"w-full",children:"Calculate Force"})]}),e.jsxs(M,{value:"velocity",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"distance-velocity",children:"Distance (m)"}),e.jsx(f,{id:"distance-velocity",type:"number",step:"0.1",value:n,onChange:p=>S(p.target.value),placeholder:"Enter distance"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"time-velocity",children:"Time (s)"}),e.jsx(f,{id:"time-velocity",type:"number",step:"0.1",min:"0.01",value:d,onChange:p=>R(p.target.value),placeholder:"Enter time"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"acceleration-velocity",children:"Acceleration (m/s²)"}),e.jsx(f,{id:"acceleration-velocity",type:"number",step:"0.1",value:u,onChange:p=>j(p.target.value),placeholder:"Optional acceleration"})]})]}),e.jsx(i,{onClick:c,className:"w-full",children:"Calculate Velocity"})]}),e.jsx("div",{className:"flex gap-2 mt-4",children:e.jsx(i,{variant:"outline",onClick:m,className:"w-full",children:"Reset All"})}),v&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Calculation Results"})}),e.jsxs(E,{className:"space-y-4",children:[v.result!==void 0&&e.jsx("div",{className:"text-center p-4 bg-background rounded-lg",children:e.jsxs("div",{className:"text-3xl font-bold text-primary",children:[v.result.toFixed(3)," ",v.unit]})}),v.calculations&&e.jsx("div",{className:"grid grid-cols-2 gap-4",children:Object.entries(v.calculations).map(([p,a])=>e.jsxs("div",{className:"text-center p-2 bg-background rounded",children:[e.jsx("div",{className:"font-semibold text-sm",children:p}),e.jsx("div",{className:"text-muted-foreground",children:a.toFixed(3)})]},p))}),v.recommendations&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-2",children:"Formula & Analysis:"}),e.jsx("ul",{className:"space-y-1",children:v.recommendations.map((p,a)=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:p})]},a))})]})]})]})]})})]})}function cs(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState(""),[v,l]=N.useState(""),[F,t]=N.useState(null),o=()=>{const s=parseFloat(r),y=parseFloat(n);if(isNaN(s)||isNaN(y))return{recommendations:["Please enter valid area and seed rate values"]};const w=s*y,g=Math.ceil(w/50),A=g*25;return{result:w,unit:"kg",breakdown:{"Field Area":`${s} acres`,"Seed Rate":`${y} kg/acre`,"Total Seeds Needed":`${w} kg`,"Bags Required":`${g} bags`,"Estimated Cost":`$${A}`},recommendations:["Seeding Rate = Area × Seeds per Acre",`Total field coverage: ${s} acres`,y>30?"High seeding rate - ensure adequate spacing":"Standard seeding rate","Consider soil conditions and crop type for optimal rates"]}},c=()=>{const s=parseFloat(r),y=parseFloat(d);if(isNaN(s)||isNaN(y))return{recommendations:["Please enter valid area and fertilizer rate values"]};const w=s*y,g=Math.ceil(w/50),A=g*35;return{result:w,unit:"lbs",breakdown:{"Field Area":`${s} acres`,"Application Rate":`${y} lbs/acre`,"Total Fertilizer":`${w} lbs`,"Bags Required":`${g} bags`,"Estimated Cost":`$${A}`},recommendations:["Fertilizer Amount = Area × Application Rate","Consider soil test results for optimal nutrient balance",y>200?"High application rate - risk of runoff":"Standard application rate","Apply in multiple splits for better uptake"]}},m=()=>{const s=parseFloat(r),y=parseFloat(C);if(isNaN(s)||isNaN(y))return{recommendations:["Please enter valid area and water volume values"]};const w=s*y,g=w*27154,A=w/.5;return{result:w,unit:"acre-inches",breakdown:{"Field Area":`${s} acres`,"Water Depth":`${y} inches`,"Total Water":`${w}
12 acre-inches`,Gallons:`${g.toLocaleString()} gallons`,"Irrigation Time":`${A} hours`},recommendations:["Water Volume = Area × Water Depth","Monitor soil moisture before irrigation",y>2?"Deep irrigation - check for runoff":"Standard irrigation depth","Consider weather conditions and crop stage"]}},p=()=>{const s=parseFloat(r),y=parseFloat(u),w=parseFloat(x),g=parseFloat(v);if(isNaN(s)||isNaN(y)||isNaN(w)||isNaN(g))return{recommendations:["Please enter all values for profitability calculation"]};const A=s*y,V=A*w,I=s*g,D=V-I,q=D/s,_=D/I*100;return{result:D,unit:"$",breakdown:{"Field Area":`${s} acres`,"Yield per Acre":`${y} bushels/acre`,"Total Yield":`${A} bushels`,"Price per Bushel":`$${w}`,"Total Revenue":`$${V.toFixed(2)}`,"Total Costs":`$${I.toFixed(2)}`,"Profit per Acre":`$${q.toFixed(2)}`,ROI:`${_.toFixed(1)}%`},recommendations:["Profit = (Yield × Price) - Costs",D>0?"Profitable operation":"Operating at a loss",_>15?"Excellent return on investment":_>5?"Good ROI":"Consider cost reduction","Monitor market prices and input costs regularly"]}},a=()=>{k(""),S(""),R(""),T(""),j(""),b(""),l(""),t(null)};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsx(L,{className:"text-center",children:"Farming Calculator"})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"seeding",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4",children:[e.jsx($,{value:"seeding",children:"Seeding"}),e.jsx($,{value:"fertilizer",children:"Fertilizer"}),e.jsx($,{value:"irrigation",children:"Irrigation"}),e.jsx($,{value:"profit",children:"Profitability"})]}),e.jsxs(M,{value:"seeding",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"area",children:"Field Area (acres)"}),e.jsx(f,{id:"area",type:"number",step:"0.1",value:r,onChange:s=>k(s.target.value),placeholder:"Enter field area"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"seedRate",children:"Seed Rate (kg/acre)"}),e.jsx(f,{id:"seedRate",type:"number",step:"0.5",value:n,onChange:s=>S(s.target.value),placeholder:"Enter seeding rate"})]})]}),e.jsx(i,{onClick:o,className:"w-full",children:"Calculate Seeding Requirements"})]}),e.jsxs(M,{value:"fertilizer",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"area",children:"Field Area (acres)"}),e.jsx(f,{id:"area",type:"number",step:"0.1",value:r,onChange:s=>k(s.target.value),placeholder:"Enter field area"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fertilizerRate",children:"Application Rate (lbs/acre)"}),e.jsx(f,{id:"fertilizerRate",type:"number",step:"1",value:d,onChange:s=>R(s.target.value),placeholder:"Enter fertilizer rate"})]})]}),e.jsx(i,{onClick:c,className:"w-full",children:"Calculate Fertilizer Needs"})]}),e.jsxs(M,{value:"irrigation",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"area",children:"Field Area (acres)"}),e.jsx(f,{id:"area",type:"number",step:"0.1",value:r,onChange:s=>k(s.target.value),placeholder:"Enter field area"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"waterVolume",children:"Water Depth (inches)"}),e.jsx(f,{id:"waterVolume",type:"number",step:"0.1",value:C,onChange:s=>T(s.target.value),placeholder:"Enter irrigation depth"})]})]}),e.jsx(i,{onClick:m,className:"w-full",children:"Calculate Irrigation Requirements"})]}),e.jsxs(M,{value:"profit",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"area",children:"Field Area (acres)"}),e.jsx(f,{id:"area",type:"number",step:"0.1",value:r,onChange:s=>k(s.target.value),placeholder:"Enter field area"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"cropYield",children:"Yield (bushels/acre)"}),e.jsx(f,{id:"cropYield",type:"number",step:"0.1",value:u,onChange:s=>j(s.target.value),placeholder:"Expected yield"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"price",children:"Price ($/bushel)"}),e.jsx(f,{id:"price",type:"number",step:"0.01",value:x,onChange:s=>b(s.target.value),placeholder:"Market price"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"costs",children:"Costs ($/acre)"}
12),e.jsx(f,{id:"costs",type:"number",step:"1",value:v,onChange:s=>l(s.target.value),placeholder:"Total costs per acre"})]})]}),e.jsx(i,{onClick:p,className:"w-full",children:"Calculate Profitability"})]}),e.jsx("div",{className:"flex gap-2 mt-4",children:e.jsx(i,{variant:"outline",onClick:a,className:"w-full",children:"Reset All"})}),F&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Calculation Results"})}),e.jsxs(E,{className:"space-y-4",children:[F.result&&e.jsx("div",{className:"text-center p-4 bg-background rounded-lg",children:e.jsxs("div",{className:"text-3xl font-bold text-primary",children:[typeof F.result=="number"?F.result.toLocaleString():F.result," ",F.unit]})}),F.breakdown&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"Detailed Breakdown:"}),Object.entries(F.breakdown).map(([s,y])=>e.jsxs("div",{className:"flex justify-between p-2 bg-background rounded",children:[e.jsxs("span",{className:"font-medium",children:[s,":"]}),e.jsx("span",{className:"text-muted-foreground",children:y})]},s))]}),F.recommendations&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-2",children:"Recommendations:"}),e.jsx("ul",{className:"space-y-1",children:F.recommendations.map((s,y)=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:s})]},y))})]})]})]})]})})]})}function os(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState("single"),[v,l]=N.useState("dc"),[F,t]=N.useState(null),o=()=>{const s=parseFloat(r),y=parseFloat(n),w=parseFloat(d);if([!isNaN(s),!isNaN(y),!isNaN(w)].filter(Boolean).length!==2)return{recommendations:["Please enter exactly two values to calculate the third"]};let A,V,I;if(!isNaN(s)&&!isNaN(y)&&isNaN(w)){if(y===0)return{recommendations:["Current cannot be zero for resistance calculation"]};A=s/y,V="Ω",I="Resistance"}else if(!isNaN(s)&&isNaN(y)&&!isNaN(w)){if(w===0)return{recommendations:["Resistance cannot be zero for current calculation"]};A=s/w,V="A",I="Current"}else if(isNaN(s)&&!isNaN(y)&&!isNaN(w))A=y*w,V="V",I="Voltage";else return{recommendations:["Invalid combination of values provided"]};const D=isNaN(s)?A:s,q=isNaN(y)?I==="Current"?A:D/w:y,_=isNaN(w)?A:w,Z=D*q;return{result:A,unit:V,calculations:{"Voltage (V)":D,"Current (A)":q,"Resistance (Ω)":_,"Power (W)":Z},recommendations:[`Calculated ${I}: ${A.toFixed(4)} ${V}`,"Ohm's Law: V = I × R","Power = V × I = I²R = V²/R",Z>1e3?"High power - ensure adequate heat dissipation":"",D>50?"Caution: High voltage - follow safety protocols":"",q>10?"High current - verify conductor ratings":""].filter(Boolean)}},c=()=>{const s=parseFloat(r),y=parseFloat(n);if(isNaN(s)||isNaN(y)||s<0||y<0)return{recommendations:["Please enter valid positive voltage and current values"]};const w=s*y,g=v==="ac"?.85:.95,A=w*g,V=v==="ac"?.85:1;return{result:w,unit:"W",calculations:{"Voltage (V)":s,"Current (A)":y,"Apparent Power (VA)":w,"Real Power (W)":A,"Power Factor":V,"Efficiency (%)":g*100},recommendations:[`Apparent Power = Voltage × Current = ${w.toFixed(2)} W`,`${v.toUpperCase()} efficiency: ${(g*100).toFixed(1)}%`,v==="ac"?`Power factor assumed: ${V}`:"DC power calculation (100% power factor)",w>1e3?"High power - ensure adequate cooling and protection":"Standard power range",v==="ac"?"Consider reactive power for complete AC analysis":""].filter(Boolean)}},m=()=>{const s=parseFloat(r),y=parseFloat(u),w=parseFloat(n);if(isNaN(s)||isNaN(y)||s<0||y<=0)return{recommendations:["Please enter valid positive voltage and frequency values"]};const g=s*Math.sqrt(2),A=s,V=1/y,I=2*Math.PI*y;let D=1,q=s,_=s;x==="three"&&(D=Math.sqrt(3),_=s/D,q=s);const Z={"RMS Voltage (V)":A,"Peak Voltage (V)":g,"Frequency (Hz)":y,"Period (ms)":V*1e3,"Angular Frequency (rad/s)":I};if(x==="three"&&(Z["Line Voltage (V)"]=q,Z["Phase Voltage (V)"]=_,Z["√3 Factor"]=D),!isNaN(w)&&w>0){const ie=w,ke=x==="three"?ie/D:ie;Z["Line Current (A)"]=ie,x==="three"&&(Z["Phase Current (A)"]=ke)}return{result:g,unit:"V (peak)",calculations:Z,recommendations:[`AC ${x}-phase system at ${y} Hz`,`Peak voltage = √2 × RMS = ${g.toFixed(1)}V`,`Period = ${(V*1e3).toFixed(2)} milliseconds`,y===50?"European/International standard (50 Hz)":y===60?"North American standard (60 Hz)":"Non-standard frequency",x==="three"?"Three-phase provides more efficient power transmission":"Single-phase system",x==="three"?`Phase voltage = Line voltage ÷ √3 = ${_.toFixed(1)}
12V`:""].filter(Boolean)}},p=()=>{const s=parseFloat(r),y=parseFloat(n),w=parseFloat(d);if(isNaN(s)||isNaN(y)||isNaN(w)||s<=0||y<0||w<0)return{recommendations:["Please enter valid positive values for source voltage, current, and resistance"]};const g=y*w,A=s-g,V=g/s*100,I=Math.pow(y,2)*w,D=A/s*100;return{result:g,unit:"V",calculations:{"Source Voltage (V)":s,"Load Current (A)":y,"Conductor Resistance (Ω)":w,"Voltage Drop (V)":g,"Voltage at Load (V)":A,"Drop Percentage (%)":V,"Power Loss (W)":I,"Efficiency (%)":D},recommendations:[`Voltage drop: ${g.toFixed(3)}V (${V.toFixed(2)}%)`,V>5?"⚠️ Excessive voltage drop - increase conductor size":V>3?"⚠️ High voltage drop - monitor performance":"✓ Acceptable voltage drop",A<s*.9?"Load voltage may be insufficient for proper operation":"",`Power loss in conductors: ${I.toFixed(2)}W`,`System efficiency: ${D.toFixed(1)}%`,V>3?"Consider using larger conductors or higher voltage":""].filter(Boolean)}},a=()=>{k(""),S(""),R(""),T(""),j(""),t(null)};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsx(L,{className:"text-center",children:"Electrical Calculator"})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"ohms",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4",children:[e.jsx($,{value:"ohms",children:"Ohm's Law"}),e.jsx($,{value:"power",children:"Power"}),e.jsx($,{value:"ac",children:"AC Analysis"}),e.jsx($,{value:"drop",children:"Voltage Drop"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4 mb-6",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"currentType",children:"Current Type"}),e.jsxs(B,{value:v,onValueChange:l,children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsxs(G,{children:[e.jsx(z,{value:"dc",children:"DC (Direct Current)"}),e.jsx(z,{value:"ac",children:"AC (Alternating Current)"})]})]})]}),v==="ac"&&e.jsxs("div",{children:[e.jsx(h,{htmlFor:"phase",children:"Phase Configuration"}),e.jsxs(B,{value:x,onValueChange:b,children:[e.jsx(O,{children:e.jsx(H,{})}),e.jsxs(G,{children:[e.jsx(z,{value:"single",children:"Single Phase"}),e.jsx(z,{value:"three",children:"Three Phase"})]})]})]})]}),e.jsxs(M,{value:"ohms",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"voltage-ohms",children:"Voltage (V)"}),e.jsx(f,{id:"voltage-ohms",type:"number",step:"0.1",min:"0",value:r,onChange:s=>k(s.target.value),placeholder:"Enter voltage"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"current-ohms",children:"Current (A)"}),e.jsx(f,{id:"current-ohms",type:"number",step:"0.001",min:"0",value:n,onChange:s=>S(s.target.value),placeholder:"Enter current"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"resistance-ohms",children:"Resistance (Ω)"}),e.jsx(f,{id:"resistance-ohms",type:"number",step:"0.001",min:"0",value:d,onChange:s=>R(s.target.value),placeholder:"Enter resistance"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter any two values to calculate the third using Ohm's Law (V = I × R)"}),e.jsx(i,{onClick:o,className:"w-full",children:"Calculate Missing Value"})]}),e.jsxs(M,{value:"power",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"voltage-power",children:"Voltage (V)"}),e.jsx(f,{id:"voltage-power",type:"number",step:"0.1",min:"0",value:r,onChange:s=>k(s.target.value),placeholder:"Enter voltage"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"current-power",children:"Current (A)"}),e.jsx(f,{id:"current-power",type:"number",step:"0.001",min:"0",value:n,onChange:s=>S(s.target.value),placeholder:"Enter current"})]})]}),e.jsx(i,{onClick:c,className:"w-full",children:"Calculate Power & Efficiency"})]}),e.jsxs(M,{value:"ac",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"voltage-ac",children:"RMS Voltage (V)"}),e.jsx(f,{id:"voltage-ac",type:"number",step:"0.1",min:"0",value:r,onChange:s=>k(s.target.value),placeholder:"Enter RMS voltage"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"frequency",children:"Frequency (Hz)"}),e.jsx(f,{id:"frequency",type:"number",step:"0.1",min:"0",value:u,onChange:s=>j(s.target.value),placeholder:"50 or 60"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"current-ac",children:"Current (A) - Optional"}),e.jsx(f,{id:"current-ac",type:"number",step:"0.001",min:"0",value:n,onChange:s=>S(s.target.value),placeholder:"Optional current"})]})]}),e.jsx(i,{onClick:m,className:"w-full",children:"Analyze AC Properties"})]}),e.jsxs(M,{value:"drop",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"voltage-drop",children:"Source Voltage (V)"}),e.jsx(f,{id:"voltage-drop",type:"number",step:"0.1",min:"0",value:r,onChange:s=>k(s.target.value),placeholder:"Enter source voltage"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"current-drop",children:"Load Current (A)"}),e.jsx(f,{id:"current-drop",type:"number",step:"0.001",min:"0",value:n,onChange:s=>S(s.target.value),placeholder:"Enter load current"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"resistance-drop",children:"Wire Resistance (Ω)"}),e.jsx(f,{id:"resistance-drop",type:"number",step:"0.001",min:"0",value:d,onChange:s=>R(s.target.value),placeholder:"Total wire resistance"})]})]}),e.jsx(i,{onClick:p,className:"w-full",children:"Calculate Voltage Drop"})]}),e.jsx("div",{className:"flex gap-2 mt-4",children:e.jsx(i,{variant:"outline",onClick:a,className:"w-full",children:"Reset All Values"})}),F&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Calculation Results"})}),e.jsxs(E,{className:"space-y-4",children:[F.result!==void 0&&e.jsx("div",{className:"text-center p-4 bg-background rounded-lg",children:e.jsxs("div",{className:"text-3xl font-bold text-primary",children:[F.result.toFixed(4)," ",F.unit]})}),F.calculations&&e.jsx("div",{className:"grid grid-cols-2 gap-4",children:Object.entries(F.calculations).map(([s,y])=>e.jsxs("div",{className:"text-center p-2 bg-background rounded",children:[e.jsx("div",{className:"font-semibold text-sm",children:s}),e.jsx("div",{className:"text-muted-foreground",children:y.toFixed(4)})]},s))}),F.recommendations&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-2",children:"Analysis & Recommendations:"}),e.jsx("ul",{className:"space-y-1",children:F.recommendations.map((s,y)=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:s})]},y))})]})]})]})]})})]})}function ds(){const[r,k]=N.useState(()=>{const u=localStorage.getItem("vehicleMaintenanceRecords");return u?JSON.parse(u):[]}),[n,S]=N.useState({date:"",mileage:"",serviceType:"",description:"",cost:"",mechanic:"",nextServiceMileage:""}),d=["Oil Change","Tire Rotation","Brake Service","Air Filter","Transmission Service","Coolant Flush","Spark Plugs","Battery Replacement","Cleaning and Detailing","Inspection","Other"],R=()=>
12{if(!n.date||!n.mileage||!n.serviceType){alert("Please fill in the required fields (Date, Mileage, Service Type)");return}const j=[{id:Date.now().toString(),date:n.date,mileage:parseInt(n.mileage),serviceType:n.serviceType,description:n.description,cost:parseFloat(n.cost)||0,mechanic:n.mechanic,nextServiceMileage:n.nextServiceMileage?parseInt(n.nextServiceMileage):void 0},...r];k(j),localStorage.setItem("vehicleMaintenanceRecords",JSON.stringify(j)),S({date:"",mileage:"",serviceType:"",description:"",cost:"",mechanic:"",nextServiceMileage:""})},C=u=>{const j=r.filter(x=>x.id!==u);k(j),localStorage.setItem("vehicleMaintenanceRecords",JSON.stringify(j))},T=r.reduce((u,j)=>u+j.cost,0);return e.jsxs(P,{className:"w-full max-w-6xl mx-auto",children:[e.jsx(U,{children:e.jsx(L,{className:"text-center",children:"Vehicle Maintenance Log"})}),e.jsxs(E,{className:"space-y-6",children:[e.jsxs(P,{className:"bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Add New Maintenance Record"})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"date",children:"Date *"}),e.jsx(f,{id:"date",type:"date",value:n.date,onChange:u=>S({...n,date:u.target.value})})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"mileage",children:"Mileage *"}),e.jsx(f,{id:"mileage",type:"number",placeholder:"Current mileage",value:n.mileage,onChange:u=>S({...n,mileage:u.target.value})})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serviceType",children:"Service Type *"}),e.jsxs(B,{value:n.serviceType,onValueChange:u=>S({...n,serviceType:u}),children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select service type"})}),e.jsx(G,{children:d.map(u=>e.jsx(z,{value:u,children:u},u))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"cost",children:"Cost ($)"}),e.jsx(f,{id:"cost",type:"number",step:"0.01",placeholder:"Service cost",value:n.cost,onChange:u=>S({...n,cost:u.target.value})})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"mechanic",children:"Mechanic/Shop"}),e.jsx(f,{id:"mechanic",placeholder:"Who performed the service",value:n.mechanic,onChange:u=>S({...n,mechanic:u.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"description",children:"Description/Notes"}),e.jsx(Ue,{id:"description",placeholder:"Additional details about the service",value:n.description,onChange:u=>S({...n,description:u.target.value})})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"nextServiceMileage",children:"Next Service Due (miles)"}),e.jsx(f,{id:"nextServiceMileage",type:"number",placeholder:"When is next service due",value:n.nextServiceMileage,onChange:u=>S({...n,nextServiceMileage:u.target.value})})]})]}),e.jsxs(i,{onClick:R,className:"w-full",children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Add Maintenance Record"]})]})]}),r.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(P,{className:"text-center p-4",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:r.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Records"})]}),e.jsxs(P,{className:"text-center p-4",children:[e.jsxs("div",{className:"text-2xl font-bold text-green-600",children:["$",T.toFixed(2)]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Spent"})]}),e.jsxs(P,{className:"text-center p-4",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:r.length>0?Math.max(...r.map(u=>u.mileage)).toLocaleString():0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Latest Mileage"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Maintenance History"}),r.length===0?e.jsx(P,{className:"p-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No maintenance records yet. Add your first record above."})}):r.map(u=>e.jsx(P,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 flex-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:u.serviceType}),e.jsx("div",{className:"text-sm text-muted-foreground",children:u.date})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold",children:[u.mileage.toLocaleStr
12ing()," miles"]}),u.nextServiceMileage&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Next: ",u.nextServiceMileage.toLocaleString()," miles"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold",children:["$",u.cost.toFixed(2)]}),u.mechanic&&e.jsx("div",{className:"text-sm text-muted-foreground",children:u.mechanic})]}),e.jsx("div",{children:u.description&&e.jsx("div",{className:"text-sm",children:u.description})})]}),e.jsx(i,{variant:"destructive",size:"sm",onClick:()=>C(u.id),children:e.jsx(Q,{className:"w-4 h-4"})})]})},u.id))]})]})]})}function us(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(null),u=()=>{const b=r.split(",").map(a=>parseFloat(a.trim())).filter(a=>!isNaN(a));if(b.length===0)return;const v=b.reduce((a,s)=>a+s,0)/b.length,l=[...b].sort((a,s)=>a-s),F=l.length%2===0?(l[l.length/2-1]+l[l.length/2])/2:l[Math.floor(l.length/2)],t={};b.forEach(a=>t[a]=(t[a]||0)+1);const o=Math.max(...Object.values(t)),c=Object.keys(t).filter(a=>t[Number(a)]===o).map(Number),m=b.reduce((a,s)=>a+Math.pow(s-v,2),0)/b.length,p=Math.sqrt(m);T({mean:v.toFixed(2),median:F.toFixed(2),mode:c.join(", "),standardDeviation:p.toFixed(2),variance:m.toFixed(2),count:b.length,min:Math.min(...b),max:Math.max(...b)})},j=()=>{const b=parseInt(n),v=parseInt(d);if(b>0&&v>=0&&v<=b){const l=o=>o<=1?1:o*l(o-1),F=l(b)/(l(v)*l(b-v)),t=l(b)/l(b-v);T({combinations:F.toLocaleString(),permutations:t.toLocaleString(),probability:`1 in ${F.toLocaleString()}`})}},x=()=>{C&&se({title:"Probability & Statistics Calculator Results",module:"Probability",data:{"Input Data":r||`n=${n}, r=${d}`,"Calculation Type":r?"Statistical Analysis":"Combinations/Permutations"},calculations:C,recommendations:["Statistical analysis helps understand data distribution and trends","Use combinations for selection problems where order doesn't matter","Use permutations for arrangement problems where order matters","Standard deviation indicates how spread out your data is"]})};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(L,{children:"Probability & Statistics Calculator"}),C&&e.jsxs(i,{onClick:x,variant:"outline",size:"sm",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),"Export PDF"]})]})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"statistics",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-2",children:[e.jsx($,{value:"statistics",children:"Statistics"}),e.jsx($,{value:"combinations",children:"Combinations"})]}),e.jsxs(M,{value:"statistics",className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"data",children:"Data (comma-separated numbers)"}),e.jsx(f,{id:"data",value:r,onChange:b=>k(b.target.value),placeholder:"1, 2, 3, 4, 5, 6, 7, 8, 9, 10"})]}),e.jsx(i,{onClick:u,className:"w-full",children:"Calculate Statistics"})]}),e.jsxs(M,{value:"combinations",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"n",children:"Total Items (n)"}),e.jsx(f,{id:"n",type:"number",value:n,onChange:b=>S(b.target.value),placeholder:"10"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"r",children:"Items to Choose (r)"}),e.jsx(f,{id:"r",type:"number",value:d,onChange:b=>R(b.target.value),placeholder:"3"})]})]}),e.jsx(i,{onClick:j,className:"w-full",children:"Calculate Combinations & Permutations"})]}),C&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Results"})}),e.jsx(E,{className:"space-y-2",children:Object.entries(C).map(([b,v])=>e.jsxs("div",{className:"flex justify-between p-2 bg-background rounded",children:[e.jsxs("span",{className:"font-medium capitalize",children:[b.replace(/([A-Z])/g," $1"),":"]}),e.jsx("span",{className:"text-muted-foreground",children:String(v)})]},b))})]})]})})]})}function ms(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState(null),v=()=>
12{const o=parseFloat(r),c=parseFloat(n)/100,m=parseFloat(d),p=parseFloat(u)||0;if(o&&c&&m){const a=o*c*m,s=o+a+p;b({principal:J(o),interestRate:`${n}%`,timeYears:`${m} years`,fees:J(p),interestEarned:J(a),totalAmount:J(s)})}},l=()=>{const o=parseFloat(r),c=parseFloat(n)/100,m=parseFloat(d),p=parseFloat(u)||0;if(o&&c&&m){const a=o*Math.pow(1+c,m),s=a-o,y=a+p;b({principal:J(o),interestRate:`${n}%`,timeYears:`${m} years`,fees:J(p),compoundInterest:J(s),finalAmount:J(a),totalWithFees:J(y)})}},F=()=>{const o=parseFloat(r),c=parseFloat(n)/100/12,m=parseFloat(C),p=parseFloat(u)||0;if(o&&c&&m&&m>o*c){const a=Math.log(1+o*c/m)/Math.log(1+c),s=m*a,y=s-o;b({loanAmount:J(o),monthlyPayment:J(m),interestRate:`${parseFloat(n)}% APR`,fees:J(p),monthsToPayoff:Math.ceil(a),yearsToPayoff:(a/12).toFixed(1),totalPayments:J(s),totalInterest:J(y),totalCost:J(s+p)})}},t=()=>{x&&se({title:"Loan & Interest Calculator Results",module:"Loan",data:{"Principal Amount":r,"Interest Rate":`${n}%`,"Time Period":`${d} years`,"Monthly Payment":C||"N/A","Additional Fees":u||"$0"},calculations:x,recommendations:["Compare different loan terms to find the best option","Consider making extra payments to reduce total interest","Factor in all fees when comparing loan offers","Compound interest grows exponentially over time"]})};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(L,{children:"Loan & Interest Calculator"}),x&&e.jsxs(i,{onClick:t,variant:"outline",size:"sm",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),"Export PDF"]})]})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"simple",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-3",children:[e.jsx($,{value:"simple",children:"Simple Interest"}),e.jsx($,{value:"compound",children:"Compound Interest"}),e.jsx($,{value:"payoff",children:"Loan Payoff"})]}),e.jsxs(M,{value:"simple",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"principal",children:"Principal Amount ($)"}),e.jsx(f,{id:"principal",type:"number",value:r,onChange:o=>k(o.target.value),placeholder:"10000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"rate",children:"Interest Rate (%)"}),e.jsx(f,{id:"rate",type:"number",step:"0.01",value:n,onChange:o=>S(o.target.value),placeholder:"5.5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"time",children:"Time (years)"}),e.jsx(f,{id:"time",type:"number",step:"0.1",value:d,onChange:o=>R(o.target.value),placeholder:"5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fees",children:"Additional Fees ($)"}),e.jsx(f,{id:"fees",type:"number",value:u,onChange:o=>j(o.target.value),placeholder:"0"})]})]}),e.jsx(i,{onClick:v,className:"w-full",children:"Calculate Simple Interest"})]}),e.jsxs(M,{value:"compound",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"principal",children:"Principal Amount ($)"}),e.jsx(f,{id:"principal",type:"number",value:r,onChange:o=>k(o.target.value),placeholder:"10000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"rate",children:"Annual Interest Rate (%)"}),e.jsx(f,{id:"rate",type:"number",step:"0.01",value:n,onChange:o=>S(o.target.value),placeholder:"5.5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"time",children:"Time (years)"}),e.jsx(f,{id:"time",type:"number",step:"0.1",value:d,onChange:o=>R(o.target.value),placeholder:"5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fees",children:"Additional Fees ($)"}),e.jsx(f,{id:"fees",type:"number",value:u,onChange:o=>j(o.target.value),placeholder:"0"})]})]}),e.jsx(i,{onClick:l,className:"w-full",children:"Calculate Compound Interest"})]}),e.jsxs(M,{value:"payoff",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"principal",children:"Loan Amount ($)"}),e.jsx(f,{id:"principal",type:"number",value:r,onChange:o=>k(o.target.value),placeholder:"250000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"rate",children:"Annual Interest Rate (%)"}),e.jsx(f,{id:"rate",type:"number",step:"0.01",value:n,onChange:o=>S(o.target.value),placeholder:"4.5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"monthlyPayment",children:"Monthly Payment ($)"}),e.jsx(f,{id:"monthlyPayment",type:"number",value:C,onChange:o=>T(o.target.value),placeholder:"1500"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fees",children:"Loan Fees ($)"}),e.jsx(f,{id:"fees",type:"number",value:u,onChange:o=>j(o.target.value),placeholder:"2500"})]})]}),e.jsx(i,{onClick:F,className:"w-full",children:"Calculate Loan Payoff Schedule"})]}),x&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Calculation Results"})}),e.jsx(E,{className:"space-y-2",children:Object.entries(x).map(([o,c])=>e.jsxs("div",{className:"flex justify-between p-2 bg-background rounded",children:[e.jsxs("span",{className:"font-medium capitalize",children:[o.replace(/([A-Z])/g," $1"),":"]}),e.jsx("span",{className:"text-muted-foreground font-bold",children:String(c)})]},o))})]})]})})]})}function hs(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState("");N.useState("");const[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState(null),v=()=>{const c=parseFloat(r),m=parseFloat(n);if(c&&m){const p=c/m;b({mass:`${c} g`,molarMass:`${m} g/mol`,moles:`${p.toFixed(4)} mol`,avogadroNumber:"6.022 × 10²³",numberOfMolecules:`${(p*6022e20).toExponential(2)} molecules`})}},l=()=>{const c=parseFloat(r)/parseFloat(n),m=parseFloat(d);if(c&&m){const p=c/m;b({moles:`${c.toFixed(4)} mol`,volume:`${m} L`,molarity:`${p.toFixed(3)} M`,concentration:`${p.toFixed(3)} mol/L`,millimolar:`${(p*1e3).toFixed(1)} mM`})}},F=()=>{const c=parseFloat(r),m=parseFloat(d);if(c&&m){const p=c/m;b({mass:`${c} g`,volume:`${m} mL`,density:`${p.toFixed(3)} g/mL`,densityKgM3:`${(p*1e3).toFixed(1)} kg/m³`,specificGravity:p.toFixed(3)})}},t=()=>{const c=parseFloat(u);if(!isNaN(c)){const m=c,p=c*9/5+32,a=c+273.15,s=p+459.67;b({celsius:`${m}°C`,fahrenheit:`${p.toFixed(1)}°F`,kelvin:`${a.toFixed(1)} K`,rankine:`${s.toFixed(1)}°R`,absoluteZero:"-273.15°C = 0 K"})}},o=()=>{x&&se({title:"Science & Chemistry Calculator Results",module:"Science",data:{Mass:r?`${r} g`:"N/A","Molar Mass":n?`${n} g/mol`:"N/A",Volume:d?`${d} L/mL`:"N/A",Temperature:u?`${u}°C`:"N/A",Concentration:C||"N/A"},calculations:x,recommendations:["Always use proper units when performing calculations","Double-check molecular formulas for accurate molar mass","Temperature conversions are essential for gas law calculations","Molarity is temperature-dependent, consider experimental conditions"]})};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(L,{children:"Science & Chemistry Calculator"}),x&&e.jsxs(i,{onClick:o,variant:"outline",size:"sm",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),"Export PDF"]})]})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"moles",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4",children:[e.jsx($,{value:"moles",children:"Moles"}),e.jsx($,{value:"molarity",children:"Molarity"}),e.jsx($,{value:"density",children:"Density"}),e.jsx($,{value:"temperature",children:"Temperature"})]}),e.jsxs(M,{value:"moles",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"mass",children:"Mass (g)"}),e.jsx(f,{id:"mass",type:"number",step:"0.01",value:r,onChange:c=>k(c.target.value),placeholder:"18.0"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"molarMass",children:"Molar Mass (g/mol)"}),e.jsx(f,{id:"molarMass",type:"number",step:"0.01",value:n,onChange:c=>S(c.target.value),placeholder:"18.015"})]})]}),e.jsx(i,{onClick:v,className:"w-full",children:"Calculate Moles & Molecules"})]}),e.jsxs(M,{value:"molarity",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"mass",children:"Mass (g)"}),e.jsx(f,{id:"mass",type:"number",step:"0.01",value:r,onChange:c=>k(c.target.value),placeholder:"5.85"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"molarMass",children:"Molar Mass (g/mol)"}),e.jsx(f,{id:"molarMass",type:"number",step:"0.01",value:n,onChange:c=>S(c.target.value),placeholder:"58.44"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"volume",children:"Volume (L)"}),e.jsx(f,{id:"volume",type:"number",step:"0.001",value:d,onChange:c=>R(c.target.value),placeholder:"0.1"})]})]}),e.jsx(i,{onClick:l,className:"w-full",children:"Calculate Molarity & Concentration"})]}),e.jsxs(M,{value:"density",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"mass",children:"Mass (g)"}),e.jsx(f,{id:"mass",type:"number",step:"0.01",value:r,onChange:c=>k(c.target.value),placeholder:"100"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"volume",children:"Volume (mL)"}),e.jsx(f,{id:"volume",type:"number",step:"0.01",value:d,onChange:c=>R(c.target.value),placeholder:"100"})]})]}),e.jsx(i,{onClick:F,className:"w-full",children:"Calculate Density & Specific Gravity"})]}),e.jsxs(M,{value:"temperature",className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"temperature",children:"Temperature (°C)"}),e.jsx(f,{id:"temperature",type:"number",step:"0.1",value:u,onChange:c=>j(c.target.value),placeholder:"25"})]}),e.jsx(i,{onClick:t,className:"w-full",children:"Convert Temperature Units"})]}),x&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Scientific Re
12sults"})}),e.jsx(E,{className:"space-y-2",children:Object.entries(x).map(([c,m])=>e.jsxs("div",{className:"flex justify-between p-2 bg-background rounded",children:[e.jsxs("span",{className:"font-medium capitalize",children:[c.replace(/([A-Z])/g," $1"),":"]}),e.jsx("span",{className:"text-muted-foreground font-mono",children:String(m)})]},c))})]})]})})]})}function xs(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState(""),[v,l]=N.useState(null),F=()=>{const m=parseFloat(r),p=parseFloat(n)/100;if(m&&p){const a=m/(p*p);let s="";a<18.5?s="Underweight":a<25?s="Normal weight":a<30?s="Overweight":s="Obese",l({weight:`${m} kg`,height:`${n} cm`,bmi:a.toFixed(1),category:s,healthyRange:"18.5 - 24.9"})}},t=()=>{const m=parseFloat(r),p=parseFloat(n),a=parseFloat(d);if(m&&p&&a&&C){let s;C==="male"?s=10*m+6.25*p-5*a+5:s=10*m+6.25*p-5*a-161;const w={sedentary:1.2,light:1.375,moderate:1.55,active:1.725,very_active:1.9}[u]||1.2,g=s*w;l({weight:`${m} kg`,height:`${p} cm`,age:`${a} years`,gender:C.charAt(0).toUpperCase()+C.slice(1),activityLevel:u==null?void 0:u.replace("_"," ").toUpperCase(),bmr:`${Math.round(s)} calories/day`,tdee:`${Math.round(g)} calories/day`,weightLoss:`${Math.round(g-500)} calories/day (-0.5kg/week)`,weightGain:`${Math.round(g+500)} calories/day (+0.5kg/week)`})}},o=()=>{const m=parseFloat(r),p=parseFloat(x);if(m){const a=m*35,s=a/240,y=a/1e3;let w="";p&&(p>=a*.9?w="Excellent hydration!":p>=a*.7?w="Good hydration":w="Need more water"),l({bodyWeight:`${m} kg`,recommendedDaily:`${Math.round(a)} ml`,recommendedLiters:`${y.toFixed(1)} L`,recommendedCups:`${Math.round(s)} cups (8oz)`,currentIntake:p?`${p} ml`:"Not specified",hydrationStatus:w||"Track your intake",tip:"Drink water throughout the day, not all at once"})}},c=()=>{v&&se({title:"Health & Nutrition Calculator Results",module:"Health",data:{Weight:r?`${r} kg`:"N/A",Height:n?`${n} cm`:"N/A",Age:d?`${d} years`:"N/A",Gender:C||"N/A","Activity Level":(u==null?void 0:u.replace("_"," "))||"N/A","Water Intake":x?`${x} ml`:"N/A"},calculations:v,recommendations:["Consult healthcare professionals for personalized advice","BMI is a general indicator, not suitable for athletes or elderly","Maintain consistent hydration throughout the day","Caloric needs may vary based on individual factors"]})};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(L,{children:"Health & Nutrition Calculator"}),v&&e.jsxs(i,{onClick:c,variant:"outline",size:"sm",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),"Export PDF"]})]})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"bmi",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-3",children:[e.jsx($,{value:"bmi",children:"BMI"}),e.jsx($,{value:"bmr",children:"BMR/TDEE"}),e.jsx($,{value:"water",children:"Hydration"})]}),e.jsxs(M,{value:"bmi",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"weight",children:"Weight (kg)"}),e.jsx(f,{id:"weight",type:"number",step:"0.1",value:r,onChange:m=>k(m.target.value),placeholder:"70"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"height",children:"Height (cm)"}),e.jsx(f,{id:"height",type:"number",value:n,onChange:m=>S(m.target.value),placeholder:"175"})]})]}),e.jsx(i,{onClick:F,className:"w-full",children:"Calculate BMI"})]}),e.jsxs(M,{value:"bmr",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"weight",children:"Weight (kg)"}),e.jsx(f,{id:"weight",type:"number",step:"0.1",value:r,onChange:m=>k(m.target.value),placeholder:"70"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"height",children:"Height (cm)"}),e.jsx(f,{id:"height",type:"number",value:n,onChange:m=>S(m.target.value),placeholder:"175"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"age",children:"Age (years)"}),e.jsx(f,{id:"age",type:"number",value:d,onChange:m=>R(m.target.value),placeholder:"30"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"gender",children:"Gender"}),e.jsxs(B,{value:C,onValueChange:T,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select gender"})}),e.jsxs(G,{children:[e.jsx(z,{value:"male",children:"Male"}),e.jsx(z,{value:"female",children:"Female"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"activity",children:"Activity Level"}),e.jsxs(B,{value:u,onValueChange:j,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select activity level"})}),e.jsxs(G,{children:[e.jsx(z,{value:"sedentary",children:"Sedentary (little/no exercise)"}),e.jsx(z,{value:"light",children:"Light (light exercise 1-3 days/week)"}),e.jsx(z,{value:"moderate",children:"Moderate (moderate exercise 3-5 days/week)"}),e.jsx(z,{value:"active",children:"Active (hard exercise 6-7 days/week)"}),e.jsx(z,{value:"very_active",children:"Very Active (very hard exercise, physical job)"})]})]})]}),e.jsx(i,{onClick:t,className:"w-full",children:"Calculate BMR & TDEE"})]}),e.jsxs(M,{value:"water",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"weight",children:"Weight (kg)"}),e.jsx(f,{id:"weight",type:"number",step:"0.1",value:r,onChange:m=>k(m.target.value),placeholder:"70"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"waterIntake",children:"Current Daily Intake (ml)"}),e.jsx(f,{id:"waterIntake",type:"number",value:x,onChange:m=>b(m.target.value),placeholder:"2000"})]})]}),e.jsx(i,{onClick:o,className:"w-full",children:"Calculate Hydration Needs"})]}),v&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Health Results"})}),e.jsx(E,{className:"space-y-2",children:Object.entries(v).map(([m,p])=>e.jsxs("div",{className:"flex justify-between p-2 bg-background rounded",children:[e.jsxs("span",{className:"font-medium capitalize",children:[m.replace(/([A-Z])/g," $1"),":"]}),e.jsx("span",{className:"text-muted-foreground",children:String(p)})]},m))})]})]})})]})}function ps(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState(null),v=()=>{try{const c=r.replace(/[^0-9+\-*/().x\s]/g,"");if(c.includes("x"))c.split("=").length===2&&b({equation:r,type:"Linear Equation",solution:"Use a dedicated math solver for complex equations",steps:["Parse the equation","Isolate variables","Solve for x","Verify solution"]});else{const m=Function(`"use strict"; return (${c})`)();b({expression:r,result:m.toString(),type:"Expression Evaluation"})}}catch{b({equation:r,error:"Invalid equation format",suggestion:"Please enter a valid mathematical expression"})}},l=()=>{const c=parseInt(n)||1,m=parseInt(d)||100;if(c>m){b({error:"Minimum cannot be greater than maximum",range:`${c} - ${m}`});return}const p=Array.from({length:10},()=>Math.floor(Math.random()*(m-c+1))+c);b({range:`${c} - ${m}`,singleRandom:p[0],tenRandomNumbers:p.join(", "),mean:(p.reduce((a,s)=>a+s,0)/p.length).toFixed(2),min:Math.min(...p),max:Math.max(...p)})},F=()=>{const c=parseInt(C)||1,m=parseInt(u)||6;if(c>100||m>100){b({error:"Maximum 100 dice with 100 sides each",suggestion:"Use reasonable values for dice simulation"});return}const p=Array.from({length:c},()=>Math.floor(Math.random()*m)+1),a=p.reduce((g,A)=>g+A,0),s=a/c,y=c,w=c*m;b({diceConfiguration:`${c}d${m}`,individualRolls:p.join(", "),totalSum:a,average:s.toFixed(2),minimumPossible:y,maximumPossible:w,probability:`${(1/Math.pow(m,c)*100).toFixed(4)}% for any specific combination`})},t=()=>{const c=Array.from({length:20},()=>Math.random()<.5?"Heads":"Tails"),m=c.filter(a=>a==="Heads").length,p=c.length-m;
12b({totalFlips:c.length,results:c.join(", "),headsCount:m,tailsCount:p,headsPercentage:`${(m/c.length*100).toFixed(1)}%`,tailsPercentage:`${(p/c.length*100).toFixed(1)}%`,expectedProbability:"50% each for fair coin"})},o=()=>{x&&se({title:"Random Math Tools Results",module:"RandomMath",data:{Equation:r||"N/A","Number Range":`${n||1} - ${d||100}`,"Dice Configuration":`${C||1}d${u||6}`,"Generated At":new Date().toLocaleString()},calculations:x,recommendations:["Random numbers are pseudorandom for computational purposes","Use appropriate ranges for your specific needs","Dice probabilities assume fair dice","Statistical outcomes approach theoretical probabilities with larger samples"]})};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(L,{children:"Random Math Tools"}),x&&e.jsxs(i,{onClick:o,variant:"outline",size:"sm",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),"Export PDF"]})]})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"equation",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-4",children:[e.jsx($,{value:"equation",children:"Equation Solver"}),e.jsx($,{value:"random",children:"Random Numbers"}),e.jsx($,{value:"dice",children:"Dice Roller"}),e.jsx($,{value:"coins",children:"Coin Flip"})]}),e.jsxs(M,{value:"equation",className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"equation",children:"Mathematical Expression"}),e.jsx(f,{id:"equation",value:r,onChange:c=>k(c.target.value),placeholder:"2 + 3 * 4 or 2x + 5 = 11"})]}),e.jsx(i,{onClick:v,className:"w-full",children:"Solve Equation"})]}),e.jsxs(M,{value:"random",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"minRange",children:"Minimum Value"}),e.jsx(f,{id:"minRange",type:"number",value:n,onChange:c=>S(c.target.value),placeholder:"1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"maxRange",children:"Maximum Value"}),e.jsx(f,{id:"maxRange",type:"number",value:d,onChange:c=>R(c.target.value),placeholder:"100"})]})]}),e.jsx(i,{onClick:l,className:"w-full",children:"Generate Random Numbers"})]}),e.jsxs(M,{value:"dice",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"diceCount",children:"Number of Dice"}),e.jsx(f,{id:"diceCount",type:"number",value:C,onChange:c=>T(c.target.value),placeholder:"2"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"diceSides",children:"Sides per Die"}),e.jsx(f,{id:"diceSides",type:"number",value:u,onChange:c=>j(c.target.value),placeholder:"6"})]})]}),e.jsxs(i,{onClick:F,className:"w-full",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Roll Dice"]})]}),e.jsx(M,{value:"coins",className:"space-y-4",children:e.jsxs("div",{className:"text-center p-4 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Simulate 20 coin flips and analyze the results"}),e.jsxs(i,{onClick:t,className:"w-full",children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),"Flip 20 Coins"]})]})}),x&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Results"})}),e.jsx(E,{className:"space-y-2",children:Object.entries(x).map(([c,m])=>e.jsxs("div",{className:"flex justify-between p-2 bg-background rounded",children:[e.jsxs("span",{className:"font-medium capitalize",children:[c.replace(/([A-Z])/g," $1"),":"]}),e.jsx("span",{className:"text-muted-foreground",children:String(m)})]},c))})]})]})})]})}function js(){const[r,k]=N.useState(""),[n,S]=N.useState(""),[d,R]=N.useState(""),[C,T]=N.useState(""),[u,j]=N.useState(""),[x,b]=N.useState(""),[v,l]=N.useState(null),F=[{value:"mm",label:"Millimeters"},{value:"cm",label:"Centimeters"},{value:"m",label:"Meters"},{value:"km",label:"Kilometers"},{value:"in",label:"Inches"},{value:"ft",label:"Feet"},{value:"yd",label:"Yards"},{value:"mi",label:"Miles"}],t=[{value:"mg",label:"Milligrams"},{value:"g",label:"Grams"},{value:"kg",label:"Kilograms"},{value:"oz",label:"Ounces"},{value:"lb",label:"Pounds"},{value:"ton",label:"Tons"}],o=[{value:"ml",label:"Milliliters"},{value:"l",label:"Liters"},{value:"fl_oz",label:"Fluid Ounces"},{value:"cup",label:"Cups"},{value:"pint",label:"Pints"},{value:"qt",label:"Quarts"},{value:"gal",label:"Gallons"}],c=[{value:"c",label:"Celsius"},{value:"f",label:"Fahrenheit"},{value:"k",label:"Kelvin"}],m=()=>{const g=parseFloat(r);if(!g||!n||!d)return;const A={mm:.001,cm:.01,m:1,km:1e3,in:.0254,ft:.3048,yd:.9144,mi:1609.34},V=g*A[n],I=V/A[d];l({originalValue:`${g} ${n}`,convertedValue:`${I.toFixed(6)} ${d}`,inMeters:`${V.toFixed(6)} m`,conversionFactor:`1 ${n} = ${A[n]} meters`})},p=()=>{const g=parseFloat(r);if(!g||!n||!d)return;const A={mg:.001,g:1,kg:1e3,oz:28.3495,lb:453.592,ton:1e6},V=g*A[n],I=V/A[d];l({originalValue:`${g} ${n}`,convertedValue:`${I.toFixed(6)} ${d}`,inGrams:`${V.toFixed(3)} g`,inKilograms:`${(V/1e3).toFixed(6)} kg`})},a=()=>{const g=parseFloat(r);if(!g||!n||!d)return;const A={ml:1,l:1e3,fl_oz:29.5735,cup:236.588,pint:473.176,qt:946.353,gal:3785.41},V=g*A[n],I=V/A[d];l({originalValue:`${g} ${n}`,convertedValue:`${I.toFixed(6)} ${d}`,inMilliliters:`${V.toFixed(3)} ml`,inLiters:`${(V/1e3).toFixed(6)} L`})},s=()=>{const g=parseFloat(r);if(!g||!n||!d)return;let A;switch(n){case"c":A=g;break;case"f":A=(g-32)*5/9;break;case"k":A=g-273.15;break;default:return}let V;switch(d){case"c":V=A;break;case"f":V=A*9/5+32;break;case"k":V=A+273.15;break;default:return}l({originalValue:`${g}°${n.toUpperCase()}`,convertedValue:`${V.toFixed(2)}°${d.toUpperCase()}`,celsius:`${A.toFixed(2)}°C`,fahrenheit:`${(A*9/5+32).toFixed(2)}°F`,kelvin:`${(A+273.15).toFixed(2)}K`})},y=()=>{const g=parseFloat(C),A=parseFloat(u),V=parseFloat(x);if(g&&A&&V){const I=V/A,D=g*I;l({originalRecipe:`${g} (serves ${A})`,scaledRecipe:`${D.toFixed(3)} (serves ${V})`,scaleFactor:`${I.toFixed(3)}x`,percentage:`${(I*100).toFixed(1)}%`,direction:I>1?"Scaling Up":I<1?"Scaling Down":"Same Size"})}},w=()=>{v&&se({title:"Unit Conversion Results",module:"Conversions",data:{"Original Value":r,"From Unit":n,"To Unit":d,"Recipe Value":C||"N/A","Original Servings":u||"N/A","New Servings":x||"N/A"},calculations:v,recommendations:["Always double-check conversions for critical applications","Recipe scaling may require adjustments for seasonings and leavening agents","Temperature conversions are exact, use appropriate precision","Consider rounding to practical values for cooking and construction"]})};return e.jsxs(P,{className:"w-full max-w-4xl mx-auto",children:[e.jsx(U,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(L,{children:"Advanced Unit Conversions"}),v&&e.jsxs(i,{onClick:w,variant:"outline",size:"sm",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),"Export PDF"]})]})}),e.jsx(E,{children:e.jsxs(Y,{defaultValue:"length",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-5",children:[e.jsx($,{value:"length",children:"Length"}),e.jsx($,{value:"weight",children:"Weight"}),e.jsx($,{value:"volume",children:"Volume"}),e.jsx($,{value:"temperature",children:"Temperature"}),e.jsx($,{value:"recipe",children:"Recipe"})]}),e.jsxs(M,{value:"length",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"value",children:"Value"}),e.jsx(f,{id:"value",type:"number",step:"0.001",value:r,onChange:g=>k(g.target.value),placeholder:"100"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fromUnit",children:"From"}),e.jsxs(B,{value:n,onValueChange:S,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:F.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"toUnit",children:"To"}),e.jsxs(B,{value:d,onValueChange:R,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:F.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]})]}),e.jsx(i,{onClick:m,className:"w-full",children:"Convert Length"})]}),e.jsxs(M,{value:"weight",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"value",children:"Value"}),e.jsx(f,{id:"value",type:"number",step:"0.001",value:r,onChange:g=>k(g.target.value),placeholder:"1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fromUnit",children:"From"}),e.jsxs(B,{value:n,onValueChange:S,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:t.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"toUnit",children:"To"}),e.jsxs(B,{value:d,onValueChange:R,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:t.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]})]}),e.jsx(i,{onClick:p,className:"w-full",children:"Convert Weight"})]}),e.jsxs(M,{value:"volume",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"value",children:"Value"}),e.jsx(f,{id:"value",type:"number",step:"0.001",value:r,onChange:g=>k(g.target.value),placeholder:"1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fromUnit",children:"From"}),e.jsxs(B,{value:n,onValueChange:S,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:o.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"toUnit",children:"To"}),e.jsxs(B,{value:d,onValueChange:R,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:o.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]})]}),e.jsx(i,{onClick:a,className:"w-full",children:"Convert Volume"})]}),e.jsxs(M,{value:"temperature",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"value",children:"Value"}),e.jsx(f,{id:"value",type:"number",step:"0.1",value:r,onChange:g=>k(g.target.value),placeholder:"25"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"fromUnit",children:"From"}),e.jsxs(B,{value:n,onValueChange:S,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:c.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"toUnit",children:"To"}),e.jsxs(B,{value:d,onValueChange:R,children:[e.jsx(O,{children:e.jsx(H,{placeholder:"Select unit"})}),e.jsx(G,{children:c.map(g=>e.jsx(z,{value:g.value,children:g.label},g.value))})]})]})]}),e.jsx(i,{onClick:s,className:"w-full",children:"Convert Temperature"})]}),e.jsxs(M,{value:"recipe",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"recipeValue",children:"Ingredient Amount"}),e.jsx(f,{id:"recipeValue",type:"number",step:"0.01",value:C,onChange:g=>T(g.target.value),placeholder:"2.5"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"servings",children:"Current Servings"}),e.jsx(f,{id:"servings",type:"number",value:u,onChange:g=>j(g.target.value),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"newServings",children:"Desired Servings"}),e.jsx(f,{id:"newServings",type:"number",value:x,onChange:g=>b(g.target.value),placeholder:"8"})]})]}),e.jsx(i,{onClick:y,className:"w-full",children:"Scale Recipe"})]}),v&&e.jsxs(P,{className:"mt-6 bg-muted/50",children:[e.jsx(U,{children:e.jsx(L,{className:"text-lg",children:"Conversion Results"})}),e.jsx(E,{className:"space-y-2",children:Object.entries(v).map(([g,A])=>e.jsxs("div",{className:"flex justify-between p-2 bg-background rounded",children:[e.jsxs("span",{className:"font-medium capitalize",children:[g.replace(/([A-Z])/g," $1"),":"]}),e.jsx("span",{className:"text-muted-foreground font-mono",children:String(A)})]},g))})]})]})})]})}function $s(){return N.useEffect(()=>
12{console.log("CalculatorPanel mounted successfully")},[]),e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"CriderGPT Calculator Suite"}),e.jsx("p",{className:"text-muted-foreground",children:"Professional calculators with PDF export for mathematics, engineering, science, health, and more"})]}),e.jsxs(Y,{defaultValue:"advanced",className:"w-full",children:[e.jsxs(K,{className:"grid w-full grid-cols-6 lg:grid-cols-12 text-xs",children:[e.jsx($,{value:"advanced",children:"Advanced"}),e.jsx($,{value:"welding",children:"Welding"}),e.jsx($,{value:"mechanics",children:"Mechanics"}),e.jsx($,{value:"farming",children:"Farming"}),e.jsx($,{value:"voltage",children:"Electrical"}),e.jsx($,{value:"maintenance",children:"Vehicle"}),e.jsx($,{value:"probability",children:"Probability"}),e.jsx($,{value:"loan",children:"Loan/Interest"}),e.jsx($,{value:"science",children:"Science"}),e.jsx($,{value:"health",children:"Health"}),e.jsx($,{value:"random",children:"Random Math"}),e.jsx($,{value:"conversion",children:"Conversions"})]}),e.jsx(M,{value:"advanced",className:"mt-6",children:e.jsx(ns,{})}),e.jsx(M,{value:"welding",className:"mt-6",children:e.jsx(rs,{})}),e.jsx(M,{value:"mechanics",className:"mt-6",children:e.jsx(is,{})}),e.jsx(M,{value:"farming",className:"mt-6",children:e.jsx(cs,{})}),e.jsx(M,{value:"voltage",className:"mt-6",children:e.jsx(os,{})}),e.jsx(M,{value:"maintenance",className:"mt-6",children:e.jsx(ds,{})}),e.jsx(M,{value:"probability",className:"mt-6",children:e.jsx(us,{})}),e.jsx(M,{value:"loan",className:"mt-6",children:e.jsx(ms,{})}),e.jsx(M,{value:"science",className:"mt-6",children:e.jsx(hs,{})}),e.jsx(M,{value:"health",className:"mt-6",children:e.jsx(xs,{})}),e.jsx(M,{value:"random",className:"mt-6",children:e.jsx(ps,{})}),e.jsx(M,{value:"conversion",className:"mt-6",children:e.jsx(js,{})})]})]})}export{$s as CalculatorPanel};

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.