PageSourceSearch

https://smartcalculators.ai/assets/EmbedPage-D3iLAt_C.js

js smartcalculators.ai collected 2026-10-05 14:30:43 UTC 81,174 bytes, 264 lines download raw bytes

1import{h as B,r as c,j as e,i as Pe,P as xe,k as ae,l as jt,m as wt,R as $,n as va,o as ya,I as ja,c as J,p as wa,b as A,q as Nt,s as Ct,t as _t,v as kt,w as Na,x as Ca,y as _a,F as ka,D as Pa,z as Sa,E as Ta,G as Ra,J as Ma,K as Ia,N as Aa,f as te,S as it,O as W,Q as We,U as Pt,V as St,W as Tt,X as ee,M as dt,Y as Ba,H as za,Z as Ea,_ as ut}from"./index-BxANg2aK.js";import{L as M}from"./label-suKr8x3S.js";import{I as se}from"./input-BqbQr4nY.js";import{S as Ve,a as Ge,b as Ue,c as De,d as pe}from"./select-Sg2y-KzG.js";import{T as me}from"./textarea-B4vX7hd2.js";import{S as $a}from"./PieChart-BaKll7Df.js";import{S as Ce}from"./switch-CvHgasFy.js";import{T as mt,a as pt,b as ie,c as de}from"./tabs-C613Q1Bj.js";import{D as He,a as qe,b as Ye,c as Ke,d as xt,e as ft}from"./dialog-Bqm_WM81.js";import{a5 as La,a6 as Fa,ac as Oa,P as Wa,O as Va,N as Ga,M as Ua,L as Da,K as Ha,q as qa,w as Ya,v as Ka,t as Ja,G as Za,E as Xa,D as Qa,C as es,F as ts,J as as,I as ss,H as rs,B as os,A as ls,z as ns,x as cs,y as is,p as ds,s as us,r as ms,k as ps,j as xs,i as fs,o as hs,n as gs,h as bs,g as vs,e as ys,d as js,m as ws,l as Ns,b as Cs,c as _s,a as ks,ad as Ps,U as Ss,T as Ts,V as Rs,a1 as Ms,a2 as Is,a0 as As,$ as Bs,_ as zs,Z as Es,Y as $s,X as Ls,W as Fs,R as Os,S as Ws,Q as Vs,ae as Fe}from"./ArmVsFixedCalculator-IE6u4msA.js";import{e as Je,W as Gs,E as Se,H as Us,F as we}from"./WidgetThemeWrapper-jzmmTIWx.js";import{A as Rt,a as V,b as G,c as U}from"./accordion-7bq_kn5X.js";import{L as Ds}from"./link-2-84YVMm2b.js";import{S as Hs,C as Ne}from"./search-Cbm58GPc.js";import{L as qs}from"./loader-circle-DaA_FtT6.js";import{T as Ys}from"./trash-2-rbwhPRcN.js";import{P as Ks}from"./palette-DcDuDSv0.js";import{T as Js}from"./triangle-alert-CFCeoNY9.js";import{S as Zs}from"./save-ClMyOynH.js";import{E as Xs}from"./eye-uEPgs6e6.js";import{C as Qs}from"./copy-B9myrYVy.js";import"./index-BdQq_4o_.js";import"./AreaChart-DgwGKUs9.js";import"./DisclaimerDialog-BnogISHM.js";import"./file-text-DTBUT6YO.js";import"./table-DgzTU4dR.js";import"./card-CUg6U1K8.js";import"./collapsible-49Zlg5fl.js";import"./index-CCcfoYKC.js";import"./dollar-sign-CzRlthLk.js";import"./shield-Cpi3_8QG.js";import"./CartesianGrid-BgOAv-4S.js";import"./zap-vHmDm3lu.js";import"./scale-DN5bpadt.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 er=B("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/**
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 tr=B("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const ht=B("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const ar=B("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/**
22 * @license lucide-react v0.462.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const sr=B("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",ke
26y:"1mlx9k"}]]);/**
27 * @license lucide-react v0.462.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const rr=B("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/**
32 * @license lucide-react v0.462.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const or=B("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
37 * @license lucide-react v0.462.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const lr=B("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
42 * @license lucide-react v0.462.0 - ISC
43 *
44 * This source code is licensed under the ISC license.
45 * See the LICENSE file in the root directory of this source tree.
46 */const nr=B("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
47 * @license lucide-react v0.462.0 - ISC
48 *
49 * This source code is licensed under the ISC license.
50 * See the LICENSE file in the root directory of this source tree.
51 */const cr=B("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
52 * @license lucide-react v0.462.0 - ISC
53 *
54 * This source code is licensed under the ISC license.
55 * See the LICENSE file in the root directory of this source tree.
56 */const Mt=B("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
57 * @license lucide-react v0.462.0 - ISC
58 *
59 * This source code is licensed under the ISC license.
60 * See the LICENSE file in the root directory of this source tree.
61 */const ir=B("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/**
62 * @license lucide-react v0.462.0 - ISC
63 *
64 * This source code is licensed under the ISC license.
65 * See the LICENSE file in the root directory of this source tree.
66 */const dr=B("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
67 * @license lucide-react v0.462.0 - ISC
68 *
69 * This source code is licensed under the ISC license.
70 * See the LICENSE file in the root directory of this source tree.
71 */const ur=B("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/**
72 * @license lucide-react v0.462.0 - ISC
73 *
74 * This source code is licensed under the ISC license.
75 * See the LICENSE file in the root directory of this source tree.
76 */const mr=B("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]),pr={"mortgage-payment":Wa,"home-affordability":Va,"refinance-calculator":Ga,"rent-vs-buy":Ua,"extra-payment-impact":Da,"arm-vs-fi
76xed":Ha,"loan-comparison":qa,"heloc-calculator":Ya,"heloc-vs-cashout":Ka,"debt-consolidation":Ja,"dividend-income":Za,"drip-growth":Xa,"expense-ratio-impact":Qa,"portfolio-income":es,"net-worth":ts,"savings-growth":as,"compound-interest-calculator":ss,"retirement-calculator":rs,"fire-number":os,"debt-payoff":ls,"personal-loan":ns,"etf-comparison":cs,"yield-vs-total-return":is,"tax-refund-calculator":ds,"bmi-calculator":us,"body-fat-calculator":ms,"calorie-calculator":ps,"macro-calculator":xs,"ideal-weight-calculator":fs,"percentage-calculator":hs,"fraction-calculator":gs,"scientific-calculator":bs,"random-number-generator":vs,"triangle-calculator":ys,"standard-deviation-calculator":js,"age-calculator":ws,"date-calculator":Ns,"solar-roi-calculator":Cs,"roof-replacement-cost-estimator":_s,"solar-vs-grid-cost":ks,"home-renovation-calculator":Ps},xr=["bmi-calculator","macro-calculator","refinance-calculator","cashout-refinance-calculator","rent-vs-buy","extra-payment-impact","mortgage-points-calculator","home-renovation-calculator","student-loan-refinance","student-loan-refinance-simple","student-loan-repayment","arm-vs-fixed","va-loan-calculator","mortgage-payment","mortgage-amortization-calculator","home-affordability"];function It({calculator:t,colorScheme:a,font:s,size:o,borderRadius:n,showBranding:d,ctaSettings:r,disclaimer:i}){const x=o==="compact"?"400px":o==="standard"?"600px":"100%",f=c.useMemo(()=>Je(a),[a]),v=t&&xr.includes(t.id),y=c.useMemo(()=>{if(!t)return{};const g={};return t.inputs.forEach(P=>{g[P.id]=P.defaultValue}),g},[t]),[k,I]=c.useState(y);c.useEffect(()=>{I(y)},[y]);const R=c.useMemo(()=>{if(!t||v)return null;const g=pr[t.id];if(!g)return null;try{return g(k)}catch(P){return console.error("Calculation error:",P),null}},[t,k,v]),O=(g,P)=>{I(q=>({...q,[g]:P}))},p=c.useMemo(()=>{if(!t||!R)return 0;const g=t.primaryMetric.id;return R[g]??0},[t,R]),j=c.useMemo(()=>!t||!R?[]:t.secondaryMetrics.map(g=>({metric:g,value:R[g.id]??0})).filter(g=>g.value!==void 0),[t,R]);if(!t)return e.jsx("div",{className:"flex items-center justify-center h-[400px] border-2 border-dashed rounded-xl",style:{borderColor:"hsl(var(--border))"},children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a calculator to preview"})});const S={colors:f,font:s,borderRadius:n},C=o==="compact"||o==="responsive",u=()=>{switch(t.id){case"bmi-calculator":return e.jsx(Vs,{isCompact:C});case"macro-calculator":return e.jsx(Ws,{isCompact:C});case"refinance-calculator":return e.jsx(Os,{isCompact:C});case"rent-vs-buy":return e.jsx(Fs,{isCompact:C,customDisclaimer:i!=null&&i.enabled?i.text:void 0});case"extra-payment-impact":return e.jsx(Ls,{isCompact:C});case"mortgage-points-calculator":return e.jsx($s,{isCompact:C});case"home-renovation-calculator":return e.jsx(Es,{isCompact:C});case"cashout-refinance-calculator":return e.jsx(zs,{isCompact:C});case"student-loan-refinance":return e.jsx(Bs,{isCompact:C});case"student-loan-refinance-simple":return e.jsx(As,{isCompact:C});case"arm-vs-fixed":return e.jsx(Is,{isCompact:C});case"student-loan-repayment":return e.jsx(Ms,{isCompact:C});case"va-loan-calculator":return e.jsx(Rs,{isCompact:C});case"mortgage-payment":return e.jsx(Ts,{isCompact:C});case"mortgage-amortization-calculator":return e.jsx(Ss,{isCompact:C});case"home-affordability":return e.jsx(Us,{isCompact:C});default:return null}},m=g=>{if(!g)return{};const P={};return g.split(";").forEach(q=>{const[oe,le]=q.split(":").map(Z=>Z.trim());if(oe&&le){const Z=oe.replace(/-([a-z])/g,ne=>ne[1].toUpperCase());P[Z]=le}}),P},N={small:"px-3 py-1.5 text-xs",default:"px-4 py-2 text-sm",large:"px-6 py-3 text-base"};return e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{style:{width:x,maxWidth:"100%"},children:e.jsx(Gs,{theme:S,children:e.jsxs("div",{className:"bg-background border border-border p-6",style:{borderRadius:`${n}px`},children:[v?u():e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2 text-foreground",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.question})]}),e.jsx("div",{className:"space-y-4 mb-6",children:t.inputs.map(g=>e.jsx(La,{input:g,value:k[g.id]??g.defaultValue,onChange:P=>O(g.id,P),categoryId:t.category.id},g.id))}),e.jsx(Fa,{primaryMetric:t.primaryMetric,primaryValue:p,secondaryMetrics:j})]}),(r==null?void 0:r.enabled)&&r.text&&r.url&&e.jsx("div",{className:"mt-4 pt-4 border-t border-border flex justify-center",children:e.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center justify-center gap-2 rounded-md font-medium transition-opacity hover:opacity-90 ${N[r.size]||N.default}`,style:{backgroundColor:r.bgColor,color:r.textColor,...m(r.customCss)},onClick:g=>g.preventDefault(),children:[r.text,e.jsx(Se,{className:"h-3 w-3"})]})}),t.id!=="rent-vs-buy"&&(i==null?void 0:i.enabled)&&i.text&&e.jsx("div",{className:"mt-4 pt-4 border-t border-border",children:e.jsx(Oa,{html:i.text,className:"text-xs text-muted-foreground leading-relaxed"})}),d&&e.jsx("div",{className:`${r!=null&&r.enabled?"mt-3":"mt-4 pt-4 border-t border-border"} text-center`,children:e.jsx("a",{href:"https://smartcalculators.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:underline",children:"Powered by SmartCalculators.ai →"})})]})})})})}function fr({calculator:t,colorScheme:a,font:s,borderRadius:o,showBranding:n,onClick:d,ctaSettings:r,disclaimer:i}){return e.jsxs("div",{className:"relative cursor-pointer group",onClick:d,children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/0 group-hover:bg-black/40 transition-colors rounded-xl",children:e.jsxs("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity flex flex-col items-center gap-2 text-white",children:[e.jsx(ar,{className:"h-8 w-8"}),e.jsx("span",{className:"text-sm font-medium",children:"Click to expand"})]})}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("div",{className:"w-[320px] relative",children:[e.jsxs("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 z-20 bg-primary text-primary-foreground text-xs px-2 py-0.5 rounded-full flex items-center gap-1",children:[e.jsx(Mt,{className:"h-3 w-3"}),"Mobile Preview"]}),e.jsxs("div",{className:"border-4 border-muted rounded-[24px] shadow-lg bg-muted/30 p-2 pt-4",children:[e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx("div",{className:"w-20 h-5 bg-muted rounded-full"})}),e.jsx("div",{className:"bg-background rounded-lg overflow-hidden overflow-y-auto",style:{maxHeight:"500px",width:"100%"},children:e.jsx("div",{className:"origin-top-left",style:{width:"375px",transform:"scale(0.76)",transformOrigin:"top left"},children:e.jsx(It,{calculator:t,colorScheme:a,font:s,size:"responsive",borderRadius:o,showBranding:n,ctaSettings:r,disclaimer:i})})}),e.jsx("div",{className:"flex justify-center mt-2",children:e.jsx("div",{className:"w-10 h-10 border-2 border-muted rounded-full"})})]})]})})]})}var At="Toggle",Ze=c.forwardRef((t,a)=>
76{const{pressed:s,defaultPressed:o,onPressedChange:n,...d}=t,[r,i]=Pe({prop:s,onChange:n,defaultProp:o??!1,caller:At});return e.jsx(xe.button,{type:"button","aria-pressed":r,"data-state":r?"on":"off","data-disabled":t.disabled?"":void 0,...d,ref:a,onClick:ae(t.onClick,()=>{t.disabled||i(!r)})})});Ze.displayName=At;var Bt=Ze,D="ToggleGroup",[zt,Mo]=jt(D,[wt]),Et=wt(),Xe=$.forwardRef((t,a)=>{const{type:s,...o}=t;if(s==="single"){const n=o;return e.jsx(hr,{...n,ref:a})}if(s==="multiple"){const n=o;return e.jsx(gr,{...n,ref:a})}throw new Error(`Missing prop \`type\` expected on \`${D}\``)});Xe.displayName=D;var[$t,Lt]=zt(D),hr=$.forwardRef((t,a)=>{const{value:s,defaultValue:o,onValueChange:n=()=>{},...d}=t,[r,i]=Pe({prop:s,defaultProp:o??"",onChange:n,caller:D});return e.jsx($t,{scope:t.__scopeToggleGroup,type:"single",value:$.useMemo(()=>r?[r]:[],[r]),onItemActivate:i,onItemDeactivate:$.useCallback(()=>i(""),[i]),children:e.jsx(Ft,{...d,ref:a})})}),gr=$.forwardRef((t,a)=>{const{value:s,defaultValue:o,onValueChange:n=()=>{},...d}=t,[r,i]=Pe({prop:s,defaultProp:o??[],onChange:n,caller:D}),x=$.useCallback(v=>i((y=[])=>[...y,v]),[i]),f=$.useCallback(v=>i((y=[])=>y.filter(k=>k!==v)),[i]);return e.jsx($t,{scope:t.__scopeToggleGroup,type:"multiple",value:r,onItemActivate:x,onItemDeactivate:f,children:e.jsx(Ft,{...d,ref:a})})});Xe.displayName=D;var[br,vr]=zt(D),Ft=$.forwardRef((t,a)=>{const{__scopeToggleGroup:s,disabled:o=!1,rovingFocus:n=!0,orientation:d,dir:r,loop:i=!0,...x}=t,f=Et(s),v=va(r),y={role:"group",dir:v,...x};return e.jsx(br,{scope:s,rovingFocus:n,disabled:o,children:n?e.jsx(ya,{asChild:!0,...f,orientation:d,dir:v,loop:i,children:e.jsx(xe.div,{...y,ref:a})}):e.jsx(xe.div,{...y,ref:a})})}),ke="ToggleGroupItem",Ot=$.forwardRef((t,a)=>{const s=Lt(ke,t.__scopeToggleGroup),o=vr(ke,t.__scopeToggleGroup),n=Et(t.__scopeToggleGroup),d=s.value.includes(t.value),r=o.disabled||t.disabled,i={...t,pressed:d,disabled:r},x=$.useRef(null);return o.rovingFocus?e.jsx(ja,{asChild:!0,...n,focusable:!r,active:d,ref:x,children:e.jsx(gt,{...i,ref:a})}):e.jsx(gt,{...i,ref:a})});Ot.displayName=ke;var gt=$.forwardRef((t,a)=>{const{__scopeToggleGroup:s,value:o,...n}=t,d=Lt(ke,s),r={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=d.type==="single"?r:void 0;
76return e.jsx(Ze,{...i,...n,ref:a,onPressedChange:x=>{x?d.onItemActivate(o):d.onItemDeactivate(o)}})}),Wt=Xe,Vt=Ot;const Gt=wa("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),yr=c.forwardRef(({className:t,variant:a,size:s,...o},n)=>e.jsx(Bt,{ref:n,className:J(Gt({variant:a,size:s,className:t})),...o}));yr.displayName=Bt.displayName;const Ut=c.createContext({size:"default",variant:"default"}),Dt=c.forwardRef(({className:t,variant:a,size:s,children:o,...n},d)=>e.jsx(Wt,{ref:d,className:J("flex items-center justify-center gap-1",t),...n,children:e.jsx(Ut.Provider,{value:{variant:a,size:s},children:o})}));Dt.displayName=Wt.displayName;const _e=c.forwardRef(({className:t,children:a,variant:s,size:o,...n},d)=>{const r=c.useContext(Ut);return e.jsx(Vt,{ref:d,className:J(Gt({variant:r.variant||s,size:r.size||o}),t),...n,children:a})});_e.displayName=Vt.displayName;const jr={mobile:{width:"375px",label:"Mobile"},tablet:{width:"768px",label:"Tablet"},desktop:{width:"100%",label:"Desktop"}};function wr({open:t,onOpenChange:a,calculator:s,colorScheme:o,font:n,borderRadius:d,showBranding:r,ctaSettings:i,disclaimer:x}){const[f,v]=c.useState("mobile");return e.jsx(He,{open:t,onOpenChange:a,children:e.jsxs(qe,{className:"max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(Ye,{className:"flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ke,{children:"Widget Preview"}),e.jsxs(Dt,{type:"single",value:f,onValueChange:y=>y&&v(y),className:"border rounded-lg p-1",children:[e.jsxs(_e,{value:"mobile","aria-label":"Mobile view",className:"gap-2 px-3",children:[e.jsx(Mt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Mobile"})]}),e.jsxs(_e,{value:"tablet","aria-label":"Tablet view",className:"gap-2 px-3",children:[e.jsx(ir,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Tablet"})]}),e.jsxs(_e,{value:"desktop","aria-label":"Desktop view",className:"gap-2 px-3",children:[e.jsx(nr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Desktop"})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-auto py-4",children:e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"transition-all duration-300 ease-out",style:{width:jr[f].width,maxWidth:"100%"},children:e.jsxs("div",{className:`${f!=="desktop"?"border-4 border-muted rounded-2xl shadow-xl bg-muted/20 p-2":""}`,children:[f!=="desktop"&&e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx("div",{className:"w-16 h-1 bg-muted rounded-full"})}),e.jsx("div",{className:f!=="desktop"?"bg-background rounded-lg overflow-hidden":"",children:e.jsx(It,{calculator:s,colorScheme:o,font:n,size:f==="mobile"?"compact":f==="tablet"?"standard":"full",borderRadius:d,showBranding:r,ctaSettings:i,disclaimer:x})}),f!=="desktop"&&e.jsx("div",{className:"flex justify-center mt-2",children:e.jsx("div",{className:"w-8 h-8 border-2 border-muted rounded-full"})})]})})})})]})})}function T({label:t,value:a,onChange:s}){return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-md border border-border cursor-pointer overflow-hidden flex-shrink-0",style:{backgroundColor:a},children:e.jsx("input",{type:"color",value:a,onChange:o=>s(o.target.value),className:"w-full h-full opacity-0 cursor-pointer"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:t}),e.jsx(se,{value:a,onChange:o=>s(o.target.value),className:"h-8 text-xs font-mono"})]})]})}function Nr({colors:t,onChange:a}){return e.jsxs(Rt,{type:"multiple",defaultValue:["general","buttons"],className:"w-full",children:[e.jsxs(V,{value:"general",children:[e.jsx(G,{className:"text-sm font-medium",children:"General Colors"}),e.jsxs(U,{className:"space-y-3 pt-2",children:[e.jsx(T,{label:"Backgroun
76d",value:t.background,onChange:s=>a("background",s)}),e.jsx(T,{label:"Card Background",value:t.cardBg,onChange:s=>a("cardBg",s)}),e.jsx(T,{label:"Text Color",value:t.text,onChange:s=>a("text",s)}),e.jsx(T,{label:"Muted Text",value:t.muted,onChange:s=>a("muted",s)}),e.jsx(T,{label:"Border Color",value:t.border,onChange:s=>a("border",s)})]})]}),e.jsxs(V,{value:"buttons",children:[e.jsx(G,{className:"text-sm font-medium",children:"Button & Accent Colors"}),e.jsxs(U,{className:"space-y-3 pt-2",children:[e.jsx(T,{label:"Primary / Button",value:t.primary,onChange:s=>a("primary",s)}),e.jsx(T,{label:"Button Text",value:t.primaryForeground,onChange:s=>a("primaryForeground",s)}),e.jsx(T,{label:"Accent Color",value:t.accent,onChange:s=>a("accent",s)})]})]}),e.jsxs(V,{value:"inputs",children:[e.jsx(G,{className:"text-sm font-medium",children:"Input Field Colors"}),e.jsxs(U,{className:"space-y-3 pt-2",children:[e.jsx(T,{label:"Input Background",value:t.inputBg,onChange:s=>a("inputBg",s)}),e.jsx(T,{label:"Input Border",value:t.inputBorder,onChange:s=>a("inputBorder",s)}),e.jsx(T,{label:"Input Text",value:t.inputText,onChange:s=>a("inputText",s)})]})]}),e.jsxs(V,{value:"results",children:[e.jsx(G,{className:"text-sm font-medium",children:"Results Card Colors"}),e.jsxs(U,{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:'Controls the summary/results panel (e.g. "Estimated Monthly Payment").'}),e.jsx(T,{label:"Results Background",value:t.resultsBg??t.cardBg,onChange:s=>a("resultsBg",s)}),e.jsx(T,{label:"Results Text",value:t.resultsText??t.text,onChange:s=>a("resultsText",s)}),e.jsx(T,{label:"Results Accent",value:t.resultsAccent??t.primary,onChange:s=>a("resultsAccent",s)})]})]}),e.jsxs(V,{value:"breakdown",children:[e.jsx(G,{className:"text-sm font-medium",children:"Payment Breakdown Colors"}),e.jsxs(U,{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:'Controls the donut chart segments in the "Estimated Monthly Payment" breakdown.'}),e.jsx(T,{label:"Principal & Interest",value:t.breakdownPI??"#3b82f6",onChange:s=>a("breakdownPI",s)}),e.jsx(T,{label:"Property Taxes",value:t.breakdownTaxes??"#eab308",onChange:s=>a("breakdownTaxes",s)}),e.jsx(T,{label:"Home Insurance",value:t.breakdownInsurance??"#10b981",onChange:s=>a("breakdownInsurance",s)}),e.jsx(T,{label:"PMI",value:t.breakdownPMI??"#ef4444",onChange:s=>a("breakdownPMI",s)}),e.jsx(T,{label:"HOA Fees",value:t.breakdownHOA??"#a855f7",onChange:s=>a("breakdownHOA",s)})]})]})]})}function bt({label:t,value:a,onChange:s}){return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-md border border-border cursor-pointer overflow-hidden flex-shrink-0",style:{backgroundColor:a},children:e.jsx("input",{type:"color",value:a,onChange:o=>s(o.target.value),className:"w-full h-full opacity-0 cursor-pointer"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:t}),e.jsx(se,{value:a,onChange:o=>s(o.target.value),className:"h-8 text-xs font-mono"})]})]})}function Cr({settings:t,onChange:a}){return e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Se,{className:"h-5 w-5 text-primary"}),"CTA Button"]}),e.jsx(Ce,{checked:t.enabled,onCheckedChange:s=>a("enabled",s)})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a call-to-action button that opens a link in a new tab."}),t.enabled&&e.jsxs(Rt,{type:"single",collapsible:!0,defaultValue:"content",className:"w-full",children:[e.jsxs(V,{value:"content",children:[e.jsx(G,{className:"text-sm font-medium",children:"Content"}),e.jsxs(U,{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Button Text"}),e.jsx(se,{value:t.text,onChange:s=>a("text",s.target.value),placeholder:"Learn More"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Link URL"}),e.jsx(se,{value:t.url,onChange:s=>a("url",s.target.value),placeholder:"https://example.com",type:"url"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opens in a new tab when clicked"})]})]})]}),e.jsxs(V,{value:"style",children:[e.jsx(G,{className:"text-sm font-medium",children:"Styling"}),e.jsxs(U,{className:"space-y-4 pt-2",children:[e.jsx(bt,{label:"Backgroun
76d Color",value:t.bgColor,onChange:s=>a("bgColor",s)}),e.jsx(bt,{label:"Text Color",value:t.textColor,onChange:s=>a("textColor",s)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Button Size"}),e.jsxs(Ve,{value:t.size,onValueChange:s=>a("size",s),children:[e.jsx(Ge,{children:e.jsx(Ue,{})}),e.jsxs(De,{children:[e.jsx(pe,{value:"small",children:"Small"}),e.jsx(pe,{value:"default",children:"Default"}),e.jsx(pe,{value:"large",children:"Large"})]})]})]})]})]}),e.jsxs(V,{value:"advanced",children:[e.jsx(G,{className:"text-sm font-medium",children:"Advanced (Custom CSS)"}),e.jsx(U,{className:"space-y-4 pt-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Custom CSS"}),e.jsx(me,{value:t.customCss,onChange:s=>a("customCss",s.target.value),placeholder:"border-radius: 50px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);",className:"font-mono text-xs h-20"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Additional inline styles for the button (CSS properties only)"})]})})]})]}),t.enabled&&t.text&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border",children:[e.jsx(M,{className:"text-xs text-muted-foreground mb-2 block",children:"Preview"}),e.jsx("div",{className:"flex justify-center p-4 bg-muted/30 rounded-lg",children:e.jsx(_r,{settings:t})})]})]})}function _r({settings:t}){const a={small:"px-3 py-1.5 text-xs",default:"px-4 py-2 text-sm",large:"px-6 py-3 text-base"},s=o=>{if(!o)return{};const n={};return o.split(";").forEach(d=>{const[r,i]=d.split(":").map(x=>x.trim());if(r&&i){const x=r.replace(/-([a-z])/g,f=>f[1].toUpperCase());n[x]=i}}),n};return e.jsxs("a",{href:t.url||"#",target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center justify-center gap-2 rounded-md font-medium transition-opacity hover:opacity-90 ${a[t.size]}`,style:{backgroundColor:t.bgColor,color:t.textColor,...s(t.customCss)},onClick:o=>o.preventDefault(),children:[t.text,e.jsx(Se,{className:"h-3 w-3"})]})}const kr=[{command:"bold",label:"Bold",icon:er},{command:"italic",label:"Italic",icon:rr},{command:"underline",label:"Underline",icon:ur},{command:"insertUnorderedList",label:"Bulleted list",icon:lr},{command:"insertOrderedList",label:"Numbered list",icon:or}];function Pr({value:t,onChange:a,placeholder:s}){const o=c.useRef(null);c.useEffect(()=>{const r=o.current;r&&document.activeElement!==r&&r.innerHTML!==t&&(r.innerHTML=Fe(t))},[t]);const n=(r,i)=>{var f;(f=o.current)==null||f.focus(),document.execCommand(r,!1,i);const x=o.current;x&&a(Fe(x.innerHTML))},d=()=>{const r=window.prompt("Enter a full link, including https://");r&&n("createLink",r)};return e.jsxs("div",{className:"overflow-hidden rounded-md border border-input bg-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-b border-border bg-muted/40 p-1.5",children:[kr.map(({command:r,label:i,icon:x})=>e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",title:i,"aria-label":i,onMouseDown:f=>f.preventDefault(),onClick:()=>n(r),children:e.jsx(x,{className:"h-4 w-4"})},r)),e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",title:"Add link","aria-label":"Add link",onMouseDown:r=>r.preventDefault(),onClick:d,children:e.jsx(Ds,{className:"h-4 w-4"})})]}),e.jsx("div",{ref:o,contentEditable:!0,role:"textbox","aria-multiline":"true","aria-label":"Disclaimer text","data-placeholder":s,className:"min-h-32 px-3 py-2 text-sm text-foreground outline-none empty:before:pointer-events-none empty:before:text-muted-foreground empty:before:content-[attr(data-placeholder)] [&_a]:text-primary [&_a]:underline [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5",onInput:r=>a(Fe(r.currentTarget.innerHTML)),suppressContentEditableWarning:!0})]})}const Q=[{id:"light",name:"Light",colors:{background:"#ffffff",text:"#1a1a1a",muted:"#737373",border:"#e5e5e5",primary:"#3b82f6",primaryForeground:"#ffffff",inputBg:"#fafafa",inputBorder:"#d4d4d4",inputText:"#1a1a1a",cardBg:"#f9fafb",accent:"#14b8a6"}},{id:"dark",name:"Dark",colors:{background:"#18181b",text:"#fafafa",muted:"#a1a1aa",border:"#3f3f46",primary:"#3b82f6",primaryForeground:"#ffffff",inputBg:"#27272a",inputBorder:"#52525b",inputText:"#fafafa",cardBg:"#27272a",accent:"#22d3ee"}},{id:"midnight",name:"Midnight Blue",colors:{background:"#0f172a",text:"#f8fafc",muted:"#94a3b8",border:"#334155",primary:"#6366f1",primaryForeground:"#ffffff",inputBg:"#1e293b",inputBorder:"#475569",inputText:"#f8fafc",cardBg:"#1e293b",accent:"#a85
765f7"}},{id:"ocean",name:"Ocean Blue",colors:{background:"#f0f9ff",text:"#0c4a6e",muted:"#0369a1",border:"#bae6fd",primary:"#0284c7",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#7dd3fc",inputText:"#0c4a6e",cardBg:"#e0f2fe",accent:"#06b6d4"}},{id:"forest",name:"Forest Green",colors:{background:"#f0fdf4",text:"#14532d",muted:"#15803d",border:"#bbf7d0",primary:"#16a34a",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#86efac",inputText:"#14532d",cardBg:"#dcfce7",accent:"#10b981"}},{id:"sunset",name:"Sunset Orange",colors:{background:"#fff7ed",text:"#7c2d12",muted:"#c2410c",border:"#fed7aa",primary:"#ea580c",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#fdba74",inputText:"#7c2d12",cardBg:"#ffedd5",accent:"#f59e0b"}},{id:"lavender",name:"Lavender Purple",colors:{background:"#faf5ff",text:"#3b0764",muted:"#7e22ce",border:"#e9d5ff",primary:"#9333ea",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#d8b4fe",inputText:"#3b0764",cardBg:"#f3e8ff",accent:"#ec4899"}},{id:"teal",name:"Teal Fresh",colors:{background:"#f0fdfa",text:"#134e4a",muted:"#0f766e",border:"#99f6e4",primary:"#14b8a6",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#5eead4",inputText:"#134e4a",cardBg:"#ccfbf1",accent:"#06b6d4"}},{id:"rose",name:"Rose Pink",colors:{background:"#fff1f2",text:"#881337",muted:"#be123c",border:"#fecdd3",primary:"#e11d48",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#fda4af",inputText:"#881337",cardBg:"#ffe4e6",accent:"#f472b6"}},{id:"charcoal",name:"Charcoal Pro",colors:{background:"#1c1c1e",text:"#ffffff",muted:"#8e8e93",border:"#3a3a3c",primary:"#ff9f0a",primaryForeground:"#1c1c1e",inputBg:"#2c2c2e",inputBorder:"#48484a",inputText:"#ffffff",cardBg:"#2c2c2e",accent:"#30d158"}},{id:"minimal",name:"Minimal Gray",colors:{background:"#fafafa",text:"#171717",muted:"#737373",border:"#e5e5e5",primary:"#404040",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#d4d4d4",inputText:"#171717",cardBg:"#f5f5f5",accent:"#525252"}},{id:"brand-blue",name:"Corporate Blue",colors:{background:"#f8fafc",text:"#1e293b",muted:"#64748b",border:"#cbd5e1",primary:"#2563eb",primaryForeground:"#ffffff",inputBg:"#ffffff",inputBorder:"#94a3b8",inputText:"#1e293b",cardBg:"#f1f5f9",accent:"#0ea5e9"}}];var Te="Popover",[Ht,Io]=jt(Te,[Nt]),fe=Nt(),[Sr,H]=Ht(Te),qt=t=>{const{__scopePopover:a,children:s,open:o,defaultOpen:n,onOpenChange:d,modal:r=!1}=t,i=fe(a),x=c.useRef(null),[f,v]=c.useState(!1),[y,k]=Pe({prop:o,defaultProp:n??!1,onChange:d,caller:Te});return e.jsx(Ra,{...i,children:e.jsx(Sr,{scope:a,contentId:Ma(),triggerRef:x,open:y,onOpenChange:k,onOpenToggle:c.useCallback(()=>k(I=>!I),[k]),hasCustomAnchor:f,onCustomAnchorAdd:c.useCallback(()=>v(!0),[]),onCustomAnchorRemove:c.useCallback(()=>v(!1),[]),modal:r,children:s})})};qt.displayName=Te;var Yt="PopoverAnchor",Tr=c.forwardRef((t,a)=>{const{__scopePopover:s,...o}=t,n=H(Yt,s),d=fe(s),{onCustomAnchorAdd:r,onCustomAnchorRemove:i}=n;return c.useEffect(()=>(r(),()=>i()),[r,i]),e.jsx(Ct,{...d,...o,ref:a})});Tr.displayName=Yt;var Kt="PopoverTrigger",Jt=c.forwardRef((t,a)=>{const{__scopePopover:s,...o}=t,n=H(Kt,s),d=fe(s),r=_t(a,n.triggerRef),i=e.jsx(xe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":ta(n.open),...o,ref:r,onClick:ae(t.onClick,n.onOpenToggle)});return n.hasCustomAnchor?i:e.jsx(Ct,{asChild:!0,...d,children:i})});Jt.displayName=Kt;var Qe="PopoverPortal",[Rr,Mr]=Ht(Qe,{forceMount:void 0}),Zt=t=>{const{__scopePopover:a,forceMount:s,children:o,container:n}=t,d=H(Qe,a);return e.jsx(Rr,{scope:a,forceMount:s,children:e.jsx(kt,{present:s||d.open,children:e.jsx(Ia,{asChild:!0,container:n,children:o})})})};Zt.displayName=Qe;var re="PopoverContent",Xt=c.forwardRef((t,a)=>{const s=Mr(re,t.__scopePopover),{forceMount:o=s.forceMount,...n}=t,d=H(re,t.__scopePopover);return e.jsx(kt,{present:o||d.open,children:d.modal?e.jsx(Ar,{...n,ref:a}):e.jsx(Br,{...n,ref:a})})});Xt.displayName=re;var Ir=Aa("PopoverContent.RemoveScroll"),Ar=c.forwardRef((t,a)=>{const s=H(re,t.__scopePopover),o=c.useRef(null),n=_t(a,o),d=c.useRef(!1);return c.useEffect(()=>{const r=o.current;if(r)return Na(r)},[]),e.jsx(Ca,{as:Ir,allowPinchZoom:!0,children:e.jsx(Qt,{...t,ref:n,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(t.onCloseAutoFocus,r=>{var i;r.preventDefault(),d.current||(i=s.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(t.onPointerDownOutside,r=>{const i=r.detail.originalEvent,x=i.button===0&&i.ctrlKey===!0,f=i.button===2||x;d.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:ae(t.onFocusOutside,r=>r.preventDefault(),{checkForDefaultPrevented:!1})})})}),Br=c.forwardRef((t,a)=>{const s=H(re,t.__scopePopover),o=c.useRef(!1),n=c.useRef(!1);
76return e.jsx(Qt,{...t,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var r,i;(r=t.onCloseAutoFocus)==null||r.call(t,d),d.defaultPrevented||(o.current||(i=s.triggerRef.current)==null||i.focus(),d.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:d=>{var x,f;(x=t.onInteractOutside)==null||x.call(t,d),d.defaultPrevented||(o.current=!0,d.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const r=d.target;((f=s.triggerRef.current)==null?void 0:f.contains(r))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&n.current&&d.preventDefault()}})}),Qt=c.forwardRef((t,a)=>{const{__scopePopover:s,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:d,disableOutsidePointerEvents:r,onEscapeKeyDown:i,onPointerDownOutside:x,onFocusOutside:f,onInteractOutside:v,...y}=t,k=H(re,s),I=fe(s);return _a(),e.jsx(ka,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:d,children:e.jsx(Pa,{asChild:!0,disableOutsidePointerEvents:r,onInteractOutside:v,onEscapeKeyDown:i,onPointerDownOutside:x,onFocusOutside:f,onDismiss:()=>k.onOpenChange(!1),children:e.jsx(Sa,{"data-state":ta(k.open),role:"dialog",id:k.contentId,...I,...y,ref:a,style:{...y.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),ea="PopoverClose",zr=c.forwardRef((t,a)=>{const{__scopePopover:s,...o}=t,n=H(ea,s);return e.jsx(xe.button,{type:"button",...o,ref:a,onClick:ae(t.onClick,()=>n.onOpenChange(!1))})});zr.displayName=ea;var Er="PopoverArrow",$r=c.forwardRef((t,a)=>{const{__scopePopover:s,...o}=t,n=fe(s);return e.jsx(Ta,{...n,...o,ref:a})});$r.displayName=Er;function ta(t){return t?"open":"closed"}var Lr=qt,Fr=Jt,Or=Zt,aa=Xt;const Wr=Lr,Vr=Fr,sa=c.forwardRef(({className:t,align:a="center",sideOffset:s=4,...o},n)=>e.jsx(Or,{children:e.jsx(aa,{ref:n,align:a,sideOffset:s,className:J("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...o})}));sa.displayName=aa.displayName;function Gr({value:t,onSelect:a,isCalculatorAvailable:s,aiCalculators:o=[]}){const[n,d]=c.useState(!1),[r,i]=c.useState(""),x=Object.values(Pt),f=t?te[t]:null,v=!f&&t?o.find(p=>p.id===t):null,y=c.useMemo(()=>{const p=new Set;return x.forEach(j=>j.calculators.forEach(S=>p.add(S))),Object.values(te).filter(j=>!p.has(j.id))},[x]),k=c.useMemo(()=>{const p=r.toLowerCase().trim();return p?x.map(j=>({...j,calculators:j.calculators.filter(S=>{const C=te[S];return C&&C.title.toLowerCase().includes(p)})})).filter(j=>j.calculators.length>0):x},[r,x]),I=c.useMemo(()=>{const p=r.toLowerCase().trim();return p?y.filter(j=>j.title.toLowerCase().includes(p)):y},[r,y]),R=c.useMemo(()=>{const p=r.toLowerCase().trim();return p?o.filter(j=>j.title.toLowerCase().includes(p)):o},[r,o]),O=f?f.title:v?v.title:"Choose a calculator...";return e.jsxs(Wr,{open:n,onOpenChange:d,children:[e.jsx(Vr,{asChild:!0,children:e.jsxs(A,{variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[v&&e.jsx(it,{className:"h-3.5 w-3.5 text-primary shrink-0"}),O]}),e.jsx(tr,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxs(sa,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx(se,{placeholder:"Search calculators...",value:r,onChange:p=>i(p.target.value),className:"border-0 p-0 h-8 shadow-none focus-visible:ring-0"})]}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto p-1",children:[k.length===0&&R.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No calculators found."}),R.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:[e.jsx(it,{className:"h-3 w-3"}),"My AI Calculators"]}),R.map(p=>{const j=t===p.id;return e.jsxs("button",{onClick:()=>{a(p.id),d(!1),i("")},className:J("flex items-center gap-2 w-full rounded-sm px-2 py-1.5 text-sm cursor-pointer transition-colors","hover:bg-accent hover:text-accent-foreground",j&&"bg-accent text-accent-foreground"),children:[j?e.jsx(W,{className:"h-3.5 w-3.5 text-primary shrink-0"}):e.jsx("span",{className:"w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:p.title})]}
76,p.id)})]}),k.map(p=>e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:p.name}),p.calculators.map(j=>{const S=te[j];if(!S)return null;const C=s(j),u=t===S.id;return e.jsxs("button",{onClick:()=>{a(S.id),d(!1),i("")},disabled:!C,className:J("flex items-center gap-2 w-full rounded-sm px-2 py-1.5 text-sm cursor-pointer transition-colors","hover:bg-accent hover:text-accent-foreground",!C&&"opacity-50 cursor-not-allowed",u&&"bg-accent text-accent-foreground"),children:[u?e.jsx(W,{className:"h-3.5 w-3.5 text-primary shrink-0"}):e.jsx("span",{className:"w-3.5 shrink-0"}),!C&&e.jsx(We,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:C?"":"text-muted-foreground",children:S.title}),!C&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"(Pro)"})]},S.id)})]},p.id)),I.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Other Tools"}),I.map(p=>{const j=s(p.id),S=t===p.id;return e.jsxs("button",{onClick:()=>{a(p.id),d(!1),i("")},disabled:!j,className:J("flex items-center gap-2 w-full rounded-sm px-2 py-1.5 text-sm cursor-pointer transition-colors","hover:bg-accent hover:text-accent-foreground",!j&&"opacity-50 cursor-not-allowed",S&&"bg-accent text-accent-foreground"),children:[S?e.jsx(W,{className:"h-3.5 w-3.5 text-primary shrink-0"}):e.jsx("span",{className:"w-3.5 shrink-0"}),!j&&e.jsx(We,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:j?"":"text-muted-foreground",children:p.title}),!j&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"(Pro)"})]},p.id)})]})]})]})]})}const ra=["mortgage-payment","home-affordability","bmi-calculator","percentage-calculator","age-calculator"],Ur={free:{widgets:3,canRemoveBranding:!1,allCalculators:!1},starter:{widgets:10,canRemoveBranding:!0,allCalculators:!0},growth:{widgets:10,canRemoveBranding:!0,allCalculators:!0},pro:{widgets:50,canRemoveBranding:!0,allCalculators:!0}};function Oe(t){const a=t;return{id:a.id,user_id:a.user_id,name:a.name,calculator_id:a.calculator_id,color_scheme:a.color_scheme,size:a.size,border_radius:a.border_radius,show_branding:a.show_branding,allowed_domains:a.allowed_domains||[],created_at:a.created_at,updated_at:a.updated_at,cta_enabled:a.cta_enabled,cta_text:a.cta_text,cta_url:a.cta_url,cta_bg_color:a.cta_bg_color,cta_text_color:a.cta_text_color,cta_size:a.cta_size,cta_custom_css:a.cta_custom_css,show_insights:a.show_insights,font:a.font,disclaimer_enabled:a.disclaimer_enabled,disclaimer_text:a.disclaimer_text}}function Dr(){const{user:t}=St(),{toast:a}=Tt(),[s,o]=c.useState([]),[n,d]=c.useState(null),[r,i]=c.useState(!0),x=async()=>{if(!t){o([]),i(!1);return}const{data:u,error:m}=await ee.from("user_widgets").select("*").eq("user_id",t.id).order("created_at",{ascending:!1});m?console.error("Error fetching widgets:",m):o((u||[]).map(Oe)),i(!1)},f=async()=>{if(!t){d(null);return}const{data:u,error:m}=await ee.from("user_subscriptions").select("*").eq("user_id",t.id).maybeSingle();m?console.error("Error fetching subscription:",m):u&&d(u)};c.useEffect(()=>{x(),f()},[t]);const v=(n==null?void 0:n.tier)||"free",y=Ur[v],k=async u=>{if(!t)return null;const m={user_id:t.id,name:u.name,calculator_id:u.calculator_id,color_scheme:u.color_scheme,size:u.size,border_radius:u.border_radius,show_branding:u.show_branding,allowed_domains:u.allowed_domains||[],cta_enabled:u.cta_enabled??!1,cta_text:u.cta_text??"Learn More",cta_url:u.cta_url??"",cta_bg_color:u.cta_bg_color??"#3b82f6",cta_text_color:u.cta_text_color??"#ffffff",cta_size:u.cta_size??"default",cta_custom_css:u.cta_custom_css??"",show_insights:u.show_insights??!0,font:u.font??"'Source Sans 3', system-ui, sans-serif",disclaimer_enabled:u.disclaimer_enabled??!1,disclaimer_text:u.disclaimer_text??""},{data:N,error:g}=await ee.from("user_widgets").insert(m).select().single();return g?(g.message.includes("Widget limit reached")?a({title:"Widget Limit Reached",description:`Your plan allows ${y.widgets} widgets. Upgrade for more.`,variant:"destructive"}):a({title:"Error",description:g.message||"Failed to create widget",variant:"destructive"}),null):(a({title:"Widget Created",description:"Your widget has been saved successfully."}),await x(),Oe(N))},I=async(u,m)=>{if(!t)return null;const N={};m.name!==void 0&&(N.name=m.name),m.calculator_id!==void 0&&(N.calculator_id=m.calculator_id),m.color_scheme!==void 0&&(N.color_scheme=m.color_scheme),m.size!==void 0&&(N.size=m.size),m.border_radius!==void 0&&(N.border_radius=m.border_radius),m.show_branding!==void 0&&(N.show_branding=m.show_branding),m.allowed_domains!==void 0&&(N.allowed_domains=m.allowed_domains),m.cta_enabled!==void 0&&(N.cta_enabled=m.cta_enabled),m.cta_text!==void 0&&(N.cta_text=m.cta_text),m.cta_url!==void 0&&(N.cta_url=m.cta_url),m.cta_bg_color!==void 0&&(N.cta_bg_color=m.cta_bg_color),m.cta_text_color!==void 0&&(N.cta_text_color=m.cta_text_color),m.cta_size!==void 0&&(N.cta_size=m.cta_size),m.cta_custom_css!==void 0&&(N.cta_custom_css=m.cta_custom_css),m.show_insights!==void 0&&(N.show_insights=m.show_insights),m.font!==void 0&&(N.font=m.font),m.disclaimer_enabled!==void 0&&(N.disclaimer_enabled=m.disclaimer_enabled),m.disclaimer_text!==void 0&&(N.disclaimer_text=m.disclaimer_text);const{data:g,error:P}=await ee.from("user_widgets").update(N).eq("id",u).eq("user_id",t.id).select().single();return P?(a({title:"Error",description:"Failed to update widget",variant:"destructive"}),null):(a({title:"Widget Updated",description:"Your widget has been updated successfully."}),await x(),Oe(g))},R=async u=>t?j?await k({name:`${u.name} (Copy)`,calculator_id:u.calculator_id,color_scheme:u.color_scheme,size:u.size,border_radius:u.border_radius,show_branding:u.show_branding,allowed_domains:u.allowed_domains,cta_enabled:u.cta_enabled,cta_text:u.cta_text,cta_url:u.cta_url,cta_bg_color:u.cta_bg_color,cta_text_color:u.cta_text_color,cta_size:u.cta_size,cta_custom_css:u.cta_custom_css,show_insights:u.show_insights,font:u.font,disclaimer_enabled:u.disclaimer_enabled,disclaimer_text:u.disclaimer_text}):(a({title:"Widget Limit Reached",description:`Your plan allows ${y.widgets} widgets. Upgrade for more.`,variant:"destructive"}),null):null,O=async u=>
76{if(!t)return!1;const{error:m}=await ee.from("user_widgets").delete().eq("id",u).eq("user_id",t.id);return m?(a({title:"Error",description:"Failed to delete widget",variant:"destructive"}),!1):(a({title:"Widget Deleted",description:"Your widget has been deleted."}),await x(),!0)},p=s.length,j=p<y.widgets,S=y.canRemoveBranding;return{widgets:s,subscription:n,loading:r,createWidget:k,cloneWidget:R,updateWidget:I,deleteWidget:O,fetchWidgets:x,tier:v,limits:y,widgetCount:p,canCreateWidget:j,canRemoveBranding:S,isCalculatorAvailable:u=>y.allCalculators||ra.includes(u)}}const vt={enabled:!1,text:"Learn More",url:"",bgColor:"#3b82f6",textColor:"#ffffff",size:"default",customCss:""},ue="This calculator provides estimates for informational purposes only and does not constitute financial advice.",Hr=[{value:"compact",label:"Compact (400px)"},{value:"standard",label:"Standard (500px)"},{value:"full",label:"Full Width"}],yt=["mortgage-payment","bmi-calculator","macro-calculator","savings-growth","percentage-calculator"];function Ao(){const{user:t,isLoading:a,signOut:s}=St(),{toast:o}=Tt(),{widgets:n,loading:d,createWidget:r,updateWidget:i,deleteWidget:x,cloneWidget:f,tier:v,limits:y,widgetCount:k,canCreateWidget:I,canRemoveBranding:R,isCalculatorAvailable:O}=Dr(),[p,j]=c.useState(""),[S,C]=c.useState("light"),[u,m]=c.useState("standard"),[N,g]=c.useState(12),[P,q]=c.useState(!0),[oe,le]=c.useState(!1),[Z,ne]=c.useState("My Widget"),[b,he]=c.useState(null),[E,oa]=c.useState("iframe"),[la,F]=c.useState(!1),[na,et]=c.useState(!1),[ca,ge]=c.useState(!1),[Re,tt]=c.useState(null),[Me,be]=c.useState(Q[0].colors),[Ie,ve]=c.useState(!1),[X,Ae]=c.useState(we[0].value),[L,Be]=c.useState(vt),[at,ze]=c.useState(!0),[ce,Ee]=c.useState(!1),[ye,je]=c.useState(ue),[$e,ia]=c.useState([]);c.useEffect(()=>{t&&(async()=>{const{data:l}=await ee.from("ai_calculators").select("id, title, description").eq("user_id",t.id).order("created_at",{ascending:!1});ia(l||[])})()},[t]),Object.values(Pt);const w=te[p],z=c.useMemo(()=>{if(Ie)return Je(Me);const l=Q.find(_=>_.id===S);return l?l.colors:Q[0].colors},[Ie,Me,S]);c.useEffect(()=>{if(b){j(b.calculator_id),m(b.size),g(b.border_radius),q(b.show_branding),ne(b.name),be(Je(b.color_scheme)),ve(!0);const l=b;Be({enabled:l.cta_enabled??!1,text:l.cta_text??"Learn More",url:l.cta_url??"",bgColor:l.cta_bg_color??"#3b82f6",textColor:l.cta_text_color??"#ffffff",size:l.cta_size??"default",customCss:l.cta_custom_css??""}),ze(b.show_insights??!0),Ee(b.disclaimer_enabled??!1),je(b.disclaimer_text||ue),Ae(b.font||we[0].value)}},[b]);const da=b?`https://smartcalculators.ai/embed/${b.id}`:"",st=b?`<iframe 
77  src="${da}" 
78  width="${u==="compact"?"400":u==="standard"?"500":"100%"}" 
79  height="500" 
80  frameborder="0" 
81  style="border: none; max-width: 100%;"
82  title="SmartCalculators.ai Widget">
83</iframe>`:"Save your widget first to get the iframe embed code.",rt=c.useMemo(()=>{if(!b)return"";const l=u==="compact"?"400":u==="standard"?"500":"100%",_=`https://smartcalculators.ai/embed/${b.id}`;return`<!-- SmartCalculators.ai Widget -->
84<div id="sc-widget-${b.id}" style="width: ${l==="100%"?l:l+"px"}; max-width: 100%;">
85  <iframe 
86    src="${_}" 
87    width="100%" 
88    height="500" 
89    frameborder="0" 
90    style="border: none; width: 100%; min-height: 450px;"
91    title="SmartCalculators.ai Widget"
92    loading="lazy">
93  </iframe>
94</div>
95<!-- End SmartCalculators.ai Widget -->`},[b,u]),ot=c.useMemo(()=>{var ct;if(!p||!w)return"";const l="https://greobntgwuacrkajsyni.supabase.co/functions/v1/calculators-api",_=u==="compact"?"400px":u==="standard"?"500px":"100%",h=w==null?void 0:w.slug,Le=(ct=w==null?void 0:w.category)==null?void 0:ct.slug,Y=qr((w==null?void 0:w.id)||""),ga=Yr(Y.format),ba=(K=>{switch(K){case"bmi-calculator":return"bmi";case"macro-calculator":return"proteinGrams";case"mortgage-payment":return"monthlyPayment";case"savings-growth":return"futureValue";case"percentage-calculator":return"percentOf";default:return"result"}})(w.id);return`<!-- SmartCalculators.ai API Widget -->
96<!-- No API key required - public endpoint -->
97<div id="sc-api-widget-${h}" style="width: ${_}; max-width: 100%;">
98  <style>
99    #sc-api-widget-${h} {
100      --sc-bg: ${z.background};
101      --sc-text: ${z.text};
102      --sc-muted: ${z.muted};
103      --sc-border: ${z.border};
104      --sc-primary: ${z.primary};
105      --sc-primary-fg: ${z.primaryForeground};
106      --sc-input-bg: ${z.inputBg};
107      --sc-input-border: ${z.inputBorder};
108      --sc-input-text: ${z.inputText};
109      --sc-card-bg: ${z.cardBg};
110      --sc-radius: ${N}px;
111      font-family: ${X};
112    }
113    #sc-api-widget-${h} .sc-container { background: var(--sc-bg); border: 1px solid var(--sc-border); border-radius: var(--sc-radius); padding: 24px; color: var(--sc-text); }
114    #sc-api-widget-${h} .sc-title { font-size: 18px; font-weight: 600; margin: 0 0 8px 0; }
115    #sc-api-widget-${h} .sc-description { font-size: 14px; color: var(--sc-muted); margin: 0 0 20px 0; }
116    #sc-api-widget-${h} .sc-form { display: flex; flex-direction: column; gap: 16px; }
117    #sc-api-widget-${h} .sc-field { display: flex; flex-direction: column; gap: 6px; }
118    #sc-api-widget-${h} .sc-label { font-size: 13px; font-weight: 500; color: var(--sc-muted); }
119    #sc-api-widget-${h}
119 .sc-input { padding: 10px 12px; border: 1px solid var(--sc-input-border); border-radius: calc(var(--sc-radius) - 4px); background: var(--sc-input-bg); color: var(--sc-input-text); font-size: 16px; width: 100%; box-sizing: border-box; }
120    #sc-api-widget-${h} .sc-input:focus { outline: none; border-color: var(--sc-primary); }
121    #sc-api-widget-${h} .sc-result { margin-top: 20px; padding: 16px; background: var(--sc-primary); border-radius: calc(var(--sc-radius) - 4px); text-align: center; }
122    #sc-api-widget-${h} .sc-result-label { font-size: 12px; color: var(--sc-primary-fg); opacity: 0.8; text-transform: uppercase; letter-spacing: 0.5px; }
123    #sc-api-widget-${h} .sc-result-value { font-size: 28px; font-weight: 700; color: var(--sc-primary-fg); margin-top: 4px; }
124    #sc-api-widget-${h} .sc-secondary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
125    #sc-api-widget-${h} .sc-secondary-item { background: var(--sc-card-bg); padding: 12px; border-radius: calc(var(--sc-radius) - 4px); text-align: center; border: 1px solid var(--sc-border); }
126    #sc-api-widget-${h} .sc-secondary-label { font-size: 11px; color: var(--sc-muted); text-transform: uppercase; }
127    #sc-api-widget-${h} .sc-secondary-value { font-size: 16px; font-weight: 600; color: var(--sc-text); margin-top: 4px; }
128    #sc-api-widget-${h} .sc-footer { margin-top: 16px; text-align: center; }
129    #sc-api-widget-${h} .sc-link { font-size: 12px; color: var(--sc-muted); text-decoration: none; }
130    #sc-api-widget-${h} .sc-link:hover { color: var(--sc-primary); }
131    #sc-api-widget-${h} .sc-loading { opacity: 0.6; }
132  </style>
133  
134  <div class="sc-container">
135    <h3 class="sc-title">${(w==null?void 0:w.title)||"Calculator"}</h3>
136    <p class="sc-description">${(w==null?void 0:w.question)||""}</p>
137    <form class="sc-form" id="sc-api-form-${h}">
138      ${(w==null?void 0:w.inputs.slice(0,6).map(K=>`
139      <div class="sc-field">
140        <label class="sc-label">${K.label}</label>
141        <input type="number" class="sc-input" name="${K.id}" value="${K.defaultValue}" step="${K.step||(K.type==="percentage"?"0.1":"1")}" />
142      </div>`).join(""))||""}
143    </form>
144    <div class="sc-result">
145      <div class="sc-result-label">${(w==null?void 0:w.primaryMetric.label)||"Result"}</div>
146      <div class="sc-result-value" id="sc-api-result-${h}">${ga}</div>
147    </div>
148    <div class="sc-secondary" id="sc-api-secondary-${h}"></div>
149    ${P?`<div class="sc-footer"><a href="https://smartcalculators.ai/${Le}/${h}" target="_blank" class="sc-link">Powered by SmartCalculators.ai →</a></div>`:""}
150  </div>
151  
152  <script>
153    (function() {
154      var API_URL = '${l}';
155      var CALC_ID = '${h}';
156      var form = document.getElementById('sc-api-form-' + CALC_ID);
157      var resultEl = document.getElementById('sc-api-result-' + CALC_ID);
158      var secondaryEl = document.getElementById('sc-api-secondary-' + CALC_ID);
159      var debounceTimer;
160      
161      function formatValue(value, key) {
162        if (typeof value === 'string') return value;
163        if (key.includes('bmi') || key === 'bmi') return value.toFixed(1);
164        if (key.includes('Percent') || key.includes('percent')) return value.toFixed(1) + '%';
165        if (key.includes('Grams') || key.includes('grams')) return Math.round(value) + 'g';
166        if (key.includes('Payment') || key.includes('payment') || key.includes('Income') || key.includes('Value') || key.includes('Savings')) {
167          return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(value);
168        }
169        return typeof value === 'number' ? (value % 1 === 0 ? value.toLocaleString() : value.toFixed(2)) : value;
170      }
171      
172      function calculate() {
173        clearTimeout(debounceTimer);
174        debounceTimer = setTimeout(function() {
175          var inputs = form.querySelectorAll('.sc-input');
176          var values = {};
177          inputs.forEach(function(input) { values[input.name] = parseFloat(input.value) || 0; });
178          
179          resultEl.classList.add('sc-loading');
180          
181          fetch(API_URL + '?calculate=' + CALC_ID, {
182            method: 'POST',
183            headers: { 'Content-Type': 'application/json' },
184            body: JSON.stringify(values)
185          })
186          .then(function(res) { return res.json(); })
187          .then(function(data) {
188            resultEl.classList.remove('sc-loading');
189            if (data.success && data.result) {
190              var primaryKey = '${ba}';
191              var primaryValue = data.result[primaryKey];
192              resultEl.textContent = formatValue(primaryValue, primaryKey);
193              
194              // Show secondary results
195              var secondaryHtml = '';
196              Object.keys(data.result).forEach(function(key) {
197                if (key !== primaryKey && typeof data.result[key] !== 'object') {
198                  var label = key.replace(/([A-Z])/g, ' $1').replace(/^./, function(s) { return s.toUpperCase(); });
199                  secondaryHtml += '<div class="sc-secondary-item"><div class="sc-secondary-label">' + label + '</div><div class="sc-secondary-value">' + formatValue(data.result[key], key) + '</div></div>';
200                }
201              });
202              secondaryEl.innerHTML = secondaryHtml;
203            }
204          })
205          .catch(function(err) {
206            resultEl.classList.remove('sc-loading');
207            console.error('Calculation error:', err);
208          });
209        }, 300);
210      }
211      
212      form.addEventListener('input', calculate);
213      calculate();
214    })();
215  <\/script>
216</div>
217<!-- End SmartCalculators.ai API Widget -->`},[p,z,u,N,P,w,X]);if(a)return e.jsx(dt,{children:e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx(qs,{className:"h-8 w-8 animate-spin text-primary"})})});if(!t)return e.jsx(Ba,{to:"/auth",replace:!0});const ua=l=>{C(l);const _=Q.find(h=>h.id===l);_&&be(_.colors),ve(!1)},ma=(l,_)=>{be(h=>({...h,[l]:_})),ve(!0)},pa=l=>{if(!$e.some(h=>h.id===l)&&!O(l)){F(!0);return}j(l)},xa=async()=>{if(!p){o({title:"Select a Calculator",description:"Please select a calculator before saving.",variant:"destructive"});return}if(!I&&!b){F(!0);return}const l={name:Z,calculator_id:p,color_scheme:z,size:u,border_radius:N,show_branding:P||!R,cta_enabled:L.enabled,cta_text:L.text,cta_url:L.url,cta_bg_color:L.bgColor,cta_text_color:L.textColor,cta_size:L.size,cta_custom_css:L.customCss,show_insights:at,font:X,disclaimer_enabled:ce,disclaimer_text:ye};if(b)await i(b.id,l);else{const _=await r(l);_&&he(_)}},fa=async()=>{Re&&(await x(Re),(b==null?void 0:b.id)===Re&&lt()),ge(!1),tt(null)},lt=()=>{he(null),j(""),ne("My Widget"),C("light"),be(Q[0].colors),ve(!1),Ae(we[0].value),m("standard"),g(12),q(!0),Be(vt),ze(!0),Ee(!1),je(ue)},nt=async l=>{if(!I){F(!0);return}const _=await f(l);_&&he(_)},ha=async()=>{let l="";E==="iframe"?l=st:E==="script"?l=rt:E==="api"&&w&&(l=ot),await navigator.clipboard.writeText(l),le(!0),o({title:"Copied!",description:E==="api"?"API widget code copied to clipboard":"Embed code copied to clipboard"}),setTimeout(()=>le(!1),2e3)};return e.jsxs(dt,{children:[e.jsxs(za,{children:[e.jsx("title",{children:"Widget Builder | SmartCalculators.ai"}),e.jsx("meta",{name:"description",content:"Create embeddable calculator widgets for your website. Customize colors, save your widgets, and embed via iframe or script."})]}),e.jsx("div",{className:"container py-12 md:py-16",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground tracking-tight",children:"Widget Builder"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Create and manage embeddable calculator widgets for your website."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Signed in as ",e.jsx("span",{className:"font-medium text-foreground",children:t.email})]}),e.jsxs(A,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(Ea,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]}),e.jsx("div",{className:`mb-8 p-4 rounded-lg border ${v!=="free"?"bg-primary/5 border-primary/20":"bg-secondary/50 border-border"}`,children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${v!=="free"?"bg-primary/10":"bg-muted"}`,children:e.jsx(Ne,{className:`h-5 w-5 ${v!=="free"?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium capitalize",children:[v," Plan"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v==="free"?`${k}/${y.widgets} widgets • Basic calculators • Branding required`:v==="starter"?`${k}/${y.widgets} widgets • All calculators • No branding`:`${k}/${y.widgets} widgets • All features • Priority support`})]})]}),v==="free"&&e.jsxs(A,{onClick:()=>F(!0),className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),"Upgrade Plan"]})]})}),n.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Your Widgets"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[n.map(l
217=>{const _=te[l.calculator_id],h=_?null:$e.find(Y=>Y.id===l.calculator_id),Le=(_==null?void 0:_.title)||(h==null?void 0:h.title)||"Unknown";return e.jsxs("div",{className:`p-4 border rounded-lg cursor-pointer transition-all hover:border-primary/50 ${(b==null?void 0:b.id)===l.id?"border-primary bg-primary/5":"border-border bg-card"}`,onClick:()=>he(l),children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm truncate",children:l.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Le})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx(A,{variant:"ghost",size:"icon",title:"Duplicate this widget",className:"h-7 w-7 text-muted-foreground hover:text-primary",onClick:Y=>{Y.stopPropagation(),nt(l)},children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsx(A,{variant:"ghost",size:"icon",title:"Delete this widget",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:Y=>{Y.stopPropagation(),tt(l.id),ge(!0)},children:e.jsx(Ys,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"h-2 rounded-full mt-2",style:{background:l.color_scheme.primary}})]},l.id)}),I&&e.jsx("div",{className:"p-4 border-2 border-dashed border-border rounded-lg cursor-pointer transition-all hover:border-primary/50 flex items-center justify-center min-h-[100px]",onClick:lt,children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"+ Create New Widget"})})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-primary"}),"Widget Settings"]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Widget Name"}),e.jsx(se,{value:Z,onChange:l=>ne(l.target.value),placeholder:"My Calculator Widget"})]})})]}),e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(ut,{className:"h-5 w-5 text-primary"}),"Select Calculator"]}),e.jsx(Gr,{value:p,onSelect:pa,isCalculatorAvailable:O,aiCalculators:$e}),v==="free"&&e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Free plan includes: ",ra.length," basic calculators. ",e.jsx("button",{onClick:()=>F(!0),className:"text-primary hover:underline",children:"Upgrade for all calculators"})]})]}),e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(Ks,{className:"h-5 w-5 text-primary"}),"Customize Appearance"]}),e.jsxs(mt,{defaultValue:"presets",className:"w-full",children:[e.jsxs(pt,{className:"w-full mb-4",children:[e.jsx(ie,{value:"presets",className:"flex-1",children:"Presets"}),e.jsx(ie,{value:"custom",className:"flex-1",children:"Custom"})]}),e.jsx(de,{value:"presets",className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:Q.map(l=>e.jsxs("button",{onClick:()=>ua(l.id),className:`p-3 rounded-lg border-2 transition-all text-left ${S===l.id&&!Ie?"border-primary":"border-border hover:border-primary/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:l.colors.primary}}),e.jsx("span",{className:"text-xs font-medium truncate",children:l.name})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-4 h-4 rounded",style:{backgroundColor:l.colors.background}}),e.jsx("div",{className:"w-4 h-4 rounded",style:{backgroundColor:l.colors.cardBg}}),e.jsx("div",{className:"w-4 h-4 rounded",style:{backgroundColor:l.colors.primary}}),e.jsx("div",{className:"w-4 h-4 rounded",style:{backgroundColor:l.colors.accent}})]})]},l.id))})}),e.jsx(de,{value:"custom",className:"space-y-4",children:e.jsx(Nr,{colors:Me,onCh
217ange:ma})})]})]}),e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"h-4 w-4"}),"Font Family"]}),e.jsxs(Ve,{value:X,onValueChange:Ae,children:[e.jsx(Ge,{children:e.jsx(Ue,{})}),e.jsx(De,{children:we.map(l=>e.jsx(pe,{value:l.value,children:e.jsx("span",{style:{fontFamily:l.value},children:l.label})},l.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Widget Size"}),e.jsxs(Ve,{value:u,onValueChange:m,children:[e.jsx(Ge,{children:e.jsx(Ue,{})}),e.jsx(De,{children:Hr.map(l=>e.jsx(pe,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{children:["Border Radius: ",N,"px"]}),e.jsx($a,{value:[N],onValueChange:([l])=>g(l),min:0,max:24,step:2})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{htmlFor:"branding",children:"Show SmartCalculators.ai branding"}),!R&&e.jsx(We,{className:"h-3 w-3 text-muted-foreground"})]}),e.jsx(Ce,{id:"branding",checked:P,onCheckedChange:l=>{if(!l&&!R){F(!0);return}q(l)},disabled:!R&&P})]}),!R&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("button",{onClick:()=>F(!0),className:"text-primary hover:underline",children:"Upgrade to Pro"})," to remove branding"]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(M,{htmlFor:"insights",children:"Show Dynamic Insights"}),e.jsx(Ce,{id:"insights",checked:at,onCheckedChange:ze})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display personalized tips and analysis below calculator results (available on supported calculators)."})]}),e.jsx(Cr,{settings:L,onChange:(l,_)=>Be(h=>({...h,[l]:_}))}),e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Js,{className:"h-5 w-5 text-primary"}),"Disclaimer"]}),e.jsx(Ce,{checked:ce,onCheckedChange:Ee})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:p==="rent-vs-buy"?"Replace the content inside this calculator’s Legal Disclaimer pop-up.":"Show a custom disclaimer at the bottom of this calculator only. Other calculators are unaffected."}),ce&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Disclaimer Text"}),e.jsx(Pr,{value:ye,onChange:je,placeholder:ue}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Bold, italic, underline, lists, and links are supported."}),e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>je(ue),children:"Reset to default"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(A,{size:"lg",className:"w-full gap-2",onClick:xa,disabled:!p,children:[e.jsx(Zs,{className:"h-4 w-4"}),b?"Update Widget":"Save Widget"]}),b&&e.jsxs(A,{size:"lg",variant:"outline",className:"w-full gap-2",onClick:()=>nt(b),children:[e.jsx(ht,{className:"h-4 w-4"}),"Duplicate This Widget"]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(Xs,{className:"h-5 w-5 text-primary"}),"Live Preview"]}),e.jsx(fr,{calculator:w,colorScheme:z,font:X,borderRadius:N,showBranding:P,onClick:()=>et(!0),ctaSettings:L,disclaimer:{enabled:ce,text:ye}})]}),e.jsx(wr,{open:na,onOpenChange:et,calculator:w,colorScheme:z,font:X,borderRadius:N,showBranding:P,ctaSettings:L,disclaimer:{enabled:ce,text:ye}}),e.jsxs("div",{className:"p-6 bg-card border border-border rounded-xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(sr,{className:"h-5 w-5 text-primary"}),"Embed Code"]}),e.jsxs(A,{variant:"outline",size:"sm",onClick:ha,disabled:!p||E==="iframe"&&!b||E==="api"&&!w,className:"gap-2",children:[oe?e.jsx(W,{className:"h-4 w-4"}):e.jsx(Qs,{className:"h-4 w-4"}),oe?"Copied":"Copy"]})]}),e.jsxs(mt,{value:E,onValueChange:l=>oa(l),className:"w-full",children:[e.jsxs(pt,{className:"w-full mb-4",children:[e.jsxs(ie,{value:"iframe",className:"flex-1 gap-1 text-xs sm:text-sm",children:[e.jsx(Se,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Iframe"})]}),e.jsxs(ie,{value:"script",className:"flex-1 gap-1 text-xs sm:text-sm",children:[e.jsx(ut,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Script"})]}),e.jsxs(ie,{value:"api",className:"flex-1 gap-1 text-xs sm:text-sm",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"API"})]})]}),e.jsxs(de,{value:"iframe",children:[b?e.jsx(me,{value:st,readOnly:!0,className:"font-mono text-xs h-32 resize-none bg-muted/50"}):e.jsx("div",{className:"h-32 flex items-center justify-center bg-muted/30 rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-muted-foreground text-sm text-center px-4",children:"Save your widget first to get the iframe embed code"})}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Iframe embeds are hosted by us and automatically stay up-to-date when you edit your widget."})]}),e.jsxs(de,{value:"script",children:[b?e.jsx(me,{value:rt,readOnly:!0,className:"font-mono text-xs h-32 resize-none bg-muted/50"}):e.jsx("div",{className:"h-32 flex items-center justify-center bg-muted/30 rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-muted-foreground text-sm text-center px-4",children:"Save your widget first to get the script embed code"})}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Script embeds use the same hosted widget as iframe. Your changes are automatically reflected."})]}),e.jsxs(de,{value:"api",children:[p&&w?e.jsxs("div",{className:"space-y-4",children:[!yt.includes(w.id)&&e.jsxs("div",{className:"p-3 rounded-lg border border-warning/40 bg-warning/10 text-warning-foreground text-xs",children:[e.jsx("strong",{children:"Heads up:"})," The API endpoint currently supports"," ",yt.join(", "),'. The "',w.title,`" calculator isn't available via API yet — use the Iframe or Script embed for full functionality, or contact us to request API support.`]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground mb-2 block",children:"API Endpoint"}),e.jsxs("div",{className:"bg-muted/50 p-3 rounded-lg font-mono text-xs break-all",children:["POST https://greobntgwuacrkajsyni.supabase.co/functions/v1/calculators-api?calculate=",w.slug]}),e.jsx("p",{className:"mt-1 text-xs text-emerald-600",children:"✓ No API key required - public endpoint"})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground mb-2 block",children:"Request Body (JSON)"}),e.jsx(me,{value:JSON.stringify(w.inputs.reduce((l,_)=>({...l,[_.id]:_.defaultValue}),{}),null,2),readOnly:!0,className:"font-mono text-xs h-32 resize-none bg-muted/50"})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground mb-2 block",children:"Complete Embed Code (HTML + CSS + JavaScript)"}),e.jsx(me,{value:ot,readOnly:!0,className:"font-mono text-xs h-64 resize-none bg-muted/50"})]})]}):e.jsx("div",{className:"h-48 flex items-center justify-center bg-muted/30 rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a calculator to generate API code"})}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Build your own UI with custom HTML/CSS and use our API for calculations. Full control over design."})]})]})]}),e.jsxs("div",{className:"p-4 bg-secondary/50 rounded-lg",children:[e.jsxs("h3",{className:"font-medium text-sm mb-2",children:["How to use ",E==="iframe"?"the Iframe embed":E==="script"?"the Script embed":"the API embed",":"]}
217),e.jsxs("ol",{className:"text-sm text-muted-foreground space-y-1 list-decimal list-inside",children:[E==="iframe"&&e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"Select a calculator and customize its appearance"}),e.jsx("li",{children:"Save your widget to generate a hosted URL"}),e.jsx("li",{children:"Copy the iframe snippet from the box above"}),e.jsx("li",{children:"Paste it anywhere in your site's HTML — edits to your widget update automatically"})]}),E==="script"&&e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"Select a calculator and customize its appearance"}),e.jsx("li",{children:"Save your widget so we can host it on our domain"}),e.jsx("li",{children:"Copy the script/div snippet above"}),e.jsx("li",{children:"Paste it into your CMS, WordPress block, or HTML — it auto-loads on page render"})]}),E==="api"&&e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"Select an API-supported calculator (no save required)"}),e.jsx("li",{children:"Copy the complete HTML + CSS + JS snippet above"}),e.jsx("li",{children:"Paste it into your site — fully customize the markup and styles to match your brand"}),e.jsx("li",{children:"Calculations are powered by our public API — no API key needed"})]})]})]})]})]})]})}),e.jsx(He,{open:la,onOpenChange:F,children:e.jsxs(qe,{children:[e.jsxs(Ye,{children:[e.jsxs(Ke,{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-5 w-5 text-primary"}),"Upgrade to Pro"]}),e.jsx(xt,{children:"Get unlimited access to all features for just $9.99/month."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{children:"Unlimited widgets (Free: 5 max)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{children:"Access to all 30+ calculators"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{children:"Remove SmartCalculators.ai branding"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{children:"Priority support"})]})]})}),e.jsxs(ft,{children:[e.jsx(A,{variant:"outline",onClick:()=>F(!1),children:"Maybe Later"}),e.jsxs(A,{className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),"Upgrade Now - $9.99/mo"]})]})]})}),e.jsx(He,{open:ca,onOpenChange:ge,children:e.jsxs(qe,{children:[e.jsxs(Ye,{children:[e.jsx(Ke,{children:"Delete Widget?"}),e.jsx(xt,{children:"This will permanently delete this widget. Any sites using the iframe embed will stop working."})]}),e.jsxs(ft,{children:[e.jsx(A,{variant:"outline",onClick:()=>ge(!1),children:"Cancel"}),e.jsx(A,{variant:"destructive",onClick:fa,children:"Delete Widget"})]})]})})]})}function qr(t){switch(t){case"mortgage-payment":return{logic:`
218        var principal = values.homePrice * (1 - values.downPayment / 100);
219        var monthlyRate = values.interestRate / 100 / 12;
220        var numPayments = values.loanTerm * 12;
221        if (monthlyRate > 0) {
222          result = principal * (monthlyRate * Math.pow(1 + monthlyRate, numPayments)) / (Math.pow(1 + monthlyRate, numPayments) - 1);
223          result += (values.homePrice * values.propertyTax / 100 / 12) + (values.insurance / 12);
224        }
225      `,format:"currency"};case"home-affordability":return{logic:`
226        var monthlyIncome = values.annualIncome / 12;
227        var maxHousingRatio = 0.28;
228        if (values.creditScore === 'excellent') maxHousingRatio = 0.31;
229        else if (values.creditScore === 'good') maxHousingRatio = 0.29;
230        var maxPayment = monthlyIncome * maxHousingRatio - values.monthlyDebts;
231        var loanTermYears = parseInt(values.loanTerm) || 30;
232        var monthlyRate = values.interestRate / 100 / 12;
233        var numPayments = loanTermYears * 12;
234        var monthlyTaxInsurance = (values.homeInsurance || 0) / 12 + (values.hoaFees || 0);
235        var availablePI = maxPayment - monthlyTaxInsurance;
236        if (monthlyRate > 0 && availablePI > 0) {
237          var loanAmount = availablePI * (Math.pow(1 + monthlyRate, numPayments) - 1) / (monthlyRate * Math.pow(1 + monthlyRate, numPayments));
238          result = loanAmount + values.downPayment;
239        }
240      `,format:"currency"};case"bmi-calculator":return{logic:`
241        var heightInches = values.heightFeet * 12 + values.heightInches;
242        result = (values.weight / (heightInches * heightInches)) * 703;
243      `,format:"decimal"};case"macro-calculator":return{logic:`
244        var proteinRatio = 0.30, carbRatio = 0.40, fatRatio = 0.30;
245        result = Math.round((values.calories * proteinRatio) / 4);
246      `,format:"number"};case"calorie-calculator":return{logic:`
247        var bmr = 10 * values.weight / 2.205 + 6.25 * (values.heightFeet * 30.48 + values.heightInches * 2.54) - 5 * values.age + 5;
248        result = Math.round(bmr * 1.55);
249      `,format:"number"};case"body-fat-calculator":return{logic:`
250        var heightInches = values.heightFeet * 12 + values.heightInches;
251        result = 495 / (1.0324 - 0.19077 * Math.log10(values.waist - values.neck) + 0.15456 * Math.log10(heightInches)) - 450;
252      `,format:"percent"};case"percentage-calculator":return{logic:`
253        result = (values.value * values.percentage) / 100;
254      `,format:"decimal"};case"age-calculator":return{logic:`
255        result = new Date().getFullYear() - values.birthYear;
256      `,format:"years"};case"dividend-income":case"drip-growth":case"net-worth":case"savings-growth":case"fire-number":case"debt-payoff":case"personal-loan":case"heloc-calculator":case"debt-consolidation":case"refinance-calculator":case"rent-vs-buy":case"extra-payment-impact":case"solar-roi-calculator":return{logic:`
257        var sum = 0;
258        for (var key in values) { sum += values[key]; }
259        result = sum;
260      `,format:"currency"};default:return{logic:`
261        var sum = 0;
262        for (var key in values) { sum += values[key]; }
263        result = sum;
264      `,format:"number"}}}function Yr(t){switch(t){case"currency":return"$0";case"decimal":return"0.0";case"percent":return"0%";
264case"years":return"0 years";case"number":default:return"0"}}export{Ao as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.