@classytic/labs 0.1.0 → 0.2.0

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.
Files changed (455) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +18 -0
  2. package/dist/biology/enzyme-rate/preset.mjs +5 -5
  3. package/dist/biology/genetic-cross/core.d.mts +7 -7
  4. package/dist/biology/genetic-cross/core.mjs +4 -4
  5. package/dist/biology/genetic-cross/grid.mjs +132 -123
  6. package/dist/biology/genetic-cross/preset.mjs +4 -4
  7. package/dist/biology/genetic-cross/sex-linked.mjs +7 -7
  8. package/dist/biology/photosynthesis-factors/preset.mjs +8 -8
  9. package/dist/biology/respiration/preset.mjs +4 -4
  10. package/dist/biology/sequence/central-dogma.mjs +5 -5
  11. package/dist/biology/sequence/core.d.mts +6 -6
  12. package/dist/biology/sequence/core.mjs +1 -1
  13. package/dist/biology/sequence/preset.mjs +6 -6
  14. package/dist/blocks/authoring.mjs +5 -5
  15. package/dist/blocks/biology.d.mts +2 -2
  16. package/dist/blocks/biology.mjs +5 -5
  17. package/dist/blocks/chem.d.mts +2 -2
  18. package/dist/blocks/chem.mjs +13 -13
  19. package/dist/blocks/circuits.d.mts +293 -4
  20. package/dist/blocks/circuits.mjs +874 -9
  21. package/dist/blocks/discrete.d.mts +30 -2
  22. package/dist/blocks/discrete.mjs +74 -4
  23. package/dist/blocks/economics.mjs +1 -1
  24. package/dist/blocks/geography.mjs +1 -1
  25. package/dist/blocks/geometry.mjs +3 -3
  26. package/dist/blocks/ict.d.mts +90 -1
  27. package/dist/blocks/ict.mjs +217 -7
  28. package/dist/blocks/index.d.mts +3064 -657
  29. package/dist/blocks/index.mjs +9 -9
  30. package/dist/blocks/lab-block.mjs +5 -5
  31. package/dist/blocks/lab-config.d.mts +1 -1
  32. package/dist/blocks/lab-config.mjs +4 -4
  33. package/dist/blocks/lab-gallery.d.mts +1 -1
  34. package/dist/blocks/lab-gallery.mjs +2 -2
  35. package/dist/blocks/language.d.mts +6 -6
  36. package/dist/blocks/language.mjs +12 -12
  37. package/dist/blocks/lesson.mjs +4 -4
  38. package/dist/blocks/math.d.mts +577 -11
  39. package/dist/blocks/math.mjs +1648 -14
  40. package/dist/blocks/ml.d.mts +45 -1
  41. package/dist/blocks/ml.mjs +80 -6
  42. package/dist/blocks/physics.d.mts +9 -4
  43. package/dist/blocks/physics.mjs +75 -28
  44. package/dist/blocks/statistics.mjs +1 -1
  45. package/dist/build/CircuitEditor.d.mts +14 -0
  46. package/dist/build/CircuitEditor.mjs +787 -0
  47. package/dist/build/CircuitPlayer.d.mts +19 -0
  48. package/dist/build/CircuitPlayer.mjs +53 -0
  49. package/dist/build/CircuitScene.d.mts +61 -0
  50. package/dist/build/CircuitScene.mjs +383 -0
  51. package/dist/build/contract.d.mts +116 -0
  52. package/dist/build/editor-ops.d.mts +65 -0
  53. package/dist/build/editor-ops.mjs +306 -0
  54. package/dist/build/editor-ui.mjs +121 -0
  55. package/dist/build/flow.d.mts +14 -0
  56. package/dist/build/flow.mjs +119 -0
  57. package/dist/build/index.d.mts +10 -0
  58. package/dist/build/index.mjs +10 -0
  59. package/dist/build/parts/ammeter.d.mts +1 -0
  60. package/dist/build/parts/ammeter.mjs +32 -0
  61. package/dist/build/parts/bulb.d.mts +1 -0
  62. package/dist/build/parts/bulb.mjs +50 -0
  63. package/dist/build/parts/capacitor.d.mts +1 -0
  64. package/dist/build/parts/capacitor.mjs +26 -0
  65. package/dist/build/parts/cell.d.mts +1 -0
  66. package/dist/build/parts/cell.mjs +40 -0
  67. package/dist/build/parts/diode.d.mts +1 -0
  68. package/dist/build/parts/diode.mjs +33 -0
  69. package/dist/build/parts/index.d.mts +5 -0
  70. package/dist/build/parts/index.mjs +43 -0
  71. package/dist/build/parts/mosfet.d.mts +1 -0
  72. package/dist/build/parts/mosfet.mjs +95 -0
  73. package/dist/build/parts/node.d.mts +1 -0
  74. package/dist/build/parts/node.mjs +32 -0
  75. package/dist/build/parts/resistor.d.mts +1 -0
  76. package/dist/build/parts/resistor.mjs +49 -0
  77. package/dist/build/parts/shared.mjs +42 -0
  78. package/dist/build/parts/switch.d.mts +1 -0
  79. package/dist/build/parts/switch.mjs +34 -0
  80. package/dist/build/parts.d.mts +1 -0
  81. package/dist/build/registry.d.mts +9 -0
  82. package/dist/build/registry.mjs +15 -0
  83. package/dist/build/solve.d.mts +8 -0
  84. package/dist/build/solve.mjs +0 -0
  85. package/dist/catalog/registry.d.mts +2 -2
  86. package/dist/catalog/templates.d.mts +1 -1
  87. package/dist/catalog/templates.mjs +6 -6
  88. package/dist/chem/battery.mjs +1 -1
  89. package/dist/chem/bohr-atom.mjs +4 -4
  90. package/dist/chem/diffusion/preset.mjs +4 -4
  91. package/dist/chem/electrochem/preset.mjs +5 -5
  92. package/dist/chem/equilibrium/preset.d.mts +1 -1
  93. package/dist/chem/equilibrium/preset.mjs +6 -6
  94. package/dist/chem/gas-box/preset.mjs +6 -6
  95. package/dist/chem/kinetics/preset.mjs +6 -6
  96. package/dist/chem/periodic-trends/preset.mjs +7 -7
  97. package/dist/chem/reaction-lab.mjs +3 -3
  98. package/dist/chem/reaction-profile.mjs +4 -4
  99. package/dist/chem/solution/dilution.mjs +6 -6
  100. package/dist/chem/solution/field.d.mts +2 -2
  101. package/dist/chem/solution/field.mjs +2 -2
  102. package/dist/chem/solution/solution-box.mjs +7 -7
  103. package/dist/chem/stoichiometry/preset.mjs +5 -5
  104. package/dist/chem/titration/preset.mjs +5 -5
  105. package/dist/circuits/ac-dc/asset.mjs +1 -1
  106. package/dist/circuits/ac-dc/preset.mjs +2 -2
  107. package/dist/circuits/brownout/index.d.mts +1 -0
  108. package/dist/circuits/brownout/preset.d.mts +22 -0
  109. package/dist/circuits/brownout/preset.mjs +399 -0
  110. package/dist/circuits/capacitor-leak/preset.mjs +13 -8
  111. package/dist/circuits/circuit/asset.mjs +71 -14
  112. package/dist/circuits/circuit/preset.mjs +23 -5
  113. package/dist/circuits/circuit-builder.mjs +60 -132
  114. package/dist/circuits/circuit-lab.mjs +60 -40
  115. package/dist/circuits/cmos-gate/index.d.mts +1 -0
  116. package/dist/circuits/cmos-gate/preset.d.mts +75 -0
  117. package/dist/circuits/cmos-gate/preset.mjs +1491 -0
  118. package/dist/circuits/diode/index.d.mts +1 -0
  119. package/dist/circuits/diode/preset.d.mts +25 -0
  120. package/dist/circuits/diode/preset.mjs +266 -0
  121. package/dist/circuits/index.d.mts +7 -1
  122. package/dist/circuits/index.mjs +7 -1
  123. package/dist/circuits/rc-charging/index.d.mts +1 -0
  124. package/dist/circuits/rc-charging/preset.d.mts +27 -0
  125. package/dist/circuits/rc-charging/preset.mjs +329 -0
  126. package/dist/circuits/semiconductor/index.d.mts +1 -0
  127. package/dist/circuits/semiconductor/preset.d.mts +102 -0
  128. package/dist/circuits/semiconductor/preset.mjs +1855 -0
  129. package/dist/circuits/transistor/index.d.mts +1 -0
  130. package/dist/circuits/transistor/preset.d.mts +27 -0
  131. package/dist/circuits/transistor/preset.mjs +329 -0
  132. package/dist/commerce/accounting/core.d.mts +1 -1
  133. package/dist/commerce/accounting/equation-balance.mjs +5 -5
  134. package/dist/commerce/accounting/journal-poster.mjs +8 -8
  135. package/dist/commerce/accounting/statement-sorter.mjs +4 -4
  136. package/dist/commerce/economics/core.d.mts +2 -2
  137. package/dist/commerce/economics/core.mjs +1 -1
  138. package/dist/commerce/economics/demand-shift-vs-move.mjs +6 -6
  139. package/dist/commerce/economics/elasticity-revenue.mjs +6 -6
  140. package/dist/commerce/economics/market-equilibrium.mjs +5 -5
  141. package/dist/core/easing.d.mts +3 -3
  142. package/dist/core/easing.mjs +2 -2
  143. package/dist/core/numeric.d.mts +3 -3
  144. package/dist/core/numeric.mjs +2 -2
  145. package/dist/core/reactive.d.mts +1 -1
  146. package/dist/core/reactive.mjs +1 -1
  147. package/dist/core/rng.d.mts +2 -2
  148. package/dist/core/rng.mjs +1 -1
  149. package/dist/core/tex.mjs +2 -2
  150. package/dist/core/timeline.d.mts +1 -1
  151. package/dist/core/timeline.mjs +1 -1
  152. package/dist/core/util.mjs +11 -1
  153. package/dist/discrete/arrangements/preset.mjs +6 -14
  154. package/dist/discrete/bayes/preset.mjs +43 -35
  155. package/dist/discrete/binomial/preset.mjs +2 -2
  156. package/dist/discrete/combination-studio/figure.d.mts +6 -0
  157. package/dist/discrete/combination-studio/figure.mjs +159 -0
  158. package/dist/discrete/combination-studio/index.d.mts +2 -0
  159. package/dist/discrete/combination-studio/preset.d.mts +44 -0
  160. package/dist/discrete/combination-studio/preset.mjs +440 -0
  161. package/dist/discrete/core/combinatorics.d.mts +23 -3
  162. package/dist/discrete/core/combinatorics.mjs +38 -3
  163. package/dist/discrete/core/pigeonhole.d.mts +1 -1
  164. package/dist/discrete/core/pigeonhole.mjs +1 -1
  165. package/dist/discrete/core/probability.d.mts +3 -3
  166. package/dist/discrete/core/probability.mjs +3 -3
  167. package/dist/discrete/core/sets.d.mts +1 -1
  168. package/dist/discrete/counting-slots/preset.mjs +8 -8
  169. package/dist/discrete/counting-tree/preset.mjs +65 -8
  170. package/dist/discrete/expected-value/preset.mjs +13 -13
  171. package/dist/discrete/hypergeometric/preset.mjs +48 -15
  172. package/dist/discrete/index.d.mts +4 -2
  173. package/dist/discrete/index.mjs +4 -2
  174. package/dist/discrete/karnaugh/preset.mjs +26 -20
  175. package/dist/discrete/lln/preset.mjs +44 -3
  176. package/dist/discrete/logic-circuit/preset.mjs +2 -2
  177. package/dist/discrete/monte-carlo/preset.d.mts +1 -1
  178. package/dist/discrete/monte-carlo/preset.mjs +14 -14
  179. package/dist/discrete/monty-hall/preset.mjs +6 -6
  180. package/dist/discrete/outcome-builder/preset.mjs +3 -3
  181. package/dist/discrete/pascal/preset.mjs +37 -7
  182. package/dist/discrete/rules.d.mts +20 -0
  183. package/dist/discrete/rules.mjs +264 -0
  184. package/dist/discrete/sample-space/preset.mjs +4 -4
  185. package/dist/discrete/selection/preset.mjs +7 -13
  186. package/dist/discrete/truth-table/preset.mjs +32 -9
  187. package/dist/discrete/venn/preset.mjs +71 -48
  188. package/dist/geography/cycle-lab/preset.mjs +17 -10
  189. package/dist/geography/cycles.d.mts +3 -3
  190. package/dist/geography/cycles.mjs +3 -3
  191. package/dist/geometry/board/preset.d.mts +2 -0
  192. package/dist/geometry/board/preset.mjs +11 -15
  193. package/dist/geometry/builder.mjs +3 -3
  194. package/dist/ict/number-systems/base-odometer.mjs +4 -4
  195. package/dist/ict/number-systems/bit-grouper.d.mts +1 -1
  196. package/dist/ict/number-systems/bit-grouper.mjs +4 -4
  197. package/dist/ict/number-systems/place-value-dial.d.mts +1 -1
  198. package/dist/ict/number-systems/place-value-dial.mjs +3 -3
  199. package/dist/ict/number-systems/wheel.d.mts +3 -3
  200. package/dist/ict/number-systems/wheel.mjs +4 -4
  201. package/dist/kit/annotate.mjs +3 -3
  202. package/dist/kit/answer-check.d.mts +2 -2
  203. package/dist/kit/answer-check.mjs +34 -6
  204. package/dist/kit/ask.d.mts +19 -0
  205. package/dist/kit/ask.mjs +46 -0
  206. package/dist/kit/bar-strip.mjs +53 -0
  207. package/dist/kit/calc.d.mts +33 -0
  208. package/dist/kit/calc.mjs +27 -0
  209. package/dist/kit/carrier-engine.mjs +147 -0
  210. package/dist/kit/clue-scene.d.mts +86 -0
  211. package/dist/kit/clue-scene.mjs +424 -0
  212. package/dist/kit/cluster.d.mts +30 -0
  213. package/dist/kit/cluster.mjs +81 -0
  214. package/dist/kit/controls.mjs +11 -5
  215. package/dist/kit/coords.d.mts +88 -0
  216. package/dist/kit/coords.mjs +192 -0
  217. package/dist/kit/data-scene.d.mts +27 -0
  218. package/dist/kit/data-scene.mjs +199 -0
  219. package/dist/kit/diagram.mjs +111 -50
  220. package/dist/kit/electronics.mjs +552 -60
  221. package/dist/kit/expr-analysis.d.mts +18 -6
  222. package/dist/kit/expr-analysis.mjs +82 -28
  223. package/dist/kit/frame.d.mts +3 -3
  224. package/dist/kit/frame.mjs +25 -6
  225. package/dist/kit/gameshow.mjs +2 -2
  226. package/dist/kit/index.d.mts +14 -2
  227. package/dist/kit/index.mjs +13 -1
  228. package/dist/kit/logic-gates.mjs +246 -47
  229. package/dist/kit/palette.mjs +26 -0
  230. package/dist/kit/pedagogy.d.mts +4 -4
  231. package/dist/kit/pedagogy.mjs +21 -17
  232. package/dist/kit/play.d.mts +1 -1
  233. package/dist/kit/play.mjs +3 -3
  234. package/dist/kit/predict.d.mts +55 -0
  235. package/dist/kit/predict.mjs +146 -0
  236. package/dist/kit/receipt.d.mts +29 -0
  237. package/dist/kit/receipt.mjs +94 -0
  238. package/dist/kit/rich.mjs +2 -2
  239. package/dist/kit/rule.d.mts +59 -0
  240. package/dist/kit/rule.mjs +215 -0
  241. package/dist/kit/scale.mjs +1 -1
  242. package/dist/kit/scene-library.d.mts +22 -0
  243. package/dist/kit/scene-library.mjs +311 -0
  244. package/dist/kit/scene-studio.d.mts +14 -0
  245. package/dist/kit/scene-studio.mjs +338 -0
  246. package/dist/kit/scenes.d.mts +31 -0
  247. package/dist/kit/scenes.mjs +569 -0
  248. package/dist/kit/slot-fill.d.mts +61 -0
  249. package/dist/kit/slot-fill.mjs +207 -0
  250. package/dist/kit/solve.d.mts +21 -0
  251. package/dist/kit/solve.mjs +75 -0
  252. package/dist/kit/space.mjs +5 -5
  253. package/dist/kit/steps.mjs +2 -2
  254. package/dist/kit/vessel.d.mts +69 -0
  255. package/dist/kit/vessel.mjs +191 -0
  256. package/dist/language/agreement/preset.mjs +2 -2
  257. package/dist/language/article-lens/preset.d.mts +1 -1
  258. package/dist/language/article-lens/preset.mjs +8 -8
  259. package/dist/language/deck.d.mts +3 -3
  260. package/dist/language/deck.mjs +1 -1
  261. package/dist/language/preposition-scene/preset.d.mts +2 -2
  262. package/dist/language/preposition-scene/preset.mjs +5 -5
  263. package/dist/language/sentence-builder/preset.mjs +5 -5
  264. package/dist/language/transform/preset.d.mts +2 -2
  265. package/dist/language/transform/preset.mjs +5 -5
  266. package/dist/language/ui.d.mts +3 -3
  267. package/dist/language/ui.mjs +4 -4
  268. package/dist/language/word-match/preset.mjs +3 -3
  269. package/dist/logic/LogicBuildLab.d.mts +22 -0
  270. package/dist/logic/LogicBuildLab.mjs +170 -0
  271. package/dist/logic/LogicEditScene.d.mts +31 -0
  272. package/dist/logic/LogicEditScene.mjs +276 -0
  273. package/dist/logic/LogicEditor.d.mts +14 -0
  274. package/dist/logic/LogicEditor.mjs +413 -0
  275. package/dist/logic/LogicScene.d.mts +32 -0
  276. package/dist/logic/LogicScene.mjs +277 -0
  277. package/dist/logic/contract.d.mts +72 -0
  278. package/dist/logic/display.d.mts +24 -0
  279. package/dist/logic/display.mjs +127 -0
  280. package/dist/logic/edit-ops.d.mts +44 -0
  281. package/dist/logic/edit-ops.mjs +177 -0
  282. package/dist/logic/evaluate.d.mts +11 -0
  283. package/dist/logic/evaluate.mjs +93 -0
  284. package/dist/logic/gates.d.mts +10 -0
  285. package/dist/logic/gates.mjs +73 -0
  286. package/dist/logic/index.d.mts +14 -0
  287. package/dist/logic/index.mjs +13 -0
  288. package/dist/logic/lab.d.mts +32 -0
  289. package/dist/logic/lab.mjs +160 -0
  290. package/dist/logic/presets.d.mts +12 -0
  291. package/dist/logic/presets.mjs +241 -0
  292. package/dist/logic/registry.d.mts +9 -0
  293. package/dist/logic/registry.mjs +15 -0
  294. package/dist/math/area-model/preset.mjs +70 -44
  295. package/dist/math/balance-algebra/preset.mjs +14 -5
  296. package/dist/math/broken-tree/index.d.mts +1 -0
  297. package/dist/math/broken-tree/preset.d.mts +26 -0
  298. package/dist/math/broken-tree/preset.mjs +435 -0
  299. package/dist/math/circle/index.d.mts +1 -0
  300. package/dist/math/circle/preset.d.mts +44 -0
  301. package/dist/math/circle/preset.mjs +198 -0
  302. package/dist/math/complex/core.d.mts +93 -0
  303. package/dist/math/complex/core.mjs +239 -0
  304. package/dist/math/complex/index.d.mts +3 -0
  305. package/dist/math/complex/preset.d.mts +31 -0
  306. package/dist/math/complex/preset.mjs +377 -0
  307. package/dist/math/complex/rules.d.mts +6 -0
  308. package/dist/math/complex/rules.mjs +121 -0
  309. package/dist/math/conic/index.d.mts +1 -0
  310. package/dist/math/conic/preset.d.mts +30 -0
  311. package/dist/math/conic/preset.mjs +334 -0
  312. package/dist/math/derivation.mjs +5 -5
  313. package/dist/math/derivative-explorer/preset.mjs +5 -5
  314. package/dist/math/domain-range/index.d.mts +1 -0
  315. package/dist/math/domain-range/preset.d.mts +33 -0
  316. package/dist/math/domain-range/preset.mjs +313 -0
  317. package/dist/math/fraction-bar/index.d.mts +1 -0
  318. package/dist/math/fraction-bar/preset.d.mts +27 -0
  319. package/dist/math/fraction-bar/preset.mjs +197 -0
  320. package/dist/math/function-machine/preset.mjs +2 -2
  321. package/dist/math/gradient-descent.mjs +6 -6
  322. package/dist/math/grapher/preset.d.mts +1 -1
  323. package/dist/math/grapher/preset.mjs +4 -4
  324. package/dist/math/harmonic-form/preset.mjs +6 -6
  325. package/dist/math/index.d.mts +27 -2
  326. package/dist/math/index.mjs +27 -2
  327. package/dist/math/integral-explorer/preset.mjs +2 -2
  328. package/dist/math/interactive/preset.mjs +3 -3
  329. package/dist/math/limit-explorer/preset.mjs +4 -4
  330. package/dist/math/linear-model/index.d.mts +1 -0
  331. package/dist/math/linear-model/preset.d.mts +53 -0
  332. package/dist/math/linear-model/preset.mjs +164 -0
  333. package/dist/math/linear-system/preset.mjs +4 -4
  334. package/dist/math/mystery-bucket/preset.mjs +6 -6
  335. package/dist/math/number-line/preset.mjs +3 -2
  336. package/dist/math/parabola/preset.mjs +4 -3
  337. package/dist/math/pattern/preset.mjs +7 -13
  338. package/dist/math/percent-bar/index.d.mts +1 -0
  339. package/dist/math/percent-bar/preset.d.mts +37 -0
  340. package/dist/math/percent-bar/preset.mjs +275 -0
  341. package/dist/math/poly/core.d.mts +50 -0
  342. package/dist/math/poly/core.mjs +268 -0
  343. package/dist/math/poly/index.d.mts +3 -0
  344. package/dist/math/poly/preset.d.mts +23 -0
  345. package/dist/math/poly/preset.mjs +141 -0
  346. package/dist/math/poly/steps.d.mts +10 -0
  347. package/dist/math/poly/steps.mjs +99 -0
  348. package/dist/math/rate-machine/index.d.mts +1 -0
  349. package/dist/math/rate-machine/preset.d.mts +35 -0
  350. package/dist/math/rate-machine/preset.mjs +281 -0
  351. package/dist/math/ratio-share/index.d.mts +1 -0
  352. package/dist/math/ratio-share/preset.d.mts +24 -0
  353. package/dist/math/ratio-share/preset.mjs +204 -0
  354. package/dist/math/receipt/index.d.mts +1 -0
  355. package/dist/math/receipt/preset.d.mts +22 -0
  356. package/dist/math/receipt/preset.mjs +137 -0
  357. package/dist/math/sequence-predict/index.d.mts +1 -0
  358. package/dist/math/sequence-predict/preset.d.mts +34 -0
  359. package/dist/math/sequence-predict/preset.mjs +130 -0
  360. package/dist/math/straight-line/index.d.mts +1 -0
  361. package/dist/math/straight-line/preset.d.mts +37 -0
  362. package/dist/math/straight-line/preset.mjs +374 -0
  363. package/dist/math/system-solve/index.d.mts +1 -0
  364. package/dist/math/system-solve/preset.d.mts +21 -0
  365. package/dist/math/system-solve/preset.mjs +227 -0
  366. package/dist/math/transform/index.d.mts +1 -0
  367. package/dist/math/transform/preset.d.mts +41 -0
  368. package/dist/math/transform/preset.mjs +343 -0
  369. package/dist/math/triangle-trig/preset.mjs +12 -9
  370. package/dist/math/trig/core.d.mts +37 -0
  371. package/dist/math/trig/core.mjs +150 -0
  372. package/dist/math/trig/diagrams.d.mts +1 -0
  373. package/dist/math/trig/diagrams.mjs +321 -0
  374. package/dist/math/trig/index.d.mts +3 -0
  375. package/dist/math/trig/preset.d.mts +25 -0
  376. package/dist/math/trig/preset.mjs +260 -0
  377. package/dist/math/trig/rules.d.mts +6 -0
  378. package/dist/math/trig/rules.mjs +159 -0
  379. package/dist/math/trig-explorer.mjs +4 -4
  380. package/dist/ml/boundary/preset.mjs +8 -3
  381. package/dist/ml/classifier/preset.mjs +31 -6
  382. package/dist/ml/kmeans/preset.mjs +4 -4
  383. package/dist/ml/knn/preset.mjs +47 -12
  384. package/dist/ml/regression/preset.mjs +36 -7
  385. package/dist/physics/atwood/preset.mjs +4 -4
  386. package/dist/physics/bullet-walls/preset.d.mts +1 -1
  387. package/dist/physics/bullet-walls/preset.mjs +7 -7
  388. package/dist/physics/carnot/preset.mjs +6 -6
  389. package/dist/physics/circular-motion/preset.mjs +36 -5
  390. package/dist/physics/collision-track/preset.mjs +35 -5
  391. package/dist/physics/efficiency/preset.d.mts +2 -2
  392. package/dist/physics/efficiency/preset.mjs +5 -5
  393. package/dist/physics/electric-field/preset.mjs +32 -23
  394. package/dist/physics/electric-flux/index.d.mts +1 -0
  395. package/dist/physics/electric-flux/preset.d.mts +29 -0
  396. package/dist/physics/electric-flux/preset.mjs +264 -0
  397. package/dist/physics/energy-skate/preset.mjs +5 -5
  398. package/dist/physics/entropy/preset.mjs +7 -7
  399. package/dist/physics/expansion/preset.mjs +13 -13
  400. package/dist/physics/exponential/asset.mjs +1 -1
  401. package/dist/physics/exponential/preset.mjs +4 -4
  402. package/dist/physics/gas-process/preset.mjs +3 -3
  403. package/dist/physics/gauss-law/index.d.mts +1 -0
  404. package/dist/physics/gauss-law/preset.d.mts +20 -0
  405. package/dist/physics/gauss-law/preset.mjs +286 -0
  406. package/dist/physics/gravitation/preset.mjs +7 -7
  407. package/dist/physics/gravity-drop.mjs +4 -4
  408. package/dist/physics/heat-transfer/preset.d.mts +1 -1
  409. package/dist/physics/heat-transfer/preset.mjs +10 -10
  410. package/dist/physics/impulse/preset.mjs +5 -5
  411. package/dist/physics/index.d.mts +4 -1
  412. package/dist/physics/index.mjs +4 -1
  413. package/dist/physics/kepler/preset.mjs +4 -4
  414. package/dist/physics/lever/preset.mjs +3 -3
  415. package/dist/physics/lorentz/preset.mjs +11 -11
  416. package/dist/physics/magnetism/preset.mjs +3 -3
  417. package/dist/physics/optics/preset.mjs +2 -2
  418. package/dist/physics/orbit-lab.mjs +5 -5
  419. package/dist/physics/projectile-lab.mjs +4 -4
  420. package/dist/physics/rain-relative/preset.mjs +5 -5
  421. package/dist/physics/ramp-forces/preset.mjs +5 -5
  422. package/dist/physics/river-boat.mjs +6 -6
  423. package/dist/physics/shm/preset.mjs +9 -9
  424. package/dist/physics/stopping-distance/preset.mjs +3 -3
  425. package/dist/physics/temperature-scales/preset.mjs +105 -116
  426. package/dist/physics/terminal-velocity/preset.mjs +5 -5
  427. package/dist/physics/thermal/preset.mjs +5 -5
  428. package/dist/physics/vector-board/preset.mjs +7 -6
  429. package/dist/physics/vector-scene.mjs +2 -2
  430. package/dist/physics/vector-types/preset.mjs +37 -3
  431. package/dist/physics/water-density/preset.mjs +12 -12
  432. package/dist/physics/waves/doppler.mjs +2 -2
  433. package/dist/physics/waves/preset.mjs +4 -4
  434. package/dist/physics/waves/ripple.mjs +6 -6
  435. package/dist/physics/waves/string.mjs +5 -5
  436. package/dist/physics/work-energy/preset.mjs +4 -4
  437. package/dist/physics/work-potential/index.d.mts +1 -0
  438. package/dist/physics/work-potential/preset.d.mts +20 -0
  439. package/dist/physics/work-potential/preset.mjs +276 -0
  440. package/dist/schemas/index.d.mts +6 -6
  441. package/dist/schemas/index.mjs +3 -3
  442. package/dist/statistics/center-spread/preset.mjs +3 -3
  443. package/dist/statistics/core/descriptive.d.mts +2 -2
  444. package/dist/statistics/core/descriptive.mjs +2 -2
  445. package/dist/statistics/core/normal.d.mts +3 -3
  446. package/dist/statistics/core/normal.mjs +3 -3
  447. package/dist/statistics/core/sequences.d.mts +1 -1
  448. package/dist/statistics/galton/preset.mjs +2 -2
  449. package/dist/statistics/histogram/preset.mjs +6 -6
  450. package/dist/statistics/normal/preset.mjs +2 -2
  451. package/dist/statistics/sampling/preset.mjs +4 -4
  452. package/dist/statistics/sequence/preset.mjs +58 -15
  453. package/dist/statistics/z-table/preset.mjs +17 -4
  454. package/package.json +11 -3
  455. package/styles.css +4 -1
@@ -0,0 +1,276 @@
1
+ 'use client';
2
+
3
+ import { JunctionDot, Wire, orthPoints } from "../kit/electronics.mjs";
4
+ import { GateGlyph, Lamp, ToggleSwitch, gatePorts } from "../kit/logic-gates.mjs";
5
+ import { getGate } from "./registry.mjs";
6
+ import { evaluate } from "./evaluate.mjs";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+
9
+ //#region src/logic/LogicEditScene.tsx
10
+ const SW_W = 52;
11
+ const SW_H = 28;
12
+ const GATE = 50;
13
+ const LED_R = 15;
14
+ const glyphOf = (kind) => getGate(kind)?.glyph ?? "AND";
15
+ const xy = (n, dx, dy) => ({
16
+ x: n.x ?? dx,
17
+ y: n.y ?? dy
18
+ });
19
+ function LogicEditScene({ doc, selectedId, wireStart, previewCursor, onNodePointerDown, onPortPointerDown, onBackground, ariaLabel }) {
20
+ const sol = evaluate(doc);
21
+ const W = doc.size?.w ?? 640, H = doc.size?.h ?? 360;
22
+ const pos = /* @__PURE__ */ new Map();
23
+ doc.inputs.forEach((n, i) => pos.set(n.id, xy(n, 40, 40 + i * 56)));
24
+ doc.gates.forEach((n, i) => pos.set(n.id, xy(n, 260, 60 + i * 80)));
25
+ doc.outputs.forEach((n, i) => pos.set(n.id, xy(n, W - 80, 60 + i * 70)));
26
+ const outPort = (id) => {
27
+ const p = pos.get(id);
28
+ if (!p) return null;
29
+ if (doc.inputs.some((n) => n.id === id)) return {
30
+ x: p.x + 52,
31
+ y: p.y + 28 / 2
32
+ };
33
+ const g = doc.gates.find((n) => n.id === id);
34
+ if (g) return gatePorts(glyphOf(g.kind), p.x, p.y, 50).output;
35
+ return null;
36
+ };
37
+ const gateInPorts = (id) => {
38
+ const p = pos.get(id);
39
+ const g = doc.gates.find((n) => n.id === id);
40
+ if (!p || !g) return [];
41
+ return gatePorts(glyphOf(g.kind), p.x, p.y, 50).inputs;
42
+ };
43
+ const outInPort = (id) => {
44
+ const p = pos.get(id);
45
+ return p ? {
46
+ x: p.x,
47
+ y: p.y + 15
48
+ } : null;
49
+ };
50
+ const wires = [];
51
+ const wire = (key, a, b, on) => {
52
+ if (!a || !b) return;
53
+ wires.push(/* @__PURE__ */ jsx(Wire, {
54
+ points: orthPoints(a, b),
55
+ live: on
56
+ }, key));
57
+ };
58
+ doc.gates.forEach((g) => g.in.forEach((src, i) => {
59
+ if (src) wire(`w-${g.id}-${i}`, outPort(src), gateInPorts(g.id)[i] ?? null, sol.high(src));
60
+ }));
61
+ doc.outputs.forEach((o) => {
62
+ if (o.in) wire(`wo-${o.id}`, outPort(o.in), outInPort(o.id), sol.high(o.in));
63
+ });
64
+ const fanout = /* @__PURE__ */ new Map();
65
+ const bump = (id) => {
66
+ if (id) fanout.set(id, (fanout.get(id) ?? 0) + 1);
67
+ };
68
+ doc.gates.forEach((g) => g.in.forEach(bump));
69
+ doc.outputs.forEach((o) => bump(o.in));
70
+ const junctions = [];
71
+ fanout.forEach((n, src) => {
72
+ if (n >= 2) {
73
+ const sp = outPort(src);
74
+ if (sp) junctions.push(/* @__PURE__ */ jsx(JunctionDot, {
75
+ x: sp.x,
76
+ y: sp.y,
77
+ r: 3.5,
78
+ live: sol.high(src)
79
+ }, `j-${src}`));
80
+ }
81
+ });
82
+ const isStart = (r) => !!wireStart && wireStart.nodeId === r.nodeId && wireStart.dir === r.dir && wireStart.slot === r.slot;
83
+ const portDot = (ref, at, on) => {
84
+ if (!at) return null;
85
+ const start = isStart(ref);
86
+ return /* @__PURE__ */ jsxs("g", {
87
+ onPointerDown: (e) => {
88
+ e.stopPropagation();
89
+ onPortPointerDown?.(ref, e);
90
+ },
91
+ style: { cursor: "crosshair" },
92
+ children: [
93
+ /* @__PURE__ */ jsx("circle", {
94
+ cx: at.x,
95
+ cy: at.y,
96
+ r: 9,
97
+ fill: "transparent"
98
+ }),
99
+ start && /* @__PURE__ */ jsx("circle", {
100
+ cx: at.x,
101
+ cy: at.y,
102
+ r: 7,
103
+ fill: "none",
104
+ stroke: "var(--stage-accent)",
105
+ strokeWidth: 2
106
+ }),
107
+ /* @__PURE__ */ jsx("circle", {
108
+ cx: at.x,
109
+ cy: at.y,
110
+ r: 4,
111
+ fill: on ? "var(--stage-live)" : "var(--stage-metal)",
112
+ stroke: "var(--stage-bg)",
113
+ strokeWidth: 1
114
+ })
115
+ ]
116
+ }, `p-${ref.nodeId}-${ref.dir}-${ref.slot ?? "x"}`);
117
+ };
118
+ const selRing = (id, x, y, w, h) => selectedId === id ? /* @__PURE__ */ jsx("rect", {
119
+ x: x - 5,
120
+ y: y - 5,
121
+ width: w + 10,
122
+ height: h + 10,
123
+ rx: 7,
124
+ fill: "none",
125
+ stroke: "var(--stage-accent)",
126
+ strokeWidth: 1.5,
127
+ strokeDasharray: "4 3"
128
+ }) : null;
129
+ return /* @__PURE__ */ jsxs("svg", {
130
+ viewBox: `0 0 ${W} ${H}`,
131
+ width: "100%",
132
+ style: {
133
+ maxWidth: W,
134
+ display: "block",
135
+ background: "var(--stage-bg)",
136
+ borderRadius: 10,
137
+ touchAction: "none"
138
+ },
139
+ role: "img",
140
+ "aria-label": ariaLabel ?? "logic circuit builder canvas",
141
+ children: [
142
+ /* @__PURE__ */ jsx("rect", {
143
+ x: 0,
144
+ y: 0,
145
+ width: W,
146
+ height: H,
147
+ fill: "transparent",
148
+ onPointerDown: () => onBackground?.()
149
+ }),
150
+ wires,
151
+ junctions,
152
+ wireStart && previewCursor && (() => {
153
+ const a = outPort(wireStart.nodeId);
154
+ if (!a) return null;
155
+ let target = null, bd = 18;
156
+ const consider = (pt) => {
157
+ if (pt) {
158
+ const d = Math.hypot(previewCursor.x - pt.x, previewCursor.y - pt.y);
159
+ if (d < bd) {
160
+ bd = d;
161
+ target = pt;
162
+ }
163
+ }
164
+ };
165
+ doc.gates.forEach((g) => gateInPorts(g.id).forEach((pt) => consider(pt)));
166
+ doc.outputs.forEach((o) => consider(outInPort(o.id)));
167
+ const b = target ?? previewCursor;
168
+ const dx = Math.max(18, Math.abs(b.x - a.x) * .45);
169
+ return /* @__PURE__ */ jsxs("g", {
170
+ style: { pointerEvents: "none" },
171
+ children: [/* @__PURE__ */ jsx("path", {
172
+ d: `M${a.x},${a.y} C${a.x + dx},${a.y} ${b.x - dx},${b.y} ${b.x},${b.y}`,
173
+ fill: "none",
174
+ stroke: "var(--stage-accent)",
175
+ strokeWidth: 2.5,
176
+ strokeDasharray: "5 4",
177
+ strokeLinecap: "round",
178
+ opacity: .9
179
+ }), /* @__PURE__ */ jsx("circle", {
180
+ cx: b.x,
181
+ cy: b.y,
182
+ r: target ? 6 : 4,
183
+ fill: target ? "var(--stage-accent)" : "var(--stage-bg)",
184
+ stroke: "var(--stage-accent)",
185
+ strokeWidth: 2
186
+ })]
187
+ });
188
+ })(),
189
+ doc.inputs.map((inp) => {
190
+ const p = pos.get(inp.id);
191
+ return /* @__PURE__ */ jsxs("g", { children: [
192
+ selRing(inp.id, p.x, p.y, 52, 28),
193
+ /* @__PURE__ */ jsx("g", {
194
+ onPointerDown: (e) => onNodePointerDown?.(inp.id, e),
195
+ style: { cursor: "grab" },
196
+ children: /* @__PURE__ */ jsx(ToggleSwitch, {
197
+ x: p.x,
198
+ y: p.y,
199
+ w: 52,
200
+ h: 28,
201
+ on: sol.value(inp.id),
202
+ label: inp.label
203
+ })
204
+ }),
205
+ portDot({
206
+ nodeId: inp.id,
207
+ dir: "out"
208
+ }, outPort(inp.id), sol.high(inp.id))
209
+ ] }, inp.id);
210
+ }),
211
+ doc.gates.map((g) => {
212
+ const p = pos.get(g.id);
213
+ const ins = gateInPorts(g.id);
214
+ return /* @__PURE__ */ jsxs("g", { children: [
215
+ selRing(g.id, p.x, p.y, 50, 50),
216
+ /* @__PURE__ */ jsx("g", {
217
+ onPointerDown: (e) => onNodePointerDown?.(g.id, e),
218
+ style: { cursor: "grab" },
219
+ children: /* @__PURE__ */ jsx(GateGlyph, {
220
+ x: p.x,
221
+ y: p.y,
222
+ size: 50,
223
+ type: glyphOf(g.kind),
224
+ live: sol.high(g.id),
225
+ label: g.label ?? getGate(g.kind)?.label
226
+ })
227
+ }),
228
+ ins.map((_, i) => portDot({
229
+ nodeId: g.id,
230
+ dir: "in",
231
+ slot: i
232
+ }, ins[i] ?? null, !!g.in[i] && sol.high(g.in[i]))),
233
+ portDot({
234
+ nodeId: g.id,
235
+ dir: "out"
236
+ }, outPort(g.id), sol.high(g.id))
237
+ ] }, g.id);
238
+ }),
239
+ doc.outputs.map((o) => {
240
+ const p = pos.get(o.id);
241
+ const lit = !!o.in && sol.high(o.in);
242
+ const met = o.goal !== void 0 && (sol.outputs[o.id] ?? false) === o.goal;
243
+ return /* @__PURE__ */ jsxs("g", { children: [
244
+ selRing(o.id, p.x, p.y, 15 * 2, 15 * 2),
245
+ /* @__PURE__ */ jsx("g", {
246
+ onPointerDown: (e) => onNodePointerDown?.(o.id, e),
247
+ style: { cursor: "grab" },
248
+ children: /* @__PURE__ */ jsx(Lamp, {
249
+ cx: p.x + 15,
250
+ cy: p.y + 15,
251
+ r: 15,
252
+ on: lit,
253
+ color: o.color,
254
+ label: o.label
255
+ })
256
+ }),
257
+ o.goal !== void 0 && /* @__PURE__ */ jsx("circle", {
258
+ cx: p.x + 15,
259
+ cy: p.y + 15,
260
+ r: 20,
261
+ fill: "none",
262
+ stroke: met ? "var(--stage-good)" : "var(--stage-danger, #e03131)",
263
+ strokeWidth: 2
264
+ }),
265
+ portDot({
266
+ nodeId: o.id,
267
+ dir: "in"
268
+ }, outInPort(o.id), lit)
269
+ ] }, o.id);
270
+ })
271
+ ]
272
+ });
273
+ }
274
+
275
+ //#endregion
276
+ export { LogicEditScene };
@@ -0,0 +1,14 @@
1
+ import { LogicDoc } from "./contract.mjs";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/logic/LogicEditor.d.ts
5
+ interface LogicEditorProps {
6
+ value: LogicDoc;
7
+ onChange: (doc: LogicDoc) => void;
8
+ }
9
+ declare function LogicEditor({
10
+ value,
11
+ onChange
12
+ }: LogicEditorProps): ReactNode;
13
+ //#endregion
14
+ export { LogicEditor, LogicEditorProps };
@@ -0,0 +1,413 @@
1
+ 'use client';
2
+
3
+ import { GateGlyph } from "../kit/logic-gates.mjs";
4
+ import { EBtn, Field, Panel, TextInput } from "../build/editor-ui.mjs";
5
+ import { listGates } from "./registry.mjs";
6
+ import { LogicEditScene } from "./LogicEditScene.mjs";
7
+ import { addNode, connect, deleteNode, disconnect, moveNode, relabel, setGoal, toggleInput } from "./edit-ops.mjs";
8
+ import { useEffect, useRef, useState } from "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+
11
+ //#region src/logic/LogicEditor.tsx
12
+ /**
13
+ * LogicEditor — the drag-and-drop digital-logic canvas (the gate-circuit counterpart of the
14
+ * analog CircuitEditor, reusing its editor-UI kit and click-vs-drag interaction). Drop a
15
+ * source, an LED, or any gate from the palette; drag nodes to lay them out; click an OUTPUT
16
+ * dot then an INPUT slot to wire them; toggle a source by clicking it. The doc evaluates live,
17
+ * so wires glow and LEDs light as you build. Emits the LogicDoc via `onChange`.
18
+ */
19
+ const SNAP = 10;
20
+ const snap = (n) => Math.round(n / SNAP) * SNAP;
21
+ const emptyDoc = {
22
+ inputs: [],
23
+ gates: [],
24
+ outputs: [],
25
+ size: {
26
+ w: 640,
27
+ h: 360
28
+ }
29
+ };
30
+ function PaletteThumb({ glyph }) {
31
+ if (!glyph) return /* @__PURE__ */ jsx("span", {
32
+ style: {
33
+ width: 30,
34
+ textAlign: "center",
35
+ fontSize: 16
36
+ },
37
+ "aria-hidden": true,
38
+ children: "●"
39
+ });
40
+ return /* @__PURE__ */ jsx("svg", {
41
+ viewBox: "0 0 34 34",
42
+ width: 30,
43
+ height: 22,
44
+ "aria-hidden": true,
45
+ style: { flexShrink: 0 },
46
+ children: /* @__PURE__ */ jsx(GateGlyph, {
47
+ x: 2,
48
+ y: 2,
49
+ size: 30,
50
+ type: glyph
51
+ })
52
+ });
53
+ }
54
+ function LogicEditor({ value, onChange }) {
55
+ const doc = value ?? emptyDoc;
56
+ const W = doc.size?.w ?? 640;
57
+ const [selected, setSelected] = useState(null);
58
+ const [wireStart, setWireStart] = useState(null);
59
+ const [cursor, setCursor] = useState(null);
60
+ const [full, setFull] = useState(false);
61
+ const hostRef = useRef(null);
62
+ const docRef = useRef(doc);
63
+ docRef.current = doc;
64
+ const onChangeRef = useRef(onChange);
65
+ onChangeRef.current = onChange;
66
+ const wireRef = useRef(wireStart);
67
+ wireRef.current = wireStart;
68
+ const toCanvas = (cx, cy) => {
69
+ const host = hostRef.current;
70
+ if (!host) return {
71
+ x: 0,
72
+ y: 0
73
+ };
74
+ const r = host.getBoundingClientRect();
75
+ const scale = r.width / W;
76
+ return {
77
+ x: (cx - r.left) / scale,
78
+ y: (cy - r.top) / scale
79
+ };
80
+ };
81
+ useEffect(() => {
82
+ if (!wireStart) {
83
+ setCursor(null);
84
+ return;
85
+ }
86
+ const move = (ev) => setCursor(toCanvas(ev.clientX, ev.clientY));
87
+ const key = (ev) => {
88
+ if (ev.key === "Escape") setWireStart(null);
89
+ };
90
+ window.addEventListener("pointermove", move);
91
+ window.addEventListener("keydown", key);
92
+ return () => {
93
+ window.removeEventListener("pointermove", move);
94
+ window.removeEventListener("keydown", key);
95
+ };
96
+ }, [wireStart]);
97
+ const palette = [
98
+ {
99
+ kind: "input",
100
+ label: "Source (switch)"
101
+ },
102
+ ...listGates().map((g) => ({
103
+ kind: g.kind,
104
+ label: g.label,
105
+ glyph: g.glyph
106
+ })),
107
+ {
108
+ kind: "output",
109
+ label: "LED (output)"
110
+ }
111
+ ];
112
+ const sel = [
113
+ ...doc.inputs,
114
+ ...doc.gates,
115
+ ...doc.outputs
116
+ ].find((n) => n.id === selected) ?? null;
117
+ const selKind = !sel ? null : doc.inputs.some((n) => n.id === sel.id) ? "input" : doc.gates.some((n) => n.id === sel.id) ? "gate" : "output";
118
+ const selOutput = selKind === "output" ? doc.outputs.find((o) => o.id === sel.id) ?? null : null;
119
+ const selInput = selKind === "input" ? doc.inputs.find((i) => i.id === sel.id) ?? null : null;
120
+ const place = (kind, at) => {
121
+ const { doc: next, id } = addNode(docRef.current, kind, at);
122
+ onChangeRef.current(next);
123
+ setSelected(id);
124
+ };
125
+ const dropAt = (kind, clientX, clientY) => {
126
+ const host = hostRef.current;
127
+ const n = docRef.current.gates.length + docRef.current.inputs.length;
128
+ const fallback = {
129
+ x: snap(120 + n % 3 * 140),
130
+ y: snap(70 + Math.floor(n / 3) * 80)
131
+ };
132
+ if (!host) return place(kind, fallback);
133
+ const r = host.getBoundingClientRect();
134
+ if (clientX < r.left || clientX > r.right || clientY < r.top || clientY > r.bottom) return place(kind, fallback);
135
+ const sc = r.width / W;
136
+ place(kind, {
137
+ x: snap((clientX - r.left) / sc),
138
+ y: snap((clientY - r.top) / sc)
139
+ });
140
+ };
141
+ const startPaletteDrag = (kind) => {
142
+ const up = (ev) => {
143
+ window.removeEventListener("pointerup", up);
144
+ dropAt(kind, ev.clientX, ev.clientY);
145
+ };
146
+ window.addEventListener("pointerup", up);
147
+ };
148
+ const portClick = (ref) => {
149
+ if (ref.dir === "out") {
150
+ setWireStart((prev) => prev && prev.nodeId === ref.nodeId ? null : ref);
151
+ return;
152
+ }
153
+ const start = wireRef.current;
154
+ if (start) {
155
+ onChangeRef.current(connect(docRef.current, start.nodeId, {
156
+ nodeId: ref.nodeId,
157
+ slot: ref.slot
158
+ }));
159
+ setWireStart(null);
160
+ } else onChangeRef.current(disconnect(docRef.current, {
161
+ nodeId: ref.nodeId,
162
+ slot: ref.slot
163
+ }));
164
+ };
165
+ const nodeClick = (id) => {
166
+ setSelected(id);
167
+ if (docRef.current.inputs.some((i) => i.id === id)) onChangeRef.current(toggleInput(docRef.current, id));
168
+ };
169
+ const beginDrag = (id, e, onClick) => {
170
+ const node = [
171
+ ...docRef.current.inputs,
172
+ ...docRef.current.gates,
173
+ ...docRef.current.outputs
174
+ ].find((n) => n.id === id);
175
+ const host = hostRef.current;
176
+ if (!node || !host) return;
177
+ e.preventDefault();
178
+ const scale = host.getBoundingClientRect().width / W;
179
+ const sx = e.clientX, sy = e.clientY, ox = node.x ?? 0, oy = node.y ?? 0;
180
+ let moved = false;
181
+ const move = (ev) => {
182
+ if (!moved && Math.abs(ev.clientX - sx) + Math.abs(ev.clientY - sy) > 4) {
183
+ moved = true;
184
+ setSelected(id);
185
+ }
186
+ if (moved) onChangeRef.current(moveNode(docRef.current, id, {
187
+ x: snap(ox + (ev.clientX - sx) / scale),
188
+ y: snap(oy + (ev.clientY - sy) / scale)
189
+ }));
190
+ };
191
+ const up = () => {
192
+ window.removeEventListener("pointermove", move);
193
+ window.removeEventListener("pointerup", up);
194
+ if (!moved) onClick();
195
+ };
196
+ window.addEventListener("pointermove", move);
197
+ window.addEventListener("pointerup", up);
198
+ };
199
+ const onNodePointerDown = (id, e) => beginDrag(id, e, () => nodeClick(id));
200
+ const onPortPointerDown = (ref, e) => beginDrag(ref.nodeId, e, () => portClick(ref));
201
+ return /* @__PURE__ */ jsxs("div", {
202
+ style: full ? {
203
+ position: "fixed",
204
+ inset: 0,
205
+ zIndex: 60,
206
+ background: "var(--background, #fff)",
207
+ padding: 18,
208
+ overflow: "auto",
209
+ display: "grid",
210
+ gridTemplateColumns: "188px 1fr 240px",
211
+ gap: 16,
212
+ alignItems: "start"
213
+ } : {
214
+ display: "grid",
215
+ gridTemplateColumns: "180px 1fr 224px",
216
+ gap: 14,
217
+ alignItems: "start"
218
+ },
219
+ children: [
220
+ /* @__PURE__ */ jsx(Panel, {
221
+ title: "Add",
222
+ children: /* @__PURE__ */ jsx("div", {
223
+ style: {
224
+ display: "flex",
225
+ flexDirection: "column",
226
+ gap: 4
227
+ },
228
+ children: palette.map((it) => /* @__PURE__ */ jsxs("button", {
229
+ type: "button",
230
+ onPointerDown: () => startPaletteDrag(it.kind),
231
+ title: `add ${it.label} (or drag onto the canvas)`,
232
+ style: {
233
+ display: "flex",
234
+ alignItems: "center",
235
+ gap: 9,
236
+ width: "100%",
237
+ textAlign: "left",
238
+ padding: "6px 9px",
239
+ fontSize: 13,
240
+ fontWeight: 600,
241
+ color: "var(--foreground, #1c1c1c)",
242
+ background: "transparent",
243
+ border: "1px solid transparent",
244
+ borderRadius: "calc(var(--radius, 0.6rem) - 2px)",
245
+ cursor: "pointer"
246
+ },
247
+ onMouseEnter: (e) => {
248
+ e.currentTarget.style.background = "var(--accent, #f1f1f3)";
249
+ e.currentTarget.style.borderColor = "var(--border, #e4e4e7)";
250
+ },
251
+ onMouseLeave: (e) => {
252
+ e.currentTarget.style.background = "transparent";
253
+ e.currentTarget.style.borderColor = "transparent";
254
+ },
255
+ children: [
256
+ /* @__PURE__ */ jsx(PaletteThumb, { glyph: it.glyph }),
257
+ /* @__PURE__ */ jsx("span", {
258
+ style: { flex: 1 },
259
+ children: it.label
260
+ }),
261
+ /* @__PURE__ */ jsx("span", {
262
+ style: {
263
+ color: "var(--muted-foreground, #999)",
264
+ fontSize: 15,
265
+ lineHeight: 1
266
+ },
267
+ children: "+"
268
+ })
269
+ ]
270
+ }, it.kind))
271
+ })
272
+ }),
273
+ /* @__PURE__ */ jsxs("div", {
274
+ style: {
275
+ display: "flex",
276
+ flexDirection: "column",
277
+ gap: 8
278
+ },
279
+ children: [/* @__PURE__ */ jsxs("div", {
280
+ style: {
281
+ display: "flex",
282
+ alignItems: "center",
283
+ gap: 10,
284
+ fontSize: 12,
285
+ color: "var(--muted-foreground, #777)"
286
+ },
287
+ children: [
288
+ /* @__PURE__ */ jsx("span", {
289
+ style: { flex: 1 },
290
+ children: wireStart ? "Now click an input slot to connect (the wire follows your cursor). Press Esc or click empty space to cancel." : "Drag to arrange. Wire: click an output dot ● then an input slot. Click a source to flip it. Click a filled input slot to unwire it."
291
+ }),
292
+ wireStart && /* @__PURE__ */ jsx(EBtn, {
293
+ variant: "ghost",
294
+ onClick: () => setWireStart(null),
295
+ children: "cancel wire"
296
+ }),
297
+ /* @__PURE__ */ jsx(EBtn, {
298
+ variant: "ghost",
299
+ onClick: () => setFull((f) => !f),
300
+ children: full ? "⤡ exit fullscreen" : "⤢ fullscreen"
301
+ })
302
+ ]
303
+ }), /* @__PURE__ */ jsx("div", {
304
+ ref: hostRef,
305
+ children: /* @__PURE__ */ jsx(LogicEditScene, {
306
+ doc,
307
+ selectedId: selected ?? void 0,
308
+ wireStart: wireStart ?? void 0,
309
+ previewCursor: wireStart ? cursor ?? void 0 : void 0,
310
+ onNodePointerDown,
311
+ onPortPointerDown,
312
+ onBackground: () => {
313
+ setSelected(null);
314
+ setWireStart(null);
315
+ },
316
+ ariaLabel: "logic circuit builder canvas"
317
+ })
318
+ })]
319
+ }),
320
+ /* @__PURE__ */ jsx(Panel, {
321
+ title: "Inspector",
322
+ children: !sel ? /* @__PURE__ */ jsx("div", {
323
+ style: {
324
+ fontSize: 13,
325
+ color: "var(--muted-foreground, #777)",
326
+ lineHeight: 1.5
327
+ },
328
+ children: "Select a node to edit it, or add one from the palette."
329
+ }) : /* @__PURE__ */ jsxs("div", {
330
+ style: {
331
+ display: "flex",
332
+ flexDirection: "column",
333
+ gap: 12
334
+ },
335
+ children: [
336
+ /* @__PURE__ */ jsx(Field, {
337
+ label: "label",
338
+ children: /* @__PURE__ */ jsx(TextInput, {
339
+ value: sel.label ?? "",
340
+ onChange: (v) => onChange(relabel(doc, sel.id, v)),
341
+ ariaLabel: "node label"
342
+ })
343
+ }),
344
+ selInput && /* @__PURE__ */ jsx(Field, {
345
+ label: "value",
346
+ children: /* @__PURE__ */ jsx(EBtn, {
347
+ active: !!selInput.value,
348
+ onClick: () => onChange(toggleInput(doc, sel.id)),
349
+ children: selInput.value ? "1 (HIGH)" : "0 (LOW)"
350
+ })
351
+ }),
352
+ selOutput && /* @__PURE__ */ jsxs("div", {
353
+ style: {
354
+ display: "flex",
355
+ flexDirection: "column",
356
+ gap: 8
357
+ },
358
+ children: [/* @__PURE__ */ jsx("span", {
359
+ style: {
360
+ fontSize: 10.5,
361
+ fontWeight: 700,
362
+ letterSpacing: "0.04em",
363
+ textTransform: "uppercase",
364
+ color: "var(--muted-foreground, #999)"
365
+ },
366
+ children: "Goal (this LED)"
367
+ }), /* @__PURE__ */ jsxs("div", {
368
+ style: {
369
+ display: "flex",
370
+ gap: 6,
371
+ flexWrap: "wrap"
372
+ },
373
+ children: [
374
+ /* @__PURE__ */ jsx(EBtn, {
375
+ active: selOutput.goal === void 0,
376
+ onClick: () => onChange(setGoal(doc, sel.id, void 0)),
377
+ children: "none"
378
+ }),
379
+ /* @__PURE__ */ jsx(EBtn, {
380
+ active: selOutput.goal === false,
381
+ onClick: () => onChange(setGoal(doc, sel.id, false)),
382
+ children: "want 0"
383
+ }),
384
+ /* @__PURE__ */ jsx(EBtn, {
385
+ active: selOutput.goal === true,
386
+ onClick: () => onChange(setGoal(doc, sel.id, true)),
387
+ children: "want 1"
388
+ })
389
+ ]
390
+ })]
391
+ }),
392
+ /* @__PURE__ */ jsx("div", { style: {
393
+ height: 1,
394
+ background: "var(--border, #e4e4e7)"
395
+ } }),
396
+ /* @__PURE__ */ jsx(EBtn, {
397
+ variant: "danger",
398
+ title: "delete node",
399
+ onClick: () => {
400
+ onChange(deleteNode(doc, sel.id));
401
+ setSelected(null);
402
+ },
403
+ children: "🗑 delete"
404
+ })
405
+ ]
406
+ })
407
+ })
408
+ ]
409
+ });
410
+ }
411
+
412
+ //#endregion
413
+ export { LogicEditor };