@harmonia-core/ui 1.0.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 (77) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +267 -0
  3. package/dist/capacity/animation.d.ts +77 -0
  4. package/dist/capacity/animation.d.ts.map +1 -0
  5. package/dist/capacity/constants.d.ts +119 -0
  6. package/dist/capacity/constants.d.ts.map +1 -0
  7. package/dist/capacity/feedback.d.ts +55 -0
  8. package/dist/capacity/feedback.d.ts.map +1 -0
  9. package/dist/capacity/fields/field-manager.d.ts +45 -0
  10. package/dist/capacity/fields/field-manager.d.ts.map +1 -0
  11. package/dist/capacity/index.d.ts +15 -0
  12. package/dist/capacity/index.d.ts.map +1 -0
  13. package/dist/capacity/index.js +1313 -0
  14. package/dist/capacity/index.js.map +1 -0
  15. package/dist/capacity/index.mjs +1267 -0
  16. package/dist/capacity/index.mjs.map +1 -0
  17. package/dist/capacity/mode.d.ts +50 -0
  18. package/dist/capacity/mode.d.ts.map +1 -0
  19. package/dist/capacity/prediction/hooks.d.ts +11 -0
  20. package/dist/capacity/prediction/hooks.d.ts.map +1 -0
  21. package/dist/capacity/prediction/pattern-extractor.d.ts +26 -0
  22. package/dist/capacity/prediction/pattern-extractor.d.ts.map +1 -0
  23. package/dist/capacity/prediction/pattern-store.d.ts +35 -0
  24. package/dist/capacity/prediction/pattern-store.d.ts.map +1 -0
  25. package/dist/capacity/prediction/prediction-engine.d.ts +39 -0
  26. package/dist/capacity/prediction/prediction-engine.d.ts.map +1 -0
  27. package/dist/capacity/prediction/types.d.ts +24 -0
  28. package/dist/capacity/prediction/types.d.ts.map +1 -0
  29. package/dist/capacity/provider.d.ts +119 -0
  30. package/dist/capacity/provider.d.ts.map +1 -0
  31. package/dist/capacity/signals/aggregator.d.ts +38 -0
  32. package/dist/capacity/signals/aggregator.d.ts.map +1 -0
  33. package/dist/capacity/signals/detectors/environment-detector.d.ts +31 -0
  34. package/dist/capacity/signals/detectors/environment-detector.d.ts.map +1 -0
  35. package/dist/capacity/signals/detectors/input-detector.d.ts +23 -0
  36. package/dist/capacity/signals/detectors/input-detector.d.ts.map +1 -0
  37. package/dist/capacity/signals/detectors/interaction-detector.d.ts +27 -0
  38. package/dist/capacity/signals/detectors/interaction-detector.d.ts.map +1 -0
  39. package/dist/capacity/signals/detectors/scroll-detector.d.ts +35 -0
  40. package/dist/capacity/signals/detectors/scroll-detector.d.ts.map +1 -0
  41. package/dist/capacity/signals/detectors/session-detector.d.ts +23 -0
  42. package/dist/capacity/signals/detectors/session-detector.d.ts.map +1 -0
  43. package/dist/capacity/signals/detectors/time-detector.d.ts +20 -0
  44. package/dist/capacity/signals/detectors/time-detector.d.ts.map +1 -0
  45. package/dist/capacity/signals/detectors/types.d.ts +25 -0
  46. package/dist/capacity/signals/detectors/types.d.ts.map +1 -0
  47. package/dist/capacity/signals/signal-bus.d.ts +50 -0
  48. package/dist/capacity/signals/signal-bus.d.ts.map +1 -0
  49. package/dist/capacity/types.d.ts +239 -0
  50. package/dist/capacity/types.d.ts.map +1 -0
  51. package/dist/capacity/utils/index.d.ts +7 -0
  52. package/dist/capacity/utils/index.d.ts.map +1 -0
  53. package/dist/capacity/utils/typography.d.ts +176 -0
  54. package/dist/capacity/utils/typography.d.ts.map +1 -0
  55. package/dist/components/ambient-field-monitor.d.ts +10 -0
  56. package/dist/components/ambient-field-monitor.d.ts.map +1 -0
  57. package/dist/components/capacity-controls.d.ts +15 -0
  58. package/dist/components/capacity-controls.d.ts.map +1 -0
  59. package/dist/components/capacity-demo-card.d.ts +13 -0
  60. package/dist/components/capacity-demo-card.d.ts.map +1 -0
  61. package/dist/components/index.d.ts +18 -0
  62. package/dist/components/index.d.ts.map +1 -0
  63. package/dist/components/index.js +1703 -0
  64. package/dist/components/index.js.map +1 -0
  65. package/dist/components/index.mjs +1688 -0
  66. package/dist/components/index.mjs.map +1 -0
  67. package/dist/components/ui/badge.d.ts +8 -0
  68. package/dist/components/ui/badge.d.ts.map +1 -0
  69. package/dist/components/ui/button.d.ts +10 -0
  70. package/dist/components/ui/button.d.ts.map +1 -0
  71. package/dist/components/ui/card.d.ts +10 -0
  72. package/dist/components/ui/card.d.ts.map +1 -0
  73. package/dist/components/ui/select.d.ts +6 -0
  74. package/dist/components/ui/select.d.ts.map +1 -0
  75. package/dist/components/ui/slider.d.ts +14 -0
  76. package/dist/components/ui/slider.d.ts.map +1 -0
  77. package/package.json +98 -0
@@ -0,0 +1,1703 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var react$1 = require('motion/react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var tokens = require('@renge-ui/tokens');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __defProps = Object.defineProperties;
10
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
11
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __objRest = (source, exclude) => {
28
+ var target = {};
29
+ for (var prop in source)
30
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
+ target[prop] = source[prop];
32
+ if (source != null && __getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(source)) {
34
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
+ target[prop] = source[prop];
36
+ }
37
+ return target;
38
+ };
39
+ var FEEDBACK_FREQUENCIES = {
40
+ low: 396,
41
+ // Foundation/root elements
42
+ mid: 528,
43
+ // Primary interactive content
44
+ high: 741
45
+ // Dynamic/feedback elements
46
+ };
47
+ var DEFAULT_FIELD_CONFIG = {
48
+ smoothing: 0.15,
49
+ // Exponential smoothing factor
50
+ velocityThreshold: 0.05,
51
+ // Min velocity to register as trend
52
+ debounceMs: 100
53
+ // Debounce rapid changes
54
+ };
55
+ var DEFAULT_USER_CAPACITY = {
56
+ cognitive: 0.7,
57
+ temporal: 0.7,
58
+ emotional: 0.7
59
+ };
60
+ var DEFAULT_EMOTIONAL_STATE = {
61
+ valence: 0.3,
62
+ // > 0.15 (with emotional > 0.6) triggers expressive motion mode
63
+ arousal: 0.5
64
+ };
65
+
66
+ // lib/capacity/feedback.ts
67
+ var HAPTIC_PATTERNS = {
68
+ /** Short tap — confirm/select */
69
+ tap: [8],
70
+ /** Two pulses — toggle/switch */
71
+ toggle: [8, 50, 8],
72
+ /** Gentle pulse — ambient/ambient confirmation */
73
+ pulse: [15, 30, 15],
74
+ /** Error/warning — three quick */
75
+ error: [50, 30, 50, 30, 50]
76
+ };
77
+ function triggerHaptic(pattern = "tap") {
78
+ if (typeof navigator !== "undefined" && "vibrate" in navigator) {
79
+ navigator.vibrate(HAPTIC_PATTERNS[pattern]);
80
+ }
81
+ }
82
+ var _audioCtx = null;
83
+ function getAudioContext() {
84
+ if (typeof window === "undefined") return null;
85
+ try {
86
+ if (!_audioCtx || _audioCtx.state === "closed") {
87
+ _audioCtx = new AudioContext();
88
+ }
89
+ if (_audioCtx.state === "suspended") {
90
+ _audioCtx.resume();
91
+ }
92
+ return _audioCtx;
93
+ } catch (e) {
94
+ return null;
95
+ }
96
+ }
97
+ function playSonicFeedback(frequency, duration = 120, volume = 0.06) {
98
+ const ctx = getAudioContext();
99
+ if (!ctx) return;
100
+ const oscillator = ctx.createOscillator();
101
+ const gainNode = ctx.createGain();
102
+ oscillator.connect(gainNode);
103
+ gainNode.connect(ctx.destination);
104
+ oscillator.type = "sine";
105
+ oscillator.frequency.setValueAtTime(frequency, ctx.currentTime);
106
+ gainNode.gain.setValueAtTime(0, ctx.currentTime);
107
+ gainNode.gain.linearRampToValueAtTime(volume, ctx.currentTime + 0.015);
108
+ gainNode.gain.linearRampToValueAtTime(0, ctx.currentTime + duration / 1e3);
109
+ oscillator.start(ctx.currentTime);
110
+ oscillator.stop(ctx.currentTime + duration / 1e3 + 0.02);
111
+ }
112
+ function getFrequencyForPace(pace) {
113
+ if (pace === "activated") return FEEDBACK_FREQUENCIES.high;
114
+ if (pace === "calm") return FEEDBACK_FREQUENCIES.low;
115
+ return FEEDBACK_FREQUENCIES.mid;
116
+ }
117
+ function playPacedSonic(pace, duration) {
118
+ playSonicFeedback(getFrequencyForPace(pace), duration);
119
+ }
120
+
121
+ // lib/capacity/fields/field-manager.ts
122
+ function deriveEnergyField(capacity) {
123
+ const { cognitive, temporal, emotional } = capacity;
124
+ return Math.pow(cognitive * temporal * emotional, 1 / 3);
125
+ }
126
+ function deriveAttentionField(capacity) {
127
+ return 1 - capacity.temporal * 0.5;
128
+ }
129
+ function deriveEmotionalValenceField(state) {
130
+ return state.valence;
131
+ }
132
+ function createFieldValue(value, previousValue) {
133
+ var _a;
134
+ const now = Date.now();
135
+ const lastChange = (_a = previousValue == null ? void 0 : previousValue.lastChange) != null ? _a : now;
136
+ const timeDelta = (now - lastChange) / 1e3;
137
+ let trend = "stable";
138
+ let velocity;
139
+ if (typeof value === "number" && previousValue && typeof previousValue.value === "number") {
140
+ const valueDelta = value - previousValue.value;
141
+ velocity = timeDelta > 0 ? valueDelta / timeDelta : 0;
142
+ if (Math.abs(velocity) > DEFAULT_FIELD_CONFIG.velocityThreshold) {
143
+ trend = velocity > 0 ? "rising" : "falling";
144
+ }
145
+ }
146
+ return {
147
+ value,
148
+ lastChange: now,
149
+ trend,
150
+ velocity
151
+ };
152
+ }
153
+ var FieldManagerClass = class {
154
+ constructor() {
155
+ this.listeners = /* @__PURE__ */ new Set();
156
+ this.config = DEFAULT_FIELD_CONFIG;
157
+ const initialCapacity = DEFAULT_USER_CAPACITY;
158
+ const initialState = DEFAULT_EMOTIONAL_STATE;
159
+ this.context = {
160
+ energy: createFieldValue(deriveEnergyField(initialCapacity)),
161
+ attention: createFieldValue(deriveAttentionField(initialCapacity)),
162
+ emotionalValence: createFieldValue(deriveEmotionalValenceField(initialState)),
163
+ userCapacity: initialCapacity,
164
+ emotionalState: initialState
165
+ };
166
+ }
167
+ /**
168
+ * Get current ambient context (read-only)
169
+ */
170
+ getContext() {
171
+ return this.context;
172
+ }
173
+ /**
174
+ * Update user capacity (Phase 1 slider system writes here)
175
+ */
176
+ updateCapacity(capacity) {
177
+ const newCapacity = __spreadValues(__spreadValues({}, this.context.userCapacity), capacity);
178
+ this.context = __spreadProps(__spreadValues({}, this.context), {
179
+ userCapacity: newCapacity,
180
+ energy: createFieldValue(deriveEnergyField(newCapacity), this.context.energy),
181
+ attention: createFieldValue(deriveAttentionField(newCapacity), this.context.attention)
182
+ });
183
+ this.notifyListeners();
184
+ }
185
+ /**
186
+ * Update emotional state (Phase 1 slider system writes here)
187
+ */
188
+ updateEmotionalState(state) {
189
+ const newState = __spreadValues(__spreadValues({}, this.context.emotionalState), state);
190
+ this.context = __spreadProps(__spreadValues({}, this.context), {
191
+ emotionalState: newState,
192
+ emotionalValence: createFieldValue(deriveEmotionalValenceField(newState), this.context.emotionalValence)
193
+ });
194
+ this.notifyListeners();
195
+ }
196
+ /**
197
+ * Subscribe to field changes
198
+ */
199
+ subscribe(listener) {
200
+ this.listeners.add(listener);
201
+ return () => {
202
+ this.listeners.delete(listener);
203
+ };
204
+ }
205
+ /**
206
+ * Notify all listeners of field changes
207
+ */
208
+ notifyListeners() {
209
+ this.listeners.forEach((listener) => {
210
+ try {
211
+ listener(this.context);
212
+ } catch (error) {
213
+ console.error("[v0] Field listener error:", error);
214
+ }
215
+ });
216
+ }
217
+ /**
218
+ * Update field configuration
219
+ */
220
+ updateConfig(config) {
221
+ this.config = __spreadValues(__spreadValues({}, this.config), config);
222
+ }
223
+ /**
224
+ * Get current field configuration
225
+ */
226
+ getConfig() {
227
+ return this.config;
228
+ }
229
+ };
230
+ new FieldManagerClass();
231
+
232
+ // lib/capacity/mode.ts
233
+ function deriveMode(field) {
234
+ var _a;
235
+ const lowCognitive = field.cognitive < 0.4;
236
+ const highCognitive = field.cognitive > 0.7;
237
+ const lowEmotional = field.emotional < 0.4;
238
+ const highEmotional = field.emotional > 0.6;
239
+ const lowTemporal = field.temporal < 0.4;
240
+ const highValence = field.valence > 0.15;
241
+ const negValence = field.valence < -0.15;
242
+ const density = lowCognitive ? "low" : highCognitive ? "high" : "medium";
243
+ const choiceLoad = lowTemporal ? "minimal" : "normal";
244
+ const guidance = lowCognitive ? "high" : lowTemporal ? "medium" : "low";
245
+ const veryLowEmotional = field.emotional < 0.15;
246
+ const motion2 = veryLowEmotional ? "off" : lowEmotional ? "soothing" : highEmotional && highValence ? "expressive" : "subtle";
247
+ const contrast = negValence ? "boosted" : "standard";
248
+ const focus = motion2 === "off" ? "default" : lowCognitive ? "guided" : !highCognitive ? "gentle" : "default";
249
+ const arousal = (_a = field.arousal) != null ? _a : 0.5;
250
+ const pace = arousal < 0.35 ? "calm" : arousal > 0.65 ? "activated" : "neutral";
251
+ return { density, guidance, motion: motion2, contrast, choiceLoad, focus, pace };
252
+ }
253
+ function deriveModeLabel(inputs) {
254
+ const { cognitive, temporal, emotional } = inputs;
255
+ if (cognitive > 0.6 && emotional > 0.6) {
256
+ return "Exploratory";
257
+ }
258
+ if (cognitive < 0.4 && temporal < 0.4) {
259
+ return "Minimal";
260
+ }
261
+ if (cognitive >= 0.55 && temporal >= 0.55) {
262
+ return "Focused";
263
+ }
264
+ return "Calm";
265
+ }
266
+ function getModeBadgeColor(label) {
267
+ switch (label) {
268
+ case "Calm":
269
+ return "oklch(0.65 0.15 220)";
270
+ // Soft blue
271
+ case "Focused":
272
+ return "oklch(0.68 0.16 45)";
273
+ // Primary rust
274
+ case "Exploratory":
275
+ return "oklch(0.65 0.2 135)";
276
+ // Toxic green
277
+ case "Minimal":
278
+ return "oklch(0.55 0.1 280)";
279
+ // Muted purple
280
+ default:
281
+ return "oklch(0.5 0 0)";
282
+ }
283
+ }
284
+ var CapacityContext = react.createContext(null);
285
+ function useCapacityContext() {
286
+ const context = react.useContext(CapacityContext);
287
+ if (!context) {
288
+ throw new Error("useCapacityContext must be used within CapacityProvider");
289
+ }
290
+ return context;
291
+ }
292
+ function useEnergyField() {
293
+ const { context } = useCapacityContext();
294
+ return context.energy;
295
+ }
296
+ function useAttentionField() {
297
+ const { context } = useCapacityContext();
298
+ return context.attention;
299
+ }
300
+ function useEmotionalValenceField() {
301
+ const { context } = useCapacityContext();
302
+ return context.emotionalValence;
303
+ }
304
+ function useDerivedMode() {
305
+ const { context } = useCapacityContext();
306
+ const field = {
307
+ cognitive: context.userCapacity.cognitive,
308
+ temporal: context.userCapacity.temporal,
309
+ emotional: context.userCapacity.emotional,
310
+ valence: context.emotionalState.valence,
311
+ arousal: context.emotionalState.arousal
312
+ };
313
+ const mode = deriveMode(field);
314
+ return { field, mode };
315
+ }
316
+ function useFeedback() {
317
+ const { hapticEnabled, sonicEnabled, setHapticEnabled, setSonicEnabled } = useCapacityContext();
318
+ const { mode } = useDerivedMode();
319
+ const fire = react.useCallback((pattern = "tap") => {
320
+ if (hapticEnabled) triggerHaptic(pattern);
321
+ if (sonicEnabled) playPacedSonic(mode.pace);
322
+ }, [hapticEnabled, sonicEnabled, mode.pace]);
323
+ return { hapticEnabled, sonicEnabled, setHapticEnabled, setSonicEnabled, fire };
324
+ }
325
+
326
+ // lib/capacity/animation.ts
327
+ var ENTRANCE_PRESETS = {
328
+ /** Liquid organic morph -> gentle scale fade -> soft bloom -> none */
329
+ morph: { expressive: "morph-fade-in", subtle: "sacred-fade", soothing: "bloom", off: "" },
330
+ /** Spinning vortex -> gentle scale fade -> soft bloom -> none */
331
+ vortex: { expressive: "vortex-reveal", subtle: "sacred-fade", soothing: "bloom", off: "" },
332
+ /** Spiral in from corner -> soft bloom -> soft bloom -> none */
333
+ spiral: { expressive: "spiral-in", subtle: "bloom", soothing: "bloom", off: "" }
334
+ };
335
+ function entranceClass(motion2, preset, hasPlayed) {
336
+ return ENTRANCE_PRESETS[preset][motion2];
337
+ }
338
+ function hoverClass(motion2) {
339
+ if (motion2 === "expressive") return "hover-expand";
340
+ if (motion2 === "subtle" || motion2 === "soothing") return "hover-lift";
341
+ return "";
342
+ }
343
+ function ambientClass(motion2, type) {
344
+ if (motion2 === "expressive") return type;
345
+ if (motion2 === "soothing" && (type === "breathe" || type === "float")) return type;
346
+ return "";
347
+ }
348
+ function listItemClass(motion2) {
349
+ if (motion2 === "expressive") return "helix-rise";
350
+ if (motion2 === "subtle" || motion2 === "soothing") return "sacred-fade";
351
+ return "";
352
+ }
353
+ var SLIDER_STYLES = `
354
+ [data-renge-slider] {
355
+ -webkit-appearance: none;
356
+ appearance: none;
357
+ width: 100%;
358
+ height: ${tokens.rengeVars.space[1]};
359
+ background: ${tokens.rengeVars.color.bgMuted};
360
+ border-radius: ${tokens.rengeVars.radius.full};
361
+ outline: none;
362
+ cursor: pointer;
363
+ transition: background ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out};
364
+ }
365
+ [data-renge-slider]:focus-visible {
366
+ box-shadow: 0 0 0 2px ${tokens.rengeVars.color.bg}, 0 0 0 4px ${tokens.rengeVars.color.borderFocus};
367
+ }
368
+ [data-renge-slider]:disabled {
369
+ opacity: 0.45;
370
+ cursor: not-allowed;
371
+ }
372
+
373
+ /* WebKit track */
374
+ [data-renge-slider]::-webkit-slider-runnable-track {
375
+ height: ${tokens.rengeVars.space[1]};
376
+ background: ${tokens.rengeVars.color.bgMuted};
377
+ border-radius: ${tokens.rengeVars.radius.full};
378
+ }
379
+
380
+ /* WebKit thumb */
381
+ [data-renge-slider]::-webkit-slider-thumb {
382
+ -webkit-appearance: none;
383
+ appearance: none;
384
+ width: ${tokens.rengeVars.space[3]};
385
+ height: ${tokens.rengeVars.space[3]};
386
+ margin-top: calc((${tokens.rengeVars.space[1]} - ${tokens.rengeVars.space[3]}) / 2);
387
+ border-radius: ${tokens.rengeVars.radius.full};
388
+ background: ${tokens.rengeVars.color.accent};
389
+ border: none;
390
+ cursor: pointer;
391
+ transition:
392
+ background ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out},
393
+ transform ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.spring};
394
+ }
395
+ [data-renge-slider]:not(:disabled)::-webkit-slider-thumb:hover {
396
+ background: ${tokens.rengeVars.color.accentHover};
397
+ transform: scale(1.2);
398
+ }
399
+ [data-renge-slider]:not(:disabled):active::-webkit-slider-thumb {
400
+ transform: scale(1.1);
401
+ }
402
+
403
+ /* Firefox track */
404
+ [data-renge-slider]::-moz-range-track {
405
+ height: ${tokens.rengeVars.space[1]};
406
+ background: ${tokens.rengeVars.color.bgMuted};
407
+ border-radius: ${tokens.rengeVars.radius.full};
408
+ border: none;
409
+ }
410
+
411
+ /* Firefox thumb */
412
+ [data-renge-slider]::-moz-range-thumb {
413
+ width: ${tokens.rengeVars.space[3]};
414
+ height: ${tokens.rengeVars.space[3]};
415
+ border-radius: ${tokens.rengeVars.radius.full};
416
+ background: ${tokens.rengeVars.color.accent};
417
+ border: none;
418
+ cursor: pointer;
419
+ transition:
420
+ background ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out},
421
+ transform ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.spring};
422
+ }
423
+ [data-renge-slider]:not(:disabled)::-moz-range-thumb:hover {
424
+ background: ${tokens.rengeVars.color.accentHover};
425
+ transform: scale(1.2);
426
+ }
427
+ `;
428
+ var stylesInjected = false;
429
+ function Slider(_a) {
430
+ var _b = _a, {
431
+ className,
432
+ value,
433
+ defaultValue,
434
+ min = 0,
435
+ max = 100,
436
+ step,
437
+ onChange,
438
+ disabled,
439
+ style
440
+ } = _b, props = __objRest(_b, [
441
+ "className",
442
+ "value",
443
+ "defaultValue",
444
+ "min",
445
+ "max",
446
+ "step",
447
+ "onChange",
448
+ "disabled",
449
+ "style"
450
+ ]);
451
+ if (typeof document !== "undefined" && !stylesInjected) {
452
+ const el = document.createElement("style");
453
+ el.setAttribute("data-renge-slider-styles", "");
454
+ el.textContent = SLIDER_STYLES;
455
+ document.head.appendChild(el);
456
+ stylesInjected = true;
457
+ }
458
+ return /* @__PURE__ */ jsxRuntime.jsx(
459
+ "input",
460
+ __spreadValues({
461
+ "data-slot": "slider",
462
+ "data-renge-slider": "",
463
+ type: "range",
464
+ className,
465
+ value,
466
+ defaultValue,
467
+ min,
468
+ max,
469
+ step,
470
+ disabled,
471
+ "aria-valuemin": min,
472
+ "aria-valuemax": max,
473
+ "aria-valuenow": value != null ? value : defaultValue,
474
+ onChange: (e) => onChange == null ? void 0 : onChange(parseFloat(e.target.value)),
475
+ style
476
+ }, props)
477
+ );
478
+ }
479
+ var BUTTON_STYLES = `
480
+ [data-renge-btn] {
481
+ display: inline-flex;
482
+ align-items: center;
483
+ justify-content: center;
484
+ font-weight: 500;
485
+ cursor: pointer;
486
+ border: none;
487
+ outline: none;
488
+ text-decoration: none;
489
+ user-select: none;
490
+ transition:
491
+ background ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out},
492
+ color ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out},
493
+ box-shadow ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out},
494
+ transform ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.spring};
495
+ }
496
+ [data-renge-btn]:active:not(:disabled) {
497
+ transform: scale(0.97);
498
+ }
499
+ [data-renge-btn]:disabled {
500
+ opacity: 0.45;
501
+ cursor: not-allowed;
502
+ }
503
+ [data-renge-btn]:focus-visible {
504
+ box-shadow: 0 0 0 2px ${tokens.rengeVars.color.bg}, 0 0 0 4px ${tokens.rengeVars.color.borderFocus};
505
+ }
506
+
507
+ [data-renge-btn="default"]:hover:not(:disabled) { background: ${tokens.rengeVars.color.accentHover}; }
508
+ [data-renge-btn="destructive"]:hover:not(:disabled) { filter: brightness(1.1); }
509
+ [data-renge-btn="outline"]:hover:not(:disabled) {
510
+ background: ${tokens.rengeVars.color.bgSubtle};
511
+ border-color: ${tokens.rengeVars.color.accent};
512
+ color: ${tokens.rengeVars.color.accent};
513
+ }
514
+ [data-renge-btn="secondary"]:hover:not(:disabled) { background: ${tokens.rengeVars.color.bgMuted}; }
515
+ [data-renge-btn="ghost"]:hover:not(:disabled) { background: ${tokens.rengeVars.color.bgSubtle}; }
516
+ [data-renge-btn="link"]:hover:not(:disabled) { color: ${tokens.rengeVars.color.accentHover}; }
517
+ `;
518
+ var variantStyles = {
519
+ default: {
520
+ background: tokens.rengeVars.color.accent,
521
+ color: tokens.rengeVars.color.fgInverse
522
+ },
523
+ destructive: {
524
+ background: tokens.rengeVars.color.danger,
525
+ color: tokens.rengeVars.color.fgInverse
526
+ },
527
+ outline: {
528
+ background: "transparent",
529
+ color: tokens.rengeVars.color.fg,
530
+ border: `1px solid ${tokens.rengeVars.color.border}`
531
+ },
532
+ secondary: {
533
+ background: tokens.rengeVars.color.bgSubtle,
534
+ color: tokens.rengeVars.color.fg
535
+ },
536
+ ghost: {
537
+ background: "transparent",
538
+ color: tokens.rengeVars.color.fg
539
+ },
540
+ link: {
541
+ background: "transparent",
542
+ color: tokens.rengeVars.color.accent,
543
+ textDecoration: "underline",
544
+ textUnderlineOffset: "3px"
545
+ }
546
+ };
547
+ var sizeStyles = {
548
+ default: {
549
+ padding: `${tokens.rengeVars.space[2]} ${tokens.rengeVars.space[4]}`,
550
+ fontSize: tokens.rengeVars.fontSize.sm,
551
+ borderRadius: tokens.rengeVars.radius[2],
552
+ gap: tokens.rengeVars.space[2]
553
+ },
554
+ sm: {
555
+ padding: `${tokens.rengeVars.space[1]} ${tokens.rengeVars.space[3]}`,
556
+ fontSize: tokens.rengeVars.fontSize.xs,
557
+ borderRadius: tokens.rengeVars.radius[2],
558
+ gap: tokens.rengeVars.space[1]
559
+ },
560
+ lg: {
561
+ padding: `${tokens.rengeVars.space[3]} ${tokens.rengeVars.space[5]}`,
562
+ fontSize: tokens.rengeVars.fontSize.base,
563
+ borderRadius: tokens.rengeVars.radius[3],
564
+ gap: tokens.rengeVars.space[2]
565
+ },
566
+ icon: {
567
+ width: tokens.rengeVars.space[6],
568
+ height: tokens.rengeVars.space[6],
569
+ padding: tokens.rengeVars.space[2],
570
+ borderRadius: tokens.rengeVars.radius[2],
571
+ flexShrink: 0
572
+ },
573
+ "icon-sm": {
574
+ width: tokens.rengeVars.space[5],
575
+ height: tokens.rengeVars.space[5],
576
+ padding: tokens.rengeVars.space[1],
577
+ borderRadius: tokens.rengeVars.radius[2],
578
+ flexShrink: 0
579
+ },
580
+ "icon-lg": {
581
+ width: tokens.rengeVars.space[7],
582
+ height: tokens.rengeVars.space[7],
583
+ padding: tokens.rengeVars.space[3],
584
+ borderRadius: tokens.rengeVars.radius[3],
585
+ flexShrink: 0
586
+ }
587
+ };
588
+ var stylesInjected2 = false;
589
+ function Button(_a) {
590
+ var _b = _a, {
591
+ className,
592
+ variant = "default",
593
+ size = "default",
594
+ style
595
+ } = _b, props = __objRest(_b, [
596
+ "className",
597
+ "variant",
598
+ "size",
599
+ "style"
600
+ ]);
601
+ if (typeof document !== "undefined" && !stylesInjected2) {
602
+ const el = document.createElement("style");
603
+ el.setAttribute("data-renge-button-styles", "");
604
+ el.textContent = BUTTON_STYLES;
605
+ document.head.appendChild(el);
606
+ stylesInjected2 = true;
607
+ }
608
+ return /* @__PURE__ */ jsxRuntime.jsx(
609
+ "button",
610
+ __spreadValues({
611
+ "data-slot": "button",
612
+ "data-renge-btn": variant,
613
+ className,
614
+ style: __spreadValues(__spreadValues(__spreadValues({}, variantStyles[variant]), sizeStyles[size]), style)
615
+ }, props)
616
+ );
617
+ }
618
+ function Card(_a) {
619
+ var _b = _a, { className, style } = _b, props = __objRest(_b, ["className", "style"]);
620
+ return /* @__PURE__ */ jsxRuntime.jsx(
621
+ "div",
622
+ __spreadValues({
623
+ "data-slot": "card",
624
+ className,
625
+ style: __spreadValues({
626
+ background: tokens.rengeVars.color.bgSubtle,
627
+ border: `1px solid ${tokens.rengeVars.color.border}`,
628
+ borderRadius: tokens.rengeVars.radius[4],
629
+ boxShadow: `0 1px 3px color-mix(in oklch, ${tokens.rengeVars.color.fg} 8%, transparent)`,
630
+ transition: `box-shadow ${tokens.rengeVars.duration[2]} ${tokens.rengeVars.easing.out}`,
631
+ overflow: "hidden"
632
+ }, style)
633
+ }, props)
634
+ );
635
+ }
636
+ function CardHeader(_a) {
637
+ var _b = _a, { className, style } = _b, props = __objRest(_b, ["className", "style"]);
638
+ return /* @__PURE__ */ jsxRuntime.jsx(
639
+ "div",
640
+ __spreadValues({
641
+ "data-slot": "card-header",
642
+ className,
643
+ style: __spreadValues({
644
+ padding: `${tokens.rengeVars.space[4]} ${tokens.rengeVars.space[4]} 0`,
645
+ display: "grid",
646
+ gridAutoRows: "min-content",
647
+ gap: tokens.rengeVars.space[1]
648
+ }, style)
649
+ }, props)
650
+ );
651
+ }
652
+ function CardTitle(_a) {
653
+ var _b = _a, { className, style } = _b, props = __objRest(_b, ["className", "style"]);
654
+ return /* @__PURE__ */ jsxRuntime.jsx(
655
+ "div",
656
+ __spreadValues({
657
+ "data-slot": "card-title",
658
+ className,
659
+ style: __spreadValues({
660
+ fontSize: tokens.rengeVars.fontSize.base,
661
+ lineHeight: tokens.rengeVars.lineHeight.base,
662
+ fontWeight: 600,
663
+ color: tokens.rengeVars.color.fg
664
+ }, style)
665
+ }, props)
666
+ );
667
+ }
668
+ function CardDescription(_a) {
669
+ var _b = _a, { className, style } = _b, props = __objRest(_b, ["className", "style"]);
670
+ return /* @__PURE__ */ jsxRuntime.jsx(
671
+ "div",
672
+ __spreadValues({
673
+ "data-slot": "card-description",
674
+ className,
675
+ style: __spreadValues({
676
+ fontSize: tokens.rengeVars.fontSize.sm,
677
+ lineHeight: tokens.rengeVars.lineHeight.sm,
678
+ color: tokens.rengeVars.color.fgSubtle
679
+ }, style)
680
+ }, props)
681
+ );
682
+ }
683
+ function CardAction(_a) {
684
+ var _b = _a, { className, style } = _b, props = __objRest(_b, ["className", "style"]);
685
+ return /* @__PURE__ */ jsxRuntime.jsx(
686
+ "div",
687
+ __spreadValues({
688
+ "data-slot": "card-action",
689
+ className,
690
+ style: __spreadValues({
691
+ gridColumn: "2",
692
+ gridRow: "1 / span 2",
693
+ alignSelf: "start",
694
+ justifySelf: "end"
695
+ }, style)
696
+ }, props)
697
+ );
698
+ }
699
+ function CardContent(_a) {
700
+ var _b = _a, { className, style } = _b, props = __objRest(_b, ["className", "style"]);
701
+ return /* @__PURE__ */ jsxRuntime.jsx(
702
+ "div",
703
+ __spreadValues({
704
+ "data-slot": "card-content",
705
+ className,
706
+ style: __spreadValues({
707
+ padding: `0 ${tokens.rengeVars.space[4]} ${tokens.rengeVars.space[4]}`
708
+ }, style)
709
+ }, props)
710
+ );
711
+ }
712
+ function CardFooter(_a) {
713
+ var _b = _a, { className, style } = _b, props = __objRest(_b, ["className", "style"]);
714
+ return /* @__PURE__ */ jsxRuntime.jsx(
715
+ "div",
716
+ __spreadValues({
717
+ "data-slot": "card-footer",
718
+ className,
719
+ style: __spreadValues({
720
+ display: "flex",
721
+ alignItems: "center",
722
+ padding: `0 ${tokens.rengeVars.space[4]} ${tokens.rengeVars.space[4]}`
723
+ }, style)
724
+ }, props)
725
+ );
726
+ }
727
+ var variantStyles2 = {
728
+ default: {
729
+ background: tokens.rengeVars.color.accent,
730
+ color: tokens.rengeVars.color.fgInverse
731
+ },
732
+ secondary: {
733
+ background: tokens.rengeVars.color.accentSubtle,
734
+ color: tokens.rengeVars.color.fg
735
+ },
736
+ destructive: {
737
+ background: tokens.rengeVars.color.danger,
738
+ color: tokens.rengeVars.color.fgInverse
739
+ },
740
+ outline: {
741
+ background: "transparent",
742
+ color: tokens.rengeVars.color.fg,
743
+ border: `1px solid ${tokens.rengeVars.color.border}`
744
+ }
745
+ };
746
+ var baseStyle = {
747
+ display: "inline-flex",
748
+ alignItems: "center",
749
+ padding: `${tokens.rengeVars.space[1]} ${tokens.rengeVars.space[2]}`,
750
+ borderRadius: tokens.rengeVars.radius.full,
751
+ fontSize: tokens.rengeVars.fontSize.xs,
752
+ lineHeight: tokens.rengeVars.lineHeight.xs,
753
+ fontWeight: 500,
754
+ whiteSpace: "nowrap",
755
+ border: "none",
756
+ transition: `background ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out},
757
+ color ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out}`
758
+ };
759
+ function Badge(_a) {
760
+ var _b = _a, {
761
+ className,
762
+ variant = "default",
763
+ style
764
+ } = _b, props = __objRest(_b, [
765
+ "className",
766
+ "variant",
767
+ "style"
768
+ ]);
769
+ return /* @__PURE__ */ jsxRuntime.jsx(
770
+ "span",
771
+ __spreadValues({
772
+ "data-slot": "badge",
773
+ className,
774
+ style: __spreadValues(__spreadValues(__spreadValues({}, baseStyle), variantStyles2[variant]), style)
775
+ }, props)
776
+ );
777
+ }
778
+ var SELECT_STYLES = `
779
+ [data-renge-select]:focus {
780
+ outline: none;
781
+ border-color: ${tokens.rengeVars.color.borderFocus};
782
+ box-shadow: 0 0 0 2px ${tokens.rengeVars.color.accentSubtle};
783
+ }
784
+ [data-renge-select]:hover:not(:disabled):not(:focus) {
785
+ border-color: ${tokens.rengeVars.color.accent};
786
+ }
787
+ [data-renge-select]:disabled {
788
+ opacity: 0.45;
789
+ cursor: not-allowed;
790
+ }
791
+ `;
792
+ var stylesInjected3 = false;
793
+ function Select(_a) {
794
+ var _b = _a, {
795
+ className,
796
+ children,
797
+ value,
798
+ defaultValue,
799
+ onChange,
800
+ style
801
+ } = _b, props = __objRest(_b, [
802
+ "className",
803
+ "children",
804
+ "value",
805
+ "defaultValue",
806
+ "onChange",
807
+ "style"
808
+ ]);
809
+ if (typeof document !== "undefined" && !stylesInjected3) {
810
+ const el = document.createElement("style");
811
+ el.setAttribute("data-renge-select-styles", "");
812
+ el.textContent = SELECT_STYLES;
813
+ document.head.appendChild(el);
814
+ stylesInjected3 = true;
815
+ }
816
+ const handleChange = (e) => {
817
+ var _a3;
818
+ onChange == null ? void 0 : onChange(e);
819
+ (_a3 = props.onValueChange) == null ? void 0 : _a3.call(props, e.target.value);
820
+ };
821
+ const _a2 = props, { onValueChange: _ } = _a2, restProps = __objRest(_a2, ["onValueChange"]);
822
+ return /* @__PURE__ */ jsxRuntime.jsx(
823
+ "select",
824
+ __spreadProps(__spreadValues({
825
+ "data-slot": "select",
826
+ "data-renge-select": "",
827
+ className,
828
+ value,
829
+ defaultValue,
830
+ onChange: handleChange,
831
+ style: __spreadValues({
832
+ width: "100%",
833
+ padding: `${tokens.rengeVars.space[2]} ${tokens.rengeVars.space[3]}`,
834
+ background: tokens.rengeVars.color.bg,
835
+ color: tokens.rengeVars.color.fg,
836
+ border: `1px solid ${tokens.rengeVars.color.border}`,
837
+ borderRadius: tokens.rengeVars.radius[2],
838
+ fontSize: tokens.rengeVars.fontSize.sm,
839
+ lineHeight: tokens.rengeVars.lineHeight.sm,
840
+ cursor: "pointer",
841
+ transition: `border-color ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out},
842
+ box-shadow ${tokens.rengeVars.duration[1]} ${tokens.rengeVars.easing.out}`
843
+ }, style)
844
+ }, restProps), {
845
+ children
846
+ })
847
+ );
848
+ }
849
+ function SettingsIcon({ className }) {
850
+ return /* @__PURE__ */ jsxRuntime.jsxs(
851
+ "svg",
852
+ {
853
+ className,
854
+ fill: "none",
855
+ stroke: "currentColor",
856
+ viewBox: "0 0 24 24",
857
+ "aria-hidden": "true",
858
+ children: [
859
+ /* @__PURE__ */ jsxRuntime.jsx(
860
+ "path",
861
+ {
862
+ strokeWidth: "2",
863
+ strokeLinecap: "round",
864
+ strokeLinejoin: "round",
865
+ d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
866
+ }
867
+ ),
868
+ /* @__PURE__ */ jsxRuntime.jsx(
869
+ "path",
870
+ {
871
+ strokeWidth: "2",
872
+ strokeLinecap: "round",
873
+ strokeLinejoin: "round",
874
+ d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
875
+ }
876
+ )
877
+ ]
878
+ }
879
+ );
880
+ }
881
+ function CloseIcon({ className }) {
882
+ return /* @__PURE__ */ jsxRuntime.jsx(
883
+ "svg",
884
+ {
885
+ className,
886
+ fill: "none",
887
+ stroke: "currentColor",
888
+ viewBox: "0 0 24 24",
889
+ "aria-hidden": "true",
890
+ children: /* @__PURE__ */ jsxRuntime.jsx(
891
+ "path",
892
+ {
893
+ strokeWidth: "2",
894
+ strokeLinecap: "round",
895
+ strokeLinejoin: "round",
896
+ d: "M6 18L18 6M6 6l12 12"
897
+ }
898
+ )
899
+ }
900
+ );
901
+ }
902
+ function ResetIcon({ className }) {
903
+ return /* @__PURE__ */ jsxRuntime.jsx(
904
+ "svg",
905
+ {
906
+ className,
907
+ fill: "none",
908
+ stroke: "currentColor",
909
+ viewBox: "0 0 24 24",
910
+ "aria-hidden": "true",
911
+ children: /* @__PURE__ */ jsxRuntime.jsx(
912
+ "path",
913
+ {
914
+ strokeWidth: "2",
915
+ strokeLinecap: "round",
916
+ strokeLinejoin: "round",
917
+ d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
918
+ }
919
+ )
920
+ }
921
+ );
922
+ }
923
+ var CAPACITY_PRESETS = {
924
+ exhausted: {
925
+ label: "Exhausted",
926
+ description: "Protective mode: stripped-back, no motion, no surprises",
927
+ cognitive: 0.1,
928
+ temporal: 0.1,
929
+ emotional: 0.1,
930
+ valence: -0.6,
931
+ arousal: 0.1
932
+ },
933
+ overwhelmed: {
934
+ label: "Overwhelmed",
935
+ description: "High stress: minimal content, boosted contrast, soothing motion",
936
+ cognitive: 0.2,
937
+ temporal: 0.15,
938
+ emotional: 0.2,
939
+ valence: -0.5,
940
+ arousal: 0.2
941
+ },
942
+ distracted: {
943
+ label: "Distracted",
944
+ description: "Short attention: fewer items, guided focus on key elements",
945
+ cognitive: 0.35,
946
+ temporal: 0.25,
947
+ emotional: 0.5,
948
+ valence: 0,
949
+ arousal: 0.4
950
+ },
951
+ neutral: {
952
+ label: "Neutral",
953
+ description: "Balanced: medium density, subtle motion, gentle focus on key items",
954
+ cognitive: 0.5,
955
+ temporal: 0.5,
956
+ emotional: 0.5,
957
+ valence: 0,
958
+ arousal: 0.5
959
+ },
960
+ focused: {
961
+ label: "Focused",
962
+ description: "Task-ready: full content, subtle motion, clear hierarchy",
963
+ cognitive: 0.75,
964
+ temporal: 0.75,
965
+ emotional: 0.55,
966
+ valence: 0.1,
967
+ arousal: 0.6
968
+ },
969
+ energized: {
970
+ label: "Energized",
971
+ description: "Full engagement: dense layout, expressive animations, warm tone",
972
+ cognitive: 0.9,
973
+ temporal: 0.85,
974
+ emotional: 0.85,
975
+ valence: 0.6,
976
+ arousal: 0.8
977
+ },
978
+ exploring: {
979
+ label: "Exploring",
980
+ description: "Maximum everything: all content, all animations, all features",
981
+ cognitive: 1,
982
+ temporal: 1,
983
+ emotional: 1,
984
+ valence: 0.8,
985
+ arousal: 0.9
986
+ }
987
+ };
988
+ var DEFAULT_CALM_STATE = {
989
+ cognitive: 0.5,
990
+ temporal: 0.5,
991
+ emotional: 0.5,
992
+ valence: 0,
993
+ arousal: 0.5
994
+ };
995
+ function CapacityControls() {
996
+ var _a;
997
+ const [isOpen, setIsOpen] = react.useState(false);
998
+ const { updateCapacity, updateEmotionalState, isAutoMode, toggleAutoMode } = useCapacityContext();
999
+ const { hapticEnabled, sonicEnabled, setHapticEnabled, setSonicEnabled, fire: fireFeedback } = useFeedback();
1000
+ const { field, mode } = useDerivedMode();
1001
+ const energy = useEnergyField();
1002
+ const attention = useAttentionField();
1003
+ const valence = useEmotionalValenceField();
1004
+ const modeLabel = deriveModeLabel(field);
1005
+ const modeBadgeColor = getModeBadgeColor(modeLabel);
1006
+ const handleReset = () => {
1007
+ updateCapacity({
1008
+ cognitive: DEFAULT_CALM_STATE.cognitive,
1009
+ temporal: DEFAULT_CALM_STATE.temporal,
1010
+ emotional: DEFAULT_CALM_STATE.emotional
1011
+ });
1012
+ updateEmotionalState({
1013
+ valence: DEFAULT_CALM_STATE.valence,
1014
+ arousal: DEFAULT_CALM_STATE.arousal
1015
+ });
1016
+ };
1017
+ const fireInteractionFeedback = react.useCallback(() => {
1018
+ fireFeedback("tap");
1019
+ }, [fireFeedback]);
1020
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed bottom-4 right-4 z-50", children: [
1021
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.AnimatePresence, { children: !isOpen && /* @__PURE__ */ jsxRuntime.jsxs(
1022
+ react$1.motion.div,
1023
+ {
1024
+ initial: { opacity: 0, scale: 0.8 },
1025
+ animate: { opacity: 1, scale: 1 },
1026
+ exit: { opacity: 0, scale: 0.8 },
1027
+ className: "flex items-center gap-2",
1028
+ children: [
1029
+ /* @__PURE__ */ jsxRuntime.jsx(
1030
+ Badge,
1031
+ {
1032
+ className: "shadow-lg",
1033
+ style: { backgroundColor: modeBadgeColor, color: "white" },
1034
+ children: modeLabel
1035
+ }
1036
+ ),
1037
+ /* @__PURE__ */ jsxRuntime.jsxs(
1038
+ Button,
1039
+ {
1040
+ onClick: () => setIsOpen(true),
1041
+ variant: "outline",
1042
+ size: "sm",
1043
+ className: "shadow-lg bg-background",
1044
+ children: [
1045
+ /* @__PURE__ */ jsxRuntime.jsx(SettingsIcon, { className: "w-4 h-4 mr-2" }),
1046
+ "Capacity"
1047
+ ]
1048
+ }
1049
+ )
1050
+ ]
1051
+ }
1052
+ ) }),
1053
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
1054
+ react$1.motion.div,
1055
+ {
1056
+ initial: { opacity: 0 },
1057
+ animate: { opacity: 1 },
1058
+ exit: { opacity: 0 },
1059
+ className: "fixed inset-0 bg-black/20 backdrop-blur-sm md:hidden",
1060
+ onClick: () => setIsOpen(false),
1061
+ "aria-hidden": "true"
1062
+ }
1063
+ ) }),
1064
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
1065
+ react$1.motion.div,
1066
+ {
1067
+ initial: { opacity: 0, y: 20, scale: 0.95 },
1068
+ animate: { opacity: 1, y: 0, scale: 1 },
1069
+ exit: { opacity: 0, y: 20, scale: 0.95 },
1070
+ transition: { type: "spring", damping: 20, stiffness: 300 },
1071
+ className: "relative",
1072
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "w-80 shadow-xl max-h-[85vh] overflow-y-auto", children: [
1073
+ /* @__PURE__ */ jsxRuntime.jsxs(CardHeader, { className: "pb-3", children: [
1074
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2", children: [
1075
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1076
+ /* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-sm font-semibold", children: "Capacity Controls" }),
1077
+ /* @__PURE__ */ jsxRuntime.jsx(
1078
+ Button,
1079
+ {
1080
+ variant: "ghost",
1081
+ size: "icon",
1082
+ className: "h-8 w-8 shrink-0",
1083
+ onClick: (e) => {
1084
+ e.stopPropagation();
1085
+ setIsOpen(false);
1086
+ },
1087
+ "aria-label": "Close capacity controls",
1088
+ children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, { className: "w-4 h-4" })
1089
+ }
1090
+ )
1091
+ ] }),
1092
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1093
+ /* @__PURE__ */ jsxRuntime.jsx(
1094
+ Badge,
1095
+ {
1096
+ className: "text-xs",
1097
+ style: { backgroundColor: modeBadgeColor, color: "white" },
1098
+ children: modeLabel
1099
+ }
1100
+ ),
1101
+ /* @__PURE__ */ jsxRuntime.jsx(
1102
+ Button,
1103
+ {
1104
+ variant: isAutoMode ? "default" : "outline",
1105
+ size: "sm",
1106
+ className: "h-7 text-xs px-2",
1107
+ onClick: toggleAutoMode,
1108
+ "aria-label": isAutoMode ? "Switch to manual mode" : "Switch to auto mode",
1109
+ children: isAutoMode ? "Auto" : "Manual"
1110
+ }
1111
+ )
1112
+ ] })
1113
+ ] }),
1114
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: isAutoMode ? "Signals are driving values automatically. Move any slider to take manual control." : "Adjust your state to see the UI adapt in real-time." })
1115
+ ] }),
1116
+ /* @__PURE__ */ jsxRuntime.jsxs(CardContent, { className: "space-y-6", children: [
1117
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 flex flex-col gap-2", children: [
1118
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Quick Presets" }),
1119
+ /* @__PURE__ */ jsxRuntime.jsxs(
1120
+ Select,
1121
+ {
1122
+ defaultValue: "",
1123
+ onValueChange: (value) => {
1124
+ if (!value) return;
1125
+ const preset = CAPACITY_PRESETS[value];
1126
+ updateCapacity({
1127
+ cognitive: preset.cognitive,
1128
+ temporal: preset.temporal,
1129
+ emotional: preset.emotional
1130
+ });
1131
+ updateEmotionalState({ valence: preset.valence, arousal: preset.arousal });
1132
+ fireInteractionFeedback();
1133
+ },
1134
+ children: [
1135
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select a preset..." }),
1136
+ Object.entries(CAPACITY_PRESETS).map(([key, preset]) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: key, children: [
1137
+ preset.label,
1138
+ " \u2014 ",
1139
+ preset.description
1140
+ ] }, key))
1141
+ ]
1142
+ }
1143
+ )
1144
+ ] }),
1145
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-t border-border pt-4", children: [
1146
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Or adjust individually:" }),
1147
+ /* @__PURE__ */ jsxRuntime.jsxs(
1148
+ Button,
1149
+ {
1150
+ variant: "ghost",
1151
+ size: "sm",
1152
+ onClick: handleReset,
1153
+ className: "h-7 text-xs text-muted-foreground hover:text-foreground",
1154
+ children: [
1155
+ /* @__PURE__ */ jsxRuntime.jsx(ResetIcon, { className: "w-3 h-3 mr-1" }),
1156
+ "Reset"
1157
+ ]
1158
+ }
1159
+ )
1160
+ ] }),
1161
+ /* @__PURE__ */ jsxRuntime.jsx(
1162
+ SliderControl,
1163
+ {
1164
+ label: "Cognitive Capacity",
1165
+ description: "Controls: density, hierarchy, concurrency",
1166
+ value: field.cognitive,
1167
+ onChange: (v) => updateCapacity({ cognitive: v }),
1168
+ lowLabel: "Fewer items",
1169
+ highLabel: "More items"
1170
+ }
1171
+ ),
1172
+ /* @__PURE__ */ jsxRuntime.jsx(
1173
+ SliderControl,
1174
+ {
1175
+ label: "Temporal Capacity",
1176
+ description: "Controls: content length, shortcuts, defaults",
1177
+ value: field.temporal,
1178
+ onChange: (v) => updateCapacity({ temporal: v }),
1179
+ lowLabel: "Abbreviated",
1180
+ highLabel: "Full detail"
1181
+ }
1182
+ ),
1183
+ /* @__PURE__ */ jsxRuntime.jsx(
1184
+ SliderControl,
1185
+ {
1186
+ label: "Emotional Capacity",
1187
+ description: "Controls: motion restraint, friction",
1188
+ value: field.emotional,
1189
+ onChange: (v) => updateCapacity({ emotional: v }),
1190
+ lowLabel: "Calm UI",
1191
+ highLabel: "Expressive"
1192
+ }
1193
+ ),
1194
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2 border-t border-border", children: /* @__PURE__ */ jsxRuntime.jsx(
1195
+ ValenceSliderControl,
1196
+ {
1197
+ label: "Emotional Valence",
1198
+ description: "Controls: tone, expressiveness (not info volume)",
1199
+ value: field.valence,
1200
+ onChange: (v) => updateEmotionalState({ valence: v })
1201
+ }
1202
+ ) }),
1203
+ /* @__PURE__ */ jsxRuntime.jsx(
1204
+ SliderControl,
1205
+ {
1206
+ label: "Arousal",
1207
+ description: "Controls: animation pacing (calm \u2192 activated)",
1208
+ value: (_a = field.arousal) != null ? _a : 0.5,
1209
+ onChange: (v) => updateEmotionalState({ arousal: v }),
1210
+ lowLabel: "Calm",
1211
+ highLabel: "Activated"
1212
+ }
1213
+ ),
1214
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-2 border-t border-border space-y-2", children: [
1215
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs font-medium text-muted-foreground", children: [
1216
+ "Feedback ",
1217
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-normal opacity-60", children: "(opt-in)" })
1218
+ ] }),
1219
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
1220
+ /* @__PURE__ */ jsxRuntime.jsx(
1221
+ "button",
1222
+ {
1223
+ onClick: () => setHapticEnabled((v) => !v),
1224
+ className: `flex-1 py-1.5 px-2 rounded-md text-xs border transition-colors ${hapticEnabled ? "bg-primary/10 border-primary/50 text-primary" : "border-border text-muted-foreground hover:text-foreground"}`,
1225
+ "aria-pressed": hapticEnabled,
1226
+ children: "\u{1F4F3} Haptic"
1227
+ }
1228
+ ),
1229
+ /* @__PURE__ */ jsxRuntime.jsx(
1230
+ "button",
1231
+ {
1232
+ onClick: () => setSonicEnabled((v) => !v),
1233
+ className: `flex-1 py-1.5 px-2 rounded-md text-xs border transition-colors ${sonicEnabled ? "bg-primary/10 border-primary/50 text-primary" : "border-border text-muted-foreground hover:text-foreground"}`,
1234
+ "aria-pressed": sonicEnabled,
1235
+ children: "\u{1F514} Sonic"
1236
+ }
1237
+ )
1238
+ ] }),
1239
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-[10px] text-muted-foreground opacity-60", children: [
1240
+ "Pace: ",
1241
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.pace }),
1242
+ " \u2192 ",
1243
+ mode.pace === "calm" ? "+50% duration" : mode.pace === "activated" ? "\u221235% duration" : "standard"
1244
+ ] })
1245
+ ] }),
1246
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-4 border-t border-border", children: [
1247
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium text-muted-foreground mb-2", children: "Derived Fields" }),
1248
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-3 gap-2 text-center", children: [
1249
+ /* @__PURE__ */ jsxRuntime.jsx(FieldDisplay, { label: "Energy", value: energy.value, color: "text-chart-1" }),
1250
+ /* @__PURE__ */ jsxRuntime.jsx(FieldDisplay, { label: "Attention", value: attention.value, color: "text-chart-2" }),
1251
+ /* @__PURE__ */ jsxRuntime.jsx(FieldDisplay, { label: "Valence", value: valence.value, color: "text-chart-3", signed: true })
1252
+ ] })
1253
+ ] }),
1254
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-4 border-t border-border", children: [
1255
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium text-muted-foreground mb-2", children: "Interface Mode" }),
1256
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-1 text-xs", children: [
1257
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Density:" }),
1258
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.density }),
1259
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Guidance:" }),
1260
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.guidance }),
1261
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Motion:" }),
1262
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.motion }),
1263
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Contrast:" }),
1264
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.contrast }),
1265
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Choices:" }),
1266
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.choiceLoad }),
1267
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Focus:" }),
1268
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.focus }),
1269
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Pace:" }),
1270
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: mode.pace })
1271
+ ] })
1272
+ ] })
1273
+ ] })
1274
+ ] })
1275
+ }
1276
+ ) })
1277
+ ] });
1278
+ }
1279
+ function SliderControl({
1280
+ label,
1281
+ description,
1282
+ value,
1283
+ onChange,
1284
+ lowLabel,
1285
+ highLabel
1286
+ }) {
1287
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1288
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-baseline", children: [
1289
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: label }),
1290
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground tabular-nums", children: [
1291
+ Math.round(value * 100),
1292
+ "%"
1293
+ ] })
1294
+ ] }),
1295
+ /* @__PURE__ */ jsxRuntime.jsx(
1296
+ Slider,
1297
+ {
1298
+ value,
1299
+ onChange: (v) => onChange(v),
1300
+ min: 0,
1301
+ max: 1,
1302
+ step: 0.01,
1303
+ className: "w-full"
1304
+ }
1305
+ ),
1306
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between text-xs text-muted-foreground", children: [
1307
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: lowLabel }),
1308
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: highLabel })
1309
+ ] })
1310
+ ] });
1311
+ }
1312
+ function ValenceSliderControl({
1313
+ label,
1314
+ description,
1315
+ value,
1316
+ onChange
1317
+ }) {
1318
+ const sliderValue = (value + 1) / 2;
1319
+ const displayValue = value >= 0 ? `+${value.toFixed(2)}` : value.toFixed(2);
1320
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1321
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-baseline", children: [
1322
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: label }),
1323
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground tabular-nums font-mono", children: displayValue })
1324
+ ] }),
1325
+ /* @__PURE__ */ jsxRuntime.jsx(
1326
+ Slider,
1327
+ {
1328
+ value: sliderValue,
1329
+ onChange: (v) => onChange(v * 2 - 1),
1330
+ min: 0,
1331
+ max: 1,
1332
+ step: 0.01,
1333
+ className: "w-full"
1334
+ }
1335
+ ),
1336
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between text-xs text-muted-foreground", children: [
1337
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Negative" }),
1338
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "opacity-50", children: "Neutral" }),
1339
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Positive" })
1340
+ ] })
1341
+ ] });
1342
+ }
1343
+ function FieldDisplay({
1344
+ label,
1345
+ value,
1346
+ color,
1347
+ signed = false
1348
+ }) {
1349
+ const displayValue = signed ? (value >= 0 ? "+" : "") + value.toFixed(2) : value.toFixed(2);
1350
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted/50 rounded-md p-2", children: [
1351
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: label }),
1352
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: `text-sm font-mono font-bold ${color}`, children: displayValue })
1353
+ ] });
1354
+ }
1355
+ var DENSITY_CONTENT = {
1356
+ high: {
1357
+ title: "Adaptive Interface Demo",
1358
+ featureCount: 4,
1359
+ cta: "Explore the Framework"
1360
+ },
1361
+ medium: {
1362
+ title: "Adaptive Interface",
1363
+ featureCount: 2,
1364
+ cta: "Explore"
1365
+ },
1366
+ low: {
1367
+ title: "Live Demo",
1368
+ featureCount: 0,
1369
+ cta: "Go"
1370
+ }
1371
+ };
1372
+ var TEMPORAL_CONTENT = {
1373
+ full: {
1374
+ description: "This card demonstrates how the capacity system adapts UI in real-time based on your current state.",
1375
+ features: [
1376
+ "Cognitive capacity controls visual density",
1377
+ "Temporal capacity controls content length",
1378
+ "Emotional capacity controls motion restraint",
1379
+ "Valence controls tone and expressiveness"
1380
+ ]
1381
+ },
1382
+ abbreviated: {
1383
+ description: "UI adapts in real-time.",
1384
+ features: [
1385
+ "Density from cognitive",
1386
+ "Length from temporal",
1387
+ "Motion from emotional",
1388
+ "Tone from valence"
1389
+ ]
1390
+ }
1391
+ };
1392
+ var TONE = {
1393
+ positive: {
1394
+ greeting: "You're doing great!",
1395
+ accent: "text-green-600 dark:text-accent"
1396
+ },
1397
+ neutral: {
1398
+ greeting: "Here's how it works:",
1399
+ accent: "text-primary"
1400
+ },
1401
+ negative: {
1402
+ greeting: "Take your time.",
1403
+ accent: "text-muted-foreground"
1404
+ }
1405
+ };
1406
+ function CapacityDemoCard() {
1407
+ const { field, mode } = useDerivedMode();
1408
+ const { fire } = useFeedback();
1409
+ const modeLabel = deriveModeLabel(field);
1410
+ const modeBadgeColor = getModeBadgeColor(modeLabel);
1411
+ const densityContent = DENSITY_CONTENT[mode.density];
1412
+ const temporalContent = field.temporal > 0.4 ? TEMPORAL_CONTENT.full : TEMPORAL_CONTENT.abbreviated;
1413
+ const toneKey = field.valence > 0.2 ? "positive" : field.valence < -0.2 ? "negative" : "neutral";
1414
+ const tone = TONE[toneKey];
1415
+ const entrance = entranceClass(mode.motion, "morph");
1416
+ const hover = hoverClass(mode.motion);
1417
+ const visibleFeatures = temporalContent.features.slice(0, densityContent.featureCount);
1418
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1419
+ Card,
1420
+ {
1421
+ className: `max-w-md border-2 transition-colors ${entrance} ${hover}`,
1422
+ style: { borderColor: `color-mix(in oklch, ${modeBadgeColor} 40%, transparent)` },
1423
+ children: [
1424
+ /* @__PURE__ */ jsxRuntime.jsxs(CardHeader, { children: [
1425
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
1426
+ /* @__PURE__ */ jsxRuntime.jsxs(
1427
+ Badge,
1428
+ {
1429
+ className: "text-xs",
1430
+ style: { backgroundColor: modeBadgeColor, color: "white" },
1431
+ children: [
1432
+ modeLabel,
1433
+ " Mode"
1434
+ ]
1435
+ }
1436
+ ),
1437
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `text-xs ${tone.accent}`, children: tone.greeting })
1438
+ ] }),
1439
+ /* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: ambientClass(mode.motion, "float"), children: densityContent.title }),
1440
+ mode.density !== "low" && /* @__PURE__ */ jsxRuntime.jsx(CardDescription, { children: temporalContent.description })
1441
+ ] }),
1442
+ /* @__PURE__ */ jsxRuntime.jsxs(CardContent, { className: "space-y-4", children: [
1443
+ visibleFeatures.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: visibleFeatures.map((feature, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
1444
+ "li",
1445
+ {
1446
+ className: `flex items-start gap-2 text-sm text-muted-foreground ${listItemClass(mode.motion)}`,
1447
+ style: { animationDelay: `${idx * 0.15}s` },
1448
+ children: [
1449
+ /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "w-4 h-4 text-primary shrink-0 mt-0.5" }),
1450
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: feature })
1451
+ ]
1452
+ },
1453
+ idx
1454
+ )) }),
1455
+ mode.guidance !== "low" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground/70 italic", children: mode.guidance === "high" ? "Tip: adjust capacity controls (bottom-right) to see this card change" : "Try adjusting the capacity controls" }),
1456
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: mode.choiceLoad === "normal" ? "flex gap-2" : "", children: [
1457
+ /* @__PURE__ */ jsxRuntime.jsx(
1458
+ "button",
1459
+ {
1460
+ className: `${mode.choiceLoad === "normal" ? "flex-1" : "w-full"} py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium text-sm transition-transform ${hover} ${ambientClass(mode.motion, "breathe")}`,
1461
+ onClick: () => fire("tap"),
1462
+ children: densityContent.cta
1463
+ }
1464
+ ),
1465
+ mode.choiceLoad === "normal" && mode.density !== "low" && /* @__PURE__ */ jsxRuntime.jsx(
1466
+ "button",
1467
+ {
1468
+ className: "py-2 px-3 rounded-md border border-border text-sm text-muted-foreground hover:text-foreground transition-colors",
1469
+ onClick: () => fire("tap"),
1470
+ children: "Details"
1471
+ }
1472
+ )
1473
+ ] }),
1474
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-4 border-t border-border", children: [
1475
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mb-2", children: "Live State" }),
1476
+ mode.choiceLoad === "minimal" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-1 text-xs", children: [
1477
+ /* @__PURE__ */ jsxRuntime.jsx(StateChip, { label: "Cog", value: field.cognitive, hint: "density" }),
1478
+ /* @__PURE__ */ jsxRuntime.jsx(StateChip, { label: "Temp", value: field.temporal, hint: "length" })
1479
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-4 gap-1 text-xs", children: [
1480
+ /* @__PURE__ */ jsxRuntime.jsx(StateChip, { label: "Cog", value: field.cognitive, hint: "density" }),
1481
+ /* @__PURE__ */ jsxRuntime.jsx(StateChip, { label: "Temp", value: field.temporal, hint: "length" }),
1482
+ /* @__PURE__ */ jsxRuntime.jsx(StateChip, { label: "Emo", value: field.emotional, hint: "motion" }),
1483
+ /* @__PURE__ */ jsxRuntime.jsx(StateChip, { label: "Val", value: field.valence, hint: "tone", signed: true })
1484
+ ] })
1485
+ ] })
1486
+ ] })
1487
+ ]
1488
+ }
1489
+ );
1490
+ }
1491
+ function StateChip({
1492
+ label,
1493
+ value,
1494
+ hint,
1495
+ signed = false
1496
+ }) {
1497
+ const displayValue = signed ? (value >= 0 ? "+" : "") + value.toFixed(1) : value.toFixed(1);
1498
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted/50 rounded-md px-2 py-1 text-center", children: [
1499
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-[10px]", children: label }),
1500
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-mono font-medium", children: displayValue }),
1501
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-[9px] opacity-70", children: hint })
1502
+ ] });
1503
+ }
1504
+ function CheckIcon({ className }) {
1505
+ return /* @__PURE__ */ jsxRuntime.jsx(
1506
+ "svg",
1507
+ {
1508
+ className,
1509
+ fill: "none",
1510
+ stroke: "currentColor",
1511
+ viewBox: "0 0 24 24",
1512
+ "aria-hidden": "true",
1513
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1514
+ "path",
1515
+ {
1516
+ strokeWidth: "2",
1517
+ strokeLinecap: "round",
1518
+ strokeLinejoin: "round",
1519
+ d: "M5 13l4 4L19 7"
1520
+ }
1521
+ )
1522
+ }
1523
+ );
1524
+ }
1525
+ function AmbientFieldMonitor() {
1526
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
1527
+ /* @__PURE__ */ jsxRuntime.jsx(InputsToModeFlow, {}),
1528
+ /* @__PURE__ */ jsxRuntime.jsx(DerivationLogicExplainer, {})
1529
+ ] });
1530
+ }
1531
+ function InputsToModeFlow() {
1532
+ const { field, mode } = useDerivedMode();
1533
+ const label = deriveModeLabel(field);
1534
+ const badgeColor = getModeBadgeColor(label);
1535
+ return /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "overflow-hidden border-border/50", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid lg:grid-cols-3 divide-y lg:divide-y-0 lg:divide-x divide-border/50", children: [
1536
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 space-y-4", children: [
1537
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-muted-foreground", children: [
1538
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-6 h-6 rounded-full bg-muted flex items-center justify-center text-xs", children: "1" }),
1539
+ "Your Inputs"
1540
+ ] }),
1541
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1542
+ /* @__PURE__ */ jsxRuntime.jsx(InputGauge, { label: "Cognitive", value: field.cognitive, description: "mental bandwidth" }),
1543
+ /* @__PURE__ */ jsxRuntime.jsx(InputGauge, { label: "Temporal", value: field.temporal, description: "time available" }),
1544
+ /* @__PURE__ */ jsxRuntime.jsx(InputGauge, { label: "Emotional", value: field.emotional, description: "resilience" }),
1545
+ /* @__PURE__ */ jsxRuntime.jsx(InputGauge, { label: "Valence", value: field.valence, description: "mood", isBipolar: true })
1546
+ ] })
1547
+ ] }),
1548
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 space-y-4 bg-muted/30", children: [
1549
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-muted-foreground", children: [
1550
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-6 h-6 rounded-full bg-muted flex items-center justify-center text-xs", children: "2" }),
1551
+ "Derived Mode"
1552
+ ] }),
1553
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1554
+ Badge,
1555
+ {
1556
+ className: "text-xl font-bold px-6 py-3 shadow-lg",
1557
+ style: { backgroundColor: badgeColor, color: "white" },
1558
+ children: label
1559
+ }
1560
+ ) }),
1561
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2 justify-center", children: [
1562
+ /* @__PURE__ */ jsxRuntime.jsx(ModePill, { label: "density", value: mode.density }),
1563
+ /* @__PURE__ */ jsxRuntime.jsx(ModePill, { label: "guidance", value: mode.guidance }),
1564
+ /* @__PURE__ */ jsxRuntime.jsx(ModePill, { label: "choices", value: mode.choiceLoad }),
1565
+ /* @__PURE__ */ jsxRuntime.jsx(ModePill, { label: "motion", value: mode.motion }),
1566
+ /* @__PURE__ */ jsxRuntime.jsx(ModePill, { label: "contrast", value: mode.contrast }),
1567
+ /* @__PURE__ */ jsxRuntime.jsx(ModePill, { label: "focus", value: mode.focus })
1568
+ ] })
1569
+ ] }),
1570
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 space-y-4", children: [
1571
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-muted-foreground", children: [
1572
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-6 h-6 rounded-full bg-muted flex items-center justify-center text-xs", children: "3" }),
1573
+ "UI Effects"
1574
+ ] }),
1575
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
1576
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.density === "low", text: "Fewer items shown, simpler layouts" }),
1577
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.density === "high", text: "Full feature display, dense grids" }),
1578
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.guidance === "high", text: "More labels, helper text visible" }),
1579
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.choiceLoad === "minimal", text: "Reduced options, smart defaults" }),
1580
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.motion === "off", text: "No animations, fully static UI" }),
1581
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.motion === "soothing", text: "Slow rhythmic motion: breathe, float" }),
1582
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.motion === "subtle", text: "Calm animations, no surprises" }),
1583
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.motion === "expressive", text: "Playful micro-interactions" }),
1584
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.contrast === "boosted", text: "Higher contrast for accessibility" }),
1585
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.focus === "gentle", text: "Soft highlight on important elements" }),
1586
+ /* @__PURE__ */ jsxRuntime.jsx(EffectRow, { active: mode.focus === "guided", text: "Strong beacon glow on key elements" })
1587
+ ] })
1588
+ ] })
1589
+ ] }) });
1590
+ }
1591
+ function InputGauge({
1592
+ label,
1593
+ value,
1594
+ description,
1595
+ isBipolar = false
1596
+ }) {
1597
+ const percentage = isBipolar ? (value + 1) / 2 * 100 : value * 100;
1598
+ const getColor = () => {
1599
+ if (isBipolar) {
1600
+ if (value < -0.15) return "bg-amber-500";
1601
+ if (value > 0.15) return "bg-emerald-500";
1602
+ return "bg-sky-500";
1603
+ }
1604
+ if (value < 0.4) return "bg-amber-500";
1605
+ if (value > 0.7) return "bg-emerald-500";
1606
+ return "bg-sky-500";
1607
+ };
1608
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
1609
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-baseline", children: [
1610
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-foreground", children: label }),
1611
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: description })
1612
+ ] }),
1613
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1614
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-2 bg-muted rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
1615
+ "div",
1616
+ {
1617
+ className: `h-full rounded-full transition-all duration-300 ${getColor()}`,
1618
+ style: { width: `${percentage}%` }
1619
+ }
1620
+ ) }),
1621
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-mono tabular-nums w-12 text-right text-foreground", children: isBipolar ? (value >= 0 ? "+" : "") + value.toFixed(1) : (value * 100).toFixed(0) + "%" })
1622
+ ] })
1623
+ ] });
1624
+ }
1625
+ function ModePill({ label, value }) {
1626
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-background border border-border text-xs", children: [
1627
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground", children: [
1628
+ label,
1629
+ ":"
1630
+ ] }),
1631
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-foreground", children: value })
1632
+ ] });
1633
+ }
1634
+ function EffectRow({ active, text }) {
1635
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `py-1.5 text-sm transition-opacity ${active ? "opacity-100" : "opacity-40"}`, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: active ? "text-foreground font-medium" : "text-muted-foreground", children: [
1636
+ active ? "-> " : " ",
1637
+ text
1638
+ ] }) });
1639
+ }
1640
+ function DerivationLogicExplainer() {
1641
+ return /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "p-6 border-border/50 bg-muted/20", children: [
1642
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-muted-foreground uppercase tracking-wide mb-4", children: "Derivation Rules" }),
1643
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-4 md:grid-cols-2 text-sm", children: [
1644
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1645
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-foreground", children: "Cognitive controls density:" }),
1646
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-1 text-muted-foreground font-mono text-xs", children: [
1647
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "cognitive < 0.4 \u2192 density: low" }),
1648
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "cognitive > 0.7 \u2192 density: high" }),
1649
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "else \u2192 density: medium" })
1650
+ ] })
1651
+ ] }),
1652
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1653
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-foreground", children: "Temporal controls choices:" }),
1654
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-1 text-muted-foreground font-mono text-xs", children: [
1655
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "temporal < 0.4 \u2192 choiceLoad: minimal" }),
1656
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "else \u2192 choiceLoad: normal" })
1657
+ ] })
1658
+ ] }),
1659
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1660
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-foreground", children: "Emotional controls motion:" }),
1661
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-1 text-muted-foreground font-mono text-xs", children: [
1662
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "emotional < 0.15 \u2192 motion: off" }),
1663
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "emotional < 0.4 \u2192 motion: soothing" }),
1664
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "emotional > 0.6 & val > 0.15 \u2192 motion: expressive" }),
1665
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "else \u2192 motion: subtle" })
1666
+ ] })
1667
+ ] }),
1668
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1669
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-foreground", children: "Valence controls tone:" }),
1670
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-1 text-muted-foreground font-mono text-xs", children: [
1671
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "valence < -0.15 \u2192 contrast: boosted" }),
1672
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "else \u2192 contrast: standard" })
1673
+ ] })
1674
+ ] }),
1675
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1676
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-foreground", children: "Cognitive controls focus:" }),
1677
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-1 text-muted-foreground font-mono text-xs", children: [
1678
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "motion == off \u2192 focus: default" }),
1679
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "cognitive < 0.4 \u2192 focus: guided" }),
1680
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "cognitive < 0.7 \u2192 focus: gentle" }),
1681
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "else \u2192 focus: default" })
1682
+ ] })
1683
+ ] })
1684
+ ] })
1685
+ ] });
1686
+ }
1687
+
1688
+ exports.AmbientFieldMonitor = AmbientFieldMonitor;
1689
+ exports.Badge = Badge;
1690
+ exports.Button = Button;
1691
+ exports.CapacityControls = CapacityControls;
1692
+ exports.CapacityDemoCard = CapacityDemoCard;
1693
+ exports.Card = Card;
1694
+ exports.CardAction = CardAction;
1695
+ exports.CardContent = CardContent;
1696
+ exports.CardDescription = CardDescription;
1697
+ exports.CardFooter = CardFooter;
1698
+ exports.CardHeader = CardHeader;
1699
+ exports.CardTitle = CardTitle;
1700
+ exports.Select = Select;
1701
+ exports.Slider = Slider;
1702
+ //# sourceMappingURL=index.js.map
1703
+ //# sourceMappingURL=index.js.map