@nice2dev/ui-math 1.0.25 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +52 -52
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var B=Object.defineProperty;var T=(e,r,t)=>r in e?B(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var C=(e,r,t)=>T(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";var B=Object.defineProperty;var T=(e,r,t)=>r in e?B(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var C=(e,r,t)=>T(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),we=require("react"),_e=(e,r)=>r,te=we.createContext(_e);function Zt(){return{t:we.useContext(te)}}we.createContext({dir:"ltr",isRTL:!1,flip:e=>e,value:e=>e.ltr});we.createContext(null);we.createContext(null);const ee={radius:"md",shadow:"md",fill:"solid",buttonStyle:"flat",inputStyle:"bordered",cardStyle:"elevated",badgeStyle:"solid",tabStyle:"underline",toggleStyle:"default",tooltipStyle:"dark",modalStyle:"default",tableStyle:"default",menuStyle:"default",animation:"normal",density:"normal"};we.createContext({displayStyle:"default",variantConfig:ee,setDisplayStyle:()=>{}});we.createContext({});we.createContext({direction:"ltr",isRTL:!1,flip:e=>e,flipStyle:(e,r)=>({[e]:r})});we.createContext({permissions:{},getAccessMode:()=>"full"});we.createContext(null);const qt=process.env.NODE_ENV==="development";let O={enabled:qt,slowRenderThreshold:16};const Ne=[],Y=new Map,Ee=new Map;function Ut(){Ne.length=0,Y.clear(),Ee.clear()}function Kt(e){const r=O.slowRenderThreshold;return Ne.filter(t=>t.actualDuration>r)}function J(e){return e<1?`${(e*1e3).toFixed(0)}μs`:e<1e3?`${e.toFixed(2)}ms`:`${(e/1e3).toFixed(2)}s`}function va(){const e=Array.from(Y.values()),r=Kt(),t=e.reduce((o,i)=>o+i.renderCount,0),a=e.length>0?e.reduce((o,i)=>o+i.avgRenderTime,0)/e.length:0,n=Array.from(Ee.values());return{stats:e,slowRenders:r,totalRenders:t,avgRenderTime:a,marks:n}}function Gt(){const e=va();console.group("%c[Nice2Dev Performance Report]","color: var(--nice-info, #6366f1); font-weight: bold; font-size: 14px"),console.log(`Total renders: ${e.totalRenders}`),console.log(`Average render time: ${J(e.avgRenderTime)}`),console.log(`Slow renders: ${e.slowRenders.length}`),console.group("Component Stats"),console.table(e.stats.sort((r,t)=>t.totalRenderTime-r.totalRenderTime).map(r=>({Name:r.componentName,Renders:r.renderCount,"Avg Time":J(r.avgRenderTime),"Max Time":J(r.maxRenderTime),"Total Time":J(r.totalRenderTime),"Slow Renders":r.slowRenderCount}))),console.groupEnd(),e.slowRenders.length>0&&(console.group("Slow Renders (last 10)"),console.table(e.slowRenders.slice(-10).map(r=>({Component:r.componentName,Phase:r.phase,Duration:J(r.actualDuration),Time:new Date(r.timestamp).toLocaleTimeString()}))),console.groupEnd()),e.marks.length>0&&(console.group("Custom Marks"),console.table(e.marks.filter(r=>r.duration).map(r=>({Name:r.name,Duration:J(r.duration)}))),console.groupEnd()),console.groupEnd()}const wa=we.memo(({position:e="bottom-right",defaultCollapsed:r=!0})=>{const[t,a]=we.useState(r),[n,o]=we.useState([]),[i,c]=we.useState({used:0,total:0});if(we.useEffect(()=>{const s=()=>{const m=Array.from(Y.values());o(m.sort((g,w)=>w.totalRenderTime-g.totalRenderTime).slice(0,10));const y=window.performance;y.memory&&c({used:y.memory.usedJSHeapSize/1024/1024,total:y.memory.totalJSHeapSize/1024/1024})};s();const d=setInterval(s,2e3);return()=>clearInterval(d)},[]),!O.enabled)return null;const f={position:"fixed",zIndex:99999,...e.includes("top")?{top:8}:{bottom:8},...e.includes("left")?{left:8}:{right:8}};return jsxRuntime.jsxs("div",{style:{...f,background:"var(--nice-overlay-85, rgba(0, 0, 0, 0.85))",color:"var(--bg-primary, #fff)",borderRadius:8,fontSize:11,fontFamily:"Monaco, Consolas, monospace",padding:t?"4px 8px":8,maxWidth:t?"auto":300,maxHeight:t?"auto":400,overflow:"auto"},children:[jsxRuntime.jsxs("div",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:8},onClick:()=>a(s=>!s),children:[jsxRuntime.jsx("span",{style:{color:"var(--color-success, #22c55e)"},children:"●"}),jsxRuntime.jsx("span",{children:"Profiler"}),i.used>0&&jsxRuntime.jsxs("span",{style:{color:i.used>100?"var(--color-warning, #f59e0b)":"var(--text-muted, #64748b)"},children:[i.used.toFixed(0),"MB"]}),jsxRuntime.jsx("span",{style:{marginLeft:"auto",opacity:.5},children:t?"▼":"▲"})]}),!t&&jsxRuntime.jsxs("div",{style:{marginTop:8},children:[jsxRuntime.jsx("div",{style:{borderBottom:"1px solid var(--border-color, #333)",paddingBottom:4,marginBottom:8},children:jsxRuntime.jsx("strong",{children:"Top Components"})}),n.map(s=>jsxRuntime.jsxs("div",{style:{marginBottom:4,display:"flex",gap:8},children:[jsxRuntime.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:s.componentName}),jsxRuntime.jsx("span",{style:{color:s.avgRenderTime>16?"var(--color-warning, #f59e0b)":"var(--color-success, #22c55e)"},children:J(s.avgRenderTime)}),jsxRuntime.jsxs("span",{style:{color:"var(--text-muted, #64748b)",minWidth:30,textAlign:"right"},children:["x",s.renderCount]})]},s.componentName)),jsxRuntime.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[jsxRuntime.jsx("button",{onClick:Gt,style:{flex:1,padding:"4px 8px",background:"var(--bg-tertiary, #333)",border:"none",borderRadius:4,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:10},children:"Print Report"}),jsxRuntime.jsx("button",{onClick:Ut,style:{flex:1,padding:"4px 8px",background:"var(--bg-tertiary, #333)",border:"none",borderRadius:4,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:10},children:"Clear"})]})]})]})});wa.displayName="ProfilerOverlay";process.env.NODE_ENV;we.createContext(null);const ct=we.createContext({enabled:!0,active:!1,run:()=>{}});function Ra(){return we.useContext(ct)}function El(e,r){if(!e)return null;if(e===!0)return r&&r.length>0?r:null;if(Array.isArray(e))return e.length>0?e:null;const t=e.steps??r;return t&&t.length>0?t:null}function Pa(e,r){return e.map(t=>({target:t.target,title:t.titleKey?r(t.titleKey,t.title??""):t.title??"",content:t.contentKey?r(t.contentKey,t.content??""):t.content??"",placement:t.placement,highlightPadding:t.highlightPadding,showArrow:t.showArrow,scrollIntoView:t.scrollIntoView,disableInteraction:t.disableInteraction}))}const Ll=({steps:e,autoStart:r,label:t,size:a="md",className:n,style:o,"data-testid":i})=>{const{enabled:c,run:f}=Ra(),{t:s}=Zt();if(!c||!e||e.length===0)return null;const d=t??s("tutorial.startAria","Start tutorial");return jsxRuntime.jsx("button",{type:"button",className:`nice-tutorial-button nice-tutorial-button--${a}`+(n?` ${n}`:""),style:o,"data-testid":i,"aria-label":d,title:d,onClick:()=>f(Pa(e,s),{autoStart:r}),children:"?"})},St="nice-tutorial-button-styles";if(typeof document<"u"&&!document.getElementById(St)){const e=document.createElement("style");e.id=St,e.textContent=`
|
|
2
2
|
.nice-tutorial-button {
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
align-items: center;
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
}
|
|
25
25
|
.nice-tutorial-button--sm { width: 16px; height: 16px; font-size: 11px; }
|
|
26
26
|
.nice-tutorial-button--md { width: 20px; height: 20px; font-size: 12px; }
|
|
27
|
-
`,document.head.appendChild(e)}xe.createContext(null);xe.createContext(null);xe.createContext(null);const fe={space1:"4px",space2:"8px",space3:"12px",space4:"16px",space5:"20px",space6:"24px",space8:"32px"},ue={fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontSizeXs:"0.75rem",fontSizeSm:"0.8125rem",fontSizeMd:"0.875rem",fontSizeLg:"1rem",fontSizeXl:"1.125rem",fontWeightNormal:400,fontWeightMedium:500,fontWeightSemibold:600,fontWeightBold:700,lineHeight:1.5},me={fast:"120ms ease",normal:"200ms ease",slow:"300ms ease"},lt=e=>({color:e,radiusSm:"4px",radiusMd:"6px",radiusLg:"8px",radiusXl:"12px",radiusFull:"9999px"}),mr={sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"},fn={sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.4)"};function z(e,r,t,a,n){return{name:e,darkMode:"light",colors:{...r,surface:r.surface??t.primary,surfaceHover:r.surfaceHover??t.secondary},backgrounds:{...t,elevated:t.elevated??t.primary,inset:t.inset??t.tertiary,canvas:t.canvas??t.primary},text:{...a,inverse:a.inverse??"#ffffff"},borders:lt(n),shadows:mr,spacing:fe,typography:ue,transitions:me}}function V(e,r,t,a,n){return{name:e,darkMode:"dark",colors:{...r,surface:r.surface??t.secondary,surfaceHover:r.surfaceHover??t.tertiary},backgrounds:{...t,elevated:t.elevated??t.secondary,inset:t.inset??t.primary,canvas:t.canvas??t.primary},text:{...a,inverse:a.inverse??"#0f172a"},borders:lt(n),shadows:fn,spacing:fe,typography:ue,transitions:me}}z("Slate",{primary:"#64748b",primaryHover:"#475569",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#1e293b",secondary:"#475569",muted:"#94a3b8"},"#cbd5e1");z("Zinc",{primary:"#71717a",primaryHover:"#52525b",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fafafa",secondary:"#f4f4f5",tertiary:"#e4e4e7",hover:"#e4e4e7"},{primary:"#18181b",secondary:"#3f3f46",muted:"#a1a1aa"},"#d4d4d8");z("Stone",{primary:"#78716c",primaryHover:"#57534e",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#1c1917",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");z("Cool Gray",{primary:"#6b7280",primaryHover:"#4b5563",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#d1d5db");z("Warm Gray",{primary:"#7c7568",primaryHover:"#5c564c",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf9f7",secondary:"#f5f4f0",tertiary:"#e8e6e1",hover:"#e8e6e1"},{primary:"#1f1d19",secondary:"#4a463d",muted:"#a09888"},"#d4d0c8");z("Silver",{primary:"#94a3b8",primaryHover:"#64748b",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#38bdf8"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#334155",secondary:"#64748b",muted:"#94a3b8"},"#cbd5e1");z("Charcoal",{primary:"#374151",primaryHover:"#1f2937",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#6b7280"},"#d1d5db");z("Ivory",{primary:"#92876d",primaryHover:"#7a6f55",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffef7",secondary:"#faf6eb",tertiary:"#f0ead6",hover:"#f0ead6"},{primary:"#2b2517",secondary:"#5c5340",muted:"#9c9280"},"#ddd8c4");z("Rose",{primary:"#e11d48",primaryHover:"#be123c",success:"#16a34a",warning:"#ea580c",error:"#dc2626",info:"#0891b2"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f43f5e"},"#fda4af");z("Emerald",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#34d399"},"#6ee7b7");z("Amber",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0284c7"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#f59e0b"},"#fcd34d");z("Violet",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#2e1065",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");z("Teal",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");z("Indigo",{primary:"#4f46e5",primaryHover:"#4338ca",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#eef2ff",secondary:"#e0e7ff",tertiary:"#c7d2fe",hover:"#e0e7ff"},{primary:"#1e1b4b",secondary:"#312e81",muted:"#818cf8"},"#a5b4fc");z("Cyan",{primary:"#0891b2",primaryHover:"#0e7490",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#0284c7"},{primary:"#ecfeff",secondary:"#cffafe",tertiary:"#a5f3fc",hover:"#cffafe"},{primary:"#164e63",secondary:"#155e75",muted:"#22d3ee"},"#67e8f9");z("Lime",{primary:"#65a30d",primaryHover:"#4d7c0f",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f7fee7",secondary:"#ecfccb",tertiary:"#d9f99d",hover:"#ecfccb"},{primary:"#1a2e05",secondary:"#365314",muted:"#84cc16"},"#bef264");z("Pink",{primary:"#db2777",primaryHover:"#be185d",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#500724",secondary:"#831843",muted:"#f472b6"},"#f9a8d4");z("Orange",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#7c2d12",muted:"#fb923c"},"#fdba74");z("Fuchsia",{primary:"#c026d3",primaryHover:"#a21caf",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf4ff",secondary:"#fae8ff",tertiary:"#f5d0fe",hover:"#fae8ff"},{primary:"#4a044e",secondary:"#701a75",muted:"#d946ef"},"#e879f9");z("Sky",{primary:"#0284c7",primaryHover:"#0369a1",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#075985",muted:"#38bdf8"},"#7dd3fc");z("Ruby",{primary:"#be123c",primaryHover:"#9f1239",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#fb7185"},"#fda4af");z("Coral",{primary:"#f97316",primaryHover:"#ea580c",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#fb923c"},"#fdba74");V("Midnight",{primary:"#818cf8",primaryHover:"#6366f1",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#020617",secondary:"#0f172a",tertiary:"#1e293b",hover:"#1e293b"},{primary:"#f1f5f9",secondary:"#94a3b8",muted:"#475569"},"#1e293b");V("Obsidian",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#facc15",error:"#fb7185",info:"#38bdf8"},{primary:"#09090b",secondary:"#18181b",tertiary:"#27272a",hover:"#27272a"},{primary:"#fafafa",secondary:"#a1a1aa",muted:"#52525b"},"#3f3f46");V("Eclipse",{primary:"#c084fc",primaryHover:"#a855f7",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#67e8f9"},{primary:"#0c0a1d",secondary:"#1a1533",tertiary:"#2a2248",hover:"#2a2248"},{primary:"#f5f3ff",secondary:"#a78bfa",muted:"#6d5eac"},"#3b3266");V("Onyx",{primary:"#60a5fa",primaryHover:"#3b82f6",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#000000",secondary:"#0a0a0a",tertiary:"#171717",hover:"#171717"},{primary:"#ffffff",secondary:"#a3a3a3",muted:"#525252"},"#262626");V("Carbon",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#67e8f9"},{primary:"#161616",secondary:"#262626",tertiary:"#393939",hover:"#393939"},{primary:"#f4f4f4",secondary:"#c6c6c6",muted:"#6f6f6f"},"#525252");V("Cosmos",{primary:"#6366f1",primaryHover:"#4f46e5",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#030712",secondary:"#111827",tertiary:"#1f2937",hover:"#1f2937"},{primary:"#e5e7eb",secondary:"#9ca3af",muted:"#4b5563"},"#374151");V("Nebula",{primary:"#e879f9",primaryHover:"#d946ef",success:"#4ade80",warning:"#fbbf24",error:"#fb7185",info:"#67e8f9"},{primary:"#0d0117",secondary:"#1a0533",tertiary:"#2d0a52",hover:"#2d0a52"},{primary:"#fae8ff",secondary:"#d8b4fe",muted:"#7c3aed"},"#581c87");V("Abyss",{primary:"#22d3ee",primaryHover:"#06b6d4",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#001219",secondary:"#002a3a",tertiary:"#003e54",hover:"#003e54"},{primary:"#e0f2fe",secondary:"#7dd3fc",muted:"#0369a1"},"#075985");V("Shadow",{primary:"#a3a3a3",primaryHover:"#737373",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#38bdf8"},{primary:"#171717",secondary:"#1f1f1f",tertiary:"#2a2a2a",hover:"#2a2a2a"},{primary:"#e5e5e5",secondary:"#a3a3a3",muted:"#525252"},"#404040");V("Emerald Dark",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#022c22",secondary:"#064e3b",tertiary:"#065f46",hover:"#065f46"},{primary:"#ecfdf5",secondary:"#6ee7b7",muted:"#047857"},"#047857");z("Forest",{primary:"#166534",primaryHover:"#14532d",success:"#22c55e",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");z("Ocean",{primary:"#0369a1",primaryHover:"#075985",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#38bdf8"},"#7dd3fc");z("Desert",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#422006",secondary:"#713f12",muted:"#ca8a04"},"#fde047");z("Sunset",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#f97316"},"#fdba74");z("Aurora",{primary:"#0d9488",primaryHover:"#0f766e",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");z("Lavender",{primary:"#7e22ce",primaryHover:"#6b21a8",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#3b0764",secondary:"#581c87",muted:"#a855f7"},"#d8b4fe");z("Autumn",{primary:"#c2410c",primaryHover:"#9a3412",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#7f1d1d",muted:"#f87171"},"#fca5a5");z("Spring",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#14532d",secondary:"#166534",muted:"#4ade80"},"#86efac");z("Arctic",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");z("Tropical",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");z("Pastel Rose",{primary:"#f472b6",primaryHover:"#ec4899",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#f9a8d4");z("Pastel Sky",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#075985",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");z("Pastel Mint",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#065f46",secondary:"#047857",muted:"#6ee7b7"},"#a7f3d0");z("Pastel Peach",{primary:"#fb923c",primaryHover:"#f97316",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#7c2d12",secondary:"#9a3412",muted:"#fdba74"},"#fed7aa");z("Pastel Lavender",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#4c1d95",secondary:"#5b21b6",muted:"#c4b5fd"},"#ddd6fe");z("Pastel Lemon",{primary:"#facc15",primaryHover:"#eab308",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#713f12",secondary:"#854d0e",muted:"#fde047"},"#fef08a");z("Pastel Sage",{primary:"#86efac",primaryHover:"#4ade80",success:"#22c55e",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#166534",secondary:"#15803d",muted:"#86efac"},"#bbf7d0");z("Pastel Coral",{primary:"#fb7185",primaryHover:"#f43f5e",success:"#4ade80",warning:"#fcd34d",error:"#ef4444",info:"#67e8f9"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#881337",secondary:"#9f1239",muted:"#fda4af"},"#fecdd3");z("Banking",{primary:"#1e3a5f",primaryHover:"#152c4a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#334155",muted:"#94a3b8"},"#cbd5e1");z("Healthcare",{primary:"#0891b2",primaryHover:"#0e7490",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#e0f7fa",tertiary:"#b2ebf2",hover:"#e0f7fa"},{primary:"#134e4a",secondary:"#1a6b6a",muted:"#80cbc4"},"#b2dfdb");z("Legal",{primary:"#1e293b",primaryHover:"#0f172a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#0f172a",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");z("Tech Startup",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#1e1b4b",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");z("Enterprise",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#60a5fa"},"#93c5fd");z("Government",{primary:"#1d4ed8",primaryHover:"#1e40af",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#1e293b",muted:"#64748b"},"#cbd5e1");z("Education",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#0891b2"},{primary:"#f0fdf9",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");z("Real Estate",{primary:"#92400e",primaryHover:"#78350f",success:"#059669",warning:"#b45309",error:"#dc2626",info:"#0891b2"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#422006",secondary:"#713f12",muted:"#d97706"},"#fcd34d");z("Nord",{primary:"#5e81ac",primaryHover:"#4c6b90",success:"#a3be8c",warning:"#ebcb8b",error:"#bf616a",info:"#88c0d0"},{primary:"#eceff4",secondary:"#e5e9f0",tertiary:"#d8dee9",hover:"#d8dee9"},{primary:"#2e3440",secondary:"#3b4252",muted:"#4c566a"},"#d8dee9");V("Dracula",{primary:"#bd93f9",primaryHover:"#9d79d9",success:"#50fa7b",warning:"#f1fa8c",error:"#ff5555",info:"#8be9fd"},{primary:"#282a36",secondary:"#343746",tertiary:"#44475a",hover:"#44475a"},{primary:"#f8f8f2",secondary:"#c0c0c0",muted:"#6272a4"},"#44475a");z("Solarized Light",{primary:"#268bd2",primaryHover:"#1a6da0",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#fdf6e3",secondary:"#eee8d5",tertiary:"#e0dbc7",hover:"#eee8d5"},{primary:"#073642",secondary:"#586e75",muted:"#93a1a1"},"#eee8d5");V("Solarized Dark",{primary:"#268bd2",primaryHover:"#3d98db",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#002b36",secondary:"#073642",tertiary:"#0a4858",hover:"#073642"},{primary:"#eee8d5",secondary:"#93a1a1",muted:"#586e75"},"#073642");V("Monokai",{primary:"#66d9ef",primaryHover:"#45c0d6",success:"#a6e22e",warning:"#e6db74",error:"#f92672",info:"#66d9ef"},{primary:"#272822",secondary:"#34352e",tertiary:"#3e3d32",hover:"#3e3d32"},{primary:"#f8f8f2",secondary:"#cfcfc2",muted:"#75715e"},"#3e3d32");V("One Dark",{primary:"#61afef",primaryHover:"#4b9ee0",success:"#98c379",warning:"#e5c07b",error:"#e06c75",info:"#56b6c2"},{primary:"#282c34",secondary:"#2c313a",tertiary:"#353b45",hover:"#353b45"},{primary:"#abb2bf",secondary:"#828997",muted:"#545862"},"#3e4452");V("Synthwave",{primary:"#ff7edb",primaryHover:"#e660c2",success:"#72f1b8",warning:"#fede5d",error:"#fe4450",info:"#36f9f6"},{primary:"#241b2f",secondary:"#2d2140",tertiary:"#362a50",hover:"#362a50"},{primary:"#f0e4fc",secondary:"#b4a0cc",muted:"#6c5c84"},"#4a3866");z("Vaporwave",{primary:"#ff71ce",primaryHover:"#e655b5",success:"#78dcca",warning:"#ffb86c",error:"#ff5555",info:"#76e8fc"},{primary:"#fce4f7",secondary:"#e8d0f4",tertiary:"#d4bcf0",hover:"#e8d0f4"},{primary:"#4a1a4e",secondary:"#7b3f7d",muted:"#c080c0"},"#d8a8e8");V("Terminal Green",{primary:"#00ff41",primaryHover:"#00cc34",success:"#00ff41",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0a0a0a",secondary:"#0d1a0d",tertiary:"#1a2e1a",hover:"#1a2e1a"},{primary:"#00ff41",secondary:"#00cc33",muted:"#008822"},"#003300");z("Sepia",{primary:"#8b6914",primaryHover:"#704f10",success:"#6b8e23",warning:"#cd853f",error:"#b22222",info:"#5f9ea0"},{primary:"#faf0e6",secondary:"#f5e6d3",tertiary:"#eddcc7",hover:"#f5e6d3"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#d7ccc8");z("Vintage",{primary:"#8d6e63",primaryHover:"#6d4c41",success:"#66bb6a",warning:"#ffb300",error:"#e53935",info:"#29b6f6"},{primary:"#efebe9",secondary:"#d7ccc8",tertiary:"#bcaaa4",hover:"#d7ccc8"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#bcaaa4");V("Cyberpunk",{primary:"#00f0ff",primaryHover:"#00c8d4",success:"#39ff14",warning:"#ffff00",error:"#ff003c",info:"#bf00ff"},{primary:"#0a0e17",secondary:"#131824",tertiary:"#1c2333",hover:"#1c2333"},{primary:"#e0fbfc",secondary:"#80d4dd",muted:"#3a6b72"},"#1c3a44");V("Neon",{primary:"#ff00ff",primaryHover:"#cc00cc",success:"#00ff00",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0d0d0d",secondary:"#1a1a1a",tertiary:"#262626",hover:"#262626"},{primary:"#ffffff",secondary:"#cccccc",muted:"#666666"},"#333333");V("Retrowave",{primary:"#f77fbe",primaryHover:"#e462a3",success:"#72f1b8",warning:"#ffe261",error:"#ff4444",info:"#79e8fb"},{primary:"#1b0a2e",secondary:"#261440",tertiary:"#321e52",hover:"#321e52"},{primary:"#ffe6f7",secondary:"#c9a0c9",muted:"#6b4c7a"},"#4a2d66");z("Christmas",{primary:"#c41e3a",primaryHover:"#a01830",success:"#228b22",warning:"#ffd700",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");V("Halloween",{primary:"#ff6600",primaryHover:"#e05500",success:"#4ade80",warning:"#fbbf24",error:"#ff0000",info:"#9333ea"},{primary:"#1a0a00",secondary:"#2d1500",tertiary:"#402000",hover:"#402000"},{primary:"#ffedd5",secondary:"#fdba74",muted:"#9a5c28"},"#5c3400");z("Valentine",{primary:"#e11d48",primaryHover:"#be123c",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#ec4899"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f9a8d4"},"#fda4af");z("Easter",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fef9ff",secondary:"#f3e8ff",tertiary:"#e8d5ff",hover:"#f3e8ff"},{primary:"#581c87",secondary:"#6d28d9",muted:"#c4b5fd"},"#ddd6fe");z("Summer Beach",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#fcd34d");z("Winter Frost",{primary:"#3b82f6",primaryHover:"#2563eb",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#93c5fd"},"#bfdbfe");z("Cherry Blossom",{primary:"#ec4899",primaryHover:"#db2777",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#fbcfe8");z("Harvest",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#d97706"},"#fcd34d");z("Japanese Zen",{primary:"#6b7280",primaryHover:"#4b5563",success:"#6b8e23",warning:"#d4a017",error:"#c0392b",info:"#5f9ea0"},{primary:"#faf9f6",secondary:"#f0ece3",tertiary:"#e6e0d4",hover:"#f0ece3"},{primary:"#2c2c2c",secondary:"#5c5c5c",muted:"#a0998a"},"#d5cec0");z("Moroccan",{primary:"#c2410c",primaryHover:"#9a3412",success:"#15803d",warning:"#ca8a04",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbf0",secondary:"#fef3e0",tertiary:"#fde6c4",hover:"#fef3e0"},{primary:"#3a1a00",secondary:"#7c2d12",muted:"#d97706"},"#f5d0a0");z("Scandinavian",{primary:"#4b5563",primaryHover:"#374151",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ffffff",secondary:"#f9fafb",tertiary:"#f3f4f6",hover:"#f3f4f6"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#e5e7eb");z("Mediterranean",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#2563eb",muted:"#93c5fd"},"#bfdbfe");z("Chinese New Year",{primary:"#dc2626",primaryHover:"#b91c1c",success:"#16a34a",warning:"#d4a017",error:"#ef4444",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#991b1b",muted:"#f87171"},"#fca5a5");z("Indian Festive",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#7c3aed"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#92400e",muted:"#f59e0b"},"#fcd34d");z("Brazilian Carnival",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#facc15",error:"#ef4444",info:"#0ea5e9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");z("African Earth",{primary:"#92400e",primaryHover:"#78350f",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf5f0",secondary:"#f0e6d6",tertiary:"#e6d5bb",hover:"#f0e6d6"},{primary:"#2b1a0e",secondary:"#5c3d1e",muted:"#a08060"},"#d4b896");V("High Contrast Dark",{primary:"#ffff00",primaryHover:"#cccc00",success:"#00ff00",warning:"#ff8c00",error:"#ff0000",info:"#00ffff"},{primary:"#000000",secondary:"#1a1a1a",tertiary:"#333333",hover:"#333333"},{primary:"#ffffff",secondary:"#ffffff",muted:"#cccccc"},"#ffffff");z("Monochrome",{primary:"#404040",primaryHover:"#262626",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fafafa",secondary:"#f0f0f0",tertiary:"#e0e0e0",hover:"#e0e0e0"},{primary:"#1a1a1a",secondary:"#404040",muted:"#808080"},"#c0c0c0");z("Enhanced Contrast",{primary:"#0050b3",primaryHover:"#003d8c",success:"#006400",warning:"#cc7000",error:"#cc0000",info:"#006680"},{primary:"#ffffff",secondary:"#f5f5f5",tertiary:"#ebebeb",hover:"#ebebeb"},{primary:"#000000",secondary:"#1a1a1a",muted:"#595959"},"#8c8c8c");z("Minimalist",{primary:"#18181b",primaryHover:"#27272a",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"},{primary:"#ffffff",secondary:"#fafafa",tertiary:"#f5f5f5",hover:"#f5f5f5"},{primary:"#0a0a0a",secondary:"#404040",muted:"#a3a3a3"},"#e5e5e5");V("Warm Dark",{primary:"#f59e0b",primaryHover:"#d97706",success:"#10b981",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#1c1917",secondary:"#292524",tertiary:"#44403c",hover:"#44403c"},{primary:"#fafaf9",secondary:"#d6d3d1",muted:"#78716c"},"#57534e");V("Soft Dark",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#34d399",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#1e1e2e",secondary:"#262637",tertiary:"#313147",hover:"#313147"},{primary:"#e8e8f0",secondary:"#a0a0b8",muted:"#5c5c74"},"#3e3e58");z("Coffee",{primary:"#6f4e37",primaryHover:"#5c3d28",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf6f1",secondary:"#f0e8dc",tertiary:"#e6d8c6",hover:"#f0e8dc"},{primary:"#2c1a0e",secondary:"#5c3d28",muted:"#a08868"},"#d4c4a8");z("Wine",{primary:"#7f1d1d",primaryHover:"#641717",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");xe.createContext(null);const translations={en:{"calculator.matrixA":"Matrix A","calculator.matrixB":"Matrix B","calculator.exprPlaceholder":"Enter expression (e.g., x^2, sin(x))","calculator.differentiate":"Differentiate","calculator.integrate":"Integrate","calculator.convert":"Convert","plotter.quickAdd":"Quick add preset...","plotter.noPlots":"No plots added yet","plotter.grid":"Grid","plotter.axes":"Axes","editor.latexPlaceholder":"Enter LaTeX equation...","editor.clear":"Clear","editor.recognize":"Recognize","editor.recognizing":"Recognizing...","editor.handwritingNote":"Draw your equation above. Handwriting recognition requires external API integration."},pl:{"calculator.matrixA":"Macierz A","calculator.matrixB":"Macierz B","calculator.exprPlaceholder":"Wprowadź wyrażenie (np. x^2, sin(x))","calculator.differentiate":"Różniczkuj","calculator.integrate":"Całkuj","calculator.convert":"Przelicz","plotter.quickAdd":"Szybko dodaj ustawienie...","plotter.noPlots":"Nie dodano jeszcze żadnych wykresów","plotter.grid":"Siatka","plotter.axes":"Osie","editor.latexPlaceholder":"Wprowadź równanie LaTeX...","editor.clear":"Wyczyść","editor.recognize":"Rozpoznaj","editor.recognizing":"Rozpoznawanie...","editor.handwritingNote":"Narysuj równanie powyżej. Rozpoznawanie pisma wymaga zewnętrznej integracji API."},de:{"calculator.matrixA":"Matrix A","calculator.matrixB":"Matrix B","calculator.exprPlaceholder":"Ausdruck eingeben (z. B. x^2, sin(x))","calculator.differentiate":"Ableiten","calculator.integrate":"Integrieren","calculator.convert":"Umrechnen","plotter.quickAdd":"Voreinstellung schnell hinzufügen...","plotter.noPlots":"Noch keine Diagramme hinzugefügt","plotter.grid":"Raster","plotter.axes":"Achsen","editor.latexPlaceholder":"LaTeX-Gleichung eingeben...","editor.clear":"Löschen","editor.recognize":"Erkennen","editor.recognizing":"Erkennung läuft...","editor.handwritingNote":"Zeichnen Sie Ihre Gleichung oben. Die Handschrifterkennung erfordert eine externe API-Integration."},fr:{"calculator.matrixA":"Matrice A","calculator.matrixB":"Matrice B","calculator.exprPlaceholder":"Saisir une expression (ex. x^2, sin(x))","calculator.differentiate":"Dériver","calculator.integrate":"Intégrer","calculator.convert":"Convertir","plotter.quickAdd":"Ajouter un préréglage rapide...","plotter.noPlots":"Aucun tracé ajouté pour le moment","plotter.grid":"Grille","plotter.axes":"Axes","editor.latexPlaceholder":"Saisir une équation LaTeX...","editor.clear":"Effacer","editor.recognize":"Reconnaître","editor.recognizing":"Reconnaissance...","editor.handwritingNote":"Dessinez votre équation ci-dessus. La reconnaissance d'écriture nécessite une intégration API externe."},es:{"calculator.matrixA":"Matriz A","calculator.matrixB":"Matriz B","calculator.exprPlaceholder":"Introduce una expresión (p. ej. x^2, sin(x))","calculator.differentiate":"Derivar","calculator.integrate":"Integrar","calculator.convert":"Convertir","plotter.quickAdd":"Añadir preajuste rápido...","plotter.noPlots":"Aún no se ha añadido ningún gráfico","plotter.grid":"Cuadrícula","plotter.axes":"Ejes","editor.latexPlaceholder":"Introduce una ecuación LaTeX...","editor.clear":"Borrar","editor.recognize":"Reconocer","editor.recognizing":"Reconociendo...","editor.handwritingNote":"Dibuja tu ecuación arriba. El reconocimiento de escritura requiere integración con una API externa."},it:{"calculator.matrixA":"Matrice A","calculator.matrixB":"Matrice B","calculator.exprPlaceholder":"Inserisci un’espressione (es. x^2, sin(x))","calculator.differentiate":"Derivare","calculator.integrate":"Integrare","calculator.convert":"Converti","plotter.quickAdd":"Aggiungi un preset rapido...","plotter.noPlots":"Nessun grafico aggiunto","plotter.grid":"Griglia","plotter.axes":"Assi","editor.latexPlaceholder":"Inserisci un’equazione LaTeX...","editor.clear":"Cancella","editor.recognize":"Riconosci","editor.recognizing":"Riconoscimento...","editor.handwritingNote":"Disegna la tua equazione qui sopra. Il riconoscimento della scrittura richiede un’integrazione API esterna."},pt:{"calculator.matrixA":"Matriz A","calculator.matrixB":"Matriz B","calculator.exprPlaceholder":"Introduza uma expressão (p. ex. x^2, sin(x))","calculator.differentiate":"Derivar","calculator.integrate":"Integrar","calculator.convert":"Converter","plotter.quickAdd":"Adicionar predefinição rápida...","plotter.noPlots":"Ainda não foram adicionados gráficos","plotter.grid":"Grelha","plotter.axes":"Eixos","editor.latexPlaceholder":"Introduza uma equação LaTeX...","editor.clear":"Limpar","editor.recognize":"Reconhecer","editor.recognizing":"A reconhecer...","editor.handwritingNote":"Desenhe a sua equação acima. O reconhecimento de escrita requer integração com uma API externa."},cs:{"calculator.matrixA":"Matice A","calculator.matrixB":"Matice B","calculator.exprPlaceholder":"Zadejte výraz (např. x^2, sin(x))","calculator.differentiate":"Derivovat","calculator.integrate":"Integrovat","calculator.convert":"Převést","plotter.quickAdd":"Rychle přidat předvolbu...","plotter.noPlots":"Zatím nebyl přidán žádný graf","plotter.grid":"Mřížka","plotter.axes":"Osy","editor.latexPlaceholder":"Zadejte rovnici v LaTeXu...","editor.clear":"Vymazat","editor.recognize":"Rozpoznat","editor.recognizing":"Rozpoznávání...","editor.handwritingNote":"Nakreslete svou rovnici výše. Rozpoznávání rukopisu vyžaduje externí integraci API."},uk:{"calculator.matrixA":"Матриця A","calculator.matrixB":"Матриця B","calculator.exprPlaceholder":"Введіть вираз (напр. x^2, sin(x))","calculator.differentiate":"Диференціювати","calculator.integrate":"Інтегрувати","calculator.convert":"Перетворити","plotter.quickAdd":"Швидко додати пресет...","plotter.noPlots":"Поки що не додано жодного графіка","plotter.grid":"Сітка","plotter.axes":"Осі","editor.latexPlaceholder":"Введіть рівняння в LaTeX...","editor.clear":"Очистити","editor.recognize":"Розпізнати","editor.recognizing":"Розпізнавання...","editor.handwritingNote":"Намалюйте своє рівняння вище. Розпізнавання рукопису потребує зовнішньої інтеграції з API."}},I18nContext=xe.createContext({locale:"en",t:(e,r)=>r??e});function NiceI18nProvider({locale:e="en",overrides:r,children:t}){const a=xe.useMemo(()=>{const n={...translations.en,...translations[e],...r};return{locale:e,t:(i,c)=>n[i]??c??i}},[e,r]);return xe.createElement(I18nContext.Provider,{value:a},t)}function useNiceTranslation(){return xe.useContext(I18nContext)}const MATH_EDITOR_TOUR=[{target:".nice-math-editor",titleKey:"tutorial.mathEditor.intro.title",title:"Math editor",contentKey:"tutorial.mathEditor.intro.content",content:"Write equations as LaTeX or insert symbols from the palette; switch to handwriting input, and preview the rendered formula live.",placement:"auto"}],MATH_SYMBOLS=[{name:"alpha",latex:"\\alpha",category:"greek",preview:"α"},{name:"beta",latex:"\\beta",category:"greek",preview:"β"},{name:"gamma",latex:"\\gamma",category:"greek",preview:"γ"},{name:"delta",latex:"\\delta",category:"greek",preview:"δ"},{name:"epsilon",latex:"\\epsilon",category:"greek",preview:"ε"},{name:"zeta",latex:"\\zeta",category:"greek",preview:"ζ"},{name:"eta",latex:"\\eta",category:"greek",preview:"η"},{name:"theta",latex:"\\theta",category:"greek",preview:"θ"},{name:"iota",latex:"\\iota",category:"greek",preview:"ι"},{name:"kappa",latex:"\\kappa",category:"greek",preview:"κ"},{name:"lambda",latex:"\\lambda",category:"greek",preview:"λ"},{name:"mu",latex:"\\mu",category:"greek",preview:"μ"},{name:"nu",latex:"\\nu",category:"greek",preview:"ν"},{name:"xi",latex:"\\xi",category:"greek",preview:"ξ"},{name:"pi",latex:"\\pi",category:"greek",preview:"π"},{name:"rho",latex:"\\rho",category:"greek",preview:"ρ"},{name:"sigma",latex:"\\sigma",category:"greek",preview:"σ"},{name:"tau",latex:"\\tau",category:"greek",preview:"τ"},{name:"upsilon",latex:"\\upsilon",category:"greek",preview:"υ"},{name:"phi",latex:"\\phi",category:"greek",preview:"φ"},{name:"chi",latex:"\\chi",category:"greek",preview:"χ"},{name:"psi",latex:"\\psi",category:"greek",preview:"ψ"},{name:"omega",latex:"\\omega",category:"greek",preview:"ω"},{name:"Gamma",latex:"\\Gamma",category:"greek",preview:"Γ"},{name:"Delta",latex:"\\Delta",category:"greek",preview:"Δ"},{name:"Theta",latex:"\\Theta",category:"greek",preview:"Θ"},{name:"Lambda",latex:"\\Lambda",category:"greek",preview:"Λ"},{name:"Xi",latex:"\\Xi",category:"greek",preview:"Ξ"},{name:"Pi",latex:"\\Pi",category:"greek",preview:"Π"},{name:"Sigma",latex:"\\Sigma",category:"greek",preview:"Σ"},{name:"Phi",latex:"\\Phi",category:"greek",preview:"Φ"},{name:"Psi",latex:"\\Psi",category:"greek",preview:"Ψ"},{name:"Omega",latex:"\\Omega",category:"greek",preview:"Ω"},{name:"plus/minus",latex:"\\pm",category:"operators",preview:"±"},{name:"minus/plus",latex:"\\mp",category:"operators",preview:"∓"},{name:"times",latex:"\\times",category:"operators",preview:"×"},{name:"divide",latex:"\\div",category:"operators",preview:"÷"},{name:"cdot",latex:"\\cdot",category:"operators",preview:"·"},{name:"star",latex:"\\star",category:"operators",preview:"⋆"},{name:"circle",latex:"\\circ",category:"operators",preview:"∘"},{name:"bullet",latex:"\\bullet",category:"operators",preview:"•"},{name:"oplus",latex:"\\oplus",category:"operators",preview:"⊕"},{name:"otimes",latex:"\\otimes",category:"operators",preview:"⊗"},{name:"odot",latex:"\\odot",category:"operators",preview:"⊙"},{name:"less than",latex:"<",category:"relations",preview:"<"},{name:"greater than",latex:">",category:"relations",preview:">"},{name:"less or equal",latex:"\\leq",category:"relations",preview:"≤"},{name:"greater or equal",latex:"\\geq",category:"relations",preview:"≥"},{name:"not equal",latex:"\\neq",category:"relations",preview:"≠"},{name:"approximately",latex:"\\approx",category:"relations",preview:"≈"},{name:"equivalent",latex:"\\equiv",category:"relations",preview:"≡"},{name:"similar",latex:"\\sim",category:"relations",preview:"∼"},{name:"proportional",latex:"\\propto",category:"relations",preview:"∝"},{name:"perpendicular",latex:"\\perp",category:"relations",preview:"⊥"},{name:"parallel",latex:"\\parallel",category:"relations",preview:"∥"},{name:"right arrow",latex:"\\rightarrow",category:"arrows",preview:"→"},{name:"left arrow",latex:"\\leftarrow",category:"arrows",preview:"←"},{name:"double right",latex:"\\Rightarrow",category:"arrows",preview:"⇒"},{name:"double left",latex:"\\Leftarrow",category:"arrows",preview:"⇐"},{name:"iff",latex:"\\Leftrightarrow",category:"arrows",preview:"⇔"},{name:"up arrow",latex:"\\uparrow",category:"arrows",preview:"↑"},{name:"down arrow",latex:"\\downarrow",category:"arrows",preview:"↓"},{name:"maps to",latex:"\\mapsto",category:"arrows",preview:"↦"},{name:"sine",latex:"\\sin",category:"functions",preview:"sin"},{name:"cosine",latex:"\\cos",category:"functions",preview:"cos"},{name:"tangent",latex:"\\tan",category:"functions",preview:"tan"},{name:"cotangent",latex:"\\cot",category:"functions",preview:"cot"},{name:"arcsine",latex:"\\arcsin",category:"functions",preview:"arcsin"},{name:"arccosine",latex:"\\arccos",category:"functions",preview:"arccos"},{name:"arctangent",latex:"\\arctan",category:"functions",preview:"arctan"},{name:"logarithm",latex:"\\log",category:"functions",preview:"log"},{name:"natural log",latex:"\\ln",category:"functions",preview:"ln"},{name:"exponential",latex:"\\exp",category:"functions",preview:"exp"},{name:"limit",latex:"\\lim",category:"functions",preview:"lim"},{name:"supremum",latex:"\\sup",category:"functions",preview:"sup"},{name:"infimum",latex:"\\inf",category:"functions",preview:"inf"},{name:"maximum",latex:"\\max",category:"functions",preview:"max"},{name:"minimum",latex:"\\min",category:"functions",preview:"min"},{name:"hat",latex:"\\hat{x}",category:"accents",preview:"x̂"},{name:"bar",latex:"\\bar{x}",category:"accents",preview:"x̄"},{name:"vector",latex:"\\vec{x}",category:"accents",preview:"x⃗"},{name:"dot",latex:"\\dot{x}",category:"accents",preview:"ẋ"},{name:"double dot",latex:"\\ddot{x}",category:"accents",preview:"ẍ"},{name:"tilde",latex:"\\tilde{x}",category:"accents",preview:"x̃"},{name:"parentheses",latex:"\\left( \\right)",category:"delimiters",preview:"( )"},{name:"brackets",latex:"\\left[ \\right]",category:"delimiters",preview:"[ ]"},{name:"braces",latex:"\\left\\{ \\right\\}",category:"delimiters",preview:"{ }"},{name:"angle brackets",latex:"\\left\\langle \\right\\rangle",category:"delimiters",preview:"⟨ ⟩"},{name:"ceiling",latex:"\\left\\lceil \\right\\rceil",category:"delimiters",preview:"⌈ ⌉"},{name:"floor",latex:"\\left\\lfloor \\right\\rfloor",category:"delimiters",preview:"⌊ ⌋"},{name:"absolute",latex:"\\left| \\right|",category:"delimiters",preview:"| |"},{name:"norm",latex:"\\left\\| \\right\\|",category:"delimiters",preview:"‖ ‖"},{name:"element of",latex:"\\in",category:"sets",preview:"∈"},{name:"not element",latex:"\\notin",category:"sets",preview:"∉"},{name:"contains",latex:"\\ni",category:"sets",preview:"∋"},{name:"subset",latex:"\\subset",category:"sets",preview:"⊂"},{name:"superset",latex:"\\supset",category:"sets",preview:"⊃"},{name:"subset or equal",latex:"\\subseteq",category:"sets",preview:"⊆"},{name:"union",latex:"\\cup",category:"sets",preview:"∪"},{name:"intersection",latex:"\\cap",category:"sets",preview:"∩"},{name:"set minus",latex:"\\setminus",category:"sets",preview:"∖"},{name:"empty set",latex:"\\emptyset",category:"sets",preview:"∅"},{name:"naturals",latex:"\\mathbb{N}",category:"sets",preview:"ℕ"},{name:"integers",latex:"\\mathbb{Z}",category:"sets",preview:"ℤ"},{name:"rationals",latex:"\\mathbb{Q}",category:"sets",preview:"ℚ"},{name:"reals",latex:"\\mathbb{R}",category:"sets",preview:"ℝ"},{name:"complex",latex:"\\mathbb{C}",category:"sets",preview:"ℂ"},{name:"for all",latex:"\\forall",category:"logic",preview:"∀"},{name:"exists",latex:"\\exists",category:"logic",preview:"∃"},{name:"not exists",latex:"\\nexists",category:"logic",preview:"∄"},{name:"and",latex:"\\land",category:"logic",preview:"∧"},{name:"or",latex:"\\lor",category:"logic",preview:"∨"},{name:"not",latex:"\\neg",category:"logic",preview:"¬"},{name:"therefore",latex:"\\therefore",category:"logic",preview:"∴"},{name:"because",latex:"\\because",category:"logic",preview:"∵"},{name:"integral",latex:"\\int",category:"calculus",preview:"∫"},{name:"double integral",latex:"\\iint",category:"calculus",preview:"∬"},{name:"triple integral",latex:"\\iiint",category:"calculus",preview:"∭"},{name:"contour integral",latex:"\\oint",category:"calculus",preview:"∮"},{name:"partial",latex:"\\partial",category:"calculus",preview:"∂"},{name:"nabla/gradient",latex:"\\nabla",category:"calculus",preview:"∇"},{name:"summation",latex:"\\sum",category:"calculus",preview:"Σ"},{name:"product",latex:"\\prod",category:"calculus",preview:"Π"},{name:"infinity",latex:"\\infty",category:"calculus",preview:"∞"},{name:"matrix",latex:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",category:"matrices",preview:"[ ]"},{name:"determinant",latex:"\\begin{vmatrix} a & b \\\\ c & d \\end{vmatrix}",category:"matrices",preview:"| |"},{name:"bracket matrix",latex:"\\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix}",category:"matrices",preview:"[[ ]]"},{name:"cases",latex:"\\begin{cases} a & \\text{if } x > 0 \\\\ b & \\text{otherwise} \\end{cases}",category:"matrices",preview:"{ }"}];function getSymbolsByCategory(e){return MATH_SYMBOLS.filter(r=>r.category===e)}const EQUATION_TEMPLATES=[{name:"Fraction",latex:"\\frac{a}{b}",category:"basic"},{name:"Square root",latex:"\\sqrt{x}",category:"basic"},{name:"Nth root",latex:"\\sqrt[n]{x}",category:"basic"},{name:"Power",latex:"x^{n}",category:"basic"},{name:"Subscript",latex:"x_{n}",category:"basic"},{name:"Both",latex:"x_{i}^{n}",category:"basic"},{name:"Derivative",latex:"\\frac{d}{dx}f(x)",category:"calculus"},{name:"Partial derivative",latex:"\\frac{\\partial f}{\\partial x}",category:"calculus"},{name:"Definite integral",latex:"\\int_{a}^{b} f(x)\\,dx",category:"calculus"},{name:"Indefinite integral",latex:"\\int f(x)\\,dx",category:"calculus"},{name:"Limit",latex:"\\lim_{x \\to a} f(x)",category:"calculus"},{name:"Summation",latex:"\\sum_{i=1}^{n} a_i",category:"calculus"},{name:"Product",latex:"\\prod_{i=1}^{n} a_i",category:"calculus"},{name:"Quadratic formula",latex:"x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}",category:"algebra"},{name:"Binomial",latex:"\\binom{n}{k} = \\frac{n!}{k!(n-k)!}",category:"algebra"},{name:"System of equations",latex:"\\begin{cases} ax + by = c \\\\ dx + ey = f \\end{cases}",category:"algebra"},{name:"Pythagorean",latex:"a^2 + b^2 = c^2",category:"geometry"},{name:"Circle area",latex:"A = \\pi r^2",category:"geometry"},{name:"Sphere volume",latex:"V = \\frac{4}{3}\\pi r^3",category:"geometry"},{name:"Euler's identity",latex:"e^{i\\pi} + 1 = 0",category:"geometry"},{name:"Mean",latex:"\\bar{x} = \\frac{1}{n}\\sum_{i=1}^{n} x_i",category:"statistics"},{name:"Variance",latex:"\\sigma^2 = \\frac{1}{n}\\sum_{i=1}^{n}(x_i - \\bar{x})^2",category:"statistics"},{name:"Normal distribution",latex:"f(x) = \\frac{1}{\\sigma\\sqrt{2\\pi}}e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}",category:"statistics"},{name:"Einstein mass-energy",latex:"E = mc^2",category:"physics"},{name:"Newton's second law",latex:"F = ma",category:"physics"},{name:"Schrödinger equation",latex:"i\\hbar\\frac{\\partial}{\\partial t}\\Psi = \\hat{H}\\Psi",category:"physics"},{name:"Maxwell's equations",latex:"\\nabla \\cdot \\vec{E} = \\frac{\\rho}{\\epsilon_0}",category:"physics"}];class MathEditorService{constructor(r={}){C(this,"equations",new Map);C(this,"config");C(this,"nextNumber");this.config={enableNumbering:r.enableNumbering??!0,startNumber:r.startNumber??1,renderDelay:r.renderDelay??100},this.nextNumber=this.config.startNumber}createEquation(r,t){const a={id:this.generateId(),latex:r,label:t,number:this.config.enableNumbering?this.nextNumber++:void 0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return this.equations.set(a.id,a),a}updateEquation(r,t,a){const n=this.equations.get(r);if(!n)throw new Error(`Equation not found: ${r}`);const o={...n,latex:t,label:a??n.label,updatedAt:new Date().toISOString()};return this.equations.set(r,o),o}deleteEquation(r){this.equations.delete(r)}getEquation(r){return this.equations.get(r)}listEquations(){return Array.from(this.equations.values()).sort((r,t)=>new Date(r.createdAt).getTime()-new Date(t.createdAt).getTime())}exportToLatex(){const r=["\\documentclass{article}","\\usepackage{amsmath}","\\usepackage{amssymb}","","\\begin{document}",""];for(const t of this.listEquations())t.number!==void 0?(r.push("\\begin{equation}"),t.label&&r.push(`\\label{${t.label}}`),r.push(t.latex),r.push("\\end{equation}")):(r.push("\\["),r.push(t.latex),r.push("\\]")),r.push("");return r.push("\\end{document}"),r.join(`
|
|
28
|
-
`)}parseLatex(r){const t=[],a=/\\\[([\s\S]*?)\\\]/g;let n;for(;(n=a.exec(r))!==null;)t.push(this.createEquation(n[1].trim()));const o=/\\begin\{equation\}([\s\S]*?)\\end\{equation\}/g;for(;(n=o.exec(r))!==null;){const i=n[1].match(/\\label\{([^}]+)\}/),c=n[1].replace(/\\label\{[^}]+\}/,"").trim();t.push(this.createEquation(c,i==null?void 0:i[1]))}return t}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}}function createMathEditorService(e){return new MathEditorService(e)}async function recognizeHandwriting(e){return await new Promise(t=>setTimeout(t,500)),{latex:e.reduce((t,a)=>t+a.points.length,0)>50?"\\sqrt{x^2 + y^2}":"x",confidence:.85,alternatives:["x","X","\\times"]}}const MathEditorContext=xe.createContext(null);function useMathEditor(){const e=xe.useContext(MathEditorContext);if(!e)throw new Error("useMathEditor must be used within MathEditorProvider");return e}const styles$3={container:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"'Inter', sans-serif",fontSize:"14px"},toolbar:{display:"flex",gap:"8px",padding:"8px",borderBottom:"1px solid var(--nice-border, #e0e0e0)",backgroundColor:"var(--nice-bg-secondary, #fafafa)",flexWrap:"wrap",alignItems:"center"},main:{display:"flex",flex:1,overflow:"hidden"},sidebar:{width:"200px",borderRight:"1px solid var(--nice-border, #e0e0e0)",overflow:"auto",backgroundColor:"var(--nice-bg-secondary, #f5f5f5)"},editor:{flex:1,display:"flex",flexDirection:"column",padding:"16px",overflow:"auto"},input:{width:"100%",minHeight:"100px",padding:"12px",fontFamily:"'JetBrains Mono', monospace",fontSize:"14px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",resize:"vertical"},preview:{marginTop:"16px",padding:"20px",backgroundColor:"var(--nice-bg, #fff)",border:"1px solid var(--nice-border, #e0e0e0)",borderRadius:"4px",minHeight:"60px",fontSize:"20px",textAlign:"center"},button:{padding:"6px 12px",backgroundColor:"var(--nice-primary-hover, #1976d2)",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px"},symbolGrid:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"4px",padding:"8px"},symbolButton:{padding:"8px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",backgroundColor:"var(--nice-bg, #fff)",cursor:"pointer",fontSize:"16px",textAlign:"center"},categoryHeader:{padding:"8px 12px",backgroundColor:"var(--nice-border, #e0e0e0)",fontWeight:600,fontSize:"12px",textTransform:"uppercase"},canvas:{width:"100%",height:"200px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",backgroundColor:"var(--nice-bg, #fff)",cursor:"crosshair"}};function NiceMathEditor({service:e,initialLatex:r="",onChange:t,className:a,style:n,tutorial:o}){const{t:i}=useNiceTranslation(),[c,f]=xe.useState(r),[s,d]=xe.useState("input"),m=xe.useRef(null),y=xe.useCallback(b=>{f(b),t==null||t(b)},[t]),g=xe.useCallback(b=>{const l=m.current;if(!l){y(c+b);return}const p=l.selectionStart,h=l.selectionEnd,j=c.slice(0,p)+b+c.slice(h);y(j),setTimeout(()=>{l.focus(),l.selectionStart=l.selectionEnd=p+b.length},0)},[c,y]),w=xe.useCallback(b=>{g(b.latex)},[g]),u={service:e,latex:c,setLatex:y,insertSymbol:g,insertTemplate:w,mode:s,setMode:d};return jsxRuntime.jsx(MathEditorContext.Provider,{value:u,children:jsxRuntime.jsxs("div",{className:`nice-math-editor ${a??""}`,style:{position:"relative",...styles$3.container,...n},children:[jsxRuntime.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:jsxRuntime.jsx(wl,{steps:xl(o,MATH_EDITOR_TOUR)})}),jsxRuntime.jsx(Toolbar$1,{}),jsxRuntime.jsxs("div",{style:styles$3.main,children:[jsxRuntime.jsx(SymbolPalette,{}),jsxRuntime.jsx("div",{style:styles$3.editor,children:s==="input"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("textarea",{ref:m,value:c,onChange:b=>y(b.target.value),placeholder:i("editor.latexPlaceholder","Enter LaTeX equation..."),style:styles$3.input}),jsxRuntime.jsx(LatexPreview,{latex:c})]}):jsxRuntime.jsx(HandwritingCanvas,{})})]})]})})}function Toolbar$1(){const{mode:e,setMode:r,latex:t,insertTemplate:a}=useMathEditor(),[n,o]=xe.useState(!1);return jsxRuntime.jsxs("div",{style:styles$3.toolbar,children:[jsxRuntime.jsx("button",{onClick:()=>r("input"),style:{...styles$3.button,backgroundColor:e==="input"?"var(--nice-primary-hover, #1976d2)":"var(--nice-text-secondary, #9e9e9e)"},children:"⌨️ LaTeX Input"}),jsxRuntime.jsx("button",{onClick:()=>r("handwriting"),style:{...styles$3.button,backgroundColor:e==="handwriting"?"var(--nice-primary-hover, #1976d2)":"var(--nice-text-secondary, #9e9e9e)"},children:"✏️ Handwriting"}),jsxRuntime.jsx("div",{style:{borderLeft:"1px solid var(--nice-border, #ccc)",height:"24px",margin:"0 8px"}}),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsx("button",{onClick:()=>o(!n),style:styles$3.button,children:"📐 Templates ▾"}),n&&jsxRuntime.jsx("div",{style:{position:"absolute",top:"100%",left:0,backgroundColor:"var(--nice-bg, #fff)",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",boxShadow:"0 2px 8px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",zIndex:100,width:"300px",maxHeight:"400px",overflow:"auto"},children:["basic","calculus","algebra","geometry","statistics","physics"].map(i=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:styles$3.categoryHeader,children:i}),EQUATION_TEMPLATES.filter(c=>c.category===i).map(c=>jsxRuntime.jsxs("div",{onClick:()=>{a(c),o(!1)},style:{padding:"8px 12px",cursor:"pointer",borderBottom:"1px solid var(--nice-border, #eee)"},onMouseOver:f=>f.target.style.backgroundColor="var(--nice-bg-secondary, #f5f5f5)",onMouseOut:f=>f.target.style.backgroundColor="transparent",children:[jsxRuntime.jsx("div",{style:{fontWeight:500},children:c.name}),jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",fontFamily:"monospace"},children:[c.latex.substring(0,40),c.latex.length>40?"...":""]})]},c.name))]},i))})]}),jsxRuntime.jsx("div",{style:{flex:1}}),jsxRuntime.jsx("button",{onClick:()=>navigator.clipboard.writeText(t),style:{...styles$3.button,backgroundColor:"var(--nice-success, #4caf50)"},children:"📋 Copy LaTeX"})]})}function SymbolPalette(){const{insertSymbol:e}=useMathEditor(),[r,t]=xe.useState("greek"),a=["greek","operators","relations","arrows","functions","accents","delimiters","sets","logic","calculus","matrices"],n=getSymbolsByCategory(r);return jsxRuntime.jsxs("div",{style:styles$3.sidebar,children:[jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",padding:"8px",gap:"4px"},children:a.map(o=>jsxRuntime.jsx("button",{onClick:()=>t(o),style:{padding:"4px 8px",fontSize:"11px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",backgroundColor:r===o?"var(--nice-primary-hover, #1976d2)":"var(--nice-bg, #fff)",color:r===o?"var(--nice-bg, #fff)":"var(--nice-text, #333)",cursor:"pointer"},children:o},o))}),jsxRuntime.jsx("div",{style:styles$3.symbolGrid,children:n.map(o=>jsxRuntime.jsx("button",{onClick:()=>e(o.latex),style:styles$3.symbolButton,title:`${o.name}: ${o.latex}`,children:o.preview||o.latex},o.name))})]})}function LatexPreview({latex:e}){return jsxRuntime.jsxs("div",{style:styles$3.preview,children:[jsxRuntime.jsx("div",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",marginBottom:"8px"},children:"Preview (requires KaTeX/MathJax integration):"}),jsxRuntime.jsx("code",{style:{fontSize:"16px"},children:e||"(empty)"})]})}function HandwritingCanvas(){const{t:e}=useNiceTranslation(),{setLatex:r,setMode:t}=useMathEditor(),a=xe.useRef(null),[n,o]=xe.useState([]),[i,c]=xe.useState([]),[f,s]=xe.useState(!1),[d,m]=xe.useState(!1),y=l=>{const p=a.current;if(!p)return;s(!0);const h=p.getBoundingClientRect();c([{x:l.clientX-h.left,y:l.clientY-h.top,pressure:l.pressure,timestamp:Date.now()}])},g=l=>{if(!f)return;const p=a.current,h=p==null?void 0:p.getContext("2d");if(!p||!h)return;const j=p.getBoundingClientRect(),x={x:l.clientX-j.left,y:l.clientY-j.top,pressure:l.pressure,timestamp:Date.now()};if(c(v=>[...v,x]),i.length>0){const v=i[i.length-1];h.beginPath(),h.moveTo(v.x,v.y),h.lineTo(x.x,x.y),h.strokeStyle="var(--nice-text, #000)",h.lineWidth=2,h.lineCap="round",h.stroke()}},w=()=>{if(f){if(s(!1),i.length>1){const l={id:Date.now().toString(),points:[...i]};o(p=>[...p,l])}c([])}},u=()=>{const l=a.current,p=l==null?void 0:l.getContext("2d");p&&l&&p.clearRect(0,0,l.width,l.height),o([])},b=async()=>{if(n.length!==0){m(!0);try{const l=await recognizeHandwriting(n);r(l.latex),t("input")}finally{m(!1)}}};return xe.useEffect(()=>{const l=a.current;l&&(l.width=l.offsetWidth,l.height=200)},[]),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("canvas",{ref:a,style:styles$3.canvas,onPointerDown:y,onPointerMove:g,onPointerUp:w,onPointerLeave:w}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"12px"},children:[jsxRuntime.jsx("button",{onClick:u,style:{...styles$3.button,backgroundColor:"var(--nice-danger, #f44336)"},children:e("editor.clear","Clear")}),jsxRuntime.jsx("button",{onClick:b,disabled:n.length===0||d,style:styles$3.button,children:d?e("editor.recognizing","Recognizing..."):e("editor.recognize","Recognize")})]}),jsxRuntime.jsx("p",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",marginTop:"8px"},children:e("editor.handwritingNote","Draw your equation above. Handwriting recognition requires external API integration.")})]})}const mathConstants={pi:Math.PI,PI:Math.PI,e:Math.E,E:Math.E,phi:(1+Math.sqrt(5))/2,tau:Math.PI*2},mathFunctions={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,sqrt:Math.sqrt,cbrt:Math.cbrt,abs:Math.abs,floor:Math.floor,ceil:Math.ceil,round:Math.round,exp:Math.exp,log:Math.log,log10:Math.log10,log2:Math.log2,pow:Math.pow,min:Math.min,max:Math.max,sign:Math.sign,hypot:Math.hypot,sec:e=>1/Math.cos(e),csc:e=>1/Math.sin(e),cot:e=>1/Math.tan(e),ln:Math.log};class ExpressionParser{constructor(){C(this,"pos",0);C(this,"expr","")}parse(r){this.expr=r.replace(/\s+/g,""),this.pos=0;const t=this.parseAddSub();return a=>this.evaluate(t,{...mathConstants,...a})}parseAddSub(){let r=this.parseMulDiv();for(;this.pos<this.expr.length;){const t=this.expr[this.pos];if(t!=="+"&&t!=="-")break;this.pos++;const a=this.parseMulDiv();r={type:"binary",op:t,left:r,right:a}}return r}parseMulDiv(){let r=this.parsePower();for(;this.pos<this.expr.length;){const t=this.expr[this.pos];if(t!=="*"&&t!=="/")break;this.pos++;const a=this.parsePower();r={type:"binary",op:t,left:r,right:a}}return r}parsePower(){let r=this.parseUnary();for(;this.pos<this.expr.length&&this.expr[this.pos]==="^";){this.pos++;const t=this.parseUnary();r={type:"binary",op:"^",left:r,right:t}}return r}parseUnary(){return this.expr[this.pos]==="-"?(this.pos++,{type:"unary",op:"-",arg:this.parseUnary()}):(this.expr[this.pos]==="+"&&this.pos++,this.parsePrimary())}parsePrimary(){if(this.expr[this.pos]==="("){this.pos++;const a=this.parseAddSub();return this.expr[this.pos]===")"&&this.pos++,a}const r=this.expr.slice(this.pos).match(/^(\d+\.?\d*)/);if(r)return this.pos+=r[1].length,{type:"number",value:parseFloat(r[1])};const t=this.expr.slice(this.pos).match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);if(t){const a=t[1];if(this.pos+=a.length,this.expr[this.pos]==="("){this.pos++;const n=[];for(;this.expr[this.pos]!==")"&&this.pos<this.expr.length;)n.push(this.parseAddSub()),this.expr[this.pos]===","&&this.pos++;return this.expr[this.pos]===")"&&this.pos++,{type:"call",name:a,args:n}}return{type:"variable",name:a}}return{type:"number",value:0}}evaluate(r,t){switch(r.type){case"number":return r.value;case"variable":if(r.name in t)return t[r.name];throw new Error(`Unknown variable: ${r.name}`);case"unary":return r.op==="-"?-this.evaluate(r.arg,t):this.evaluate(r.arg,t);case"binary":{const a=this.evaluate(r.left,t),n=this.evaluate(r.right,t);switch(r.op){case"+":return a+n;case"-":return a-n;case"*":return a*n;case"/":return a/n;case"^":return Math.pow(a,n);default:return 0}}case"call":{const a=mathFunctions[r.name];if(!a)throw new Error(`Unknown function: ${r.name}`);const n=r.args.map(o=>this.evaluate(o,t));return a(...n)}default:return 0}}}class GraphService{constructor(r={}){C(this,"plots",new Map);C(this,"parser",new ExpressionParser);C(this,"config");this.config={defaultResolution:r.defaultResolution??200,maxResolution:r.maxResolution??1e3}}addPlot(r){const t={id:this.generateId(),type:r.type,expression:r.expression,expressionY:r.expressionY,expressionZ:r.expressionZ,label:r.label,color:r.color??{r:66,g:133,b:244},lineWidth:r.lineWidth??2,visible:r.visible??!0,parameterRange:r.parameterRange??{min:-Math.PI,max:Math.PI},parameterRange2:r.parameterRange2??{min:-Math.PI,max:Math.PI},resolution:r.resolution??this.config.defaultResolution};return this.plots.set(t.id,t),t}updatePlot(r,t){const a=this.plots.get(r);if(!a)throw new Error(`Plot not found: ${r}`);const n={...a,...t,id:a.id};return this.plots.set(r,n),n}removePlot(r){this.plots.delete(r)}getPlots(){return Array.from(this.plots.values())}getPlot(r){return this.plots.get(r)}compute2DFunction(r,t,a,n){const o=this.parser.parse(r),i=[],c=(t.max-t.min)/a;for(let f=0;f<=a;f++){const s=t.min+f*c;try{const d=o({x:s,...n});Number.isFinite(d)&&i.push({x:s,y:d})}catch{}}return i}compute2DParametric(r,t,a,n,o){const i=this.parser.parse(r),c=this.parser.parse(t),f=[],s=(a.max-a.min)/n;for(let d=0;d<=n;d++){const m=a.min+d*s;try{const y=i({t:m,...o}),g=c({t:m,...o});Number.isFinite(y)&&Number.isFinite(g)&&f.push({x:y,y:g})}catch{}}return f}compute2DPolar(r,t,a,n){const o=this.parser.parse(r),i=[],c=(t.max-t.min)/a;for(let f=0;f<=a;f++){const s=t.min+f*c;try{const d=o({theta:s,t:s,...n});if(Number.isFinite(d)){const m=d*Math.cos(s),y=d*Math.sin(s);i.push({x:m,y})}}catch{}}return i}compute3DSurface(r,t,a,n,o){const i=this.parser.parse(r),c=[],f=(t.max-t.min)/n,s=(a.max-a.min)/n;for(let d=0;d<=n;d++){const m=[],y=t.min+d*f;for(let g=0;g<=n;g++){const w=a.min+g*s;try{const u=i({x:y,y:w,...o});Number.isFinite(u)?m.push({x:y,y:w,z:u}):m.push({x:y,y:w,z:0})}catch{m.push({x:y,y:w,z:0})}}c.push(m)}return c}exportSVG(r,t,a,n){const i=a-80,c=n-40*2,f=m=>40+(m-t.xRange.min)/(t.xRange.max-t.xRange.min)*i,s=m=>n-40-(m-t.yRange.min)/(t.yRange.max-t.yRange.min)*c,d=[`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${n}">`,`<rect width="100%" height="100%" fill="rgb(${t.backgroundColor.r},${t.backgroundColor.g},${t.backgroundColor.b})"/>`];if(t.showGrid){d.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');for(let m=Math.ceil(t.xRange.min);m<=t.xRange.max;m++){const y=f(m);d.push(`<line x1="${y}" y1="40" x2="${y}" y2="${n-40}"/>`)}for(let m=Math.ceil(t.yRange.min);m<=t.yRange.max;m++){const y=s(m);d.push(`<line x1="40" y1="${y}" x2="${a-40}" y2="${y}"/>`)}d.push("</g>")}if(t.showAxes){d.push('<g stroke="var(--nice-text, #333)" stroke-width="1">');const m=s(0),y=f(0);d.push(`<line x1="40" y1="${m}" x2="${a-40}" y2="${m}"/>`),d.push(`<line x1="${y}" y1="40" x2="${y}" y2="${n-40}"/>`),d.push("</g>")}for(const m of r.filter(y=>y.visible))if(m.type==="2d-function"){const y=this.compute2DFunction(m.expression,t.xRange,m.resolution||200);if(y.length>0){const g=y.map((w,u)=>`${u===0?"M":"L"}${f(w.x)},${s(w.y)}`).join(" ");d.push(`<path d="${g}" fill="none" stroke="rgb(${m.color.r},${m.color.g},${m.color.b})" stroke-width="${m.lineWidth}"/>`)}}return t.showLabels&&(d.push(`<text x="${a/2}" y="${n-10}" text-anchor="middle" font-size="12">x</text>`),d.push(`<text x="10" y="${n/2}" text-anchor="middle" font-size="12" transform="rotate(-90,10,${n/2})">y</text>`)),d.push("</svg>"),d.join(`
|
|
29
|
-
`)}async exportPNG(r,t,a,n){const o=this.exportSVG(r,t,a,n);return new Promise((i,c)=>{const f=new Image;f.onload=()=>{const s=document.createElement("canvas");s.width=a,s.height=n;const d=s.getContext("2d");if(!d){c(new Error("Could not get canvas context"));return}d.drawImage(f,0,0),i(s.toDataURL("image/png"))},f.onerror=c,f.src="data:image/svg+xml;base64,"+btoa(o)})}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}}function createGraphService(e){return new GraphService(e)}const FUNCTION_PRESETS=[{name:"Linear",expression:"x",type:"2d-function",category:"basic"},{name:"Quadratic",expression:"x^2",type:"2d-function",category:"basic"},{name:"Cubic",expression:"x^3",type:"2d-function",category:"basic"},{name:"Square root",expression:"sqrt(x)",type:"2d-function",category:"basic"},{name:"Absolute",expression:"abs(x)",type:"2d-function",category:"basic"},{name:"Reciprocal",expression:"1/x",type:"2d-function",category:"basic"},{name:"Sine",expression:"sin(x)",type:"2d-function",category:"trigonometric"},{name:"Cosine",expression:"cos(x)",type:"2d-function",category:"trigonometric"},{name:"Tangent",expression:"tan(x)",type:"2d-function",category:"trigonometric"},{name:"Sine wave",expression:"sin(2*x)",type:"2d-function",category:"trigonometric"},{name:"Damped oscillation",expression:"exp(-x/5)*sin(x*3)",type:"2d-function",category:"trigonometric"},{name:"Exponential",expression:"exp(x)",type:"2d-function",category:"exponential"},{name:"Natural log",expression:"ln(x)",type:"2d-function",category:"exponential"},{name:"Gaussian",expression:"exp(-x^2)",type:"2d-function",category:"exponential"},{name:"Sigmoid",expression:"1/(1+exp(-x))",type:"2d-function",category:"exponential"},{name:"Circle",expression:"cos(t)",expressionY:"sin(t)",type:"2d-parametric",category:"parametric"},{name:"Ellipse",expression:"2*cos(t)",expressionY:"sin(t)",type:"2d-parametric",category:"parametric"},{name:"Lissajous",expression:"sin(3*t)",expressionY:"sin(2*t)",type:"2d-parametric",category:"parametric"},{name:"Spiral",expression:"t*cos(t)",expressionY:"t*sin(t)",type:"2d-parametric",category:"parametric"},{name:"Cardioid",expression:"(1-cos(t))*cos(t)",expressionY:"(1-cos(t))*sin(t)",type:"2d-parametric",category:"parametric"},{name:"Rose curve",expression:"cos(3*t)*cos(t)",expressionY:"cos(3*t)*sin(t)",type:"2d-parametric",category:"parametric"},{name:"Polar rose 3",expression:"cos(3*theta)",type:"2d-polar",category:"polar"},{name:"Polar rose 5",expression:"cos(5*theta)",type:"2d-polar",category:"polar"},{name:"Archimedean spiral",expression:"theta",type:"2d-polar",category:"polar"},{name:"Logarithmic spiral",expression:"exp(theta/10)",type:"2d-polar",category:"polar"},{name:"Paraboloid",expression:"x^2 + y^2",type:"3d-surface",category:"3d"},{name:"Saddle",expression:"x^2 - y^2",type:"3d-surface",category:"3d"},{name:"Ripple",expression:"sin(sqrt(x^2 + y^2))",type:"3d-surface",category:"3d"},{name:"Torus slice",expression:"cos(x)*sin(y)",type:"3d-surface",category:"3d"},{name:"Peaks",expression:"3*(1-x)^2*exp(-x^2-(y+1)^2) - 10*(x/5-x^3-y^5)*exp(-x^2-y^2) - 1/3*exp(-(x+1)^2-y^2)",type:"3d-surface",category:"3d"}],GraphContext=xe.createContext(null);function useGraph(){const e=xe.useContext(GraphContext);if(!e)throw new Error("useGraph must be used within GraphProvider");return e}const styles$2={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",fontSize:"14px"},sidebar:{width:"280px",borderRight:"1px solid var(--nice-border, #e0e0e0)",display:"flex",flexDirection:"column",overflow:"hidden"},plotList:{flex:1,overflow:"auto",padding:"8px"},main:{flex:1,display:"flex",flexDirection:"column",backgroundColor:"var(--nice-bg, #fff)"},canvas:{flex:1,backgroundColor:"var(--nice-bg, #fff)"},toolbar:{display:"flex",gap:"8px",padding:"8px",borderBottom:"1px solid var(--nice-border, #e0e0e0)",alignItems:"center"},button:{padding:"6px 12px",backgroundColor:"var(--nice-primary-hover, #1976d2)",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px"},input:{padding:"6px 8px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",fontSize:"13px"},plotItem:{padding:"8px",marginBottom:"8px",border:"1px solid var(--nice-border, #e0e0e0)",borderRadius:"4px",backgroundColor:"var(--nice-bg-secondary, #fafafa)"}};function NiceGraphPlotter({service:e,width:r=800,height:t=600,className:a,style:n}){const[o,i]=xe.useState([]),[c,f]=xe.useState({xRange:{min:-10,max:10},yRange:{min:-10,max:10},zRange:{min:-5,max:5},showGrid:!0,showAxes:!0,showLabels:!0,backgroundColor:{r:255,g:255,b:255},cameraRotationX:30,cameraRotationY:45,cameraDistance:5}),[s,d]=xe.useState({isPlaying:!1,parameter:"a",currentValue:0,minValue:-5,maxValue:5,speed:1}),m=xe.useCallback(()=>{i(e.getPlots())},[e]),y=xe.useCallback(p=>{f(h=>({...h,...p}))},[]),g=xe.useCallback(p=>{d(h=>({...h,...p}))},[]),w=xe.useCallback(p=>{e.addPlot(p),m()},[e,m]),u=xe.useCallback(p=>{e.removePlot(p),m()},[e,m]),b=xe.useCallback((p,h)=>{e.updatePlot(p,h),m()},[e,m]),l={service:e,plots:o,view:c,setView:y,addPlot:w,removePlot:u,updatePlot:b,animation:s,setAnimation:g,refresh:m};return jsxRuntime.jsx(GraphContext.Provider,{value:l,children:jsxRuntime.jsxs("div",{className:a,style:{...styles$2.container,...n},children:[jsxRuntime.jsxs("div",{style:styles$2.sidebar,children:[jsxRuntime.jsx(PlotControls,{}),jsxRuntime.jsx(PlotList,{})]}),jsxRuntime.jsxs("div",{style:styles$2.main,children:[jsxRuntime.jsx(GraphToolbar,{width:r,height:t}),jsxRuntime.jsx(Canvas2D,{width:r,height:t})]})]})})}function PlotControls(){const{t:e}=useNiceTranslation(),{addPlot:r}=useGraph(),[t,a]=xe.useState("sin(x)"),[n,o]=xe.useState("2d-function"),[i,c]=xe.useState("cos(x)"),f=()=>{r({type:n,expression:t,expressionY:n==="2d-parametric"?i:void 0,color:{r:Math.floor(Math.random()*200),g:Math.floor(Math.random()*200),b:Math.floor(Math.random()*200)}})};return jsxRuntime.jsxs("div",{style:{padding:"12px",borderBottom:"1px solid var(--nice-border, #e0e0e0)"},children:[jsxRuntime.jsx("div",{style:{marginBottom:"8px"},children:jsxRuntime.jsxs("select",{value:n,onChange:s=>o(s.target.value),style:{...styles$2.input,width:"100%"},children:[jsxRuntime.jsx("option",{value:"2d-function",children:"y = f(x)"}),jsxRuntime.jsx("option",{value:"2d-parametric",children:"Parametric (x(t), y(t))"}),jsxRuntime.jsx("option",{value:"2d-polar",children:"Polar r = f(θ)"}),jsxRuntime.jsx("option",{value:"3d-surface",children:"3D Surface z = f(x,y)"})]})}),jsxRuntime.jsx("div",{style:{marginBottom:"8px"},children:jsxRuntime.jsx("input",{type:"text",value:t,onChange:s=>a(s.target.value),placeholder:n==="2d-parametric"?"x(t) = ...":"Expression...",style:{...styles$2.input,width:"100%"}})}),n==="2d-parametric"&&jsxRuntime.jsx("div",{style:{marginBottom:"8px"},children:jsxRuntime.jsx("input",{type:"text",value:i,onChange:s=>c(s.target.value),placeholder:"y(t) = ...",style:{...styles$2.input,width:"100%"}})}),jsxRuntime.jsx("button",{onClick:f,style:{...styles$2.button,width:"100%"},children:"+ Add Plot"}),jsxRuntime.jsxs("select",{onChange:s=>{const d=FUNCTION_PRESETS.find(m=>m.name===s.target.value);d&&r({type:d.type,expression:d.expression,expressionY:d.expressionY,label:d.name,color:{r:Math.floor(Math.random()*200),g:Math.floor(Math.random()*200),b:Math.floor(Math.random()*200)}})},style:{...styles$2.input,width:"100%",marginTop:"8px"},value:"",children:[jsxRuntime.jsx("option",{value:"",disabled:!0,children:e("plotter.quickAdd","Quick add preset...")}),["basic","trigonometric","exponential","parametric","polar","3d"].map(s=>jsxRuntime.jsx("optgroup",{label:s.charAt(0).toUpperCase()+s.slice(1),children:FUNCTION_PRESETS.filter(d=>d.category===s).map(d=>jsxRuntime.jsxs("option",{value:d.name,children:[d.name,": ",d.expression]},d.name))},s))]})]})}function PlotList(){const{t:e}=useNiceTranslation(),{plots:r,removePlot:t,updatePlot:a}=useGraph();return jsxRuntime.jsxs("div",{style:styles$2.plotList,children:[r.length===0&&jsxRuntime.jsx("div",{style:{color:"var(--nice-text-secondary, #666)",textAlign:"center",padding:"16px"},children:e("plotter.noPlots","No plots added yet")}),r.map(n=>jsxRuntime.jsxs("div",{style:styles$2.plotItem,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.visible,onChange:o=>a(n.id,{visible:o.target.checked})}),jsxRuntime.jsx("div",{style:{width:"16px",height:"16px",borderRadius:"3px",backgroundColor:`rgb(${n.color.r},${n.color.g},${n.color.b})`}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:n.label||n.expression}),jsxRuntime.jsx("button",{onClick:()=>t(n.id),style:{padding:"2px 6px",backgroundColor:"var(--nice-danger, #f44336)",color:"white",border:"none",borderRadius:"3px",cursor:"pointer",fontSize:"12px"},children:"×"})]}),jsxRuntime.jsx("div",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",fontFamily:"monospace"},children:n.type==="2d-parametric"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["x(t) = ",n.expression,jsxRuntime.jsx("br",{}),"y(t) = ",n.expressionY]}):n.expression})]},n.id))]})}function GraphToolbar({width:e,height:r}){const{t}=useNiceTranslation(),{service:a,plots:n,view:o,setView:i}=useGraph(),c=()=>{const s=a.exportSVG(n,o,e,r),d=new Blob([s],{type:"image/svg+xml"}),m=URL.createObjectURL(d),y=document.createElement("a");y.href=m,y.download="graph.svg",y.click(),URL.revokeObjectURL(m)},f=async()=>{const s=await a.exportPNG(n,o,e,r),d=document.createElement("a");d.href=s,d.download="graph.png",d.click()};return jsxRuntime.jsxs("div",{style:styles$2.toolbar,children:[jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:["X: ["," ",jsxRuntime.jsx("input",{type:"number",value:o.xRange.min,onChange:s=>i({xRange:{...o.xRange,min:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),","," ",jsxRuntime.jsx("input",{type:"number",value:o.xRange.max,onChange:s=>i({xRange:{...o.xRange,max:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),"]"]}),jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:["Y: ["," ",jsxRuntime.jsx("input",{type:"number",value:o.yRange.min,onChange:s=>i({yRange:{...o.yRange,min:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),","," ",jsxRuntime.jsx("input",{type:"number",value:o.yRange.max,onChange:s=>i({yRange:{...o.yRange,max:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),"]"]}),jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:o.showGrid,onChange:s=>i({showGrid:s.target.checked})}),t("plotter.grid","Grid")]}),jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:o.showAxes,onChange:s=>i({showAxes:s.target.checked})}),t("plotter.axes","Axes")]}),jsxRuntime.jsx("div",{style:{flex:1}}),jsxRuntime.jsx("button",{onClick:c,style:{...styles$2.button,backgroundColor:"var(--nice-success, #4caf50)"},children:"📥 SVG"}),jsxRuntime.jsx("button",{onClick:f,style:{...styles$2.button,backgroundColor:"var(--nice-warning, #ff9800)"},children:"📥 PNG"})]})}function Canvas2D({width:e,height:r}){const t=xe.useRef(null),{service:a,plots:n,view:o,animation:i}=useGraph(),c=40;return xe.useEffect(()=>{const f=t.current,s=f==null?void 0:f.getContext("2d");if(!f||!s)return;s.fillStyle=`rgb(${o.backgroundColor.r},${o.backgroundColor.g},${o.backgroundColor.b})`,s.fillRect(0,0,e,r);const d=e-c*2,m=r-c*2,y=u=>c+(u-o.xRange.min)/(o.xRange.max-o.xRange.min)*d,g=u=>r-c-(u-o.yRange.min)/(o.yRange.max-o.yRange.min)*m;if(o.showGrid){s.strokeStyle="var(--nice-border, #e0e0e0)",s.lineWidth=.5;for(let u=Math.ceil(o.xRange.min);u<=o.xRange.max;u++){const b=y(u);s.beginPath(),s.moveTo(b,c),s.lineTo(b,r-c),s.stroke()}for(let u=Math.ceil(o.yRange.min);u<=o.yRange.max;u++){const b=g(u);s.beginPath(),s.moveTo(c,b),s.lineTo(e-c,b),s.stroke()}}if(o.showAxes){s.strokeStyle="var(--nice-text, #333)",s.lineWidth=1;const u=g(0);s.beginPath(),s.moveTo(c,u),s.lineTo(e-c,u),s.stroke();const b=y(0);if(s.beginPath(),s.moveTo(b,c),s.lineTo(b,r-c),s.stroke(),o.showLabels){s.fillStyle="var(--nice-text, #333)",s.font="12px sans-serif",s.textAlign="center",s.fillText("x",e-c+15,u+4),s.fillText("y",b,c-10),s.font="10px sans-serif";for(let l=Math.ceil(o.xRange.min);l<=o.xRange.max;l++)l!==0&&s.fillText(String(l),y(l),u+15);for(let l=Math.ceil(o.yRange.min);l<=o.yRange.max;l++)l!==0&&(s.textAlign="right",s.fillText(String(l),b-5,g(l)+4))}}const w=i.isPlaying?{[i.parameter]:i.currentValue}:{};for(const u of n.filter(b=>b.visible)){const b=`rgb(${u.color.r},${u.color.g},${u.color.b})`;s.strokeStyle=b,s.lineWidth=u.lineWidth||2;let l=[];switch(u.type){case"2d-function":l=a.compute2DFunction(u.expression,o.xRange,u.resolution||200,w);break;case"2d-parametric":l=a.compute2DParametric(u.expression,u.expressionY||"sin(t)",u.parameterRange||{min:0,max:2*Math.PI},u.resolution||200,w);break;case"2d-polar":l=a.compute2DPolar(u.expression,u.parameterRange||{min:0,max:2*Math.PI},u.resolution||200,w);break}if(l.length>0){s.beginPath();let p=!1;for(const h of l){const j=y(h.x),x=g(h.y);if(x<0||x>r){p=!1;continue}p?s.lineTo(j,x):(s.moveTo(j,x),p=!0)}s.stroke()}}},[n,o,i,a,e,r]),jsxRuntime.jsx("canvas",{ref:t,width:e,height:r,style:styles$2.canvas})}const UNITS=[{name:"Meter",symbol:"m",category:"Length",toBase:e=>e,fromBase:e=>e},{name:"Kilometer",symbol:"km",category:"Length",toBase:e=>e*1e3,fromBase:e=>e/1e3},{name:"Centimeter",symbol:"cm",category:"Length",toBase:e=>e/100,fromBase:e=>e*100},{name:"Millimeter",symbol:"mm",category:"Length",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Mile",symbol:"mi",category:"Length",toBase:e=>e*1609.344,fromBase:e=>e/1609.344},{name:"Yard",symbol:"yd",category:"Length",toBase:e=>e*.9144,fromBase:e=>e/.9144},{name:"Foot",symbol:"ft",category:"Length",toBase:e=>e*.3048,fromBase:e=>e/.3048},{name:"Inch",symbol:"in",category:"Length",toBase:e=>e*.0254,fromBase:e=>e/.0254},{name:"Kilogram",symbol:"kg",category:"Mass",toBase:e=>e,fromBase:e=>e},{name:"Gram",symbol:"g",category:"Mass",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Milligram",symbol:"mg",category:"Mass",toBase:e=>e/1e6,fromBase:e=>e*1e6},{name:"Pound",symbol:"lb",category:"Mass",toBase:e=>e*.453592,fromBase:e=>e/.453592},{name:"Ounce",symbol:"oz",category:"Mass",toBase:e=>e*.0283495,fromBase:e=>e/.0283495},{name:"Ton",symbol:"t",category:"Mass",toBase:e=>e*1e3,fromBase:e=>e/1e3},{name:"Celsius",symbol:"°C",category:"Temperature",toBase:e=>e,fromBase:e=>e},{name:"Fahrenheit",symbol:"°F",category:"Temperature",toBase:e=>(e-32)*5/9,fromBase:e=>e*9/5+32},{name:"Kelvin",symbol:"K",category:"Temperature",toBase:e=>e-273.15,fromBase:e=>e+273.15},{name:"Second",symbol:"s",category:"Time",toBase:e=>e,fromBase:e=>e},{name:"Millisecond",symbol:"ms",category:"Time",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Minute",symbol:"min",category:"Time",toBase:e=>e*60,fromBase:e=>e/60},{name:"Hour",symbol:"hr",category:"Time",toBase:e=>e*3600,fromBase:e=>e/3600},{name:"Day",symbol:"d",category:"Time",toBase:e=>e*86400,fromBase:e=>e/86400},{name:"Week",symbol:"wk",category:"Time",toBase:e=>e*604800,fromBase:e=>e/604800},{name:"Square meter",symbol:"m²",category:"Area",toBase:e=>e,fromBase:e=>e},{name:"Square kilometer",symbol:"km²",category:"Area",toBase:e=>e*1e6,fromBase:e=>e/1e6},{name:"Hectare",symbol:"ha",category:"Area",toBase:e=>e*1e4,fromBase:e=>e/1e4},{name:"Acre",symbol:"ac",category:"Area",toBase:e=>e*4046.86,fromBase:e=>e/4046.86},{name:"Square foot",symbol:"ft²",category:"Area",toBase:e=>e*.092903,fromBase:e=>e/.092903},{name:"Liter",symbol:"L",category:"Volume",toBase:e=>e,fromBase:e=>e},{name:"Milliliter",symbol:"mL",category:"Volume",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Cubic meter",symbol:"m³",category:"Volume",toBase:e=>e*1e3,fromBase:e=>e/1e3},{name:"Gallon (US)",symbol:"gal",category:"Volume",toBase:e=>e*3.78541,fromBase:e=>e/3.78541},{name:"Quart",symbol:"qt",category:"Volume",toBase:e=>e*.946353,fromBase:e=>e/.946353},{name:"Pint",symbol:"pt",category:"Volume",toBase:e=>e*.473176,fromBase:e=>e/.473176},{name:"Cup",symbol:"cup",category:"Volume",toBase:e=>e*.236588,fromBase:e=>e/.236588},{name:"Meters/second",symbol:"m/s",category:"Speed",toBase:e=>e,fromBase:e=>e},{name:"Kilometers/hour",symbol:"km/h",category:"Speed",toBase:e=>e/3.6,fromBase:e=>e*3.6},{name:"Miles/hour",symbol:"mph",category:"Speed",toBase:e=>e*.44704,fromBase:e=>e/.44704},{name:"Knots",symbol:"kn",category:"Speed",toBase:e=>e*.514444,fromBase:e=>e/.514444},{name:"Byte",symbol:"B",category:"Data",toBase:e=>e,fromBase:e=>e},{name:"Kilobyte",symbol:"KB",category:"Data",toBase:e=>e*1024,fromBase:e=>e/1024},{name:"Megabyte",symbol:"MB",category:"Data",toBase:e=>e*1048576,fromBase:e=>e/1048576},{name:"Gigabyte",symbol:"GB",category:"Data",toBase:e=>e*1073741824,fromBase:e=>e/1073741824},{name:"Terabyte",symbol:"TB",category:"Data",toBase:e=>e*1099511627776,fromBase:e=>e/1099511627776},{name:"Bit",symbol:"bit",category:"Data",toBase:e=>e/8,fromBase:e=>e*8}],MatrixOps={create(e,r,t=0){const a=[];for(let n=0;n<e;n++)a.push(new Array(r).fill(t));return{rows:e,cols:r,data:a}},identity(e){const r=this.create(e,e);for(let t=0;t<e;t++)r.data[t][t]=1;return r},add(e,r){if(e.rows!==r.rows||e.cols!==r.cols)throw new Error("Matrix dimensions must match for addition");const t=this.create(e.rows,e.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<e.cols;n++)t.data[a][n]=e.data[a][n]+r.data[a][n];return t},subtract(e,r){if(e.rows!==r.rows||e.cols!==r.cols)throw new Error("Matrix dimensions must match for subtraction");const t=this.create(e.rows,e.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<e.cols;n++)t.data[a][n]=e.data[a][n]-r.data[a][n];return t},multiply(e,r){if(e.cols!==r.rows)throw new Error("Matrix A columns must equal Matrix B rows for multiplication");const t=this.create(e.rows,r.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<r.cols;n++){let o=0;for(let i=0;i<e.cols;i++)o+=e.data[a][i]*r.data[i][n];t.data[a][n]=o}return t},scalar(e,r){const t=this.create(e.rows,e.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<e.cols;n++)t.data[a][n]=e.data[a][n]*r;return t},transpose(e){const r=this.create(e.cols,e.rows);for(let t=0;t<e.rows;t++)for(let a=0;a<e.cols;a++)r.data[a][t]=e.data[t][a];return r},determinant(e){if(e.rows!==e.cols)throw new Error("Determinant requires square matrix");if(e.rows===1)return e.data[0][0];if(e.rows===2)return e.data[0][0]*e.data[1][1]-e.data[0][1]*e.data[1][0];let r=0;for(let t=0;t<e.cols;t++)r+=Math.pow(-1,t)*e.data[0][t]*this.determinant(this.minor(e,0,t));return r},minor(e,r,t){const a=this.create(e.rows-1,e.cols-1);let n=0;for(let o=0;o<e.rows;o++){if(o===r)continue;let i=0;for(let c=0;c<e.cols;c++)c!==t&&(a.data[n][i]=e.data[o][c],i++);n++}return a},inverse(e){const r=this.determinant(e);if(r===0)throw new Error("Matrix is singular, cannot compute inverse");const t=e.rows,a=this.create(t,t);for(let n=0;n<t;n++)for(let o=0;o<t;o++){const i=Math.pow(-1,n+o),c=this.determinant(this.minor(e,n,o));a.data[o][n]=i*c}return this.scalar(a,1/r)},trace(e){if(e.rows!==e.cols)throw new Error("Trace requires square matrix");let r=0;for(let t=0;t<e.rows;t++)r+=e.data[t][t];return r},eigenvalues2x2(e){if(e.rows!==2||e.cols!==2)throw new Error("Only 2x2 matrices supported for eigenvalues");const r=e.data[0][0],t=e.data[0][1],a=e.data[1][0],n=e.data[1][1],o=r+n,i=r*n-t*a,c=o*o-4*i;if(c<0)throw new Error("Complex eigenvalues not supported");const f=Math.sqrt(c);return[(o+f)/2,(o-f)/2]},toString(e,r=4){return e.data.map(t=>"[ "+t.map(a=>a.toFixed(r).padStart(10)).join(" ")+" ]").join(`
|
|
30
|
-
`)}},CalculusOps={derivative(e,r,t=1e-7){return(e(r+t)-e(r-t))/(2*t)},secondDerivative(e,r,t=1e-5){return(e(r+t)-2*e(r)+e(r-t))/(t*t)},integrate(e,r,t,a=1e3){a%2!==0&&a++;const n=(t-r)/a;let o=e(r)+e(t);for(let i=1;i<a;i++){const c=r+i*n;o+=i%2===0?2*e(c):4*e(c)}return n/3*o},findRoot(e,r,t=1e-10,a=100){let n=r;for(let o=0;o<a;o++){const i=e(n);if(Math.abs(i)<t)return n;const c=this.derivative(e,n);if(c===0)throw new Error("Derivative is zero, Newton-Raphson failed");n=n-i/c}throw new Error("Newton-Raphson did not converge")},symbolicDerivative(e){if(e=e.trim(),/^-?\d+\.?\d*$/.test(e))return"0";if(e==="x")return"1";const r=e.match(/^x\^(\d+)$/);if(r){const a=parseInt(r[1],10);return a===1?"1":a===2?"2*x":`${a}*x^${a-1}`}const t=e.match(/^(-?\d+\.?\d*)\*x\^(\d+)$/);if(t){const a=parseFloat(t[1]),n=parseInt(t[2],10),o=a*n;return n===1?String(o):n===2?`${o}*x`:`${o}*x^${n-1}`}return e==="sin(x)"?"cos(x)":e==="cos(x)"?"-sin(x)":e==="e^x"||e==="exp(x)"?"e^x":e==="ln(x)"?"1/x":`d/dx(${e})`},symbolicIntegral(e){if(e=e.trim(),/^-?\d+\.?\d*$/.test(e))return`${e}*x + C`;if(e==="x")return"x^2/2 + C";const r=e.match(/^x\^(\d+)$/);if(r){const t=parseInt(r[1],10);return`x^${t+1}/${t+1} + C`}return e==="sin(x)"?"-cos(x) + C":e==="cos(x)"?"sin(x) + C":e==="e^x"||e==="exp(x)"?"e^x + C":e==="1/x"?"ln|x| + C":`∫(${e})dx + C`},solveQuadratic(e,r,t){const a=r*r-4*e*t;if(a<0)throw new Error("No real solutions (complex roots)");if(a===0)return[-r/(2*e)];const n=Math.sqrt(a);return[(-r+n)/(2*e),(-r-n)/(2*e)]}};class CalculatorService{constructor(e={}){C(this,"history",[]);C(this,"memory",0);C(this,"variables",new Map);C(this,"config");this.config={precision:e.precision??12,angleUnit:e.angleUnit??"rad"}}evaluate(expression){let expr=expression.replace(/π|pi/gi,String(Math.PI)).replace(/e(?![xp])/gi,String(Math.E)).replace(/\^/g,"**").replace(/√/g,"Math.sqrt").replace(/sin/gi,"Math.sin").replace(/cos/gi,"Math.cos").replace(/tan/gi,"Math.tan").replace(/asin/gi,"Math.asin").replace(/acos/gi,"Math.acos").replace(/atan/gi,"Math.atan").replace(/sinh/gi,"Math.sinh").replace(/cosh/gi,"Math.cosh").replace(/tanh/gi,"Math.tanh").replace(/log10/gi,"Math.log10").replace(/log2/gi,"Math.log2").replace(/ln/gi,"Math.log").replace(/log\b/gi,"Math.log10").replace(/exp/gi,"Math.exp").replace(/sqrt/gi,"Math.sqrt").replace(/cbrt/gi,"Math.cbrt").replace(/abs/gi,"Math.abs").replace(/floor/gi,"Math.floor").replace(/ceil/gi,"Math.ceil").replace(/round/gi,"Math.round").replace(/pow/gi,"Math.pow").replace(/min/gi,"Math.min").replace(/max/gi,"Math.max");for(const[e,r]of this.variables)expr=expr.replace(new RegExp(`\\b${e}\\b`,"g"),String(r));try{const result=eval(expr);if(typeof result!="number"||!Number.isFinite(result))throw new Error("Invalid result");return result}catch(e){throw new Error(`Invalid expression: ${e.message}`)}}addHistory(e,r,t){this.history.unshift({id:Date.now().toString(36),expression:e,result:r,timestamp:new Date().toISOString(),mode:t}),this.history.length>100&&this.history.pop()}getHistory(){return this.history}clearHistory(){this.history=[]}memoryStore(e){this.memory=e}memoryRecall(){return this.memory}memoryAdd(e){this.memory+=e}memoryClear(){this.memory=0}setVariable(e,r){this.variables.set(e,r)}getVariable(e){return this.variables.get(e)}convertBase(e,r,t){const a={BIN:2,OCT:8,DEC:10,HEX:16},n=parseInt(e,a[r]);if(isNaN(n))throw new Error("Invalid number for base conversion");return n.toString(a[t]).toUpperCase()}convertUnits(e,r,t){const a=UNITS.find(i=>i.symbol===r),n=UNITS.find(i=>i.symbol===t);if(!a||!n)throw new Error("Unknown unit");if(a.category!==n.category)throw new Error("Cannot convert between different unit categories");const o=a.toBase(e);return n.fromBase(o)}getUnitsByCategory(e){return UNITS.filter(r=>r.category===e)}getUnitCategories(){return[...new Set(UNITS.map(e=>e.category))]}format(e){const r=this.config.precision;return Math.abs(e)<1e-10?"0":Math.abs(e)>1e10||Math.abs(e)<1e-6?e.toExponential(r):parseFloat(e.toPrecision(r)).toString()}}function createCalculatorService(e){return new CalculatorService(e)}const CalculatorContext=xe.createContext(null);function useCalculator(){const e=xe.useContext(CalculatorContext);if(!e)throw new Error("useCalculator must be used within CalculatorProvider");return e}const styles$1={container:{width:"400px",fontFamily:"'Inter', sans-serif",backgroundColor:"var(--nice-bg, #1e1e1e)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 4px 20px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))"},modeSelector:{display:"flex",backgroundColor:"var(--nice-bg-secondary, #2d2d2d)"},modeButton:{flex:1,padding:"8px",border:"none",backgroundColor:"transparent",color:"var(--nice-text-secondary, #888)",fontSize:"11px",cursor:"pointer"},display:{padding:"20px",backgroundColor:"var(--nice-bg-secondary, #252525)",minHeight:"80px"},displayText:{color:"var(--nice-bg, #fff)",fontSize:"32px",fontFamily:"'JetBrains Mono', monospace",textAlign:"right",wordBreak:"break-all"},keypad:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"1px",backgroundColor:"var(--nice-text, #333)",padding:"1px"},key:{padding:"20px",border:"none",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",fontSize:"18px",cursor:"pointer",transition:"background-color 0.1s"},keyOperator:{backgroundColor:"var(--nice-warning, #ff9f0a)",color:"var(--nice-text, #000)"},keyFunction:{backgroundColor:"#505050"}};function NiceCalculator({service:e,className:r,style:t}){const[a,n]=xe.useState("0"),[o,i]=xe.useState("standard"),[c,f]=xe.useState([]),[s,d]=xe.useState(!1),m=xe.useCallback(u=>{s&&/[0-9.]/.test(u)?(n(u),d(!1)):(n(b=>b==="0"&&u!=="."?u:b+u),d(!1))},[s]),y=xe.useCallback(()=>{n("0"),d(!1)},[]),g=xe.useCallback(()=>{try{const u=e.evaluate(a),b=e.format(u);e.addHistory(a,b,o),f(e.getHistory()),n(b),d(!0)}catch{n("Error"),d(!0)}},[a,o,e]),w={service:e,display:a,setDisplay:n,mode:o,setMode:i,history:c,calculate:g,appendDigit:m,clear:y};return jsxRuntime.jsx(CalculatorContext.Provider,{value:w,children:jsxRuntime.jsxs("div",{className:r,style:{...styles$1.container,...t},children:[jsxRuntime.jsx(ModeSelector,{}),jsxRuntime.jsx(Display,{}),o==="standard"&&jsxRuntime.jsx(StandardKeypad,{}),o==="scientific"&&jsxRuntime.jsx(ScientificKeypad,{}),o==="programmer"&&jsxRuntime.jsx(ProgrammerKeypad,{}),o==="matrix"&&jsxRuntime.jsx(MatrixMode,{}),o==="calculus"&&jsxRuntime.jsx(CalculusMode,{}),o==="units"&&jsxRuntime.jsx(UnitsMode,{})]})})}function ModeSelector(){const{mode:e,setMode:r}=useCalculator(),t=[{id:"standard",label:"Standard"},{id:"scientific",label:"Scientific"},{id:"programmer",label:"Programmer"},{id:"matrix",label:"Matrix"},{id:"calculus",label:"Calculus"},{id:"units",label:"Units"}];return jsxRuntime.jsx("div",{style:styles$1.modeSelector,children:t.map(a=>jsxRuntime.jsx("button",{onClick:()=>r(a.id),style:{...styles$1.modeButton,backgroundColor:e===a.id?"var(--nice-primary-hover, #1976d2)":"transparent",color:e===a.id?"var(--nice-bg, #fff)":"var(--nice-text-secondary, #888)"},children:a.label},a.id))})}function Display(){const{display:e}=useCalculator();return jsxRuntime.jsx("div",{style:styles$1.display,children:jsxRuntime.jsx("div",{style:styles$1.displayText,children:e})})}function StandardKeypad(){const{appendDigit:e,clear:r,calculate:t,setDisplay:a,display:n}=useCalculator(),o=[{label:"AC",action:r,style:styles$1.keyFunction},{label:"±",action:()=>a(n.startsWith("-")?n.slice(1):"-"+n),style:styles$1.keyFunction},{label:"%",action:()=>e("/100"),style:styles$1.keyFunction},{label:"÷",action:()=>e("/"),style:styles$1.keyOperator},{label:"7",action:()=>e("7")},{label:"8",action:()=>e("8")},{label:"9",action:()=>e("9")},{label:"×",action:()=>e("*"),style:styles$1.keyOperator},{label:"4",action:()=>e("4")},{label:"5",action:()=>e("5")},{label:"6",action:()=>e("6")},{label:"−",action:()=>e("-"),style:styles$1.keyOperator},{label:"1",action:()=>e("1")},{label:"2",action:()=>e("2")},{label:"3",action:()=>e("3")},{label:"+",action:()=>e("+"),style:styles$1.keyOperator},{label:"0",action:()=>e("0")},{label:".",action:()=>e(".")},{label:"⌫",action:()=>a(n.length>1?n.slice(0,-1):"0")},{label:"=",action:t,style:styles$1.keyOperator}];return jsxRuntime.jsx("div",{style:styles$1.keypad,children:o.map((i,c)=>jsxRuntime.jsx("button",{onClick:i.action,style:{...styles$1.key,...i.style||{}},children:i.label},c))})}function ScientificKeypad(){const{appendDigit:e,clear:r,calculate:t,setDisplay:a,display:n}=useCalculator(),o=[{label:"sin",action:()=>e("sin(")},{label:"cos",action:()=>e("cos(")},{label:"tan",action:()=>e("tan(")},{label:"ln",action:()=>e("ln(")},{label:"log",action:()=>e("log10(")}],i=[{label:"x²",action:()=>e("^2")},{label:"x³",action:()=>e("^3")},{label:"xʸ",action:()=>e("^")},{label:"√",action:()=>e("sqrt(")},{label:"eˣ",action:()=>e("exp(")}],c=[{label:"(",action:()=>e("(")},{label:")",action:()=>e(")")},{label:"π",action:()=>e("π")},{label:"e",action:()=>e("e")},{label:"AC",action:r}];return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{...styles$1.keypad,gridTemplateColumns:"repeat(5, 1fr)"},children:[...o,...i,...c].map((f,s)=>jsxRuntime.jsx("button",{onClick:f.action,style:{...styles$1.key,...styles$1.keyFunction,padding:"12px"},children:f.label},s))}),jsxRuntime.jsx(StandardKeypad,{})]})}function ProgrammerKeypad(){const{display:e,setDisplay:r,service:t}=useCalculator(),[a,n]=xe.useState("DEC"),o=c=>{try{const f=t.convertBase(e,a,c);r(f),n(c)}catch{r("Error")}},i=a==="HEX"?["A","B","C","D","E","F"]:[];return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:"4px",padding:"8px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:["BIN","OCT","DEC","HEX"].map(c=>jsxRuntime.jsx("button",{onClick:()=>o(c),style:{flex:1,padding:"8px",border:"none",borderRadius:"4px",backgroundColor:a===c?"var(--nice-primary-hover, #1976d2)":"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",cursor:"pointer"},children:c},c))}),i.length>0&&jsxRuntime.jsx("div",{style:{...styles$1.keypad,gridTemplateColumns:"repeat(6, 1fr)"},children:i.map(c=>jsxRuntime.jsx("button",{onClick:()=>r(e==="0"?c:e+c),style:styles$1.key,children:c},c))}),jsxRuntime.jsx("div",{style:{...styles$1.keypad,gridTemplateColumns:"repeat(4, 1fr)"},children:["7","8","9","AND","4","5","6","OR","1","2","3","XOR","0","NOT","<<",">>"].map(c=>{const f=["AND","OR","XOR","NOT","<<",">>"].includes(c);return jsxRuntime.jsx("button",{onClick:()=>r(e==="0"?c:e+c),style:{...styles$1.key,...f?styles$1.keyFunction:{}},children:c},c)})})]})}function MatrixMode(){const{t:e}=useNiceTranslation(),[r,t]=xe.useState(MatrixOps.create(2,2)),[a,n]=xe.useState(MatrixOps.create(2,2)),[o,i]=xe.useState(""),c=(s,d,m,y,g)=>{const w={...s,data:s.data.map(u=>[...u])};w.data[m][y]=parseFloat(g)||0,d(w)},f=[{label:"A + B",fn:()=>MatrixOps.toString(MatrixOps.add(r,a))},{label:"A - B",fn:()=>MatrixOps.toString(MatrixOps.subtract(r,a))},{label:"A × B",fn:()=>MatrixOps.toString(MatrixOps.multiply(r,a))},{label:"det(A)",fn:()=>MatrixOps.determinant(r).toFixed(4)},{label:"Aᵀ",fn:()=>MatrixOps.toString(MatrixOps.transpose(r))},{label:"A⁻¹",fn:()=>MatrixOps.toString(MatrixOps.inverse(r))}];return jsxRuntime.jsxs("div",{style:{padding:"12px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"12px"},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{color:"var(--nice-text-secondary, #888)",marginBottom:"4px"},children:e("calculator.matrixA","Matrix A")}),jsxRuntime.jsx(MatrixInput,{matrix:r,onChange:(s,d,m)=>c(r,t,s,d,m)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{color:"var(--nice-text-secondary, #888)",marginBottom:"4px"},children:e("calculator.matrixB","Matrix B")}),jsxRuntime.jsx(MatrixInput,{matrix:a,onChange:(s,d,m)=>c(a,n,s,d,m)})]})]}),jsxRuntime.jsx("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginBottom:"12px"},children:f.map(s=>jsxRuntime.jsx("button",{onClick:()=>{try{i(s.fn())}catch(d){i(d.message)}},style:{padding:"8px 12px",backgroundColor:"var(--nice-primary-hover, #1976d2)",color:"var(--nice-bg, #fff)",border:"none",borderRadius:"4px",cursor:"pointer"},children:s.label},s.label))}),o&&jsxRuntime.jsx("pre",{style:{color:"var(--nice-bg, #fff)",fontFamily:"monospace",whiteSpace:"pre-wrap"},children:o})]})}function MatrixInput({matrix:e,onChange:r}){return jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${e.cols}, 50px)`,gap:"4px"},children:e.data.map((t,a)=>t.map((n,o)=>jsxRuntime.jsx("input",{type:"number",value:n,onChange:i=>r(a,o,i.target.value),style:{width:"100%",padding:"4px",textAlign:"center",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"}},`${a}-${o}`)))})}function CalculusMode(){const{t:e}=useNiceTranslation(),[r,t]=xe.useState("x^2"),[a,n]=xe.useState("");return jsxRuntime.jsxs("div",{style:{padding:"12px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:o=>t(o.target.value),placeholder:e("calculator.exprPlaceholder","Enter expression (e.g., x^2, sin(x))"),style:{width:"100%",padding:"8px",marginBottom:"12px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"}}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginBottom:"12px"},children:[jsxRuntime.jsx("button",{onClick:()=>n(`d/dx(${r}) = ${CalculusOps.symbolicDerivative(r)}`),style:{padding:"8px 12px",backgroundColor:"var(--nice-success, #4caf50)",color:"var(--nice-bg, #fff)",border:"none",borderRadius:"4px",cursor:"pointer"},children:e("calculator.differentiate","Differentiate")}),jsxRuntime.jsx("button",{onClick:()=>n(`∫(${r})dx = ${CalculusOps.symbolicIntegral(r)}`),style:{padding:"8px 12px",backgroundColor:"var(--nice-primary, #2196f3)",color:"var(--nice-bg, #fff)",border:"none",borderRadius:"4px",cursor:"pointer"},children:e("calculator.integrate","Integrate")})]}),a&&jsxRuntime.jsx("div",{style:{color:"var(--nice-bg, #fff)",fontFamily:"monospace",padding:"8px",backgroundColor:"var(--nice-bg, #1e1e1e)",borderRadius:"4px"},children:a})]})}function UnitsMode(){const{t:e}=useNiceTranslation(),{service:r}=useCalculator(),[t,a]=xe.useState("1"),[n,o]=xe.useState("m"),[i,c]=xe.useState("ft"),[f,s]=xe.useState("Length"),[d,m]=xe.useState(""),y=r.getUnitCategories(),g=r.getUnitsByCategory(f),w=()=>{try{const u=r.convertUnits(parseFloat(t),n,i);m(`${t} ${n} = ${r.format(u)} ${i}`)}catch(u){m(u.message)}};return jsxRuntime.jsxs("div",{style:{padding:"12px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:[jsxRuntime.jsx("select",{value:f,onChange:u=>{s(u.target.value);const b=r.getUnitsByCategory(u.target.value);b.length>=2&&(o(b[0].symbol),c(b[1].symbol))},style:{width:"100%",padding:"8px",marginBottom:"12px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"},children:y.map(u=>jsxRuntime.jsx("option",{value:u,children:u},u))}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",marginBottom:"12px"},children:[jsxRuntime.jsx("input",{type:"number",value:t,onChange:u=>a(u.target.value),style:{flex:1,padding:"8px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"}}),jsxRuntime.jsx("select",{value:n,onChange:u=>o(u.target.value),style:{padding:"8px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"},children:g.map(u=>jsxRuntime.jsxs("option",{value:u.symbol,children:[u.name," (",u.symbol,")"]},u.symbol))})]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",marginBottom:"12px"},children:[jsxRuntime.jsx("span",{style:{color:"var(--nice-text-secondary, #888)"},children:"→"}),jsxRuntime.jsx("select",{value:i,onChange:u=>c(u.target.value),style:{flex:1,padding:"8px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"},children:g.map(u=>jsxRuntime.jsxs("option",{value:u.symbol,children:[u.name," (",u.symbol,")"]},u.symbol))})]}),jsxRuntime.jsx("button",{onClick:w,style:{width:"100%",padding:"12px",backgroundColor:"var(--nice-warning, #ff9f0a)",color:"var(--nice-text, #000)",border:"none",borderRadius:"4px",fontSize:"16px",cursor:"pointer"},children:e("calculator.convert","Convert")}),d&&jsxRuntime.jsx("div",{style:{marginTop:"12px",color:"var(--nice-bg, #fff)",fontSize:"18px",textAlign:"center"},children:d})]})}const GeoMath={distance(e,r){return Math.sqrt((r.x-e.x)**2+(r.y-e.y)**2)},midpoint(e,r){return{x:(e.x+r.x)/2,y:(e.y+r.y)/2}},angle(e,r,t){const a=Math.atan2(e.y-r.y,e.x-r.x);let o=Math.atan2(t.y-r.y,t.x-r.x)-a;return o<0&&(o+=2*Math.PI),o},angleDegrees(e,r,t){return this.angle(e,r,t)*180/Math.PI},closestPointOnLine(e,r,t){const a=r.x-e.x,n=r.y-e.y,o=((t.x-e.x)*a+(t.y-e.y)*n)/(a*a+n*n);return{x:e.x+o*a,y:e.y+o*n}},lineIntersection(e,r,t,a){const n=(e.x-r.x)*(t.y-a.y)-(e.y-r.y)*(t.x-a.x);if(Math.abs(n)<1e-10)return null;const o=((e.x-t.x)*(t.y-a.y)-(e.y-t.y)*(t.x-a.x))/n;return{x:e.x+o*(r.x-e.x),y:e.y+o*(r.y-e.y)}},circleLineIntersection(e,r,t,a){const n=a.x-t.x,o=a.y-t.y,i=t.x-e.x,c=t.y-e.y,f=n*n+o*o,s=2*(i*n+c*o),d=i*i+c*c-r*r,m=s*s-4*f*d;if(m<0)return[];const y=Math.sqrt(m),g=(-s-y)/(2*f),w=(-s+y)/(2*f),u=[];return g>=0&&g<=1&&u.push({x:t.x+g*n,y:t.y+g*o}),w>=0&&w<=1&&Math.abs(w-g)>1e-10&&u.push({x:t.x+w*n,y:t.y+w*o}),u},circleCircleIntersection(e,r,t,a){const n=this.distance(e,t);if(n>r+a||n<Math.abs(r-a)||n===0)return[];const o=(r*r-a*a+n*n)/(2*n),i=Math.sqrt(r*r-o*o),c=e.x+o*(t.x-e.x)/n,f=e.y+o*(t.y-e.y)/n;return[{x:c+i*(t.y-e.y)/n,y:f-i*(t.x-e.x)/n},{x:c-i*(t.y-e.y)/n,y:f+i*(t.x-e.x)/n}]},perpendicularThrough(e,r,t){this.closestPointOnLine(e,r,t);const a=r.x-e.x,n=r.y-e.y;return{p1:t,p2:{x:t.x-n,y:t.y+a}}},parallelThrough(e,r,t){const a=r.x-e.x,n=r.y-e.y;return{p1:t,p2:{x:t.x+a,y:t.y+n}}},angleBisector(e,r,t){const a=Math.atan2(e.y-r.y,e.x-r.x),n=Math.atan2(t.y-r.y,t.x-r.x);let o=(a+n)/2;return Math.abs(n-a)>Math.PI&&(o+=Math.PI),{x:r.x+Math.cos(o),y:r.y+Math.sin(o)}},reflect(e,r,t){const a=this.closestPointOnLine(r,t,e);return{x:2*a.x-e.x,y:2*a.y-e.y}},rotate(e,r,t){const a=Math.cos(t),n=Math.sin(t),o=e.x-r.x,i=e.y-r.y;return{x:r.x+o*a-i*n,y:r.y+o*n+i*a}},translate(e,r,t){return{x:e.x+r,y:e.y+t}},dilate(e,r,t){return{x:r.x+t*(e.x-r.x),y:r.y+t*(e.y-r.y)}},polygonArea(e){let r=0;const t=e.length;for(let a=0;a<t;a++){const n=(a+1)%t;r+=e[a].x*e[n].y,r-=e[n].x*e[a].y}return Math.abs(r)/2},polygonPerimeter(e){let r=0;const t=e.length;for(let a=0;a<t;a++){const n=(a+1)%t;r+=this.distance(e[a],e[n])}return r},circumcenter(e,r,t){const a=2*(e.x*(r.y-t.y)+r.x*(t.y-e.y)+t.x*(e.y-r.y)),n=((e.x**2+e.y**2)*(r.y-t.y)+(r.x**2+r.y**2)*(t.y-e.y)+(t.x**2+t.y**2)*(e.y-r.y))/a,o=((e.x**2+e.y**2)*(t.x-r.x)+(r.x**2+r.y**2)*(e.x-t.x)+(t.x**2+t.y**2)*(r.x-e.x))/a;return{x:n,y:o}},incenter(e,r,t){const a=this.distance(e,r),n=this.distance(r,t),o=this.distance(t,e),i=a+n+o;return{x:(n*e.x+o*r.x+a*t.x)/i,y:(n*e.y+o*r.y+a*t.y)/i}},centroid(e,r,t){return{x:(e.x+r.x+t.x)/3,y:(e.y+r.y+t.y)/3}}};class GeometryService{constructor(){C(this,"elements",new Map);C(this,"nextLabel",1)}addElement(r){const t=this.generateId(),a={...r,id:t};return this.elements.set(t,a),a}getElement(r){return this.elements.get(r)}getPoint(r){const t=this.elements.get(r);return(t==null?void 0:t.type)==="point"?t:void 0}updateElement(r,t){const a=this.elements.get(r);a&&this.elements.set(r,{...a,...t,id:r,type:a.type})}deleteElement(r){var t;this.elements.delete(r);for(const[a,n]of this.elements)(t=n.dependencies)!=null&&t.includes(r)&&this.deleteElement(a)}getAllElements(){return Array.from(this.elements.values())}getElementsByType(r){return Array.from(this.elements.values()).filter(t=>t.type===r)}clear(){this.elements.clear(),this.nextLabel=1}createPoint(r,t,a){return this.addElement({type:"point",x:r,y:t,label:a??this.getNextLabel(),color:{r:0,g:0,b:0},visible:!0,selected:!1,locked:!1,size:6})}createSegment(r,t){return this.addElement({type:"segment",point1Id:r,point2Id:t,label:void 0,color:{r:50,g:50,b:50},visible:!0,selected:!1,locked:!1,width:2,dependencies:[r,t]})}createLine(r,t){return this.addElement({type:"line",point1Id:r,point2Id:t,label:void 0,color:{r:50,g:50,b:200},visible:!0,selected:!1,locked:!1,width:1,dependencies:[r,t]})}createRay(r,t){return this.addElement({type:"ray",originId:r,throughId:t,label:void 0,color:{r:50,g:150,b:50},visible:!0,selected:!1,locked:!1,width:1,dependencies:[r,t]})}createCircle(r,t){return this.addElement({type:"circle",centerId:r,radius:t,label:void 0,color:{r:200,g:50,b:50},visible:!0,selected:!1,locked:!1,width:2,dependencies:[r]})}createPolygon(r){return this.addElement({type:"polygon",pointIds:r,label:void 0,color:{r:100,g:100,b:200},visible:!0,selected:!1,locked:!1,width:2,fill:{r:100,g:100,b:200,a:.2},dependencies:r})}createMidpoint(r,t){const a=this.getPoint(r),n=this.getPoint(t);if(!a||!n)return null;const o=GeoMath.midpoint(a,n),i=this.createPoint(o.x,o.y);return i.dependencies=[r,t],i.color={r:0,g:150,b:0},i}createPerpendicular(r,t,a){const n=this.getPoint(r),o=this.getPoint(t),i=this.getPoint(a);if(!n||!o||!i)return null;const c=GeoMath.perpendicularThrough(n,o,i),f=this.createPoint(c.p2.x,c.p2.y),s=this.createLine(a,f.id);return s.dependencies=[r,t,a],s}createParallel(r,t,a){const n=this.getPoint(r),o=this.getPoint(t),i=this.getPoint(a);if(!n||!o||!i)return null;const c=GeoMath.parallelThrough(n,o,i),f=this.createPoint(c.p2.x,c.p2.y),s=this.createLine(a,f.id);return s.dependencies=[r,t,a],s}createIntersection(r,t){const a=this.elements.get(r),n=this.elements.get(t);if(!a||!n)return[];const o=[],i=s=>{if(s.type==="line"||s.type==="segment"||s.type==="ray"){const d=s,m=this.getPoint(d.point1Id??d.originId),y=this.getPoint(d.point2Id??d.throughId);if(m&&y)return[m,y]}return null},c=i(a),f=i(n);if(c&&f){const s=GeoMath.lineIntersection(c[0],c[1],f[0],f[1]);if(s){const d=this.createPoint(s.x,s.y);d.dependencies=[r,t],d.color={r:255,g:0,b:0},o.push(d)}}if(a.type==="circle"&&f){const s=a,d=this.getPoint(s.centerId);if(d){const m=GeoMath.circleLineIntersection(d,s.radius,f[0],f[1]);for(const y of m){const g=this.createPoint(y.x,y.y);g.dependencies=[r,t],g.color={r:255,g:0,b:0},o.push(g)}}}if(a.type==="circle"&&n.type==="circle"){const s=a,d=n,m=this.getPoint(s.centerId),y=this.getPoint(d.centerId);if(m&&y){const g=GeoMath.circleCircleIntersection(m,s.radius,y,d.radius);for(const w of g){const u=this.createPoint(w.x,w.y);u.dependencies=[r,t],u.color={r:255,g:0,b:0},o.push(u)}}}return o}calculateMeasurement(r,t){switch(r){case"distance":{const a=this.getPoint(t[0]),n=this.getPoint(t[1]);if(a&&n)return GeoMath.distance(a,n);break}case"angle":{const a=this.getPoint(t[0]),n=this.getPoint(t[1]),o=this.getPoint(t[2]);if(a&&n&&o)return GeoMath.angleDegrees(a,n,o);break}case"area":case"perimeter":{const a=this.elements.get(t[0]);if((a==null?void 0:a.type)==="polygon"){const n=a.pointIds.map(o=>this.getPoint(o)).filter(Boolean);return r==="area"?GeoMath.polygonArea(n):GeoMath.polygonPerimeter(n)}break}}return 0}exportSVG(r,t,a){const n=[`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${t}" viewBox="0 0 ${r} ${t}">`];n.push(`<rect width="100%" height="100%" fill="rgb(${a.backgroundColor.r},${a.backgroundColor.g},${a.backgroundColor.b})"/>`);const o=(i,c)=>({x:r/2+(i-a.centerX)*a.scale,y:t/2-(c-a.centerY)*a.scale});if(a.showGrid){n.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');for(let i=Math.floor(-r/2/a.scale+a.centerX);i<=r/2/a.scale+a.centerX;i+=a.gridSpacing){const c=o(i,0);n.push(`<line x1="${c.x}" y1="0" x2="${c.x}" y2="${t}"/>`)}for(let i=Math.floor(-t/2/a.scale+a.centerY);i<=t/2/a.scale+a.centerY;i+=a.gridSpacing){const c=o(0,i);n.push(`<line x1="0" y1="${c.y}" x2="${r}" y2="${c.y}"/>`)}n.push("</g>")}if(a.showAxes){const i=o(0,0);n.push('<g stroke="var(--nice-text, #333)" stroke-width="1">'),n.push(`<line x1="0" y1="${i.y}" x2="${r}" y2="${i.y}"/>`),n.push(`<line x1="${i.x}" y1="0" x2="${i.x}" y2="${t}"/>`),n.push("</g>")}for(const i of this.getAllElements()){if(!i.visible)continue;const c=`rgb(${i.color.r},${i.color.g},${i.color.b})`;switch(i.type){case"point":{const f=o(i.x,i.y);n.push(`<circle cx="${f.x}" cy="${f.y}" r="${i.size}" fill="${c}"/>`),i.label&&n.push(`<text x="${f.x+8}" y="${f.y-8}" font-size="12">${i.label}</text>`);break}case"segment":{const f=this.getPoint(i.point1Id),s=this.getPoint(i.point2Id);if(f&&s){const d=o(f.x,f.y),m=o(s.x,s.y);n.push(`<line x1="${d.x}" y1="${d.y}" x2="${m.x}" y2="${m.y}" stroke="${c}" stroke-width="${i.width}"/>`)}break}case"circle":{const f=this.getPoint(i.centerId);if(f){const s=o(f.x,f.y),d=i.radius*a.scale,m=i.fill?`rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a??.2})`:"none";n.push(`<circle cx="${s.x}" cy="${s.y}" r="${d}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`)}break}case"polygon":{const f=i.pointIds.map(s=>this.getPoint(s)).filter(Boolean);if(f.length>0){const d=f.map(y=>o(y.x,y.y)).map((y,g)=>`${g===0?"M":"L"}${y.x},${y.y}`).join(" ")+" Z",m=i.fill?`rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a??.2})`:"none";n.push(`<path d="${d}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`)}break}}}return n.push("</svg>"),n.join(`
|
|
31
|
-
`)}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}getNextLabel(){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t=this.nextLabel-1;return this.nextLabel++,t<26?r[t]:r[t%26]+Math.floor(t/26)}}function createGeometryService(){return new GeometryService}const GeometryContext=
|
|
27
|
+
`,document.head.appendChild(e)}we.createContext(null);we.createContext(null);we.createContext(null);const fe={space1:"4px",space2:"8px",space3:"12px",space4:"16px",space5:"20px",space6:"24px",space8:"32px"},me={fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontSizeXs:"0.75rem",fontSizeSm:"0.8125rem",fontSizeMd:"0.875rem",fontSizeLg:"1rem",fontSizeXl:"1.125rem",fontWeightNormal:400,fontWeightMedium:500,fontWeightSemibold:600,fontWeightBold:700,lineHeight:1.5},pe={fast:"120ms ease",normal:"200ms ease",slow:"300ms ease"},dt=e=>({color:e,radiusSm:"4px",radiusMd:"6px",radiusLg:"8px",radiusXl:"12px",radiusFull:"9999px"}),yr={sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"},bn={sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.4)"};function z(e,r,t,a,n){return{name:e,darkMode:"light",colors:{...r,surface:r.surface??t.primary,surfaceHover:r.surfaceHover??t.secondary},backgrounds:{...t,elevated:t.elevated??t.primary,inset:t.inset??t.tertiary,canvas:t.canvas??t.primary},text:{...a,inverse:a.inverse??"#ffffff"},borders:dt(n),shadows:yr,spacing:fe,typography:me,transitions:pe}}function V(e,r,t,a,n){return{name:e,darkMode:"dark",colors:{...r,surface:r.surface??t.secondary,surfaceHover:r.surfaceHover??t.tertiary},backgrounds:{...t,elevated:t.elevated??t.secondary,inset:t.inset??t.primary,canvas:t.canvas??t.primary},text:{...a,inverse:a.inverse??"#0f172a"},borders:dt(n),shadows:bn,spacing:fe,typography:me,transitions:pe}}z("Slate",{primary:"#64748b",primaryHover:"#475569",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#1e293b",secondary:"#475569",muted:"#94a3b8"},"#cbd5e1");z("Zinc",{primary:"#71717a",primaryHover:"#52525b",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fafafa",secondary:"#f4f4f5",tertiary:"#e4e4e7",hover:"#e4e4e7"},{primary:"#18181b",secondary:"#3f3f46",muted:"#a1a1aa"},"#d4d4d8");z("Stone",{primary:"#78716c",primaryHover:"#57534e",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#1c1917",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");z("Cool Gray",{primary:"#6b7280",primaryHover:"#4b5563",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#d1d5db");z("Warm Gray",{primary:"#7c7568",primaryHover:"#5c564c",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf9f7",secondary:"#f5f4f0",tertiary:"#e8e6e1",hover:"#e8e6e1"},{primary:"#1f1d19",secondary:"#4a463d",muted:"#a09888"},"#d4d0c8");z("Silver",{primary:"#94a3b8",primaryHover:"#64748b",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#38bdf8"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#334155",secondary:"#64748b",muted:"#94a3b8"},"#cbd5e1");z("Charcoal",{primary:"#374151",primaryHover:"#1f2937",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#6b7280"},"#d1d5db");z("Ivory",{primary:"#92876d",primaryHover:"#7a6f55",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffef7",secondary:"#faf6eb",tertiary:"#f0ead6",hover:"#f0ead6"},{primary:"#2b2517",secondary:"#5c5340",muted:"#9c9280"},"#ddd8c4");z("Rose",{primary:"#e11d48",primaryHover:"#be123c",success:"#16a34a",warning:"#ea580c",error:"#dc2626",info:"#0891b2"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f43f5e"},"#fda4af");z("Emerald",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#34d399"},"#6ee7b7");z("Amber",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0284c7"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#f59e0b"},"#fcd34d");z("Violet",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#2e1065",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");z("Teal",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");z("Indigo",{primary:"#4f46e5",primaryHover:"#4338ca",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#eef2ff",secondary:"#e0e7ff",tertiary:"#c7d2fe",hover:"#e0e7ff"},{primary:"#1e1b4b",secondary:"#312e81",muted:"#818cf8"},"#a5b4fc");z("Cyan",{primary:"#0891b2",primaryHover:"#0e7490",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#0284c7"},{primary:"#ecfeff",secondary:"#cffafe",tertiary:"#a5f3fc",hover:"#cffafe"},{primary:"#164e63",secondary:"#155e75",muted:"#22d3ee"},"#67e8f9");z("Lime",{primary:"#65a30d",primaryHover:"#4d7c0f",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f7fee7",secondary:"#ecfccb",tertiary:"#d9f99d",hover:"#ecfccb"},{primary:"#1a2e05",secondary:"#365314",muted:"#84cc16"},"#bef264");z("Pink",{primary:"#db2777",primaryHover:"#be185d",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#500724",secondary:"#831843",muted:"#f472b6"},"#f9a8d4");z("Orange",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#7c2d12",muted:"#fb923c"},"#fdba74");z("Fuchsia",{primary:"#c026d3",primaryHover:"#a21caf",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf4ff",secondary:"#fae8ff",tertiary:"#f5d0fe",hover:"#fae8ff"},{primary:"#4a044e",secondary:"#701a75",muted:"#d946ef"},"#e879f9");z("Sky",{primary:"#0284c7",primaryHover:"#0369a1",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#075985",muted:"#38bdf8"},"#7dd3fc");z("Ruby",{primary:"#be123c",primaryHover:"#9f1239",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#fb7185"},"#fda4af");z("Coral",{primary:"#f97316",primaryHover:"#ea580c",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#fb923c"},"#fdba74");V("Midnight",{primary:"#818cf8",primaryHover:"#6366f1",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#020617",secondary:"#0f172a",tertiary:"#1e293b",hover:"#1e293b"},{primary:"#f1f5f9",secondary:"#94a3b8",muted:"#475569"},"#1e293b");V("Obsidian",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#facc15",error:"#fb7185",info:"#38bdf8"},{primary:"#09090b",secondary:"#18181b",tertiary:"#27272a",hover:"#27272a"},{primary:"#fafafa",secondary:"#a1a1aa",muted:"#52525b"},"#3f3f46");V("Eclipse",{primary:"#c084fc",primaryHover:"#a855f7",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#67e8f9"},{primary:"#0c0a1d",secondary:"#1a1533",tertiary:"#2a2248",hover:"#2a2248"},{primary:"#f5f3ff",secondary:"#a78bfa",muted:"#6d5eac"},"#3b3266");V("Onyx",{primary:"#60a5fa",primaryHover:"#3b82f6",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#000000",secondary:"#0a0a0a",tertiary:"#171717",hover:"#171717"},{primary:"#ffffff",secondary:"#a3a3a3",muted:"#525252"},"#262626");V("Carbon",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#67e8f9"},{primary:"#161616",secondary:"#262626",tertiary:"#393939",hover:"#393939"},{primary:"#f4f4f4",secondary:"#c6c6c6",muted:"#6f6f6f"},"#525252");V("Cosmos",{primary:"#6366f1",primaryHover:"#4f46e5",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#030712",secondary:"#111827",tertiary:"#1f2937",hover:"#1f2937"},{primary:"#e5e7eb",secondary:"#9ca3af",muted:"#4b5563"},"#374151");V("Nebula",{primary:"#e879f9",primaryHover:"#d946ef",success:"#4ade80",warning:"#fbbf24",error:"#fb7185",info:"#67e8f9"},{primary:"#0d0117",secondary:"#1a0533",tertiary:"#2d0a52",hover:"#2d0a52"},{primary:"#fae8ff",secondary:"#d8b4fe",muted:"#7c3aed"},"#581c87");V("Abyss",{primary:"#22d3ee",primaryHover:"#06b6d4",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#001219",secondary:"#002a3a",tertiary:"#003e54",hover:"#003e54"},{primary:"#e0f2fe",secondary:"#7dd3fc",muted:"#0369a1"},"#075985");V("Shadow",{primary:"#a3a3a3",primaryHover:"#737373",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#38bdf8"},{primary:"#171717",secondary:"#1f1f1f",tertiary:"#2a2a2a",hover:"#2a2a2a"},{primary:"#e5e5e5",secondary:"#a3a3a3",muted:"#525252"},"#404040");V("Emerald Dark",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#022c22",secondary:"#064e3b",tertiary:"#065f46",hover:"#065f46"},{primary:"#ecfdf5",secondary:"#6ee7b7",muted:"#047857"},"#047857");z("Forest",{primary:"#166534",primaryHover:"#14532d",success:"#22c55e",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");z("Ocean",{primary:"#0369a1",primaryHover:"#075985",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#38bdf8"},"#7dd3fc");z("Desert",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#422006",secondary:"#713f12",muted:"#ca8a04"},"#fde047");z("Sunset",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#f97316"},"#fdba74");z("Aurora",{primary:"#0d9488",primaryHover:"#0f766e",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");z("Lavender",{primary:"#7e22ce",primaryHover:"#6b21a8",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#3b0764",secondary:"#581c87",muted:"#a855f7"},"#d8b4fe");z("Autumn",{primary:"#c2410c",primaryHover:"#9a3412",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#7f1d1d",muted:"#f87171"},"#fca5a5");z("Spring",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#14532d",secondary:"#166534",muted:"#4ade80"},"#86efac");z("Arctic",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");z("Tropical",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");z("Pastel Rose",{primary:"#f472b6",primaryHover:"#ec4899",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#f9a8d4");z("Pastel Sky",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#075985",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");z("Pastel Mint",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#065f46",secondary:"#047857",muted:"#6ee7b7"},"#a7f3d0");z("Pastel Peach",{primary:"#fb923c",primaryHover:"#f97316",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#7c2d12",secondary:"#9a3412",muted:"#fdba74"},"#fed7aa");z("Pastel Lavender",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#4c1d95",secondary:"#5b21b6",muted:"#c4b5fd"},"#ddd6fe");z("Pastel Lemon",{primary:"#facc15",primaryHover:"#eab308",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#713f12",secondary:"#854d0e",muted:"#fde047"},"#fef08a");z("Pastel Sage",{primary:"#86efac",primaryHover:"#4ade80",success:"#22c55e",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#166534",secondary:"#15803d",muted:"#86efac"},"#bbf7d0");z("Pastel Coral",{primary:"#fb7185",primaryHover:"#f43f5e",success:"#4ade80",warning:"#fcd34d",error:"#ef4444",info:"#67e8f9"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#881337",secondary:"#9f1239",muted:"#fda4af"},"#fecdd3");z("Banking",{primary:"#1e3a5f",primaryHover:"#152c4a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#334155",muted:"#94a3b8"},"#cbd5e1");z("Healthcare",{primary:"#0891b2",primaryHover:"#0e7490",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#e0f7fa",tertiary:"#b2ebf2",hover:"#e0f7fa"},{primary:"#134e4a",secondary:"#1a6b6a",muted:"#80cbc4"},"#b2dfdb");z("Legal",{primary:"#1e293b",primaryHover:"#0f172a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#0f172a",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");z("Tech Startup",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#1e1b4b",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");z("Enterprise",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#60a5fa"},"#93c5fd");z("Government",{primary:"#1d4ed8",primaryHover:"#1e40af",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#1e293b",muted:"#64748b"},"#cbd5e1");z("Education",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#0891b2"},{primary:"#f0fdf9",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");z("Real Estate",{primary:"#92400e",primaryHover:"#78350f",success:"#059669",warning:"#b45309",error:"#dc2626",info:"#0891b2"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#422006",secondary:"#713f12",muted:"#d97706"},"#fcd34d");z("Nord",{primary:"#5e81ac",primaryHover:"#4c6b90",success:"#a3be8c",warning:"#ebcb8b",error:"#bf616a",info:"#88c0d0"},{primary:"#eceff4",secondary:"#e5e9f0",tertiary:"#d8dee9",hover:"#d8dee9"},{primary:"#2e3440",secondary:"#3b4252",muted:"#4c566a"},"#d8dee9");V("Dracula",{primary:"#bd93f9",primaryHover:"#9d79d9",success:"#50fa7b",warning:"#f1fa8c",error:"#ff5555",info:"#8be9fd"},{primary:"#282a36",secondary:"#343746",tertiary:"#44475a",hover:"#44475a"},{primary:"#f8f8f2",secondary:"#c0c0c0",muted:"#6272a4"},"#44475a");z("Solarized Light",{primary:"#268bd2",primaryHover:"#1a6da0",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#fdf6e3",secondary:"#eee8d5",tertiary:"#e0dbc7",hover:"#eee8d5"},{primary:"#073642",secondary:"#586e75",muted:"#93a1a1"},"#eee8d5");V("Solarized Dark",{primary:"#268bd2",primaryHover:"#3d98db",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#002b36",secondary:"#073642",tertiary:"#0a4858",hover:"#073642"},{primary:"#eee8d5",secondary:"#93a1a1",muted:"#586e75"},"#073642");V("Monokai",{primary:"#66d9ef",primaryHover:"#45c0d6",success:"#a6e22e",warning:"#e6db74",error:"#f92672",info:"#66d9ef"},{primary:"#272822",secondary:"#34352e",tertiary:"#3e3d32",hover:"#3e3d32"},{primary:"#f8f8f2",secondary:"#cfcfc2",muted:"#75715e"},"#3e3d32");V("One Dark",{primary:"#61afef",primaryHover:"#4b9ee0",success:"#98c379",warning:"#e5c07b",error:"#e06c75",info:"#56b6c2"},{primary:"#282c34",secondary:"#2c313a",tertiary:"#353b45",hover:"#353b45"},{primary:"#abb2bf",secondary:"#828997",muted:"#545862"},"#3e4452");V("Synthwave",{primary:"#ff7edb",primaryHover:"#e660c2",success:"#72f1b8",warning:"#fede5d",error:"#fe4450",info:"#36f9f6"},{primary:"#241b2f",secondary:"#2d2140",tertiary:"#362a50",hover:"#362a50"},{primary:"#f0e4fc",secondary:"#b4a0cc",muted:"#6c5c84"},"#4a3866");z("Vaporwave",{primary:"#ff71ce",primaryHover:"#e655b5",success:"#78dcca",warning:"#ffb86c",error:"#ff5555",info:"#76e8fc"},{primary:"#fce4f7",secondary:"#e8d0f4",tertiary:"#d4bcf0",hover:"#e8d0f4"},{primary:"#4a1a4e",secondary:"#7b3f7d",muted:"#c080c0"},"#d8a8e8");V("Terminal Green",{primary:"#00ff41",primaryHover:"#00cc34",success:"#00ff41",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0a0a0a",secondary:"#0d1a0d",tertiary:"#1a2e1a",hover:"#1a2e1a"},{primary:"#00ff41",secondary:"#00cc33",muted:"#008822"},"#003300");z("Sepia",{primary:"#8b6914",primaryHover:"#704f10",success:"#6b8e23",warning:"#cd853f",error:"#b22222",info:"#5f9ea0"},{primary:"#faf0e6",secondary:"#f5e6d3",tertiary:"#eddcc7",hover:"#f5e6d3"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#d7ccc8");z("Vintage",{primary:"#8d6e63",primaryHover:"#6d4c41",success:"#66bb6a",warning:"#ffb300",error:"#e53935",info:"#29b6f6"},{primary:"#efebe9",secondary:"#d7ccc8",tertiary:"#bcaaa4",hover:"#d7ccc8"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#bcaaa4");V("Cyberpunk",{primary:"#00f0ff",primaryHover:"#00c8d4",success:"#39ff14",warning:"#ffff00",error:"#ff003c",info:"#bf00ff"},{primary:"#0a0e17",secondary:"#131824",tertiary:"#1c2333",hover:"#1c2333"},{primary:"#e0fbfc",secondary:"#80d4dd",muted:"#3a6b72"},"#1c3a44");V("Neon",{primary:"#ff00ff",primaryHover:"#cc00cc",success:"#00ff00",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0d0d0d",secondary:"#1a1a1a",tertiary:"#262626",hover:"#262626"},{primary:"#ffffff",secondary:"#cccccc",muted:"#666666"},"#333333");V("Retrowave",{primary:"#f77fbe",primaryHover:"#e462a3",success:"#72f1b8",warning:"#ffe261",error:"#ff4444",info:"#79e8fb"},{primary:"#1b0a2e",secondary:"#261440",tertiary:"#321e52",hover:"#321e52"},{primary:"#ffe6f7",secondary:"#c9a0c9",muted:"#6b4c7a"},"#4a2d66");z("Christmas",{primary:"#c41e3a",primaryHover:"#a01830",success:"#228b22",warning:"#ffd700",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");V("Halloween",{primary:"#ff6600",primaryHover:"#e05500",success:"#4ade80",warning:"#fbbf24",error:"#ff0000",info:"#9333ea"},{primary:"#1a0a00",secondary:"#2d1500",tertiary:"#402000",hover:"#402000"},{primary:"#ffedd5",secondary:"#fdba74",muted:"#9a5c28"},"#5c3400");z("Valentine",{primary:"#e11d48",primaryHover:"#be123c",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#ec4899"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f9a8d4"},"#fda4af");z("Easter",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fef9ff",secondary:"#f3e8ff",tertiary:"#e8d5ff",hover:"#f3e8ff"},{primary:"#581c87",secondary:"#6d28d9",muted:"#c4b5fd"},"#ddd6fe");z("Summer Beach",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#fcd34d");z("Winter Frost",{primary:"#3b82f6",primaryHover:"#2563eb",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#93c5fd"},"#bfdbfe");z("Cherry Blossom",{primary:"#ec4899",primaryHover:"#db2777",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#fbcfe8");z("Harvest",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#d97706"},"#fcd34d");z("Japanese Zen",{primary:"#6b7280",primaryHover:"#4b5563",success:"#6b8e23",warning:"#d4a017",error:"#c0392b",info:"#5f9ea0"},{primary:"#faf9f6",secondary:"#f0ece3",tertiary:"#e6e0d4",hover:"#f0ece3"},{primary:"#2c2c2c",secondary:"#5c5c5c",muted:"#a0998a"},"#d5cec0");z("Moroccan",{primary:"#c2410c",primaryHover:"#9a3412",success:"#15803d",warning:"#ca8a04",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbf0",secondary:"#fef3e0",tertiary:"#fde6c4",hover:"#fef3e0"},{primary:"#3a1a00",secondary:"#7c2d12",muted:"#d97706"},"#f5d0a0");z("Scandinavian",{primary:"#4b5563",primaryHover:"#374151",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ffffff",secondary:"#f9fafb",tertiary:"#f3f4f6",hover:"#f3f4f6"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#e5e7eb");z("Mediterranean",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#2563eb",muted:"#93c5fd"},"#bfdbfe");z("Chinese New Year",{primary:"#dc2626",primaryHover:"#b91c1c",success:"#16a34a",warning:"#d4a017",error:"#ef4444",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#991b1b",muted:"#f87171"},"#fca5a5");z("Indian Festive",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#7c3aed"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#92400e",muted:"#f59e0b"},"#fcd34d");z("Brazilian Carnival",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#facc15",error:"#ef4444",info:"#0ea5e9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");z("African Earth",{primary:"#92400e",primaryHover:"#78350f",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf5f0",secondary:"#f0e6d6",tertiary:"#e6d5bb",hover:"#f0e6d6"},{primary:"#2b1a0e",secondary:"#5c3d1e",muted:"#a08060"},"#d4b896");V("High Contrast Dark",{primary:"#ffff00",primaryHover:"#cccc00",success:"#00ff00",warning:"#ff8c00",error:"#ff0000",info:"#00ffff"},{primary:"#000000",secondary:"#1a1a1a",tertiary:"#333333",hover:"#333333"},{primary:"#ffffff",secondary:"#ffffff",muted:"#cccccc"},"#ffffff");z("Monochrome",{primary:"#404040",primaryHover:"#262626",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fafafa",secondary:"#f0f0f0",tertiary:"#e0e0e0",hover:"#e0e0e0"},{primary:"#1a1a1a",secondary:"#404040",muted:"#808080"},"#c0c0c0");z("Enhanced Contrast",{primary:"#0050b3",primaryHover:"#003d8c",success:"#006400",warning:"#cc7000",error:"#cc0000",info:"#006680"},{primary:"#ffffff",secondary:"#f5f5f5",tertiary:"#ebebeb",hover:"#ebebeb"},{primary:"#000000",secondary:"#1a1a1a",muted:"#595959"},"#8c8c8c");z("Minimalist",{primary:"#18181b",primaryHover:"#27272a",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"},{primary:"#ffffff",secondary:"#fafafa",tertiary:"#f5f5f5",hover:"#f5f5f5"},{primary:"#0a0a0a",secondary:"#404040",muted:"#a3a3a3"},"#e5e5e5");V("Warm Dark",{primary:"#f59e0b",primaryHover:"#d97706",success:"#10b981",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#1c1917",secondary:"#292524",tertiary:"#44403c",hover:"#44403c"},{primary:"#fafaf9",secondary:"#d6d3d1",muted:"#78716c"},"#57534e");V("Soft Dark",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#34d399",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#1e1e2e",secondary:"#262637",tertiary:"#313147",hover:"#313147"},{primary:"#e8e8f0",secondary:"#a0a0b8",muted:"#5c5c74"},"#3e3e58");z("Coffee",{primary:"#6f4e37",primaryHover:"#5c3d28",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf6f1",secondary:"#f0e8dc",tertiary:"#e6d8c6",hover:"#f0e8dc"},{primary:"#2c1a0e",secondary:"#5c3d28",muted:"#a08868"},"#d4c4a8");z("Wine",{primary:"#7f1d1d",primaryHover:"#641717",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");we.createContext(null);const translations={en:{"calculator.matrixA":"Matrix A","calculator.matrixB":"Matrix B","calculator.exprPlaceholder":"Enter expression (e.g., x^2, sin(x))","calculator.differentiate":"Differentiate","calculator.integrate":"Integrate","calculator.convert":"Convert","plotter.quickAdd":"Quick add preset...","plotter.noPlots":"No plots added yet","plotter.grid":"Grid","plotter.axes":"Axes","editor.latexPlaceholder":"Enter LaTeX equation...","editor.clear":"Clear","editor.recognize":"Recognize","editor.recognizing":"Recognizing...","editor.handwritingNote":"Draw your equation above. Handwriting recognition requires external API integration."},pl:{"calculator.matrixA":"Macierz A","calculator.matrixB":"Macierz B","calculator.exprPlaceholder":"Wprowadź wyrażenie (np. x^2, sin(x))","calculator.differentiate":"Różniczkuj","calculator.integrate":"Całkuj","calculator.convert":"Przelicz","plotter.quickAdd":"Szybko dodaj ustawienie...","plotter.noPlots":"Nie dodano jeszcze żadnych wykresów","plotter.grid":"Siatka","plotter.axes":"Osie","editor.latexPlaceholder":"Wprowadź równanie LaTeX...","editor.clear":"Wyczyść","editor.recognize":"Rozpoznaj","editor.recognizing":"Rozpoznawanie...","editor.handwritingNote":"Narysuj równanie powyżej. Rozpoznawanie pisma wymaga zewnętrznej integracji API."},de:{"calculator.matrixA":"Matrix A","calculator.matrixB":"Matrix B","calculator.exprPlaceholder":"Ausdruck eingeben (z. B. x^2, sin(x))","calculator.differentiate":"Ableiten","calculator.integrate":"Integrieren","calculator.convert":"Umrechnen","plotter.quickAdd":"Voreinstellung schnell hinzufügen...","plotter.noPlots":"Noch keine Diagramme hinzugefügt","plotter.grid":"Raster","plotter.axes":"Achsen","editor.latexPlaceholder":"LaTeX-Gleichung eingeben...","editor.clear":"Löschen","editor.recognize":"Erkennen","editor.recognizing":"Erkennung läuft...","editor.handwritingNote":"Zeichnen Sie Ihre Gleichung oben. Die Handschrifterkennung erfordert eine externe API-Integration."},fr:{"calculator.matrixA":"Matrice A","calculator.matrixB":"Matrice B","calculator.exprPlaceholder":"Saisir une expression (ex. x^2, sin(x))","calculator.differentiate":"Dériver","calculator.integrate":"Intégrer","calculator.convert":"Convertir","plotter.quickAdd":"Ajouter un préréglage rapide...","plotter.noPlots":"Aucun tracé ajouté pour le moment","plotter.grid":"Grille","plotter.axes":"Axes","editor.latexPlaceholder":"Saisir une équation LaTeX...","editor.clear":"Effacer","editor.recognize":"Reconnaître","editor.recognizing":"Reconnaissance...","editor.handwritingNote":"Dessinez votre équation ci-dessus. La reconnaissance d'écriture nécessite une intégration API externe."},es:{"calculator.matrixA":"Matriz A","calculator.matrixB":"Matriz B","calculator.exprPlaceholder":"Introduce una expresión (p. ej. x^2, sin(x))","calculator.differentiate":"Derivar","calculator.integrate":"Integrar","calculator.convert":"Convertir","plotter.quickAdd":"Añadir preajuste rápido...","plotter.noPlots":"Aún no se ha añadido ningún gráfico","plotter.grid":"Cuadrícula","plotter.axes":"Ejes","editor.latexPlaceholder":"Introduce una ecuación LaTeX...","editor.clear":"Borrar","editor.recognize":"Reconocer","editor.recognizing":"Reconociendo...","editor.handwritingNote":"Dibuja tu ecuación arriba. El reconocimiento de escritura requiere integración con una API externa."},it:{"calculator.matrixA":"Matrice A","calculator.matrixB":"Matrice B","calculator.exprPlaceholder":"Inserisci un’espressione (es. x^2, sin(x))","calculator.differentiate":"Derivare","calculator.integrate":"Integrare","calculator.convert":"Converti","plotter.quickAdd":"Aggiungi un preset rapido...","plotter.noPlots":"Nessun grafico aggiunto","plotter.grid":"Griglia","plotter.axes":"Assi","editor.latexPlaceholder":"Inserisci un’equazione LaTeX...","editor.clear":"Cancella","editor.recognize":"Riconosci","editor.recognizing":"Riconoscimento...","editor.handwritingNote":"Disegna la tua equazione qui sopra. Il riconoscimento della scrittura richiede un’integrazione API esterna."},pt:{"calculator.matrixA":"Matriz A","calculator.matrixB":"Matriz B","calculator.exprPlaceholder":"Introduza uma expressão (p. ex. x^2, sin(x))","calculator.differentiate":"Derivar","calculator.integrate":"Integrar","calculator.convert":"Converter","plotter.quickAdd":"Adicionar predefinição rápida...","plotter.noPlots":"Ainda não foram adicionados gráficos","plotter.grid":"Grelha","plotter.axes":"Eixos","editor.latexPlaceholder":"Introduza uma equação LaTeX...","editor.clear":"Limpar","editor.recognize":"Reconhecer","editor.recognizing":"A reconhecer...","editor.handwritingNote":"Desenhe a sua equação acima. O reconhecimento de escrita requer integração com uma API externa."},cs:{"calculator.matrixA":"Matice A","calculator.matrixB":"Matice B","calculator.exprPlaceholder":"Zadejte výraz (např. x^2, sin(x))","calculator.differentiate":"Derivovat","calculator.integrate":"Integrovat","calculator.convert":"Převést","plotter.quickAdd":"Rychle přidat předvolbu...","plotter.noPlots":"Zatím nebyl přidán žádný graf","plotter.grid":"Mřížka","plotter.axes":"Osy","editor.latexPlaceholder":"Zadejte rovnici v LaTeXu...","editor.clear":"Vymazat","editor.recognize":"Rozpoznat","editor.recognizing":"Rozpoznávání...","editor.handwritingNote":"Nakreslete svou rovnici výše. Rozpoznávání rukopisu vyžaduje externí integraci API."},uk:{"calculator.matrixA":"Матриця A","calculator.matrixB":"Матриця B","calculator.exprPlaceholder":"Введіть вираз (напр. x^2, sin(x))","calculator.differentiate":"Диференціювати","calculator.integrate":"Інтегрувати","calculator.convert":"Перетворити","plotter.quickAdd":"Швидко додати пресет...","plotter.noPlots":"Поки що не додано жодного графіка","plotter.grid":"Сітка","plotter.axes":"Осі","editor.latexPlaceholder":"Введіть рівняння в LaTeX...","editor.clear":"Очистити","editor.recognize":"Розпізнати","editor.recognizing":"Розпізнавання...","editor.handwritingNote":"Намалюйте своє рівняння вище. Розпізнавання рукопису потребує зовнішньої інтеграції з API."}},I18nContext=we.createContext({locale:"en",t:(e,r)=>r??e});function NiceI18nProvider({locale:e="en",overrides:r,children:t}){const a=we.useMemo(()=>{const n={...translations.en,...translations[e],...r};return{locale:e,t:(i,c)=>n[i]??c??i}},[e,r]);return we.createElement(I18nContext.Provider,{value:a},t)}function useNiceTranslation(){return we.useContext(I18nContext)}const MATH_EDITOR_TOUR=[{target:".nice-math-editor",titleKey:"tutorial.mathEditor.intro.title",title:"Math editor",contentKey:"tutorial.mathEditor.intro.content",content:"Write equations as LaTeX or insert symbols from the palette; switch to handwriting input, and preview the rendered formula live.",placement:"auto"}],MATH_SYMBOLS=[{name:"alpha",latex:"\\alpha",category:"greek",preview:"α"},{name:"beta",latex:"\\beta",category:"greek",preview:"β"},{name:"gamma",latex:"\\gamma",category:"greek",preview:"γ"},{name:"delta",latex:"\\delta",category:"greek",preview:"δ"},{name:"epsilon",latex:"\\epsilon",category:"greek",preview:"ε"},{name:"zeta",latex:"\\zeta",category:"greek",preview:"ζ"},{name:"eta",latex:"\\eta",category:"greek",preview:"η"},{name:"theta",latex:"\\theta",category:"greek",preview:"θ"},{name:"iota",latex:"\\iota",category:"greek",preview:"ι"},{name:"kappa",latex:"\\kappa",category:"greek",preview:"κ"},{name:"lambda",latex:"\\lambda",category:"greek",preview:"λ"},{name:"mu",latex:"\\mu",category:"greek",preview:"μ"},{name:"nu",latex:"\\nu",category:"greek",preview:"ν"},{name:"xi",latex:"\\xi",category:"greek",preview:"ξ"},{name:"pi",latex:"\\pi",category:"greek",preview:"π"},{name:"rho",latex:"\\rho",category:"greek",preview:"ρ"},{name:"sigma",latex:"\\sigma",category:"greek",preview:"σ"},{name:"tau",latex:"\\tau",category:"greek",preview:"τ"},{name:"upsilon",latex:"\\upsilon",category:"greek",preview:"υ"},{name:"phi",latex:"\\phi",category:"greek",preview:"φ"},{name:"chi",latex:"\\chi",category:"greek",preview:"χ"},{name:"psi",latex:"\\psi",category:"greek",preview:"ψ"},{name:"omega",latex:"\\omega",category:"greek",preview:"ω"},{name:"Gamma",latex:"\\Gamma",category:"greek",preview:"Γ"},{name:"Delta",latex:"\\Delta",category:"greek",preview:"Δ"},{name:"Theta",latex:"\\Theta",category:"greek",preview:"Θ"},{name:"Lambda",latex:"\\Lambda",category:"greek",preview:"Λ"},{name:"Xi",latex:"\\Xi",category:"greek",preview:"Ξ"},{name:"Pi",latex:"\\Pi",category:"greek",preview:"Π"},{name:"Sigma",latex:"\\Sigma",category:"greek",preview:"Σ"},{name:"Phi",latex:"\\Phi",category:"greek",preview:"Φ"},{name:"Psi",latex:"\\Psi",category:"greek",preview:"Ψ"},{name:"Omega",latex:"\\Omega",category:"greek",preview:"Ω"},{name:"plus/minus",latex:"\\pm",category:"operators",preview:"±"},{name:"minus/plus",latex:"\\mp",category:"operators",preview:"∓"},{name:"times",latex:"\\times",category:"operators",preview:"×"},{name:"divide",latex:"\\div",category:"operators",preview:"÷"},{name:"cdot",latex:"\\cdot",category:"operators",preview:"·"},{name:"star",latex:"\\star",category:"operators",preview:"⋆"},{name:"circle",latex:"\\circ",category:"operators",preview:"∘"},{name:"bullet",latex:"\\bullet",category:"operators",preview:"•"},{name:"oplus",latex:"\\oplus",category:"operators",preview:"⊕"},{name:"otimes",latex:"\\otimes",category:"operators",preview:"⊗"},{name:"odot",latex:"\\odot",category:"operators",preview:"⊙"},{name:"less than",latex:"<",category:"relations",preview:"<"},{name:"greater than",latex:">",category:"relations",preview:">"},{name:"less or equal",latex:"\\leq",category:"relations",preview:"≤"},{name:"greater or equal",latex:"\\geq",category:"relations",preview:"≥"},{name:"not equal",latex:"\\neq",category:"relations",preview:"≠"},{name:"approximately",latex:"\\approx",category:"relations",preview:"≈"},{name:"equivalent",latex:"\\equiv",category:"relations",preview:"≡"},{name:"similar",latex:"\\sim",category:"relations",preview:"∼"},{name:"proportional",latex:"\\propto",category:"relations",preview:"∝"},{name:"perpendicular",latex:"\\perp",category:"relations",preview:"⊥"},{name:"parallel",latex:"\\parallel",category:"relations",preview:"∥"},{name:"right arrow",latex:"\\rightarrow",category:"arrows",preview:"→"},{name:"left arrow",latex:"\\leftarrow",category:"arrows",preview:"←"},{name:"double right",latex:"\\Rightarrow",category:"arrows",preview:"⇒"},{name:"double left",latex:"\\Leftarrow",category:"arrows",preview:"⇐"},{name:"iff",latex:"\\Leftrightarrow",category:"arrows",preview:"⇔"},{name:"up arrow",latex:"\\uparrow",category:"arrows",preview:"↑"},{name:"down arrow",latex:"\\downarrow",category:"arrows",preview:"↓"},{name:"maps to",latex:"\\mapsto",category:"arrows",preview:"↦"},{name:"sine",latex:"\\sin",category:"functions",preview:"sin"},{name:"cosine",latex:"\\cos",category:"functions",preview:"cos"},{name:"tangent",latex:"\\tan",category:"functions",preview:"tan"},{name:"cotangent",latex:"\\cot",category:"functions",preview:"cot"},{name:"arcsine",latex:"\\arcsin",category:"functions",preview:"arcsin"},{name:"arccosine",latex:"\\arccos",category:"functions",preview:"arccos"},{name:"arctangent",latex:"\\arctan",category:"functions",preview:"arctan"},{name:"logarithm",latex:"\\log",category:"functions",preview:"log"},{name:"natural log",latex:"\\ln",category:"functions",preview:"ln"},{name:"exponential",latex:"\\exp",category:"functions",preview:"exp"},{name:"limit",latex:"\\lim",category:"functions",preview:"lim"},{name:"supremum",latex:"\\sup",category:"functions",preview:"sup"},{name:"infimum",latex:"\\inf",category:"functions",preview:"inf"},{name:"maximum",latex:"\\max",category:"functions",preview:"max"},{name:"minimum",latex:"\\min",category:"functions",preview:"min"},{name:"hat",latex:"\\hat{x}",category:"accents",preview:"x̂"},{name:"bar",latex:"\\bar{x}",category:"accents",preview:"x̄"},{name:"vector",latex:"\\vec{x}",category:"accents",preview:"x⃗"},{name:"dot",latex:"\\dot{x}",category:"accents",preview:"ẋ"},{name:"double dot",latex:"\\ddot{x}",category:"accents",preview:"ẍ"},{name:"tilde",latex:"\\tilde{x}",category:"accents",preview:"x̃"},{name:"parentheses",latex:"\\left( \\right)",category:"delimiters",preview:"( )"},{name:"brackets",latex:"\\left[ \\right]",category:"delimiters",preview:"[ ]"},{name:"braces",latex:"\\left\\{ \\right\\}",category:"delimiters",preview:"{ }"},{name:"angle brackets",latex:"\\left\\langle \\right\\rangle",category:"delimiters",preview:"⟨ ⟩"},{name:"ceiling",latex:"\\left\\lceil \\right\\rceil",category:"delimiters",preview:"⌈ ⌉"},{name:"floor",latex:"\\left\\lfloor \\right\\rfloor",category:"delimiters",preview:"⌊ ⌋"},{name:"absolute",latex:"\\left| \\right|",category:"delimiters",preview:"| |"},{name:"norm",latex:"\\left\\| \\right\\|",category:"delimiters",preview:"‖ ‖"},{name:"element of",latex:"\\in",category:"sets",preview:"∈"},{name:"not element",latex:"\\notin",category:"sets",preview:"∉"},{name:"contains",latex:"\\ni",category:"sets",preview:"∋"},{name:"subset",latex:"\\subset",category:"sets",preview:"⊂"},{name:"superset",latex:"\\supset",category:"sets",preview:"⊃"},{name:"subset or equal",latex:"\\subseteq",category:"sets",preview:"⊆"},{name:"union",latex:"\\cup",category:"sets",preview:"∪"},{name:"intersection",latex:"\\cap",category:"sets",preview:"∩"},{name:"set minus",latex:"\\setminus",category:"sets",preview:"∖"},{name:"empty set",latex:"\\emptyset",category:"sets",preview:"∅"},{name:"naturals",latex:"\\mathbb{N}",category:"sets",preview:"ℕ"},{name:"integers",latex:"\\mathbb{Z}",category:"sets",preview:"ℤ"},{name:"rationals",latex:"\\mathbb{Q}",category:"sets",preview:"ℚ"},{name:"reals",latex:"\\mathbb{R}",category:"sets",preview:"ℝ"},{name:"complex",latex:"\\mathbb{C}",category:"sets",preview:"ℂ"},{name:"for all",latex:"\\forall",category:"logic",preview:"∀"},{name:"exists",latex:"\\exists",category:"logic",preview:"∃"},{name:"not exists",latex:"\\nexists",category:"logic",preview:"∄"},{name:"and",latex:"\\land",category:"logic",preview:"∧"},{name:"or",latex:"\\lor",category:"logic",preview:"∨"},{name:"not",latex:"\\neg",category:"logic",preview:"¬"},{name:"therefore",latex:"\\therefore",category:"logic",preview:"∴"},{name:"because",latex:"\\because",category:"logic",preview:"∵"},{name:"integral",latex:"\\int",category:"calculus",preview:"∫"},{name:"double integral",latex:"\\iint",category:"calculus",preview:"∬"},{name:"triple integral",latex:"\\iiint",category:"calculus",preview:"∭"},{name:"contour integral",latex:"\\oint",category:"calculus",preview:"∮"},{name:"partial",latex:"\\partial",category:"calculus",preview:"∂"},{name:"nabla/gradient",latex:"\\nabla",category:"calculus",preview:"∇"},{name:"summation",latex:"\\sum",category:"calculus",preview:"Σ"},{name:"product",latex:"\\prod",category:"calculus",preview:"Π"},{name:"infinity",latex:"\\infty",category:"calculus",preview:"∞"},{name:"matrix",latex:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",category:"matrices",preview:"[ ]"},{name:"determinant",latex:"\\begin{vmatrix} a & b \\\\ c & d \\end{vmatrix}",category:"matrices",preview:"| |"},{name:"bracket matrix",latex:"\\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix}",category:"matrices",preview:"[[ ]]"},{name:"cases",latex:"\\begin{cases} a & \\text{if } x > 0 \\\\ b & \\text{otherwise} \\end{cases}",category:"matrices",preview:"{ }"}];function getSymbolsByCategory(e){return MATH_SYMBOLS.filter(r=>r.category===e)}const EQUATION_TEMPLATES=[{name:"Fraction",latex:"\\frac{a}{b}",category:"basic"},{name:"Square root",latex:"\\sqrt{x}",category:"basic"},{name:"Nth root",latex:"\\sqrt[n]{x}",category:"basic"},{name:"Power",latex:"x^{n}",category:"basic"},{name:"Subscript",latex:"x_{n}",category:"basic"},{name:"Both",latex:"x_{i}^{n}",category:"basic"},{name:"Derivative",latex:"\\frac{d}{dx}f(x)",category:"calculus"},{name:"Partial derivative",latex:"\\frac{\\partial f}{\\partial x}",category:"calculus"},{name:"Definite integral",latex:"\\int_{a}^{b} f(x)\\,dx",category:"calculus"},{name:"Indefinite integral",latex:"\\int f(x)\\,dx",category:"calculus"},{name:"Limit",latex:"\\lim_{x \\to a} f(x)",category:"calculus"},{name:"Summation",latex:"\\sum_{i=1}^{n} a_i",category:"calculus"},{name:"Product",latex:"\\prod_{i=1}^{n} a_i",category:"calculus"},{name:"Quadratic formula",latex:"x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}",category:"algebra"},{name:"Binomial",latex:"\\binom{n}{k} = \\frac{n!}{k!(n-k)!}",category:"algebra"},{name:"System of equations",latex:"\\begin{cases} ax + by = c \\\\ dx + ey = f \\end{cases}",category:"algebra"},{name:"Pythagorean",latex:"a^2 + b^2 = c^2",category:"geometry"},{name:"Circle area",latex:"A = \\pi r^2",category:"geometry"},{name:"Sphere volume",latex:"V = \\frac{4}{3}\\pi r^3",category:"geometry"},{name:"Euler's identity",latex:"e^{i\\pi} + 1 = 0",category:"geometry"},{name:"Mean",latex:"\\bar{x} = \\frac{1}{n}\\sum_{i=1}^{n} x_i",category:"statistics"},{name:"Variance",latex:"\\sigma^2 = \\frac{1}{n}\\sum_{i=1}^{n}(x_i - \\bar{x})^2",category:"statistics"},{name:"Normal distribution",latex:"f(x) = \\frac{1}{\\sigma\\sqrt{2\\pi}}e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}",category:"statistics"},{name:"Einstein mass-energy",latex:"E = mc^2",category:"physics"},{name:"Newton's second law",latex:"F = ma",category:"physics"},{name:"Schrödinger equation",latex:"i\\hbar\\frac{\\partial}{\\partial t}\\Psi = \\hat{H}\\Psi",category:"physics"},{name:"Maxwell's equations",latex:"\\nabla \\cdot \\vec{E} = \\frac{\\rho}{\\epsilon_0}",category:"physics"}];class MathEditorService{constructor(r={}){C(this,"equations",new Map);C(this,"config");C(this,"nextNumber");this.config={enableNumbering:r.enableNumbering??!0,startNumber:r.startNumber??1,renderDelay:r.renderDelay??100},this.nextNumber=this.config.startNumber}createEquation(r,t){const a={id:this.generateId(),latex:r,label:t,number:this.config.enableNumbering?this.nextNumber++:void 0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return this.equations.set(a.id,a),a}updateEquation(r,t,a){const n=this.equations.get(r);if(!n)throw new Error(`Equation not found: ${r}`);const o={...n,latex:t,label:a??n.label,updatedAt:new Date().toISOString()};return this.equations.set(r,o),o}deleteEquation(r){this.equations.delete(r)}getEquation(r){return this.equations.get(r)}listEquations(){return Array.from(this.equations.values()).sort((r,t)=>new Date(r.createdAt).getTime()-new Date(t.createdAt).getTime())}exportToLatex(){const r=["\\documentclass{article}","\\usepackage{amsmath}","\\usepackage{amssymb}","","\\begin{document}",""];for(const t of this.listEquations())t.number!==void 0?(r.push("\\begin{equation}"),t.label&&r.push(`\\label{${t.label}}`),r.push(t.latex),r.push("\\end{equation}")):(r.push("\\["),r.push(t.latex),r.push("\\]")),r.push("");return r.push("\\end{document}"),r.join(`
|
|
28
|
+
`)}parseLatex(r){const t=[],a=/\\\[([\s\S]*?)\\\]/g;let n;for(;(n=a.exec(r))!==null;)t.push(this.createEquation(n[1].trim()));const o=/\\begin\{equation\}([\s\S]*?)\\end\{equation\}/g;for(;(n=o.exec(r))!==null;){const i=n[1].match(/\\label\{([^}]+)\}/),c=n[1].replace(/\\label\{[^}]+\}/,"").trim();t.push(this.createEquation(c,i==null?void 0:i[1]))}return t}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}}function createMathEditorService(e){return new MathEditorService(e)}async function recognizeHandwriting(e){return await new Promise(t=>setTimeout(t,500)),{latex:e.reduce((t,a)=>t+a.points.length,0)>50?"\\sqrt{x^2 + y^2}":"x",confidence:.85,alternatives:["x","X","\\times"]}}const MathEditorContext=we.createContext(null);function useMathEditor(){const e=we.useContext(MathEditorContext);if(!e)throw new Error("useMathEditor must be used within MathEditorProvider");return e}const styles$3={container:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"'Inter', sans-serif",fontSize:"14px"},toolbar:{display:"flex",gap:"8px",padding:"8px",borderBottom:"1px solid var(--nice-border, #e0e0e0)",backgroundColor:"var(--nice-bg-secondary, #fafafa)",flexWrap:"wrap",alignItems:"center"},main:{display:"flex",flex:1,overflow:"hidden"},sidebar:{width:"200px",borderRight:"1px solid var(--nice-border, #e0e0e0)",overflow:"auto",backgroundColor:"var(--nice-bg-secondary, #f5f5f5)"},editor:{flex:1,display:"flex",flexDirection:"column",padding:"16px",overflow:"auto"},input:{width:"100%",minHeight:"100px",padding:"12px",fontFamily:"'JetBrains Mono', monospace",fontSize:"14px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",resize:"vertical"},preview:{marginTop:"16px",padding:"20px",backgroundColor:"var(--nice-bg, #fff)",border:"1px solid var(--nice-border, #e0e0e0)",borderRadius:"4px",minHeight:"60px",fontSize:"20px",textAlign:"center"},button:{padding:"6px 12px",backgroundColor:"var(--nice-primary-hover, #1976d2)",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px"},symbolGrid:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"4px",padding:"8px"},symbolButton:{padding:"8px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",backgroundColor:"var(--nice-bg, #fff)",cursor:"pointer",fontSize:"16px",textAlign:"center"},categoryHeader:{padding:"8px 12px",backgroundColor:"var(--nice-border, #e0e0e0)",fontWeight:600,fontSize:"12px",textTransform:"uppercase"},canvas:{width:"100%",height:"200px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",backgroundColor:"var(--nice-bg, #fff)",cursor:"crosshair"}};function NiceMathEditor({service:e,initialLatex:r="",onChange:t,className:a,style:n,tutorial:o}){const{t:i}=useNiceTranslation(),[c,f]=we.useState(r),[s,d]=we.useState("input"),m=we.useRef(null),y=we.useCallback(b=>{f(b),t==null||t(b)},[t]),g=we.useCallback(b=>{const l=m.current;if(!l){y(c+b);return}const p=l.selectionStart,h=l.selectionEnd,j=c.slice(0,p)+b+c.slice(h);y(j),setTimeout(()=>{l.focus(),l.selectionStart=l.selectionEnd=p+b.length},0)},[c,y]),w=we.useCallback(b=>{g(b.latex)},[g]),u={service:e,latex:c,setLatex:y,insertSymbol:g,insertTemplate:w,mode:s,setMode:d};return jsxRuntime.jsx(MathEditorContext.Provider,{value:u,children:jsxRuntime.jsxs("div",{className:`nice-math-editor ${a??""}`,style:{position:"relative",...styles$3.container,...n},children:[jsxRuntime.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:jsxRuntime.jsx(Ll,{steps:El(o,MATH_EDITOR_TOUR)})}),jsxRuntime.jsx(Toolbar$1,{}),jsxRuntime.jsxs("div",{style:styles$3.main,children:[jsxRuntime.jsx(SymbolPalette,{}),jsxRuntime.jsx("div",{style:styles$3.editor,children:s==="input"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("textarea",{ref:m,value:c,onChange:b=>y(b.target.value),placeholder:i("editor.latexPlaceholder","Enter LaTeX equation..."),style:styles$3.input}),jsxRuntime.jsx(LatexPreview,{latex:c})]}):jsxRuntime.jsx(HandwritingCanvas,{})})]})]})})}function Toolbar$1(){const{mode:e,setMode:r,latex:t,insertTemplate:a}=useMathEditor(),[n,o]=we.useState(!1);return jsxRuntime.jsxs("div",{style:styles$3.toolbar,children:[jsxRuntime.jsx("button",{onClick:()=>r("input"),style:{...styles$3.button,backgroundColor:e==="input"?"var(--nice-primary-hover, #1976d2)":"var(--nice-text-secondary, #9e9e9e)"},children:"⌨️ LaTeX Input"}),jsxRuntime.jsx("button",{onClick:()=>r("handwriting"),style:{...styles$3.button,backgroundColor:e==="handwriting"?"var(--nice-primary-hover, #1976d2)":"var(--nice-text-secondary, #9e9e9e)"},children:"✏️ Handwriting"}),jsxRuntime.jsx("div",{style:{borderLeft:"1px solid var(--nice-border, #ccc)",height:"24px",margin:"0 8px"}}),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsx("button",{onClick:()=>o(!n),style:styles$3.button,children:"📐 Templates ▾"}),n&&jsxRuntime.jsx("div",{style:{position:"absolute",top:"100%",left:0,backgroundColor:"var(--nice-bg, #fff)",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",boxShadow:"0 2px 8px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",zIndex:100,width:"300px",maxHeight:"400px",overflow:"auto"},children:["basic","calculus","algebra","geometry","statistics","physics"].map(i=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:styles$3.categoryHeader,children:i}),EQUATION_TEMPLATES.filter(c=>c.category===i).map(c=>jsxRuntime.jsxs("div",{onClick:()=>{a(c),o(!1)},style:{padding:"8px 12px",cursor:"pointer",borderBottom:"1px solid var(--nice-border, #eee)"},onMouseOver:f=>f.target.style.backgroundColor="var(--nice-bg-secondary, #f5f5f5)",onMouseOut:f=>f.target.style.backgroundColor="transparent",children:[jsxRuntime.jsx("div",{style:{fontWeight:500},children:c.name}),jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",fontFamily:"monospace"},children:[c.latex.substring(0,40),c.latex.length>40?"...":""]})]},c.name))]},i))})]}),jsxRuntime.jsx("div",{style:{flex:1}}),jsxRuntime.jsx("button",{onClick:()=>navigator.clipboard.writeText(t),style:{...styles$3.button,backgroundColor:"var(--nice-success, #4caf50)"},children:"📋 Copy LaTeX"})]})}function SymbolPalette(){const{insertSymbol:e}=useMathEditor(),[r,t]=we.useState("greek"),a=["greek","operators","relations","arrows","functions","accents","delimiters","sets","logic","calculus","matrices"],n=getSymbolsByCategory(r);return jsxRuntime.jsxs("div",{style:styles$3.sidebar,children:[jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",padding:"8px",gap:"4px"},children:a.map(o=>jsxRuntime.jsx("button",{onClick:()=>t(o),style:{padding:"4px 8px",fontSize:"11px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",backgroundColor:r===o?"var(--nice-primary-hover, #1976d2)":"var(--nice-bg, #fff)",color:r===o?"var(--nice-bg, #fff)":"var(--nice-text, #333)",cursor:"pointer"},children:o},o))}),jsxRuntime.jsx("div",{style:styles$3.symbolGrid,children:n.map(o=>jsxRuntime.jsx("button",{onClick:()=>e(o.latex),style:styles$3.symbolButton,title:`${o.name}: ${o.latex}`,children:o.preview||o.latex},o.name))})]})}function LatexPreview({latex:e}){return jsxRuntime.jsxs("div",{style:styles$3.preview,children:[jsxRuntime.jsx("div",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",marginBottom:"8px"},children:"Preview (requires KaTeX/MathJax integration):"}),jsxRuntime.jsx("code",{style:{fontSize:"16px"},children:e||"(empty)"})]})}function HandwritingCanvas(){const{t:e}=useNiceTranslation(),{setLatex:r,setMode:t}=useMathEditor(),a=we.useRef(null),[n,o]=we.useState([]),[i,c]=we.useState([]),[f,s]=we.useState(!1),[d,m]=we.useState(!1),y=l=>{const p=a.current;if(!p)return;s(!0);const h=p.getBoundingClientRect();c([{x:l.clientX-h.left,y:l.clientY-h.top,pressure:l.pressure,timestamp:Date.now()}])},g=l=>{if(!f)return;const p=a.current,h=p==null?void 0:p.getContext("2d");if(!p||!h)return;const j=p.getBoundingClientRect(),x={x:l.clientX-j.left,y:l.clientY-j.top,pressure:l.pressure,timestamp:Date.now()};if(c(v=>[...v,x]),i.length>0){const v=i[i.length-1];h.beginPath(),h.moveTo(v.x,v.y),h.lineTo(x.x,x.y),h.strokeStyle="var(--nice-text, #000)",h.lineWidth=2,h.lineCap="round",h.stroke()}},w=()=>{if(f){if(s(!1),i.length>1){const l={id:Date.now().toString(),points:[...i]};o(p=>[...p,l])}c([])}},u=()=>{const l=a.current,p=l==null?void 0:l.getContext("2d");p&&l&&p.clearRect(0,0,l.width,l.height),o([])},b=async()=>{if(n.length!==0){m(!0);try{const l=await recognizeHandwriting(n);r(l.latex),t("input")}finally{m(!1)}}};return we.useEffect(()=>{const l=a.current;l&&(l.width=l.offsetWidth,l.height=200)},[]),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("canvas",{ref:a,style:styles$3.canvas,onPointerDown:y,onPointerMove:g,onPointerUp:w,onPointerLeave:w}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"12px"},children:[jsxRuntime.jsx("button",{onClick:u,style:{...styles$3.button,backgroundColor:"var(--nice-danger, #f44336)"},children:e("editor.clear","Clear")}),jsxRuntime.jsx("button",{onClick:b,disabled:n.length===0||d,style:styles$3.button,children:d?e("editor.recognizing","Recognizing..."):e("editor.recognize","Recognize")})]}),jsxRuntime.jsx("p",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",marginTop:"8px"},children:e("editor.handwritingNote","Draw your equation above. Handwriting recognition requires external API integration.")})]})}const mathConstants={pi:Math.PI,PI:Math.PI,e:Math.E,E:Math.E,phi:(1+Math.sqrt(5))/2,tau:Math.PI*2},mathFunctions={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,sqrt:Math.sqrt,cbrt:Math.cbrt,abs:Math.abs,floor:Math.floor,ceil:Math.ceil,round:Math.round,exp:Math.exp,log:Math.log,log10:Math.log10,log2:Math.log2,pow:Math.pow,min:Math.min,max:Math.max,sign:Math.sign,hypot:Math.hypot,sec:e=>1/Math.cos(e),csc:e=>1/Math.sin(e),cot:e=>1/Math.tan(e),ln:Math.log};class ExpressionParser{constructor(){C(this,"pos",0);C(this,"expr","")}parse(r){this.expr=r.replace(/\s+/g,""),this.pos=0;const t=this.parseAddSub();return a=>this.evaluate(t,{...mathConstants,...a})}parseAddSub(){let r=this.parseMulDiv();for(;this.pos<this.expr.length;){const t=this.expr[this.pos];if(t!=="+"&&t!=="-")break;this.pos++;const a=this.parseMulDiv();r={type:"binary",op:t,left:r,right:a}}return r}parseMulDiv(){let r=this.parsePower();for(;this.pos<this.expr.length;){const t=this.expr[this.pos];if(t!=="*"&&t!=="/")break;this.pos++;const a=this.parsePower();r={type:"binary",op:t,left:r,right:a}}return r}parsePower(){let r=this.parseUnary();for(;this.pos<this.expr.length&&this.expr[this.pos]==="^";){this.pos++;const t=this.parseUnary();r={type:"binary",op:"^",left:r,right:t}}return r}parseUnary(){return this.expr[this.pos]==="-"?(this.pos++,{type:"unary",op:"-",arg:this.parseUnary()}):(this.expr[this.pos]==="+"&&this.pos++,this.parsePrimary())}parsePrimary(){if(this.expr[this.pos]==="("){this.pos++;const a=this.parseAddSub();return this.expr[this.pos]===")"&&this.pos++,a}const r=this.expr.slice(this.pos).match(/^(\d+\.?\d*)/);if(r)return this.pos+=r[1].length,{type:"number",value:parseFloat(r[1])};const t=this.expr.slice(this.pos).match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);if(t){const a=t[1];if(this.pos+=a.length,this.expr[this.pos]==="("){this.pos++;const n=[];for(;this.expr[this.pos]!==")"&&this.pos<this.expr.length;)n.push(this.parseAddSub()),this.expr[this.pos]===","&&this.pos++;return this.expr[this.pos]===")"&&this.pos++,{type:"call",name:a,args:n}}return{type:"variable",name:a}}return{type:"number",value:0}}evaluate(r,t){switch(r.type){case"number":return r.value;case"variable":if(r.name in t)return t[r.name];throw new Error(`Unknown variable: ${r.name}`);case"unary":return r.op==="-"?-this.evaluate(r.arg,t):this.evaluate(r.arg,t);case"binary":{const a=this.evaluate(r.left,t),n=this.evaluate(r.right,t);switch(r.op){case"+":return a+n;case"-":return a-n;case"*":return a*n;case"/":return a/n;case"^":return Math.pow(a,n);default:return 0}}case"call":{const a=mathFunctions[r.name];if(!a)throw new Error(`Unknown function: ${r.name}`);const n=r.args.map(o=>this.evaluate(o,t));return a(...n)}default:return 0}}}class GraphService{constructor(r={}){C(this,"plots",new Map);C(this,"parser",new ExpressionParser);C(this,"config");this.config={defaultResolution:r.defaultResolution??200,maxResolution:r.maxResolution??1e3}}addPlot(r){const t={id:this.generateId(),type:r.type,expression:r.expression,expressionY:r.expressionY,expressionZ:r.expressionZ,label:r.label,color:r.color??{r:66,g:133,b:244},lineWidth:r.lineWidth??2,visible:r.visible??!0,parameterRange:r.parameterRange??{min:-Math.PI,max:Math.PI},parameterRange2:r.parameterRange2??{min:-Math.PI,max:Math.PI},resolution:r.resolution??this.config.defaultResolution};return this.plots.set(t.id,t),t}updatePlot(r,t){const a=this.plots.get(r);if(!a)throw new Error(`Plot not found: ${r}`);const n={...a,...t,id:a.id};return this.plots.set(r,n),n}removePlot(r){this.plots.delete(r)}getPlots(){return Array.from(this.plots.values())}getPlot(r){return this.plots.get(r)}compute2DFunction(r,t,a,n){const o=this.parser.parse(r),i=[],c=(t.max-t.min)/a;for(let f=0;f<=a;f++){const s=t.min+f*c;try{const d=o({x:s,...n});Number.isFinite(d)&&i.push({x:s,y:d})}catch{}}return i}compute2DParametric(r,t,a,n,o){const i=this.parser.parse(r),c=this.parser.parse(t),f=[],s=(a.max-a.min)/n;for(let d=0;d<=n;d++){const m=a.min+d*s;try{const y=i({t:m,...o}),g=c({t:m,...o});Number.isFinite(y)&&Number.isFinite(g)&&f.push({x:y,y:g})}catch{}}return f}compute2DPolar(r,t,a,n){const o=this.parser.parse(r),i=[],c=(t.max-t.min)/a;for(let f=0;f<=a;f++){const s=t.min+f*c;try{const d=o({theta:s,t:s,...n});if(Number.isFinite(d)){const m=d*Math.cos(s),y=d*Math.sin(s);i.push({x:m,y})}}catch{}}return i}compute3DSurface(r,t,a,n,o){const i=this.parser.parse(r),c=[],f=(t.max-t.min)/n,s=(a.max-a.min)/n;for(let d=0;d<=n;d++){const m=[],y=t.min+d*f;for(let g=0;g<=n;g++){const w=a.min+g*s;try{const u=i({x:y,y:w,...o});Number.isFinite(u)?m.push({x:y,y:w,z:u}):m.push({x:y,y:w,z:0})}catch{m.push({x:y,y:w,z:0})}}c.push(m)}return c}exportSVG(r,t,a,n){const i=a-80,c=n-40*2,f=m=>40+(m-t.xRange.min)/(t.xRange.max-t.xRange.min)*i,s=m=>n-40-(m-t.yRange.min)/(t.yRange.max-t.yRange.min)*c,d=[`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${n}">`,`<rect width="100%" height="100%" fill="rgb(${t.backgroundColor.r},${t.backgroundColor.g},${t.backgroundColor.b})"/>`];if(t.showGrid){d.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');for(let m=Math.ceil(t.xRange.min);m<=t.xRange.max;m++){const y=f(m);d.push(`<line x1="${y}" y1="40" x2="${y}" y2="${n-40}"/>`)}for(let m=Math.ceil(t.yRange.min);m<=t.yRange.max;m++){const y=s(m);d.push(`<line x1="40" y1="${y}" x2="${a-40}" y2="${y}"/>`)}d.push("</g>")}if(t.showAxes){d.push('<g stroke="var(--nice-text, #333)" stroke-width="1">');const m=s(0),y=f(0);d.push(`<line x1="40" y1="${m}" x2="${a-40}" y2="${m}"/>`),d.push(`<line x1="${y}" y1="40" x2="${y}" y2="${n-40}"/>`),d.push("</g>")}for(const m of r.filter(y=>y.visible))if(m.type==="2d-function"){const y=this.compute2DFunction(m.expression,t.xRange,m.resolution||200);if(y.length>0){const g=y.map((w,u)=>`${u===0?"M":"L"}${f(w.x)},${s(w.y)}`).join(" ");d.push(`<path d="${g}" fill="none" stroke="rgb(${m.color.r},${m.color.g},${m.color.b})" stroke-width="${m.lineWidth}"/>`)}}return t.showLabels&&(d.push(`<text x="${a/2}" y="${n-10}" text-anchor="middle" font-size="12">x</text>`),d.push(`<text x="10" y="${n/2}" text-anchor="middle" font-size="12" transform="rotate(-90,10,${n/2})">y</text>`)),d.push("</svg>"),d.join(`
|
|
29
|
+
`)}async exportPNG(r,t,a,n){const o=this.exportSVG(r,t,a,n);return new Promise((i,c)=>{const f=new Image;f.onload=()=>{const s=document.createElement("canvas");s.width=a,s.height=n;const d=s.getContext("2d");if(!d){c(new Error("Could not get canvas context"));return}d.drawImage(f,0,0),i(s.toDataURL("image/png"))},f.onerror=c,f.src="data:image/svg+xml;base64,"+btoa(o)})}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}}function createGraphService(e){return new GraphService(e)}const FUNCTION_PRESETS=[{name:"Linear",expression:"x",type:"2d-function",category:"basic"},{name:"Quadratic",expression:"x^2",type:"2d-function",category:"basic"},{name:"Cubic",expression:"x^3",type:"2d-function",category:"basic"},{name:"Square root",expression:"sqrt(x)",type:"2d-function",category:"basic"},{name:"Absolute",expression:"abs(x)",type:"2d-function",category:"basic"},{name:"Reciprocal",expression:"1/x",type:"2d-function",category:"basic"},{name:"Sine",expression:"sin(x)",type:"2d-function",category:"trigonometric"},{name:"Cosine",expression:"cos(x)",type:"2d-function",category:"trigonometric"},{name:"Tangent",expression:"tan(x)",type:"2d-function",category:"trigonometric"},{name:"Sine wave",expression:"sin(2*x)",type:"2d-function",category:"trigonometric"},{name:"Damped oscillation",expression:"exp(-x/5)*sin(x*3)",type:"2d-function",category:"trigonometric"},{name:"Exponential",expression:"exp(x)",type:"2d-function",category:"exponential"},{name:"Natural log",expression:"ln(x)",type:"2d-function",category:"exponential"},{name:"Gaussian",expression:"exp(-x^2)",type:"2d-function",category:"exponential"},{name:"Sigmoid",expression:"1/(1+exp(-x))",type:"2d-function",category:"exponential"},{name:"Circle",expression:"cos(t)",expressionY:"sin(t)",type:"2d-parametric",category:"parametric"},{name:"Ellipse",expression:"2*cos(t)",expressionY:"sin(t)",type:"2d-parametric",category:"parametric"},{name:"Lissajous",expression:"sin(3*t)",expressionY:"sin(2*t)",type:"2d-parametric",category:"parametric"},{name:"Spiral",expression:"t*cos(t)",expressionY:"t*sin(t)",type:"2d-parametric",category:"parametric"},{name:"Cardioid",expression:"(1-cos(t))*cos(t)",expressionY:"(1-cos(t))*sin(t)",type:"2d-parametric",category:"parametric"},{name:"Rose curve",expression:"cos(3*t)*cos(t)",expressionY:"cos(3*t)*sin(t)",type:"2d-parametric",category:"parametric"},{name:"Polar rose 3",expression:"cos(3*theta)",type:"2d-polar",category:"polar"},{name:"Polar rose 5",expression:"cos(5*theta)",type:"2d-polar",category:"polar"},{name:"Archimedean spiral",expression:"theta",type:"2d-polar",category:"polar"},{name:"Logarithmic spiral",expression:"exp(theta/10)",type:"2d-polar",category:"polar"},{name:"Paraboloid",expression:"x^2 + y^2",type:"3d-surface",category:"3d"},{name:"Saddle",expression:"x^2 - y^2",type:"3d-surface",category:"3d"},{name:"Ripple",expression:"sin(sqrt(x^2 + y^2))",type:"3d-surface",category:"3d"},{name:"Torus slice",expression:"cos(x)*sin(y)",type:"3d-surface",category:"3d"},{name:"Peaks",expression:"3*(1-x)^2*exp(-x^2-(y+1)^2) - 10*(x/5-x^3-y^5)*exp(-x^2-y^2) - 1/3*exp(-(x+1)^2-y^2)",type:"3d-surface",category:"3d"}],GraphContext=we.createContext(null);function useGraph(){const e=we.useContext(GraphContext);if(!e)throw new Error("useGraph must be used within GraphProvider");return e}const styles$2={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",fontSize:"14px"},sidebar:{width:"280px",borderRight:"1px solid var(--nice-border, #e0e0e0)",display:"flex",flexDirection:"column",overflow:"hidden"},plotList:{flex:1,overflow:"auto",padding:"8px"},main:{flex:1,display:"flex",flexDirection:"column",backgroundColor:"var(--nice-bg, #fff)"},canvas:{flex:1,backgroundColor:"var(--nice-bg, #fff)"},toolbar:{display:"flex",gap:"8px",padding:"8px",borderBottom:"1px solid var(--nice-border, #e0e0e0)",alignItems:"center"},button:{padding:"6px 12px",backgroundColor:"var(--nice-primary-hover, #1976d2)",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px"},input:{padding:"6px 8px",border:"1px solid var(--nice-border, #ddd)",borderRadius:"4px",fontSize:"13px"},plotItem:{padding:"8px",marginBottom:"8px",border:"1px solid var(--nice-border, #e0e0e0)",borderRadius:"4px",backgroundColor:"var(--nice-bg-secondary, #fafafa)"}};function NiceGraphPlotter({service:e,width:r=800,height:t=600,className:a,style:n}){const[o,i]=we.useState([]),[c,f]=we.useState({xRange:{min:-10,max:10},yRange:{min:-10,max:10},zRange:{min:-5,max:5},showGrid:!0,showAxes:!0,showLabels:!0,backgroundColor:{r:255,g:255,b:255},cameraRotationX:30,cameraRotationY:45,cameraDistance:5}),[s,d]=we.useState({isPlaying:!1,parameter:"a",currentValue:0,minValue:-5,maxValue:5,speed:1}),m=we.useCallback(()=>{i(e.getPlots())},[e]),y=we.useCallback(p=>{f(h=>({...h,...p}))},[]),g=we.useCallback(p=>{d(h=>({...h,...p}))},[]),w=we.useCallback(p=>{e.addPlot(p),m()},[e,m]),u=we.useCallback(p=>{e.removePlot(p),m()},[e,m]),b=we.useCallback((p,h)=>{e.updatePlot(p,h),m()},[e,m]),l={service:e,plots:o,view:c,setView:y,addPlot:w,removePlot:u,updatePlot:b,animation:s,setAnimation:g,refresh:m};return jsxRuntime.jsx(GraphContext.Provider,{value:l,children:jsxRuntime.jsxs("div",{className:a,style:{...styles$2.container,...n},children:[jsxRuntime.jsxs("div",{style:styles$2.sidebar,children:[jsxRuntime.jsx(PlotControls,{}),jsxRuntime.jsx(PlotList,{})]}),jsxRuntime.jsxs("div",{style:styles$2.main,children:[jsxRuntime.jsx(GraphToolbar,{width:r,height:t}),jsxRuntime.jsx(Canvas2D,{width:r,height:t})]})]})})}function PlotControls(){const{t:e}=useNiceTranslation(),{addPlot:r}=useGraph(),[t,a]=we.useState("sin(x)"),[n,o]=we.useState("2d-function"),[i,c]=we.useState("cos(x)"),f=()=>{r({type:n,expression:t,expressionY:n==="2d-parametric"?i:void 0,color:{r:Math.floor(Math.random()*200),g:Math.floor(Math.random()*200),b:Math.floor(Math.random()*200)}})};return jsxRuntime.jsxs("div",{style:{padding:"12px",borderBottom:"1px solid var(--nice-border, #e0e0e0)"},children:[jsxRuntime.jsx("div",{style:{marginBottom:"8px"},children:jsxRuntime.jsxs("select",{value:n,onChange:s=>o(s.target.value),style:{...styles$2.input,width:"100%"},children:[jsxRuntime.jsx("option",{value:"2d-function",children:"y = f(x)"}),jsxRuntime.jsx("option",{value:"2d-parametric",children:"Parametric (x(t), y(t))"}),jsxRuntime.jsx("option",{value:"2d-polar",children:"Polar r = f(θ)"}),jsxRuntime.jsx("option",{value:"3d-surface",children:"3D Surface z = f(x,y)"})]})}),jsxRuntime.jsx("div",{style:{marginBottom:"8px"},children:jsxRuntime.jsx("input",{type:"text",value:t,onChange:s=>a(s.target.value),placeholder:n==="2d-parametric"?"x(t) = ...":"Expression...",style:{...styles$2.input,width:"100%"}})}),n==="2d-parametric"&&jsxRuntime.jsx("div",{style:{marginBottom:"8px"},children:jsxRuntime.jsx("input",{type:"text",value:i,onChange:s=>c(s.target.value),placeholder:"y(t) = ...",style:{...styles$2.input,width:"100%"}})}),jsxRuntime.jsx("button",{onClick:f,style:{...styles$2.button,width:"100%"},children:"+ Add Plot"}),jsxRuntime.jsxs("select",{onChange:s=>{const d=FUNCTION_PRESETS.find(m=>m.name===s.target.value);d&&r({type:d.type,expression:d.expression,expressionY:d.expressionY,label:d.name,color:{r:Math.floor(Math.random()*200),g:Math.floor(Math.random()*200),b:Math.floor(Math.random()*200)}})},style:{...styles$2.input,width:"100%",marginTop:"8px"},value:"",children:[jsxRuntime.jsx("option",{value:"",disabled:!0,children:e("plotter.quickAdd","Quick add preset...")}),["basic","trigonometric","exponential","parametric","polar","3d"].map(s=>jsxRuntime.jsx("optgroup",{label:s.charAt(0).toUpperCase()+s.slice(1),children:FUNCTION_PRESETS.filter(d=>d.category===s).map(d=>jsxRuntime.jsxs("option",{value:d.name,children:[d.name,": ",d.expression]},d.name))},s))]})]})}function PlotList(){const{t:e}=useNiceTranslation(),{plots:r,removePlot:t,updatePlot:a}=useGraph();return jsxRuntime.jsxs("div",{style:styles$2.plotList,children:[r.length===0&&jsxRuntime.jsx("div",{style:{color:"var(--nice-text-secondary, #666)",textAlign:"center",padding:"16px"},children:e("plotter.noPlots","No plots added yet")}),r.map(n=>jsxRuntime.jsxs("div",{style:styles$2.plotItem,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.visible,onChange:o=>a(n.id,{visible:o.target.checked})}),jsxRuntime.jsx("div",{style:{width:"16px",height:"16px",borderRadius:"3px",backgroundColor:`rgb(${n.color.r},${n.color.g},${n.color.b})`}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:n.label||n.expression}),jsxRuntime.jsx("button",{onClick:()=>t(n.id),style:{padding:"2px 6px",backgroundColor:"var(--nice-danger, #f44336)",color:"white",border:"none",borderRadius:"3px",cursor:"pointer",fontSize:"12px"},children:"×"})]}),jsxRuntime.jsx("div",{style:{fontSize:"12px",color:"var(--nice-text-secondary, #666)",fontFamily:"monospace"},children:n.type==="2d-parametric"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["x(t) = ",n.expression,jsxRuntime.jsx("br",{}),"y(t) = ",n.expressionY]}):n.expression})]},n.id))]})}function GraphToolbar({width:e,height:r}){const{t}=useNiceTranslation(),{service:a,plots:n,view:o,setView:i}=useGraph(),c=()=>{const s=a.exportSVG(n,o,e,r),d=new Blob([s],{type:"image/svg+xml"}),m=URL.createObjectURL(d),y=document.createElement("a");y.href=m,y.download="graph.svg",y.click(),URL.revokeObjectURL(m)},f=async()=>{const s=await a.exportPNG(n,o,e,r),d=document.createElement("a");d.href=s,d.download="graph.png",d.click()};return jsxRuntime.jsxs("div",{style:styles$2.toolbar,children:[jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:["X: ["," ",jsxRuntime.jsx("input",{type:"number",value:o.xRange.min,onChange:s=>i({xRange:{...o.xRange,min:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),","," ",jsxRuntime.jsx("input",{type:"number",value:o.xRange.max,onChange:s=>i({xRange:{...o.xRange,max:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),"]"]}),jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:["Y: ["," ",jsxRuntime.jsx("input",{type:"number",value:o.yRange.min,onChange:s=>i({yRange:{...o.yRange,min:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),","," ",jsxRuntime.jsx("input",{type:"number",value:o.yRange.max,onChange:s=>i({yRange:{...o.yRange,max:Number(s.target.value)}}),style:{...styles$2.input,width:"50px"}}),"]"]}),jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:o.showGrid,onChange:s=>i({showGrid:s.target.checked})}),t("plotter.grid","Grid")]}),jsxRuntime.jsxs("label",{style:{fontSize:"12px"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:o.showAxes,onChange:s=>i({showAxes:s.target.checked})}),t("plotter.axes","Axes")]}),jsxRuntime.jsx("div",{style:{flex:1}}),jsxRuntime.jsx("button",{onClick:c,style:{...styles$2.button,backgroundColor:"var(--nice-success, #4caf50)"},children:"📥 SVG"}),jsxRuntime.jsx("button",{onClick:f,style:{...styles$2.button,backgroundColor:"var(--nice-warning, #ff9800)"},children:"📥 PNG"})]})}function Canvas2D({width:e,height:r}){const t=we.useRef(null),{service:a,plots:n,view:o,animation:i}=useGraph(),c=40;return we.useEffect(()=>{const f=t.current,s=f==null?void 0:f.getContext("2d");if(!f||!s)return;s.fillStyle=`rgb(${o.backgroundColor.r},${o.backgroundColor.g},${o.backgroundColor.b})`,s.fillRect(0,0,e,r);const d=e-c*2,m=r-c*2,y=u=>c+(u-o.xRange.min)/(o.xRange.max-o.xRange.min)*d,g=u=>r-c-(u-o.yRange.min)/(o.yRange.max-o.yRange.min)*m;if(o.showGrid){s.strokeStyle="var(--nice-border, #e0e0e0)",s.lineWidth=.5;for(let u=Math.ceil(o.xRange.min);u<=o.xRange.max;u++){const b=y(u);s.beginPath(),s.moveTo(b,c),s.lineTo(b,r-c),s.stroke()}for(let u=Math.ceil(o.yRange.min);u<=o.yRange.max;u++){const b=g(u);s.beginPath(),s.moveTo(c,b),s.lineTo(e-c,b),s.stroke()}}if(o.showAxes){s.strokeStyle="var(--nice-text, #333)",s.lineWidth=1;const u=g(0);s.beginPath(),s.moveTo(c,u),s.lineTo(e-c,u),s.stroke();const b=y(0);if(s.beginPath(),s.moveTo(b,c),s.lineTo(b,r-c),s.stroke(),o.showLabels){s.fillStyle="var(--nice-text, #333)",s.font="12px sans-serif",s.textAlign="center",s.fillText("x",e-c+15,u+4),s.fillText("y",b,c-10),s.font="10px sans-serif";for(let l=Math.ceil(o.xRange.min);l<=o.xRange.max;l++)l!==0&&s.fillText(String(l),y(l),u+15);for(let l=Math.ceil(o.yRange.min);l<=o.yRange.max;l++)l!==0&&(s.textAlign="right",s.fillText(String(l),b-5,g(l)+4))}}const w=i.isPlaying?{[i.parameter]:i.currentValue}:{};for(const u of n.filter(b=>b.visible)){const b=`rgb(${u.color.r},${u.color.g},${u.color.b})`;s.strokeStyle=b,s.lineWidth=u.lineWidth||2;let l=[];switch(u.type){case"2d-function":l=a.compute2DFunction(u.expression,o.xRange,u.resolution||200,w);break;case"2d-parametric":l=a.compute2DParametric(u.expression,u.expressionY||"sin(t)",u.parameterRange||{min:0,max:2*Math.PI},u.resolution||200,w);break;case"2d-polar":l=a.compute2DPolar(u.expression,u.parameterRange||{min:0,max:2*Math.PI},u.resolution||200,w);break}if(l.length>0){s.beginPath();let p=!1;for(const h of l){const j=y(h.x),x=g(h.y);if(x<0||x>r){p=!1;continue}p?s.lineTo(j,x):(s.moveTo(j,x),p=!0)}s.stroke()}}},[n,o,i,a,e,r]),jsxRuntime.jsx("canvas",{ref:t,width:e,height:r,style:styles$2.canvas})}const UNITS=[{name:"Meter",symbol:"m",category:"Length",toBase:e=>e,fromBase:e=>e},{name:"Kilometer",symbol:"km",category:"Length",toBase:e=>e*1e3,fromBase:e=>e/1e3},{name:"Centimeter",symbol:"cm",category:"Length",toBase:e=>e/100,fromBase:e=>e*100},{name:"Millimeter",symbol:"mm",category:"Length",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Mile",symbol:"mi",category:"Length",toBase:e=>e*1609.344,fromBase:e=>e/1609.344},{name:"Yard",symbol:"yd",category:"Length",toBase:e=>e*.9144,fromBase:e=>e/.9144},{name:"Foot",symbol:"ft",category:"Length",toBase:e=>e*.3048,fromBase:e=>e/.3048},{name:"Inch",symbol:"in",category:"Length",toBase:e=>e*.0254,fromBase:e=>e/.0254},{name:"Kilogram",symbol:"kg",category:"Mass",toBase:e=>e,fromBase:e=>e},{name:"Gram",symbol:"g",category:"Mass",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Milligram",symbol:"mg",category:"Mass",toBase:e=>e/1e6,fromBase:e=>e*1e6},{name:"Pound",symbol:"lb",category:"Mass",toBase:e=>e*.453592,fromBase:e=>e/.453592},{name:"Ounce",symbol:"oz",category:"Mass",toBase:e=>e*.0283495,fromBase:e=>e/.0283495},{name:"Ton",symbol:"t",category:"Mass",toBase:e=>e*1e3,fromBase:e=>e/1e3},{name:"Celsius",symbol:"°C",category:"Temperature",toBase:e=>e,fromBase:e=>e},{name:"Fahrenheit",symbol:"°F",category:"Temperature",toBase:e=>(e-32)*5/9,fromBase:e=>e*9/5+32},{name:"Kelvin",symbol:"K",category:"Temperature",toBase:e=>e-273.15,fromBase:e=>e+273.15},{name:"Second",symbol:"s",category:"Time",toBase:e=>e,fromBase:e=>e},{name:"Millisecond",symbol:"ms",category:"Time",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Minute",symbol:"min",category:"Time",toBase:e=>e*60,fromBase:e=>e/60},{name:"Hour",symbol:"hr",category:"Time",toBase:e=>e*3600,fromBase:e=>e/3600},{name:"Day",symbol:"d",category:"Time",toBase:e=>e*86400,fromBase:e=>e/86400},{name:"Week",symbol:"wk",category:"Time",toBase:e=>e*604800,fromBase:e=>e/604800},{name:"Square meter",symbol:"m²",category:"Area",toBase:e=>e,fromBase:e=>e},{name:"Square kilometer",symbol:"km²",category:"Area",toBase:e=>e*1e6,fromBase:e=>e/1e6},{name:"Hectare",symbol:"ha",category:"Area",toBase:e=>e*1e4,fromBase:e=>e/1e4},{name:"Acre",symbol:"ac",category:"Area",toBase:e=>e*4046.86,fromBase:e=>e/4046.86},{name:"Square foot",symbol:"ft²",category:"Area",toBase:e=>e*.092903,fromBase:e=>e/.092903},{name:"Liter",symbol:"L",category:"Volume",toBase:e=>e,fromBase:e=>e},{name:"Milliliter",symbol:"mL",category:"Volume",toBase:e=>e/1e3,fromBase:e=>e*1e3},{name:"Cubic meter",symbol:"m³",category:"Volume",toBase:e=>e*1e3,fromBase:e=>e/1e3},{name:"Gallon (US)",symbol:"gal",category:"Volume",toBase:e=>e*3.78541,fromBase:e=>e/3.78541},{name:"Quart",symbol:"qt",category:"Volume",toBase:e=>e*.946353,fromBase:e=>e/.946353},{name:"Pint",symbol:"pt",category:"Volume",toBase:e=>e*.473176,fromBase:e=>e/.473176},{name:"Cup",symbol:"cup",category:"Volume",toBase:e=>e*.236588,fromBase:e=>e/.236588},{name:"Meters/second",symbol:"m/s",category:"Speed",toBase:e=>e,fromBase:e=>e},{name:"Kilometers/hour",symbol:"km/h",category:"Speed",toBase:e=>e/3.6,fromBase:e=>e*3.6},{name:"Miles/hour",symbol:"mph",category:"Speed",toBase:e=>e*.44704,fromBase:e=>e/.44704},{name:"Knots",symbol:"kn",category:"Speed",toBase:e=>e*.514444,fromBase:e=>e/.514444},{name:"Byte",symbol:"B",category:"Data",toBase:e=>e,fromBase:e=>e},{name:"Kilobyte",symbol:"KB",category:"Data",toBase:e=>e*1024,fromBase:e=>e/1024},{name:"Megabyte",symbol:"MB",category:"Data",toBase:e=>e*1048576,fromBase:e=>e/1048576},{name:"Gigabyte",symbol:"GB",category:"Data",toBase:e=>e*1073741824,fromBase:e=>e/1073741824},{name:"Terabyte",symbol:"TB",category:"Data",toBase:e=>e*1099511627776,fromBase:e=>e/1099511627776},{name:"Bit",symbol:"bit",category:"Data",toBase:e=>e/8,fromBase:e=>e*8}],MatrixOps={create(e,r,t=0){const a=[];for(let n=0;n<e;n++)a.push(new Array(r).fill(t));return{rows:e,cols:r,data:a}},identity(e){const r=this.create(e,e);for(let t=0;t<e;t++)r.data[t][t]=1;return r},add(e,r){if(e.rows!==r.rows||e.cols!==r.cols)throw new Error("Matrix dimensions must match for addition");const t=this.create(e.rows,e.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<e.cols;n++)t.data[a][n]=e.data[a][n]+r.data[a][n];return t},subtract(e,r){if(e.rows!==r.rows||e.cols!==r.cols)throw new Error("Matrix dimensions must match for subtraction");const t=this.create(e.rows,e.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<e.cols;n++)t.data[a][n]=e.data[a][n]-r.data[a][n];return t},multiply(e,r){if(e.cols!==r.rows)throw new Error("Matrix A columns must equal Matrix B rows for multiplication");const t=this.create(e.rows,r.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<r.cols;n++){let o=0;for(let i=0;i<e.cols;i++)o+=e.data[a][i]*r.data[i][n];t.data[a][n]=o}return t},scalar(e,r){const t=this.create(e.rows,e.cols);for(let a=0;a<e.rows;a++)for(let n=0;n<e.cols;n++)t.data[a][n]=e.data[a][n]*r;return t},transpose(e){const r=this.create(e.cols,e.rows);for(let t=0;t<e.rows;t++)for(let a=0;a<e.cols;a++)r.data[a][t]=e.data[t][a];return r},determinant(e){if(e.rows!==e.cols)throw new Error("Determinant requires square matrix");if(e.rows===1)return e.data[0][0];if(e.rows===2)return e.data[0][0]*e.data[1][1]-e.data[0][1]*e.data[1][0];let r=0;for(let t=0;t<e.cols;t++)r+=Math.pow(-1,t)*e.data[0][t]*this.determinant(this.minor(e,0,t));return r},minor(e,r,t){const a=this.create(e.rows-1,e.cols-1);let n=0;for(let o=0;o<e.rows;o++){if(o===r)continue;let i=0;for(let c=0;c<e.cols;c++)c!==t&&(a.data[n][i]=e.data[o][c],i++);n++}return a},inverse(e){const r=this.determinant(e);if(r===0)throw new Error("Matrix is singular, cannot compute inverse");const t=e.rows,a=this.create(t,t);for(let n=0;n<t;n++)for(let o=0;o<t;o++){const i=Math.pow(-1,n+o),c=this.determinant(this.minor(e,n,o));a.data[o][n]=i*c}return this.scalar(a,1/r)},trace(e){if(e.rows!==e.cols)throw new Error("Trace requires square matrix");let r=0;for(let t=0;t<e.rows;t++)r+=e.data[t][t];return r},eigenvalues2x2(e){if(e.rows!==2||e.cols!==2)throw new Error("Only 2x2 matrices supported for eigenvalues");const r=e.data[0][0],t=e.data[0][1],a=e.data[1][0],n=e.data[1][1],o=r+n,i=r*n-t*a,c=o*o-4*i;if(c<0)throw new Error("Complex eigenvalues not supported");const f=Math.sqrt(c);return[(o+f)/2,(o-f)/2]},toString(e,r=4){return e.data.map(t=>"[ "+t.map(a=>a.toFixed(r).padStart(10)).join(" ")+" ]").join(`
|
|
30
|
+
`)}},CalculusOps={derivative(e,r,t=1e-7){return(e(r+t)-e(r-t))/(2*t)},secondDerivative(e,r,t=1e-5){return(e(r+t)-2*e(r)+e(r-t))/(t*t)},integrate(e,r,t,a=1e3){a%2!==0&&a++;const n=(t-r)/a;let o=e(r)+e(t);for(let i=1;i<a;i++){const c=r+i*n;o+=i%2===0?2*e(c):4*e(c)}return n/3*o},findRoot(e,r,t=1e-10,a=100){let n=r;for(let o=0;o<a;o++){const i=e(n);if(Math.abs(i)<t)return n;const c=this.derivative(e,n);if(c===0)throw new Error("Derivative is zero, Newton-Raphson failed");n=n-i/c}throw new Error("Newton-Raphson did not converge")},symbolicDerivative(e){if(e=e.trim(),/^-?\d+\.?\d*$/.test(e))return"0";if(e==="x")return"1";const r=e.match(/^x\^(\d+)$/);if(r){const a=parseInt(r[1],10);return a===1?"1":a===2?"2*x":`${a}*x^${a-1}`}const t=e.match(/^(-?\d+\.?\d*)\*x\^(\d+)$/);if(t){const a=parseFloat(t[1]),n=parseInt(t[2],10),o=a*n;return n===1?String(o):n===2?`${o}*x`:`${o}*x^${n-1}`}return e==="sin(x)"?"cos(x)":e==="cos(x)"?"-sin(x)":e==="e^x"||e==="exp(x)"?"e^x":e==="ln(x)"?"1/x":`d/dx(${e})`},symbolicIntegral(e){if(e=e.trim(),/^-?\d+\.?\d*$/.test(e))return`${e}*x + C`;if(e==="x")return"x^2/2 + C";const r=e.match(/^x\^(\d+)$/);if(r){const t=parseInt(r[1],10);return`x^${t+1}/${t+1} + C`}return e==="sin(x)"?"-cos(x) + C":e==="cos(x)"?"sin(x) + C":e==="e^x"||e==="exp(x)"?"e^x + C":e==="1/x"?"ln|x| + C":`∫(${e})dx + C`},solveQuadratic(e,r,t){const a=r*r-4*e*t;if(a<0)throw new Error("No real solutions (complex roots)");if(a===0)return[-r/(2*e)];const n=Math.sqrt(a);return[(-r+n)/(2*e),(-r-n)/(2*e)]}};class CalculatorService{constructor(e={}){C(this,"history",[]);C(this,"memory",0);C(this,"variables",new Map);C(this,"config");this.config={precision:e.precision??12,angleUnit:e.angleUnit??"rad"}}evaluate(expression){let expr=expression.replace(/π|pi/gi,String(Math.PI)).replace(/e(?![xp])/gi,String(Math.E)).replace(/\^/g,"**").replace(/√/g,"Math.sqrt").replace(/sin/gi,"Math.sin").replace(/cos/gi,"Math.cos").replace(/tan/gi,"Math.tan").replace(/asin/gi,"Math.asin").replace(/acos/gi,"Math.acos").replace(/atan/gi,"Math.atan").replace(/sinh/gi,"Math.sinh").replace(/cosh/gi,"Math.cosh").replace(/tanh/gi,"Math.tanh").replace(/log10/gi,"Math.log10").replace(/log2/gi,"Math.log2").replace(/ln/gi,"Math.log").replace(/log\b/gi,"Math.log10").replace(/exp/gi,"Math.exp").replace(/sqrt/gi,"Math.sqrt").replace(/cbrt/gi,"Math.cbrt").replace(/abs/gi,"Math.abs").replace(/floor/gi,"Math.floor").replace(/ceil/gi,"Math.ceil").replace(/round/gi,"Math.round").replace(/pow/gi,"Math.pow").replace(/min/gi,"Math.min").replace(/max/gi,"Math.max");for(const[e,r]of this.variables)expr=expr.replace(new RegExp(`\\b${e}\\b`,"g"),String(r));try{const result=eval(expr);if(typeof result!="number"||!Number.isFinite(result))throw new Error("Invalid result");return result}catch(e){throw new Error(`Invalid expression: ${e.message}`)}}addHistory(e,r,t){this.history.unshift({id:Date.now().toString(36),expression:e,result:r,timestamp:new Date().toISOString(),mode:t}),this.history.length>100&&this.history.pop()}getHistory(){return this.history}clearHistory(){this.history=[]}memoryStore(e){this.memory=e}memoryRecall(){return this.memory}memoryAdd(e){this.memory+=e}memoryClear(){this.memory=0}setVariable(e,r){this.variables.set(e,r)}getVariable(e){return this.variables.get(e)}convertBase(e,r,t){const a={BIN:2,OCT:8,DEC:10,HEX:16},n=parseInt(e,a[r]);if(isNaN(n))throw new Error("Invalid number for base conversion");return n.toString(a[t]).toUpperCase()}convertUnits(e,r,t){const a=UNITS.find(i=>i.symbol===r),n=UNITS.find(i=>i.symbol===t);if(!a||!n)throw new Error("Unknown unit");if(a.category!==n.category)throw new Error("Cannot convert between different unit categories");const o=a.toBase(e);return n.fromBase(o)}getUnitsByCategory(e){return UNITS.filter(r=>r.category===e)}getUnitCategories(){return[...new Set(UNITS.map(e=>e.category))]}format(e){const r=this.config.precision;return Math.abs(e)<1e-10?"0":Math.abs(e)>1e10||Math.abs(e)<1e-6?e.toExponential(r):parseFloat(e.toPrecision(r)).toString()}}function createCalculatorService(e){return new CalculatorService(e)}const CalculatorContext=we.createContext(null);function useCalculator(){const e=we.useContext(CalculatorContext);if(!e)throw new Error("useCalculator must be used within CalculatorProvider");return e}const styles$1={container:{width:"400px",fontFamily:"'Inter', sans-serif",backgroundColor:"var(--nice-bg, #1e1e1e)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 4px 20px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))"},modeSelector:{display:"flex",backgroundColor:"var(--nice-bg-secondary, #2d2d2d)"},modeButton:{flex:1,padding:"8px",border:"none",backgroundColor:"transparent",color:"var(--nice-text-secondary, #888)",fontSize:"11px",cursor:"pointer"},display:{padding:"20px",backgroundColor:"var(--nice-bg-secondary, #252525)",minHeight:"80px"},displayText:{color:"var(--nice-bg, #fff)",fontSize:"32px",fontFamily:"'JetBrains Mono', monospace",textAlign:"right",wordBreak:"break-all"},keypad:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"1px",backgroundColor:"var(--nice-text, #333)",padding:"1px"},key:{padding:"20px",border:"none",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",fontSize:"18px",cursor:"pointer",transition:"background-color 0.1s"},keyOperator:{backgroundColor:"var(--nice-warning, #ff9f0a)",color:"var(--nice-text, #000)"},keyFunction:{backgroundColor:"#505050"}};function NiceCalculator({service:e,className:r,style:t}){const[a,n]=we.useState("0"),[o,i]=we.useState("standard"),[c,f]=we.useState([]),[s,d]=we.useState(!1),m=we.useCallback(u=>{s&&/[0-9.]/.test(u)?(n(u),d(!1)):(n(b=>b==="0"&&u!=="."?u:b+u),d(!1))},[s]),y=we.useCallback(()=>{n("0"),d(!1)},[]),g=we.useCallback(()=>{try{const u=e.evaluate(a),b=e.format(u);e.addHistory(a,b,o),f(e.getHistory()),n(b),d(!0)}catch{n("Error"),d(!0)}},[a,o,e]),w={service:e,display:a,setDisplay:n,mode:o,setMode:i,history:c,calculate:g,appendDigit:m,clear:y};return jsxRuntime.jsx(CalculatorContext.Provider,{value:w,children:jsxRuntime.jsxs("div",{className:r,style:{...styles$1.container,...t},children:[jsxRuntime.jsx(ModeSelector,{}),jsxRuntime.jsx(Display,{}),o==="standard"&&jsxRuntime.jsx(StandardKeypad,{}),o==="scientific"&&jsxRuntime.jsx(ScientificKeypad,{}),o==="programmer"&&jsxRuntime.jsx(ProgrammerKeypad,{}),o==="matrix"&&jsxRuntime.jsx(MatrixMode,{}),o==="calculus"&&jsxRuntime.jsx(CalculusMode,{}),o==="units"&&jsxRuntime.jsx(UnitsMode,{})]})})}function ModeSelector(){const{mode:e,setMode:r}=useCalculator(),t=[{id:"standard",label:"Standard"},{id:"scientific",label:"Scientific"},{id:"programmer",label:"Programmer"},{id:"matrix",label:"Matrix"},{id:"calculus",label:"Calculus"},{id:"units",label:"Units"}];return jsxRuntime.jsx("div",{style:styles$1.modeSelector,children:t.map(a=>jsxRuntime.jsx("button",{onClick:()=>r(a.id),style:{...styles$1.modeButton,backgroundColor:e===a.id?"var(--nice-primary-hover, #1976d2)":"transparent",color:e===a.id?"var(--nice-bg, #fff)":"var(--nice-text-secondary, #888)"},children:a.label},a.id))})}function Display(){const{display:e}=useCalculator();return jsxRuntime.jsx("div",{style:styles$1.display,children:jsxRuntime.jsx("div",{style:styles$1.displayText,children:e})})}function StandardKeypad(){const{appendDigit:e,clear:r,calculate:t,setDisplay:a,display:n}=useCalculator(),o=[{label:"AC",action:r,style:styles$1.keyFunction},{label:"±",action:()=>a(n.startsWith("-")?n.slice(1):"-"+n),style:styles$1.keyFunction},{label:"%",action:()=>e("/100"),style:styles$1.keyFunction},{label:"÷",action:()=>e("/"),style:styles$1.keyOperator},{label:"7",action:()=>e("7")},{label:"8",action:()=>e("8")},{label:"9",action:()=>e("9")},{label:"×",action:()=>e("*"),style:styles$1.keyOperator},{label:"4",action:()=>e("4")},{label:"5",action:()=>e("5")},{label:"6",action:()=>e("6")},{label:"−",action:()=>e("-"),style:styles$1.keyOperator},{label:"1",action:()=>e("1")},{label:"2",action:()=>e("2")},{label:"3",action:()=>e("3")},{label:"+",action:()=>e("+"),style:styles$1.keyOperator},{label:"0",action:()=>e("0")},{label:".",action:()=>e(".")},{label:"⌫",action:()=>a(n.length>1?n.slice(0,-1):"0")},{label:"=",action:t,style:styles$1.keyOperator}];return jsxRuntime.jsx("div",{style:styles$1.keypad,children:o.map((i,c)=>jsxRuntime.jsx("button",{onClick:i.action,style:{...styles$1.key,...i.style||{}},children:i.label},c))})}function ScientificKeypad(){const{appendDigit:e,clear:r,calculate:t,setDisplay:a,display:n}=useCalculator(),o=[{label:"sin",action:()=>e("sin(")},{label:"cos",action:()=>e("cos(")},{label:"tan",action:()=>e("tan(")},{label:"ln",action:()=>e("ln(")},{label:"log",action:()=>e("log10(")}],i=[{label:"x²",action:()=>e("^2")},{label:"x³",action:()=>e("^3")},{label:"xʸ",action:()=>e("^")},{label:"√",action:()=>e("sqrt(")},{label:"eˣ",action:()=>e("exp(")}],c=[{label:"(",action:()=>e("(")},{label:")",action:()=>e(")")},{label:"π",action:()=>e("π")},{label:"e",action:()=>e("e")},{label:"AC",action:r}];return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{...styles$1.keypad,gridTemplateColumns:"repeat(5, 1fr)"},children:[...o,...i,...c].map((f,s)=>jsxRuntime.jsx("button",{onClick:f.action,style:{...styles$1.key,...styles$1.keyFunction,padding:"12px"},children:f.label},s))}),jsxRuntime.jsx(StandardKeypad,{})]})}function ProgrammerKeypad(){const{display:e,setDisplay:r,service:t}=useCalculator(),[a,n]=we.useState("DEC"),o=c=>{try{const f=t.convertBase(e,a,c);r(f),n(c)}catch{r("Error")}},i=a==="HEX"?["A","B","C","D","E","F"]:[];return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:"4px",padding:"8px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:["BIN","OCT","DEC","HEX"].map(c=>jsxRuntime.jsx("button",{onClick:()=>o(c),style:{flex:1,padding:"8px",border:"none",borderRadius:"4px",backgroundColor:a===c?"var(--nice-primary-hover, #1976d2)":"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",cursor:"pointer"},children:c},c))}),i.length>0&&jsxRuntime.jsx("div",{style:{...styles$1.keypad,gridTemplateColumns:"repeat(6, 1fr)"},children:i.map(c=>jsxRuntime.jsx("button",{onClick:()=>r(e==="0"?c:e+c),style:styles$1.key,children:c},c))}),jsxRuntime.jsx("div",{style:{...styles$1.keypad,gridTemplateColumns:"repeat(4, 1fr)"},children:["7","8","9","AND","4","5","6","OR","1","2","3","XOR","0","NOT","<<",">>"].map(c=>{const f=["AND","OR","XOR","NOT","<<",">>"].includes(c);return jsxRuntime.jsx("button",{onClick:()=>r(e==="0"?c:e+c),style:{...styles$1.key,...f?styles$1.keyFunction:{}},children:c},c)})})]})}function MatrixMode(){const{t:e}=useNiceTranslation(),[r,t]=we.useState(MatrixOps.create(2,2)),[a,n]=we.useState(MatrixOps.create(2,2)),[o,i]=we.useState(""),c=(s,d,m,y,g)=>{const w={...s,data:s.data.map(u=>[...u])};w.data[m][y]=parseFloat(g)||0,d(w)},f=[{label:"A + B",fn:()=>MatrixOps.toString(MatrixOps.add(r,a))},{label:"A - B",fn:()=>MatrixOps.toString(MatrixOps.subtract(r,a))},{label:"A × B",fn:()=>MatrixOps.toString(MatrixOps.multiply(r,a))},{label:"det(A)",fn:()=>MatrixOps.determinant(r).toFixed(4)},{label:"Aᵀ",fn:()=>MatrixOps.toString(MatrixOps.transpose(r))},{label:"A⁻¹",fn:()=>MatrixOps.toString(MatrixOps.inverse(r))}];return jsxRuntime.jsxs("div",{style:{padding:"12px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"12px"},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{color:"var(--nice-text-secondary, #888)",marginBottom:"4px"},children:e("calculator.matrixA","Matrix A")}),jsxRuntime.jsx(MatrixInput,{matrix:r,onChange:(s,d,m)=>c(r,t,s,d,m)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{color:"var(--nice-text-secondary, #888)",marginBottom:"4px"},children:e("calculator.matrixB","Matrix B")}),jsxRuntime.jsx(MatrixInput,{matrix:a,onChange:(s,d,m)=>c(a,n,s,d,m)})]})]}),jsxRuntime.jsx("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginBottom:"12px"},children:f.map(s=>jsxRuntime.jsx("button",{onClick:()=>{try{i(s.fn())}catch(d){i(d.message)}},style:{padding:"8px 12px",backgroundColor:"var(--nice-primary-hover, #1976d2)",color:"var(--nice-bg, #fff)",border:"none",borderRadius:"4px",cursor:"pointer"},children:s.label},s.label))}),o&&jsxRuntime.jsx("pre",{style:{color:"var(--nice-bg, #fff)",fontFamily:"monospace",whiteSpace:"pre-wrap"},children:o})]})}function MatrixInput({matrix:e,onChange:r}){return jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${e.cols}, 50px)`,gap:"4px"},children:e.data.map((t,a)=>t.map((n,o)=>jsxRuntime.jsx("input",{type:"number",value:n,onChange:i=>r(a,o,i.target.value),style:{width:"100%",padding:"4px",textAlign:"center",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"}},`${a}-${o}`)))})}function CalculusMode(){const{t:e}=useNiceTranslation(),[r,t]=we.useState("x^2"),[a,n]=we.useState("");return jsxRuntime.jsxs("div",{style:{padding:"12px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:o=>t(o.target.value),placeholder:e("calculator.exprPlaceholder","Enter expression (e.g., x^2, sin(x))"),style:{width:"100%",padding:"8px",marginBottom:"12px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"}}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginBottom:"12px"},children:[jsxRuntime.jsx("button",{onClick:()=>n(`d/dx(${r}) = ${CalculusOps.symbolicDerivative(r)}`),style:{padding:"8px 12px",backgroundColor:"var(--nice-success, #4caf50)",color:"var(--nice-bg, #fff)",border:"none",borderRadius:"4px",cursor:"pointer"},children:e("calculator.differentiate","Differentiate")}),jsxRuntime.jsx("button",{onClick:()=>n(`∫(${r})dx = ${CalculusOps.symbolicIntegral(r)}`),style:{padding:"8px 12px",backgroundColor:"var(--nice-primary, #2196f3)",color:"var(--nice-bg, #fff)",border:"none",borderRadius:"4px",cursor:"pointer"},children:e("calculator.integrate","Integrate")})]}),a&&jsxRuntime.jsx("div",{style:{color:"var(--nice-bg, #fff)",fontFamily:"monospace",padding:"8px",backgroundColor:"var(--nice-bg, #1e1e1e)",borderRadius:"4px"},children:a})]})}function UnitsMode(){const{t:e}=useNiceTranslation(),{service:r}=useCalculator(),[t,a]=we.useState("1"),[n,o]=we.useState("m"),[i,c]=we.useState("ft"),[f,s]=we.useState("Length"),[d,m]=we.useState(""),y=r.getUnitCategories(),g=r.getUnitsByCategory(f),w=()=>{try{const u=r.convertUnits(parseFloat(t),n,i);m(`${t} ${n} = ${r.format(u)} ${i}`)}catch(u){m(u.message)}};return jsxRuntime.jsxs("div",{style:{padding:"12px",backgroundColor:"var(--nice-bg-secondary, #252525)"},children:[jsxRuntime.jsx("select",{value:f,onChange:u=>{s(u.target.value);const b=r.getUnitsByCategory(u.target.value);b.length>=2&&(o(b[0].symbol),c(b[1].symbol))},style:{width:"100%",padding:"8px",marginBottom:"12px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"},children:y.map(u=>jsxRuntime.jsx("option",{value:u,children:u},u))}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",marginBottom:"12px"},children:[jsxRuntime.jsx("input",{type:"number",value:t,onChange:u=>a(u.target.value),style:{flex:1,padding:"8px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"}}),jsxRuntime.jsx("select",{value:n,onChange:u=>o(u.target.value),style:{padding:"8px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"},children:g.map(u=>jsxRuntime.jsxs("option",{value:u.symbol,children:[u.name," (",u.symbol,")"]},u.symbol))})]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",marginBottom:"12px"},children:[jsxRuntime.jsx("span",{style:{color:"var(--nice-text-secondary, #888)"},children:"→"}),jsxRuntime.jsx("select",{value:i,onChange:u=>c(u.target.value),style:{flex:1,padding:"8px",backgroundColor:"var(--nice-border, #3c3c3c)",color:"var(--nice-bg, #fff)",border:"1px solid var(--nice-text-secondary, #555)",borderRadius:"4px"},children:g.map(u=>jsxRuntime.jsxs("option",{value:u.symbol,children:[u.name," (",u.symbol,")"]},u.symbol))})]}),jsxRuntime.jsx("button",{onClick:w,style:{width:"100%",padding:"12px",backgroundColor:"var(--nice-warning, #ff9f0a)",color:"var(--nice-text, #000)",border:"none",borderRadius:"4px",fontSize:"16px",cursor:"pointer"},children:e("calculator.convert","Convert")}),d&&jsxRuntime.jsx("div",{style:{marginTop:"12px",color:"var(--nice-bg, #fff)",fontSize:"18px",textAlign:"center"},children:d})]})}const GeoMath={distance(e,r){return Math.sqrt((r.x-e.x)**2+(r.y-e.y)**2)},midpoint(e,r){return{x:(e.x+r.x)/2,y:(e.y+r.y)/2}},angle(e,r,t){const a=Math.atan2(e.y-r.y,e.x-r.x);let o=Math.atan2(t.y-r.y,t.x-r.x)-a;return o<0&&(o+=2*Math.PI),o},angleDegrees(e,r,t){return this.angle(e,r,t)*180/Math.PI},closestPointOnLine(e,r,t){const a=r.x-e.x,n=r.y-e.y,o=((t.x-e.x)*a+(t.y-e.y)*n)/(a*a+n*n);return{x:e.x+o*a,y:e.y+o*n}},lineIntersection(e,r,t,a){const n=(e.x-r.x)*(t.y-a.y)-(e.y-r.y)*(t.x-a.x);if(Math.abs(n)<1e-10)return null;const o=((e.x-t.x)*(t.y-a.y)-(e.y-t.y)*(t.x-a.x))/n;return{x:e.x+o*(r.x-e.x),y:e.y+o*(r.y-e.y)}},circleLineIntersection(e,r,t,a){const n=a.x-t.x,o=a.y-t.y,i=t.x-e.x,c=t.y-e.y,f=n*n+o*o,s=2*(i*n+c*o),d=i*i+c*c-r*r,m=s*s-4*f*d;if(m<0)return[];const y=Math.sqrt(m),g=(-s-y)/(2*f),w=(-s+y)/(2*f),u=[];return g>=0&&g<=1&&u.push({x:t.x+g*n,y:t.y+g*o}),w>=0&&w<=1&&Math.abs(w-g)>1e-10&&u.push({x:t.x+w*n,y:t.y+w*o}),u},circleCircleIntersection(e,r,t,a){const n=this.distance(e,t);if(n>r+a||n<Math.abs(r-a)||n===0)return[];const o=(r*r-a*a+n*n)/(2*n),i=Math.sqrt(r*r-o*o),c=e.x+o*(t.x-e.x)/n,f=e.y+o*(t.y-e.y)/n;return[{x:c+i*(t.y-e.y)/n,y:f-i*(t.x-e.x)/n},{x:c-i*(t.y-e.y)/n,y:f+i*(t.x-e.x)/n}]},perpendicularThrough(e,r,t){this.closestPointOnLine(e,r,t);const a=r.x-e.x,n=r.y-e.y;return{p1:t,p2:{x:t.x-n,y:t.y+a}}},parallelThrough(e,r,t){const a=r.x-e.x,n=r.y-e.y;return{p1:t,p2:{x:t.x+a,y:t.y+n}}},angleBisector(e,r,t){const a=Math.atan2(e.y-r.y,e.x-r.x),n=Math.atan2(t.y-r.y,t.x-r.x);let o=(a+n)/2;return Math.abs(n-a)>Math.PI&&(o+=Math.PI),{x:r.x+Math.cos(o),y:r.y+Math.sin(o)}},reflect(e,r,t){const a=this.closestPointOnLine(r,t,e);return{x:2*a.x-e.x,y:2*a.y-e.y}},rotate(e,r,t){const a=Math.cos(t),n=Math.sin(t),o=e.x-r.x,i=e.y-r.y;return{x:r.x+o*a-i*n,y:r.y+o*n+i*a}},translate(e,r,t){return{x:e.x+r,y:e.y+t}},dilate(e,r,t){return{x:r.x+t*(e.x-r.x),y:r.y+t*(e.y-r.y)}},polygonArea(e){let r=0;const t=e.length;for(let a=0;a<t;a++){const n=(a+1)%t;r+=e[a].x*e[n].y,r-=e[n].x*e[a].y}return Math.abs(r)/2},polygonPerimeter(e){let r=0;const t=e.length;for(let a=0;a<t;a++){const n=(a+1)%t;r+=this.distance(e[a],e[n])}return r},circumcenter(e,r,t){const a=2*(e.x*(r.y-t.y)+r.x*(t.y-e.y)+t.x*(e.y-r.y)),n=((e.x**2+e.y**2)*(r.y-t.y)+(r.x**2+r.y**2)*(t.y-e.y)+(t.x**2+t.y**2)*(e.y-r.y))/a,o=((e.x**2+e.y**2)*(t.x-r.x)+(r.x**2+r.y**2)*(e.x-t.x)+(t.x**2+t.y**2)*(r.x-e.x))/a;return{x:n,y:o}},incenter(e,r,t){const a=this.distance(e,r),n=this.distance(r,t),o=this.distance(t,e),i=a+n+o;return{x:(n*e.x+o*r.x+a*t.x)/i,y:(n*e.y+o*r.y+a*t.y)/i}},centroid(e,r,t){return{x:(e.x+r.x+t.x)/3,y:(e.y+r.y+t.y)/3}}};class GeometryService{constructor(){C(this,"elements",new Map);C(this,"nextLabel",1)}addElement(r){const t=this.generateId(),a={...r,id:t};return this.elements.set(t,a),a}getElement(r){return this.elements.get(r)}getPoint(r){const t=this.elements.get(r);return(t==null?void 0:t.type)==="point"?t:void 0}updateElement(r,t){const a=this.elements.get(r);a&&this.elements.set(r,{...a,...t,id:r,type:a.type})}deleteElement(r){var t;this.elements.delete(r);for(const[a,n]of this.elements)(t=n.dependencies)!=null&&t.includes(r)&&this.deleteElement(a)}getAllElements(){return Array.from(this.elements.values())}getElementsByType(r){return Array.from(this.elements.values()).filter(t=>t.type===r)}clear(){this.elements.clear(),this.nextLabel=1}createPoint(r,t,a){return this.addElement({type:"point",x:r,y:t,label:a??this.getNextLabel(),color:{r:0,g:0,b:0},visible:!0,selected:!1,locked:!1,size:6})}createSegment(r,t){return this.addElement({type:"segment",point1Id:r,point2Id:t,label:void 0,color:{r:50,g:50,b:50},visible:!0,selected:!1,locked:!1,width:2,dependencies:[r,t]})}createLine(r,t){return this.addElement({type:"line",point1Id:r,point2Id:t,label:void 0,color:{r:50,g:50,b:200},visible:!0,selected:!1,locked:!1,width:1,dependencies:[r,t]})}createRay(r,t){return this.addElement({type:"ray",originId:r,throughId:t,label:void 0,color:{r:50,g:150,b:50},visible:!0,selected:!1,locked:!1,width:1,dependencies:[r,t]})}createCircle(r,t){return this.addElement({type:"circle",centerId:r,radius:t,label:void 0,color:{r:200,g:50,b:50},visible:!0,selected:!1,locked:!1,width:2,dependencies:[r]})}createPolygon(r){return this.addElement({type:"polygon",pointIds:r,label:void 0,color:{r:100,g:100,b:200},visible:!0,selected:!1,locked:!1,width:2,fill:{r:100,g:100,b:200,a:.2},dependencies:r})}createMidpoint(r,t){const a=this.getPoint(r),n=this.getPoint(t);if(!a||!n)return null;const o=GeoMath.midpoint(a,n),i=this.createPoint(o.x,o.y);return i.dependencies=[r,t],i.color={r:0,g:150,b:0},i}createPerpendicular(r,t,a){const n=this.getPoint(r),o=this.getPoint(t),i=this.getPoint(a);if(!n||!o||!i)return null;const c=GeoMath.perpendicularThrough(n,o,i),f=this.createPoint(c.p2.x,c.p2.y),s=this.createLine(a,f.id);return s.dependencies=[r,t,a],s}createParallel(r,t,a){const n=this.getPoint(r),o=this.getPoint(t),i=this.getPoint(a);if(!n||!o||!i)return null;const c=GeoMath.parallelThrough(n,o,i),f=this.createPoint(c.p2.x,c.p2.y),s=this.createLine(a,f.id);return s.dependencies=[r,t,a],s}createIntersection(r,t){const a=this.elements.get(r),n=this.elements.get(t);if(!a||!n)return[];const o=[],i=s=>{if(s.type==="line"||s.type==="segment"||s.type==="ray"){const d=s,m=this.getPoint(d.point1Id??d.originId),y=this.getPoint(d.point2Id??d.throughId);if(m&&y)return[m,y]}return null},c=i(a),f=i(n);if(c&&f){const s=GeoMath.lineIntersection(c[0],c[1],f[0],f[1]);if(s){const d=this.createPoint(s.x,s.y);d.dependencies=[r,t],d.color={r:255,g:0,b:0},o.push(d)}}if(a.type==="circle"&&f){const s=a,d=this.getPoint(s.centerId);if(d){const m=GeoMath.circleLineIntersection(d,s.radius,f[0],f[1]);for(const y of m){const g=this.createPoint(y.x,y.y);g.dependencies=[r,t],g.color={r:255,g:0,b:0},o.push(g)}}}if(a.type==="circle"&&n.type==="circle"){const s=a,d=n,m=this.getPoint(s.centerId),y=this.getPoint(d.centerId);if(m&&y){const g=GeoMath.circleCircleIntersection(m,s.radius,y,d.radius);for(const w of g){const u=this.createPoint(w.x,w.y);u.dependencies=[r,t],u.color={r:255,g:0,b:0},o.push(u)}}}return o}calculateMeasurement(r,t){switch(r){case"distance":{const a=this.getPoint(t[0]),n=this.getPoint(t[1]);if(a&&n)return GeoMath.distance(a,n);break}case"angle":{const a=this.getPoint(t[0]),n=this.getPoint(t[1]),o=this.getPoint(t[2]);if(a&&n&&o)return GeoMath.angleDegrees(a,n,o);break}case"area":case"perimeter":{const a=this.elements.get(t[0]);if((a==null?void 0:a.type)==="polygon"){const n=a.pointIds.map(o=>this.getPoint(o)).filter(Boolean);return r==="area"?GeoMath.polygonArea(n):GeoMath.polygonPerimeter(n)}break}}return 0}exportSVG(r,t,a){const n=[`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${t}" viewBox="0 0 ${r} ${t}">`];n.push(`<rect width="100%" height="100%" fill="rgb(${a.backgroundColor.r},${a.backgroundColor.g},${a.backgroundColor.b})"/>`);const o=(i,c)=>({x:r/2+(i-a.centerX)*a.scale,y:t/2-(c-a.centerY)*a.scale});if(a.showGrid){n.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');for(let i=Math.floor(-r/2/a.scale+a.centerX);i<=r/2/a.scale+a.centerX;i+=a.gridSpacing){const c=o(i,0);n.push(`<line x1="${c.x}" y1="0" x2="${c.x}" y2="${t}"/>`)}for(let i=Math.floor(-t/2/a.scale+a.centerY);i<=t/2/a.scale+a.centerY;i+=a.gridSpacing){const c=o(0,i);n.push(`<line x1="0" y1="${c.y}" x2="${r}" y2="${c.y}"/>`)}n.push("</g>")}if(a.showAxes){const i=o(0,0);n.push('<g stroke="var(--nice-text, #333)" stroke-width="1">'),n.push(`<line x1="0" y1="${i.y}" x2="${r}" y2="${i.y}"/>`),n.push(`<line x1="${i.x}" y1="0" x2="${i.x}" y2="${t}"/>`),n.push("</g>")}for(const i of this.getAllElements()){if(!i.visible)continue;const c=`rgb(${i.color.r},${i.color.g},${i.color.b})`;switch(i.type){case"point":{const f=o(i.x,i.y);n.push(`<circle cx="${f.x}" cy="${f.y}" r="${i.size}" fill="${c}"/>`),i.label&&n.push(`<text x="${f.x+8}" y="${f.y-8}" font-size="12">${i.label}</text>`);break}case"segment":{const f=this.getPoint(i.point1Id),s=this.getPoint(i.point2Id);if(f&&s){const d=o(f.x,f.y),m=o(s.x,s.y);n.push(`<line x1="${d.x}" y1="${d.y}" x2="${m.x}" y2="${m.y}" stroke="${c}" stroke-width="${i.width}"/>`)}break}case"circle":{const f=this.getPoint(i.centerId);if(f){const s=o(f.x,f.y),d=i.radius*a.scale,m=i.fill?`rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a??.2})`:"none";n.push(`<circle cx="${s.x}" cy="${s.y}" r="${d}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`)}break}case"polygon":{const f=i.pointIds.map(s=>this.getPoint(s)).filter(Boolean);if(f.length>0){const d=f.map(y=>o(y.x,y.y)).map((y,g)=>`${g===0?"M":"L"}${y.x},${y.y}`).join(" ")+" Z",m=i.fill?`rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a??.2})`:"none";n.push(`<path d="${d}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`)}break}}}return n.push("</svg>"),n.join(`
|
|
31
|
+
`)}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}getNextLabel(){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t=this.nextLabel-1;return this.nextLabel++,t<26?r[t]:r[t%26]+Math.floor(t/26)}}function createGeometryService(){return new GeometryService}const GeometryContext=we.createContext(null);function useGeometry(){const e=we.useContext(GeometryContext);if(!e)throw new Error("useGeometry must be used within GeometryProvider");return e}const styles={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",fontSize:"14px"},toolbar:{width:"50px",backgroundColor:"var(--nice-bg-secondary, #f5f5f5)",borderRight:"1px solid var(--nice-border, #e0e0e0)",display:"flex",flexDirection:"column",padding:"8px 4px",gap:"4px"},toolButton:{width:"40px",height:"40px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px"},main:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},canvas:{flex:1,cursor:"crosshair"},statusBar:{height:"30px",backgroundColor:"var(--nice-bg-secondary, #f5f5f5)",borderTop:"1px solid var(--nice-border, #e0e0e0)",padding:"0 12px",display:"flex",alignItems:"center",fontSize:"12px",color:"var(--nice-text-secondary, #666)"}};function NiceGeometry({service:e,width:r=800,height:t=600,className:a,style:n}){const[o,i]=we.useState([]),[c,f]=we.useState("point"),[s,d]=we.useState([]),[m,y]=we.useState({centerX:0,centerY:0,scale:40,showGrid:!0,showAxes:!0,gridSpacing:1,snapToGrid:!0,snapToPoints:!0,backgroundColor:{r:255,g:255,b:255}}),g=we.useCallback(()=>{i(e.getAllElements())},[e]),w=we.useCallback(b=>{y(l=>({...l,...b}))},[]);we.useEffect(()=>{g()},[g]);const u={service:e,elements:o,tool:c,setTool:f,view:m,setView:w,selectedIds:s,setSelectedIds:d,refresh:g};return jsxRuntime.jsx(GeometryContext.Provider,{value:u,children:jsxRuntime.jsxs("div",{className:a,style:{...styles.container,...n},children:[jsxRuntime.jsx(Toolbar,{}),jsxRuntime.jsxs("div",{style:styles.main,children:[jsxRuntime.jsx(Canvas,{width:r,height:t}),jsxRuntime.jsx(StatusBar,{width:r,height:t})]})]})})}function Toolbar(){const{tool:e,setTool:r}=useGeometry(),t=[{id:"select",icon:"⬚",title:"Select"},{id:"point",icon:"•",title:"Point"},{id:"segment",icon:"—",title:"Segment"},{id:"line",icon:"↔",title:"Line"},{id:"ray",icon:"→",title:"Ray"},{id:"circle",icon:"○",title:"Circle"},{id:"polygon",icon:"△",title:"Polygon"},{id:"perpendicular",icon:"⊥",title:"Perpendicular"},{id:"parallel",icon:"∥",title:"Parallel"},{id:"midpoint",icon:"⊙",title:"Midpoint"},{id:"bisector",icon:"∠",title:"Angle Bisector"},{id:"intersection",icon:"✕",title:"Intersection"},{id:"reflect",icon:"⇄",title:"Reflect"},{id:"rotate",icon:"↻",title:"Rotate"},{id:"measure",icon:"📏",title:"Measure"}];return jsxRuntime.jsx("div",{style:styles.toolbar,children:t.map(a=>jsxRuntime.jsx("button",{onClick:()=>r(a.id),title:a.title,style:{...styles.toolButton,backgroundColor:e===a.id?"var(--nice-primary-hover, #1976d2)":"transparent",color:e===a.id?"var(--nice-bg, #fff)":"var(--nice-text, #333)"},children:a.icon},a.id))})}function Canvas({width:e,height:r}){const t=we.useRef(null),{service:a,elements:n,tool:o,view:i,selectedIds:c,setSelectedIds:f,refresh:s}=useGeometry(),[d,m]=we.useState([]),y=we.useCallback((b,l)=>{const p=(b-e/2)/i.scale+i.centerX,h=-(l-r/2)/i.scale+i.centerY;return i.snapToGrid?{x:Math.round(p/i.gridSpacing)*i.gridSpacing,y:Math.round(h/i.gridSpacing)*i.gridSpacing}:{x:p,y:h}},[e,r,i]),g=we.useCallback((b,l)=>({x:e/2+(b-i.centerX)*i.scale,y:r/2-(l-i.centerY)*i.scale}),[e,r,i]),w=we.useCallback(b=>{var h;const l=(h=t.current)==null?void 0:h.getBoundingClientRect();if(!l)return;const p=y(b.clientX-l.left,b.clientY-l.top);switch(o){case"point":{a.createPoint(p.x,p.y),s();break}case"segment":case"line":case"ray":{const j=u(p);if(j)m(x=>{const v=[...x,j.id];return v.length===2?(o==="segment"?a.createSegment(v[0],v[1]):o==="line"?a.createLine(v[0],v[1]):o==="ray"&&a.createRay(v[0],v[1]),s(),[]):v});else{const x=a.createPoint(p.x,p.y);m(v=>{const R=[...v,x.id];return R.length===2?(o==="segment"?a.createSegment(R[0],R[1]):o==="line"?a.createLine(R[0],R[1]):o==="ray"&&a.createRay(R[0],R[1]),s(),[]):R}),s()}break}case"circle":{const j=u(p);if(j)m(x=>{if(x.length===0)return[j.id];const v=a.getPoint(x[0]);if(v){const R=GeoMath.distance(v,p);a.createCircle(x[0],R),s()}return[]});else if(d.length===1){const x=a.getPoint(d[0]);if(x){const v=GeoMath.distance(x,p);a.createCircle(d[0],v),s(),m([])}}else{const x=a.createPoint(p.x,p.y);m([x.id]),s()}break}case"midpoint":{const j=u(p);j&&m(x=>{const v=[...x,j.id];return v.length===2?(a.createMidpoint(v[0],v[1]),s(),[]):v});break}case"select":{const j=u(p);f(j?[j.id]:[]);break}}},[o,a,s,y,d,f]),u=b=>{for(const p of n)if(p.type==="point"&&GeoMath.distance(p,b)<.5)return p};return we.useEffect(()=>{const b=t.current,l=b==null?void 0:b.getContext("2d");if(!(!b||!l)){if(l.fillStyle=`rgb(${i.backgroundColor.r},${i.backgroundColor.g},${i.backgroundColor.b})`,l.fillRect(0,0,e,r),i.showGrid){l.strokeStyle="var(--nice-border, #e0e0e0)",l.lineWidth=.5;const p=i.gridSpacing*i.scale,h=(e/2-i.centerX*i.scale)%p,j=(r/2+i.centerY*i.scale)%p;for(let x=h;x<e;x+=p)l.beginPath(),l.moveTo(x,0),l.lineTo(x,r),l.stroke();for(let x=j;x<r;x+=p)l.beginPath(),l.moveTo(0,x),l.lineTo(e,x),l.stroke()}if(i.showAxes){const p=g(0,0);l.strokeStyle="var(--nice-text, #333)",l.lineWidth=1,l.beginPath(),l.moveTo(0,p.y),l.lineTo(e,p.y),l.stroke(),l.beginPath(),l.moveTo(p.x,0),l.lineTo(p.x,r),l.stroke()}for(const p of n){if(!p.visible)continue;const h=`rgb(${p.color.r},${p.color.g},${p.color.b})`,j=c.includes(p.id);switch(p.type){case"point":{const x=g(p.x,p.y);l.beginPath(),l.arc(x.x,x.y,j?p.size+2:p.size,0,2*Math.PI),l.fillStyle=j?"var(--nice-primary-hover, #1976d2)":h,l.fill(),p.label&&(l.fillStyle="var(--nice-text, #333)",l.font="12px sans-serif",l.fillText(p.label,x.x+8,x.y-8));break}case"segment":{const x=a.getPoint(p.point1Id),v=a.getPoint(p.point2Id);if(x&&v){const R=g(x.x,x.y),k=g(v.x,v.y);l.strokeStyle=h,l.lineWidth=p.width,l.beginPath(),l.moveTo(R.x,R.y),l.lineTo(k.x,k.y),l.stroke()}break}case"line":{const x=a.getPoint(p.point1Id),v=a.getPoint(p.point2Id);if(x&&v){const R=v.x-x.x,k=v.y-x.y,S=-1e3,M=1e3,P=g(x.x+S*R,x.y+S*k),$=g(x.x+M*R,x.y+M*k);l.strokeStyle=h,l.lineWidth=p.width,l.beginPath(),l.moveTo(P.x,P.y),l.lineTo($.x,$.y),l.stroke()}break}case"circle":{const x=a.getPoint(p.centerId);if(x){const v=g(x.x,x.y),R=p.radius*i.scale;l.beginPath(),l.arc(v.x,v.y,R,0,2*Math.PI),p.fill&&(l.fillStyle=`rgba(${p.fill.r},${p.fill.g},${p.fill.b},${p.fill.a??.2})`,l.fill()),l.strokeStyle=h,l.lineWidth=p.width,l.stroke()}break}case"polygon":{const x=p.pointIds.map(v=>a.getPoint(v)).filter(Boolean);if(x.length>0){l.beginPath();const v=g(x[0].x,x[0].y);l.moveTo(v.x,v.y);for(let R=1;R<x.length;R++){const k=g(x[R].x,x[R].y);l.lineTo(k.x,k.y)}l.closePath(),p.fill&&(l.fillStyle=`rgba(${p.fill.r},${p.fill.g},${p.fill.b},${p.fill.a??.2})`,l.fill()),l.strokeStyle=h,l.lineWidth=p.width,l.stroke()}break}}}if(d.length>0){l.fillStyle="rgba(25, 118, 210, 0.3)";for(const p of d){const h=a.getPoint(p);if(h){const j=g(h.x,h.y);l.beginPath(),l.arc(j.x,j.y,12,0,2*Math.PI),l.fill()}}}}},[n,i,e,r,c,d,a,g]),jsxRuntime.jsx("canvas",{ref:t,width:e,height:r,style:styles.canvas,onClick:w})}function StatusBar({width:e,height:r}){const{tool:t,elements:a,view:n,service:o}=useGeometry(),[i,c]=we.useState(null),f={select:"Select",point:"Point",line:"Line",ray:"Ray",segment:"Segment",circle:"Circle",arc:"Arc",polygon:"Polygon",angle:"Angle",perpendicular:"Perpendicular",parallel:"Parallel",bisector:"Angle Bisector",midpoint:"Midpoint",tangent:"Tangent",intersection:"Intersection",reflect:"Reflect",rotate:"Rotate",translate:"Translate",dilate:"Dilate",measure:"Measure",text:"Text"},s=a.filter(d=>d.type==="point").length;return jsxRuntime.jsxs("div",{style:styles.statusBar,children:[jsxRuntime.jsxs("span",{children:["Tool: ",f[t]]}),jsxRuntime.jsx("span",{style:{margin:"0 16px"},children:"|"}),jsxRuntime.jsxs("span",{children:["Objects: ",a.length]}),jsxRuntime.jsx("span",{style:{margin:"0 16px"},children:"|"}),jsxRuntime.jsxs("span",{children:["Points: ",s]}),jsxRuntime.jsx("span",{style:{margin:"0 16px"},children:"|"}),jsxRuntime.jsxs("span",{children:["Scale: ",n.scale.toFixed(1),"x"]})]})}exports.CalculatorService=CalculatorService;exports.CalculusOps=CalculusOps;exports.EQUATION_TEMPLATES=EQUATION_TEMPLATES;exports.ExpressionParser=ExpressionParser;exports.FUNCTION_PRESETS=FUNCTION_PRESETS;exports.GeoMath=GeoMath;exports.GeometryService=GeometryService;exports.GraphService=GraphService;exports.MATH_SYMBOLS=MATH_SYMBOLS;exports.MathEditorService=MathEditorService;exports.MatrixOps=MatrixOps;exports.NiceCalculator=NiceCalculator;exports.NiceGeometry=NiceGeometry;exports.NiceGraphPlotter=NiceGraphPlotter;exports.NiceI18nProvider=NiceI18nProvider;exports.NiceMathEditor=NiceMathEditor;exports.createCalculatorService=createCalculatorService;exports.createGeometryService=createGeometryService;exports.createGraphService=createGraphService;exports.createMathEditorService=createMathEditorService;exports.getSymbolsByCategory=getSymbolsByCategory;exports.recognizeHandwriting=recognizeHandwriting;exports.useCalculator=useCalculator;exports.useGeometry=useGeometry;exports.useGraph=useGraph;exports.useMathEditor=useMathEditor;exports.useNiceTranslation=useNiceTranslation;
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ var R = Object.defineProperty;
|
|
|
2
2
|
var T = (e, r, t) => r in e ? R(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
3
|
var S = (e, r, t) => T(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
|
-
import
|
|
5
|
+
import we, { useContext, createContext, memo, useState, useEffect, useMemo, useRef, useCallback } from "react";
|
|
6
6
|
const _e = (e, r) => r, te = createContext(_e);
|
|
7
7
|
function Zt() {
|
|
8
8
|
return { t: useContext(te) };
|
|
@@ -15,7 +15,7 @@ createContext({
|
|
|
15
15
|
});
|
|
16
16
|
createContext(null);
|
|
17
17
|
createContext(null);
|
|
18
|
-
const
|
|
18
|
+
const ee = {
|
|
19
19
|
radius: "md",
|
|
20
20
|
shadow: "md",
|
|
21
21
|
fill: "solid",
|
|
@@ -34,7 +34,7 @@ const Z = {
|
|
|
34
34
|
};
|
|
35
35
|
createContext({
|
|
36
36
|
displayStyle: "default",
|
|
37
|
-
variantConfig:
|
|
37
|
+
variantConfig: ee,
|
|
38
38
|
setDisplayStyle: () => {
|
|
39
39
|
}
|
|
40
40
|
});
|
|
@@ -50,60 +50,60 @@ createContext({
|
|
|
50
50
|
getAccessMode: () => "full"
|
|
51
51
|
});
|
|
52
52
|
createContext(null);
|
|
53
|
-
const
|
|
53
|
+
const qt = process.env.NODE_ENV === "development";
|
|
54
54
|
let O = {
|
|
55
|
-
enabled:
|
|
55
|
+
enabled: qt,
|
|
56
56
|
slowRenderThreshold: 16
|
|
57
57
|
};
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
|
|
58
|
+
const Ne = [], Y = /* @__PURE__ */ new Map(), Ee = /* @__PURE__ */ new Map();
|
|
59
|
+
function Ut() {
|
|
60
|
+
Ne.length = 0, Y.clear(), Ee.clear();
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function Kt(e) {
|
|
63
63
|
const r = O.slowRenderThreshold;
|
|
64
|
-
return
|
|
64
|
+
return Ne.filter((t) => t.actualDuration > r);
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function J(e) {
|
|
67
67
|
return e < 1 ? `${(e * 1e3).toFixed(0)}μs` : e < 1e3 ? `${e.toFixed(2)}ms` : `${(e / 1e3).toFixed(2)}s`;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
const e = Array.from(
|
|
69
|
+
function va() {
|
|
70
|
+
const e = Array.from(Y.values()), r = Kt(), t = e.reduce((n, i) => n + i.renderCount, 0), a = e.length > 0 ? e.reduce((n, i) => n + i.avgRenderTime, 0) / e.length : 0, o = Array.from(Ee.values());
|
|
71
71
|
return { stats: e, slowRenders: r, totalRenders: t, avgRenderTime: a, marks: o };
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const e =
|
|
73
|
+
function Gt() {
|
|
74
|
+
const e = va();
|
|
75
75
|
console.group(
|
|
76
76
|
"%c[Nice2Dev Performance Report]",
|
|
77
77
|
"color: var(--nice-info, #6366f1); font-weight: bold; font-size: 14px"
|
|
78
|
-
), console.log(`Total renders: ${e.totalRenders}`), console.log(`Average render time: ${
|
|
78
|
+
), console.log(`Total renders: ${e.totalRenders}`), console.log(`Average render time: ${J(e.avgRenderTime)}`), console.log(`Slow renders: ${e.slowRenders.length}`), console.group("Component Stats"), console.table(
|
|
79
79
|
e.stats.sort((r, t) => t.totalRenderTime - r.totalRenderTime).map((r) => ({
|
|
80
80
|
Name: r.componentName,
|
|
81
81
|
Renders: r.renderCount,
|
|
82
|
-
"Avg Time":
|
|
83
|
-
"Max Time":
|
|
84
|
-
"Total Time":
|
|
82
|
+
"Avg Time": J(r.avgRenderTime),
|
|
83
|
+
"Max Time": J(r.maxRenderTime),
|
|
84
|
+
"Total Time": J(r.totalRenderTime),
|
|
85
85
|
"Slow Renders": r.slowRenderCount
|
|
86
86
|
}))
|
|
87
87
|
), console.groupEnd(), e.slowRenders.length > 0 && (console.group("Slow Renders (last 10)"), console.table(
|
|
88
88
|
e.slowRenders.slice(-10).map((r) => ({
|
|
89
89
|
Component: r.componentName,
|
|
90
90
|
Phase: r.phase,
|
|
91
|
-
Duration:
|
|
91
|
+
Duration: J(r.actualDuration),
|
|
92
92
|
Time: new Date(r.timestamp).toLocaleTimeString()
|
|
93
93
|
}))
|
|
94
94
|
), console.groupEnd()), e.marks.length > 0 && (console.group("Custom Marks"), console.table(
|
|
95
95
|
e.marks.filter((r) => r.duration).map((r) => ({
|
|
96
96
|
Name: r.name,
|
|
97
|
-
Duration:
|
|
97
|
+
Duration: J(r.duration)
|
|
98
98
|
}))
|
|
99
99
|
), console.groupEnd()), console.groupEnd();
|
|
100
100
|
}
|
|
101
|
-
const
|
|
101
|
+
const wa = memo(
|
|
102
102
|
({ position: e = "bottom-right", defaultCollapsed: r = !0 }) => {
|
|
103
103
|
const [t, a] = useState(r), [o, n] = useState([]), [i, c] = useState({ used: 0, total: 0 });
|
|
104
104
|
if (useEffect(() => {
|
|
105
105
|
const s = () => {
|
|
106
|
-
const m = Array.from(
|
|
106
|
+
const m = Array.from(Y.values());
|
|
107
107
|
n(m.sort((g, w) => w.totalRenderTime - g.totalRenderTime).slice(0, 10));
|
|
108
108
|
const u = window.performance;
|
|
109
109
|
u.memory && c({
|
|
@@ -182,7 +182,7 @@ const va = memo(
|
|
|
182
182
|
style: {
|
|
183
183
|
color: s.avgRenderTime > 16 ? "var(--color-warning, #f59e0b)" : "var(--color-success, #22c55e)"
|
|
184
184
|
},
|
|
185
|
-
children:
|
|
185
|
+
children: J(s.avgRenderTime)
|
|
186
186
|
}
|
|
187
187
|
),
|
|
188
188
|
/* @__PURE__ */ jsxs(
|
|
@@ -200,7 +200,7 @@ const va = memo(
|
|
|
200
200
|
/* @__PURE__ */ jsx(
|
|
201
201
|
"button",
|
|
202
202
|
{
|
|
203
|
-
onClick:
|
|
203
|
+
onClick: Gt,
|
|
204
204
|
style: {
|
|
205
205
|
flex: 1,
|
|
206
206
|
padding: "4px 8px",
|
|
@@ -217,7 +217,7 @@ const va = memo(
|
|
|
217
217
|
/* @__PURE__ */ jsx(
|
|
218
218
|
"button",
|
|
219
219
|
{
|
|
220
|
-
onClick:
|
|
220
|
+
onClick: Ut,
|
|
221
221
|
style: {
|
|
222
222
|
flex: 1,
|
|
223
223
|
padding: "4px 8px",
|
|
@@ -238,19 +238,19 @@ const va = memo(
|
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
);
|
|
241
|
-
|
|
241
|
+
wa.displayName = "ProfilerOverlay";
|
|
242
242
|
process.env.NODE_ENV;
|
|
243
243
|
createContext(null);
|
|
244
|
-
const
|
|
244
|
+
const ct = createContext({
|
|
245
245
|
enabled: !0,
|
|
246
246
|
active: !1,
|
|
247
247
|
run: () => {
|
|
248
248
|
}
|
|
249
249
|
});
|
|
250
|
-
function
|
|
251
|
-
return useContext(
|
|
250
|
+
function Ra() {
|
|
251
|
+
return useContext(ct);
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function El(e, r) {
|
|
254
254
|
if (!e)
|
|
255
255
|
return null;
|
|
256
256
|
if (e === !0)
|
|
@@ -260,7 +260,7 @@ function xl(e, r) {
|
|
|
260
260
|
const t = e.steps ?? r;
|
|
261
261
|
return t && t.length > 0 ? t : null;
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function Pa(e, r) {
|
|
264
264
|
return e.map((t) => ({
|
|
265
265
|
target: t.target,
|
|
266
266
|
title: t.titleKey ? r(t.titleKey, t.title ?? "") : t.title ?? "",
|
|
@@ -272,7 +272,7 @@ function $a(e, r) {
|
|
|
272
272
|
disableInteraction: t.disableInteraction
|
|
273
273
|
}));
|
|
274
274
|
}
|
|
275
|
-
const
|
|
275
|
+
const Ll = ({
|
|
276
276
|
steps: e,
|
|
277
277
|
autoStart: r,
|
|
278
278
|
label: t,
|
|
@@ -281,7 +281,7 @@ const wl = ({
|
|
|
281
281
|
style: n,
|
|
282
282
|
"data-testid": i
|
|
283
283
|
}) => {
|
|
284
|
-
const { enabled: c, run: f } =
|
|
284
|
+
const { enabled: c, run: f } = Ra(), { t: s } = Zt();
|
|
285
285
|
if (!c || !e || e.length === 0)
|
|
286
286
|
return null;
|
|
287
287
|
const d = t ?? s("tutorial.startAria", "Start tutorial");
|
|
@@ -294,14 +294,14 @@ const wl = ({
|
|
|
294
294
|
"data-testid": i,
|
|
295
295
|
"aria-label": d,
|
|
296
296
|
title: d,
|
|
297
|
-
onClick: () => f(
|
|
297
|
+
onClick: () => f(Pa(e, s), { autoStart: r }),
|
|
298
298
|
children: "?"
|
|
299
299
|
}
|
|
300
300
|
);
|
|
301
|
-
},
|
|
302
|
-
if (typeof document < "u" && !document.getElementById(
|
|
301
|
+
}, St = "nice-tutorial-button-styles";
|
|
302
|
+
if (typeof document < "u" && !document.getElementById(St)) {
|
|
303
303
|
const e = document.createElement("style");
|
|
304
|
-
e.id =
|
|
304
|
+
e.id = St, e.textContent = `
|
|
305
305
|
.nice-tutorial-button {
|
|
306
306
|
display: inline-flex;
|
|
307
307
|
align-items: center;
|
|
@@ -340,7 +340,7 @@ const fe = {
|
|
|
340
340
|
space5: "20px",
|
|
341
341
|
space6: "24px",
|
|
342
342
|
space8: "32px"
|
|
343
|
-
},
|
|
343
|
+
}, me = {
|
|
344
344
|
fontFamily: "'Inter', system-ui, -apple-system, sans-serif",
|
|
345
345
|
fontSizeXs: "0.75rem",
|
|
346
346
|
fontSizeSm: "0.8125rem",
|
|
@@ -352,19 +352,19 @@ const fe = {
|
|
|
352
352
|
fontWeightSemibold: 600,
|
|
353
353
|
fontWeightBold: 700,
|
|
354
354
|
lineHeight: 1.5
|
|
355
|
-
},
|
|
355
|
+
}, pe = { fast: "120ms ease", normal: "200ms ease", slow: "300ms ease" }, dt = (e) => ({
|
|
356
356
|
color: e,
|
|
357
357
|
radiusSm: "4px",
|
|
358
358
|
radiusMd: "6px",
|
|
359
359
|
radiusLg: "8px",
|
|
360
360
|
radiusXl: "12px",
|
|
361
361
|
radiusFull: "9999px"
|
|
362
|
-
}),
|
|
362
|
+
}), yr = {
|
|
363
363
|
sm: "0 1px 2px rgba(0,0,0,0.05)",
|
|
364
364
|
md: "0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",
|
|
365
365
|
lg: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",
|
|
366
366
|
xl: "0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"
|
|
367
|
-
},
|
|
367
|
+
}, bn = {
|
|
368
368
|
sm: "0 1px 2px rgba(0,0,0,0.3)",
|
|
369
369
|
md: "0 4px 6px -1px rgba(0,0,0,0.4)",
|
|
370
370
|
lg: "0 10px 15px -3px rgba(0,0,0,0.4)",
|
|
@@ -386,11 +386,11 @@ function z(e, r, t, a, o) {
|
|
|
386
386
|
canvas: t.canvas ?? t.primary
|
|
387
387
|
},
|
|
388
388
|
text: { ...a, inverse: a.inverse ?? "#ffffff" },
|
|
389
|
-
borders:
|
|
390
|
-
shadows:
|
|
389
|
+
borders: dt(o),
|
|
390
|
+
shadows: yr,
|
|
391
391
|
spacing: fe,
|
|
392
|
-
typography:
|
|
393
|
-
transitions:
|
|
392
|
+
typography: me,
|
|
393
|
+
transitions: pe
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
396
|
function V(e, r, t, a, o) {
|
|
@@ -409,11 +409,11 @@ function V(e, r, t, a, o) {
|
|
|
409
409
|
canvas: t.canvas ?? t.primary
|
|
410
410
|
},
|
|
411
411
|
text: { ...a, inverse: a.inverse ?? "#0f172a" },
|
|
412
|
-
borders:
|
|
413
|
-
shadows:
|
|
412
|
+
borders: dt(o),
|
|
413
|
+
shadows: bn,
|
|
414
414
|
spacing: fe,
|
|
415
|
-
typography:
|
|
416
|
-
transitions:
|
|
415
|
+
typography: me,
|
|
416
|
+
transitions: pe
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
z(
|
|
@@ -1924,7 +1924,7 @@ function NiceI18nProvider({ locale: e = "en", overrides: r, children: t }) {
|
|
|
1924
1924
|
const o = { ...translations.en, ...translations[e], ...r };
|
|
1925
1925
|
return { locale: e, t: (i, c) => o[i] ?? c ?? i };
|
|
1926
1926
|
}, [e, r]);
|
|
1927
|
-
return
|
|
1927
|
+
return we.createElement(I18nContext.Provider, { value: a }, t);
|
|
1928
1928
|
}
|
|
1929
1929
|
function useNiceTranslation() {
|
|
1930
1930
|
return useContext(I18nContext);
|
|
@@ -2417,7 +2417,7 @@ function NiceMathEditor({
|
|
|
2417
2417
|
className: `nice-math-editor ${a ?? ""}`,
|
|
2418
2418
|
style: { position: "relative", ...styles$3.container, ...o },
|
|
2419
2419
|
children: [
|
|
2420
|
-
/* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ jsx(
|
|
2420
|
+
/* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ jsx(Ll, { steps: El(n, MATH_EDITOR_TOUR) }) }),
|
|
2421
2421
|
/* @__PURE__ */ jsx(Toolbar$1, {}),
|
|
2422
2422
|
/* @__PURE__ */ jsxs("div", { style: styles$3.main, children: [
|
|
2423
2423
|
/* @__PURE__ */ jsx(SymbolPalette, {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice2dev/ui-math",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Nice2Dev Mathematics Components - Equation editors, LaTeX rendering, formula builders, and math notation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@nice2dev/ui-core": "^1.0.
|
|
32
|
+
"@nice2dev/ui-core": "^1.0.27",
|
|
33
33
|
"react": ">=17.0.0",
|
|
34
34
|
"react-dom": ">=17.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@nice2dev/ui-core": "^1.0.
|
|
37
|
+
"@nice2dev/ui-core": "^1.0.27",
|
|
38
38
|
"@testing-library/react": "^14.1.0",
|
|
39
39
|
"@types/react": "^18.2.0",
|
|
40
40
|
"@types/react-dom": "^18.2.0",
|