hazo_ui 2.16.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
8
8
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
9
9
  import * as DialogPrimitive from '@radix-ui/react-dialog';
10
- import { X, ChevronDown, ChevronUp, Check, Circle, ChevronRight, ChevronLeft, Filter, Plus, ArrowUpDown, Loader2, AlertTriangle, OctagonAlert, CheckCircle2, ChevronsUpDown, GripVertical, ArrowUp, ArrowDown, Pencil, Calendar as Calendar$1 } from 'lucide-react';
10
+ import { X, ChevronDown, ChevronUp, Check, Circle, ChevronRight, ChevronLeft, Filter, Plus, ArrowUpDown, Loader2, AlertTriangle, OctagonAlert, CheckCircle2, ChevronsUpDown, Download, Share2, Copy, GripVertical, ArrowUp, ArrowDown, Pencil, Calendar as Calendar$1 } from 'lucide-react';
11
11
  import * as PopoverPrimitive from '@radix-ui/react-popover';
12
12
  import * as SelectPrimitive from '@radix-ui/react-select';
13
13
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
@@ -7619,6 +7619,200 @@ function useErrorDisplay() {
7619
7619
  const clearError = useCallback(() => setRaw(null), []);
7620
7620
  return { error, setError, clearError };
7621
7621
  }
7622
+ function useDebounce(value, delayMs) {
7623
+ const [debounced_value, set_debounced_value] = useState(value);
7624
+ useEffect(() => {
7625
+ const timer = setTimeout(() => {
7626
+ set_debounced_value(value);
7627
+ }, delayMs);
7628
+ return () => clearTimeout(timer);
7629
+ }, [value, delayMs]);
7630
+ return debounced_value;
7631
+ }
7632
+ function useCopyToClipboard() {
7633
+ const [copied, set_copied] = useState(false);
7634
+ const copy = useCallback(async (text) => {
7635
+ if (typeof navigator === "undefined" || !navigator.clipboard) {
7636
+ return;
7637
+ }
7638
+ try {
7639
+ await navigator.clipboard.writeText(text);
7640
+ set_copied(true);
7641
+ setTimeout(() => set_copied(false), 2e3);
7642
+ } catch {
7643
+ }
7644
+ }, []);
7645
+ return { copied, copy };
7646
+ }
7647
+
7648
+ // src/hooks/use_is_mobile.ts
7649
+ var DEFAULT_BREAKPOINT_PX = 768;
7650
+ function useIsMobile(breakpointPx = DEFAULT_BREAKPOINT_PX) {
7651
+ return useMediaQuery(`(max-width: ${breakpointPx - 1}px)`);
7652
+ }
7653
+ function useViewport(breakpoint = DEFAULT_BREAKPOINT_PX) {
7654
+ return useIsMobile(breakpoint);
7655
+ }
7656
+ function useLocalStorage(key, initialValue) {
7657
+ const read_stored = () => {
7658
+ if (typeof window === "undefined") return initialValue;
7659
+ try {
7660
+ const raw = window.localStorage.getItem(key);
7661
+ return raw !== null ? JSON.parse(raw) : initialValue;
7662
+ } catch {
7663
+ return initialValue;
7664
+ }
7665
+ };
7666
+ const [stored_value, set_stored_value] = useState(read_stored);
7667
+ const set_value = useCallback(
7668
+ (value) => {
7669
+ set_stored_value((prev) => {
7670
+ const next = typeof value === "function" ? value(prev) : value;
7671
+ try {
7672
+ if (typeof window !== "undefined") {
7673
+ window.localStorage.setItem(key, JSON.stringify(next));
7674
+ }
7675
+ } catch {
7676
+ }
7677
+ return next;
7678
+ });
7679
+ },
7680
+ [key]
7681
+ );
7682
+ return [stored_value, set_value];
7683
+ }
7684
+ function useSessionStorage(key, initialValue) {
7685
+ const read_stored = () => {
7686
+ if (typeof window === "undefined") return initialValue;
7687
+ try {
7688
+ const raw = window.sessionStorage.getItem(key);
7689
+ return raw !== null ? JSON.parse(raw) : initialValue;
7690
+ } catch {
7691
+ return initialValue;
7692
+ }
7693
+ };
7694
+ const [stored_value, set_stored_value] = useState(read_stored);
7695
+ const set_value = useCallback(
7696
+ (value) => {
7697
+ set_stored_value((prev) => {
7698
+ const next = typeof value === "function" ? value(prev) : value;
7699
+ try {
7700
+ if (typeof window !== "undefined") {
7701
+ window.sessionStorage.setItem(key, JSON.stringify(next));
7702
+ }
7703
+ } catch {
7704
+ }
7705
+ return next;
7706
+ });
7707
+ },
7708
+ [key]
7709
+ );
7710
+ return [stored_value, set_value];
7711
+ }
7712
+ function useClickOutside(ref, handler) {
7713
+ useEffect(() => {
7714
+ if (typeof document === "undefined") return;
7715
+ const handle_event = (event) => {
7716
+ const target = event.target;
7717
+ if (!ref.current || !target) return;
7718
+ if (!ref.current.contains(target)) {
7719
+ handler();
7720
+ }
7721
+ };
7722
+ document.addEventListener("mousedown", handle_event);
7723
+ document.addEventListener("touchstart", handle_event);
7724
+ return () => {
7725
+ document.removeEventListener("mousedown", handle_event);
7726
+ document.removeEventListener("touchstart", handle_event);
7727
+ };
7728
+ }, [ref, handler]);
7729
+ }
7730
+ function useWakeLock() {
7731
+ const supported = typeof navigator !== "undefined" && "wakeLock" in navigator;
7732
+ const sentinel_ref = useRef(null);
7733
+ const [acquired, set_acquired] = useState(false);
7734
+ const request = useCallback(async () => {
7735
+ if (!supported || sentinel_ref.current) return;
7736
+ try {
7737
+ const sentinel = await navigator.wakeLock.request("screen");
7738
+ sentinel.addEventListener("release", () => {
7739
+ sentinel_ref.current = null;
7740
+ set_acquired(false);
7741
+ });
7742
+ sentinel_ref.current = sentinel;
7743
+ set_acquired(true);
7744
+ } catch {
7745
+ }
7746
+ }, [supported]);
7747
+ const release = useCallback(async () => {
7748
+ if (!sentinel_ref.current) return;
7749
+ try {
7750
+ await sentinel_ref.current.release();
7751
+ } catch {
7752
+ } finally {
7753
+ sentinel_ref.current = null;
7754
+ set_acquired(false);
7755
+ }
7756
+ }, []);
7757
+ useEffect(() => {
7758
+ if (typeof document === "undefined") return;
7759
+ const handle_visibility = () => {
7760
+ if (document.visibilityState === "visible" && acquired && !sentinel_ref.current) {
7761
+ void request();
7762
+ }
7763
+ };
7764
+ document.addEventListener("visibilitychange", handle_visibility);
7765
+ return () => document.removeEventListener("visibilitychange", handle_visibility);
7766
+ }, [acquired, request]);
7767
+ useEffect(() => {
7768
+ return () => {
7769
+ if (sentinel_ref.current) {
7770
+ void sentinel_ref.current.release().catch(() => void 0);
7771
+ sentinel_ref.current = null;
7772
+ }
7773
+ };
7774
+ }, []);
7775
+ return { supported, acquired, request, release };
7776
+ }
7777
+ function useFullscreen(elementRef) {
7778
+ const [is_fullscreen, set_is_fullscreen] = useState(false);
7779
+ useEffect(() => {
7780
+ if (typeof document === "undefined") return;
7781
+ const handle_change = () => {
7782
+ set_is_fullscreen(!!document.fullscreenElement);
7783
+ };
7784
+ document.addEventListener("fullscreenchange", handle_change);
7785
+ set_is_fullscreen(!!document.fullscreenElement);
7786
+ return () => document.removeEventListener("fullscreenchange", handle_change);
7787
+ }, []);
7788
+ const get_target = useCallback(() => {
7789
+ return elementRef?.current ?? document.documentElement;
7790
+ }, [elementRef]);
7791
+ const enter = useCallback(async () => {
7792
+ if (typeof document === "undefined" || !document.documentElement.requestFullscreen) return;
7793
+ if (document.fullscreenElement) return;
7794
+ try {
7795
+ await get_target().requestFullscreen();
7796
+ } catch {
7797
+ }
7798
+ }, [get_target]);
7799
+ const exit = useCallback(async () => {
7800
+ if (typeof document === "undefined") return;
7801
+ if (!document.fullscreenElement) return;
7802
+ try {
7803
+ await document.exitFullscreen();
7804
+ } catch {
7805
+ }
7806
+ }, []);
7807
+ const toggle = useCallback(async () => {
7808
+ if (document.fullscreenElement) {
7809
+ await exit();
7810
+ } else {
7811
+ await enter();
7812
+ }
7813
+ }, [enter, exit]);
7814
+ return { isFullscreen: is_fullscreen, enter, exit, toggle };
7815
+ }
7622
7816
  function KanbanCard({
7623
7817
  item,
7624
7818
  renderCard,
@@ -9233,7 +9427,1094 @@ function SortIndicator({
9233
9427
  sort.length > 1 && /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium", children: idx + 1 })
9234
9428
  ] });
9235
9429
  }
9430
+ var VBOX_W = 200;
9431
+ var PAD = 2;
9432
+ function Sparkline({
9433
+ data,
9434
+ color: color2,
9435
+ className,
9436
+ height = 40
9437
+ }) {
9438
+ const vbox_h = height;
9439
+ const non_null_values = data.filter((v) => v !== null && !Number.isNaN(v));
9440
+ if (non_null_values.length === 0) {
9441
+ return /* @__PURE__ */ jsx(
9442
+ "svg",
9443
+ {
9444
+ viewBox: `0 0 ${VBOX_W} ${vbox_h}`,
9445
+ preserveAspectRatio: "none",
9446
+ className,
9447
+ style: { width: "100%", height: `${height}px`, display: "block" }
9448
+ }
9449
+ );
9450
+ }
9451
+ const mn = Math.min(...non_null_values);
9452
+ const mx = Math.max(...non_null_values);
9453
+ const rng = mx - mn || 1;
9454
+ const cx = (i) => data.length <= 1 ? VBOX_W / 2 : PAD + i * (VBOX_W - 2 * PAD) / (data.length - 1);
9455
+ const cy = (v) => vbox_h - PAD - (v - mn) * (vbox_h - 2 * PAD) / rng;
9456
+ let line_d = "";
9457
+ data.forEach((v, i) => {
9458
+ if (v === null || Number.isNaN(v)) return;
9459
+ line_d += `${line_d ? " L" : "M"}${cx(i).toFixed(1)},${cy(v).toFixed(1)}`;
9460
+ });
9461
+ const first_non_null_idx = data.findIndex((v) => v !== null && !Number.isNaN(v));
9462
+ const last_idx = data.length - 1;
9463
+ const last_v = data[last_idx];
9464
+ const area_d = line_d && `${line_d} L${cx(last_idx).toFixed(1)},${vbox_h - PAD} L${cx(first_non_null_idx).toFixed(1)},${vbox_h - PAD} Z`;
9465
+ const has_last = last_v !== null && last_v !== void 0 && !Number.isNaN(last_v);
9466
+ return /* @__PURE__ */ jsxs(
9467
+ "svg",
9468
+ {
9469
+ viewBox: `0 0 ${VBOX_W} ${vbox_h}`,
9470
+ preserveAspectRatio: "none",
9471
+ className,
9472
+ style: { width: "100%", height: `${height}px`, display: "block" },
9473
+ children: [
9474
+ area_d && /* @__PURE__ */ jsx("path", { d: area_d, fill: color2, fillOpacity: 0.1, stroke: "none" }),
9475
+ line_d && /* @__PURE__ */ jsx("path", { d: line_d, stroke: color2, strokeWidth: 1.5, fill: "none" }),
9476
+ has_last && /* @__PURE__ */ jsx("circle", { cx: cx(last_idx), cy: cy(last_v), r: 2, fill: color2 })
9477
+ ]
9478
+ }
9479
+ );
9480
+ }
9481
+ var PAD2 = 2;
9482
+ function InverseSparkline({
9483
+ data,
9484
+ color: color2,
9485
+ className,
9486
+ width = 62,
9487
+ height = 18
9488
+ }) {
9489
+ const non_null_values = data.filter((v) => v !== null && !Number.isNaN(v));
9490
+ if (non_null_values.length === 0) {
9491
+ return /* @__PURE__ */ jsx(
9492
+ "svg",
9493
+ {
9494
+ viewBox: `0 0 ${width} ${height}`,
9495
+ preserveAspectRatio: "none",
9496
+ className,
9497
+ style: { width: `${width}px`, height: `${height}px`, display: "block" }
9498
+ }
9499
+ );
9500
+ }
9501
+ const mn = Math.min(...non_null_values);
9502
+ const mx = Math.max(...non_null_values);
9503
+ const rng = mx - mn || 1;
9504
+ const cx = (i) => data.length <= 1 ? width / 2 : PAD2 + i * (width - 2 * PAD2) / (data.length - 1);
9505
+ const cy = (v) => PAD2 + (v - mn) * (height - 2 * PAD2) / rng;
9506
+ let line_d = "";
9507
+ data.forEach((v, i) => {
9508
+ if (v === null || Number.isNaN(v)) return;
9509
+ line_d += `${line_d ? " L" : "M"}${cx(i).toFixed(1)},${cy(v).toFixed(1)}`;
9510
+ });
9511
+ return /* @__PURE__ */ jsx(
9512
+ "svg",
9513
+ {
9514
+ viewBox: `0 0 ${width} ${height}`,
9515
+ preserveAspectRatio: "none",
9516
+ className,
9517
+ style: { width: `${width}px`, height: `${height}px`, display: "block" },
9518
+ children: line_d && /* @__PURE__ */ jsx("path", { d: line_d, stroke: color2, strokeWidth: 1.4, fill: "none" })
9519
+ }
9520
+ );
9521
+ }
9522
+
9523
+ // src/components/hazo_ui_charts/format.ts
9524
+ function format_num(n) {
9525
+ if (n === null || n === void 0) return "";
9526
+ if (typeof n === "string") return n;
9527
+ if (Number.isNaN(n)) return "";
9528
+ const abs = Math.abs(n);
9529
+ if (abs >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
9530
+ if (abs >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
9531
+ if (Number.isInteger(n)) return n.toString();
9532
+ return n.toFixed(1);
9533
+ }
9534
+ function pick_x_label_indices(length) {
9535
+ if (length <= 0) return [0, 0, 0];
9536
+ if (length === 1) return [0, 0, 0];
9537
+ if (length === 2) return [0, 0, 1];
9538
+ return [0, Math.floor(length / 2), length - 1];
9539
+ }
9540
+ var PAD_LEFT = 38;
9541
+ var PAD_RIGHT = 14;
9542
+ var PAD_TOP = 12;
9543
+ var PAD_BOTTOM = 22;
9544
+ var AXIS_LABEL_COLOR = "#8b949e";
9545
+ var GRIDLINE_COLOR = "#2a3441";
9546
+ function compute_geometry(data, width, height) {
9547
+ const vals = data.filter((v) => v !== null && !Number.isNaN(v));
9548
+ if (vals.length === 0) return null;
9549
+ const mn = Math.min(...vals);
9550
+ const mx = Math.max(...vals);
9551
+ const rng = mx - mn || mx * 0.1 + 1;
9552
+ const y_min = Math.max(0, mn - rng * 0.1);
9553
+ const y_max = mx + rng * 0.1;
9554
+ const y_rng = y_max - y_min || 1;
9555
+ const plot_w = width - PAD_LEFT - PAD_RIGHT;
9556
+ const plot_h = height - PAD_TOP - PAD_BOTTOM;
9557
+ return {
9558
+ vbox_w: width,
9559
+ vbox_h: height,
9560
+ y_min,
9561
+ y_max,
9562
+ cx: (i) => data.length <= 1 ? PAD_LEFT + plot_w / 2 : PAD_LEFT + i * plot_w / (data.length - 1),
9563
+ cy: (v) => PAD_TOP + (1 - (v - y_min) / y_rng) * plot_h
9564
+ };
9565
+ }
9566
+ function build_paths(data, g) {
9567
+ let line_d = "";
9568
+ let first_idx = -1;
9569
+ data.forEach((v, i) => {
9570
+ if (v === null || Number.isNaN(v)) return;
9571
+ if (first_idx === -1) first_idx = i;
9572
+ line_d += `${line_d ? " L" : "M"}${g.cx(i).toFixed(1)},${g.cy(v).toFixed(1)}`;
9573
+ });
9574
+ const last_idx = data.length - 1;
9575
+ const last_v = data[last_idx];
9576
+ const area_d = line_d && last_v !== null && last_v !== void 0 && !Number.isNaN(last_v) ? `${line_d} L${g.cx(last_idx).toFixed(1)},${g.vbox_h - PAD_BOTTOM} L${g.cx(first_idx).toFixed(1)},${g.vbox_h - PAD_BOTTOM} Z` : "";
9577
+ return { line_d, area_d };
9578
+ }
9579
+ function LineChart({
9580
+ data,
9581
+ dates,
9582
+ color: color2,
9583
+ width = 360,
9584
+ height = 130,
9585
+ unit = "",
9586
+ showTooltip = true,
9587
+ className
9588
+ }) {
9589
+ const geo = compute_geometry(data, width, height);
9590
+ const svg_ref = React25.useRef(null);
9591
+ const [hover_idx, set_hover_idx] = React25.useState(null);
9592
+ const handle_mouse_move = React25.useCallback(
9593
+ (e) => {
9594
+ if (!geo) return;
9595
+ const rect = e.currentTarget.getBoundingClientRect();
9596
+ if (rect.width === 0) return;
9597
+ const vbox_x = (e.clientX - rect.left) / rect.width * geo.vbox_w;
9598
+ const plot_w = geo.vbox_w - PAD_LEFT - PAD_RIGHT;
9599
+ if (vbox_x < PAD_LEFT || vbox_x > geo.vbox_w - PAD_RIGHT) {
9600
+ set_hover_idx(null);
9601
+ return;
9602
+ }
9603
+ const ratio = (vbox_x - PAD_LEFT) / plot_w;
9604
+ const idx = Math.round(ratio * (data.length - 1));
9605
+ const clamped = Math.max(0, Math.min(data.length - 1, idx));
9606
+ let resolved = clamped;
9607
+ if (data[resolved] === null || Number.isNaN(data[resolved])) {
9608
+ for (let step = 1; step < data.length; step += 1) {
9609
+ const left_i = clamped - step;
9610
+ const right_i = clamped + step;
9611
+ if (left_i >= 0 && data[left_i] !== null && !Number.isNaN(data[left_i])) {
9612
+ resolved = left_i;
9613
+ break;
9614
+ }
9615
+ if (right_i < data.length && data[right_i] !== null && !Number.isNaN(data[right_i])) {
9616
+ resolved = right_i;
9617
+ break;
9618
+ }
9619
+ }
9620
+ }
9621
+ set_hover_idx(resolved);
9622
+ },
9623
+ [geo, data]
9624
+ );
9625
+ const handle_mouse_leave = React25.useCallback(() => set_hover_idx(null), []);
9626
+ if (!geo) {
9627
+ return /* @__PURE__ */ jsx(
9628
+ "svg",
9629
+ {
9630
+ viewBox: `0 0 ${width} ${height}`,
9631
+ className: cn("cls_hazo_chart cls_hazo_chart_empty", className),
9632
+ style: { width: "100%", height: "auto", display: "block", maxHeight: `${height + 10}px` }
9633
+ }
9634
+ );
9635
+ }
9636
+ const { line_d, area_d } = build_paths(data, geo);
9637
+ const x_label_idx = pick_x_label_indices(data.length);
9638
+ const last_idx = data.length - 1;
9639
+ const last_v = data[last_idx];
9640
+ const has_last = last_v !== null && last_v !== void 0 && !Number.isNaN(last_v);
9641
+ const hover_v = hover_idx !== null ? data[hover_idx] : null;
9642
+ const hover_has_v = hover_v !== null && hover_v !== void 0 && !Number.isNaN(hover_v);
9643
+ return /* @__PURE__ */ jsxs(
9644
+ "svg",
9645
+ {
9646
+ ref: svg_ref,
9647
+ viewBox: `0 0 ${width} ${height}`,
9648
+ onMouseMove: showTooltip ? handle_mouse_move : void 0,
9649
+ onMouseLeave: showTooltip ? handle_mouse_leave : void 0,
9650
+ className: cn("cls_hazo_chart", className),
9651
+ style: {
9652
+ width: "100%",
9653
+ height: "auto",
9654
+ display: "block",
9655
+ maxHeight: `${height + 10}px`,
9656
+ cursor: showTooltip ? "crosshair" : "default"
9657
+ },
9658
+ children: [
9659
+ [0, 1, 2].map((i) => {
9660
+ const y = PAD_TOP + i / 2 * (geo.vbox_h - PAD_TOP - PAD_BOTTOM);
9661
+ return /* @__PURE__ */ jsx(
9662
+ "line",
9663
+ {
9664
+ x1: PAD_LEFT,
9665
+ x2: geo.vbox_w - PAD_RIGHT,
9666
+ y1: y,
9667
+ y2: y,
9668
+ stroke: GRIDLINE_COLOR,
9669
+ strokeWidth: 0.5,
9670
+ strokeDasharray: "2,3"
9671
+ },
9672
+ i
9673
+ );
9674
+ }),
9675
+ area_d && /* @__PURE__ */ jsx("path", { d: area_d, fill: color2, fillOpacity: 0.12, stroke: "none" }),
9676
+ line_d && /* @__PURE__ */ jsx("path", { d: line_d, stroke: color2, strokeWidth: 1.8, fill: "none" }),
9677
+ /* @__PURE__ */ jsx("text", { x: PAD_LEFT - 4, y: PAD_TOP + 3, textAnchor: "end", fill: AXIS_LABEL_COLOR, fontSize: 9, children: format_num(geo.y_max) }),
9678
+ /* @__PURE__ */ jsx(
9679
+ "text",
9680
+ {
9681
+ x: PAD_LEFT - 4,
9682
+ y: PAD_TOP + (geo.vbox_h - PAD_TOP - PAD_BOTTOM) / 2 + 3,
9683
+ textAnchor: "end",
9684
+ fill: AXIS_LABEL_COLOR,
9685
+ fontSize: 9,
9686
+ children: format_num((geo.y_max + geo.y_min) / 2)
9687
+ }
9688
+ ),
9689
+ /* @__PURE__ */ jsx(
9690
+ "text",
9691
+ {
9692
+ x: PAD_LEFT - 4,
9693
+ y: geo.vbox_h - PAD_BOTTOM + 3,
9694
+ textAnchor: "end",
9695
+ fill: AXIS_LABEL_COLOR,
9696
+ fontSize: 9,
9697
+ children: format_num(geo.y_min)
9698
+ }
9699
+ ),
9700
+ x_label_idx.map((idx, k) => {
9701
+ const anchor = k === 0 ? "start" : k === 1 ? "middle" : "end";
9702
+ const x_pos = geo.cx(idx);
9703
+ return /* @__PURE__ */ jsx(
9704
+ "text",
9705
+ {
9706
+ x: x_pos,
9707
+ y: geo.vbox_h - 6,
9708
+ textAnchor: anchor,
9709
+ fill: AXIS_LABEL_COLOR,
9710
+ fontSize: 9,
9711
+ children: dates[idx] ?? ""
9712
+ },
9713
+ `x_${k}`
9714
+ );
9715
+ }),
9716
+ has_last && hover_idx === null && (() => {
9717
+ const x = geo.cx(last_idx);
9718
+ const y = geo.cy(last_v);
9719
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
9720
+ /* @__PURE__ */ jsx(
9721
+ "line",
9722
+ {
9723
+ x1: x,
9724
+ x2: PAD_LEFT,
9725
+ y1: y,
9726
+ y2: y,
9727
+ stroke: color2,
9728
+ strokeWidth: 0.5,
9729
+ strokeDasharray: "2,2",
9730
+ opacity: 0.4
9731
+ }
9732
+ ),
9733
+ /* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: 3.5, fill: color2, stroke: color2, strokeWidth: 2, fillOpacity: 0.3 }),
9734
+ /* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: 2, fill: color2 }),
9735
+ /* @__PURE__ */ jsxs("text", { x: x - 6, y: y - 6, textAnchor: "end", fill: color2, fontSize: 10, fontWeight: 700, children: [
9736
+ format_num(last_v),
9737
+ unit
9738
+ ] })
9739
+ ] });
9740
+ })(),
9741
+ showTooltip && hover_idx !== null && hover_has_v && (() => {
9742
+ const x = geo.cx(hover_idx);
9743
+ const y = geo.cy(hover_v);
9744
+ const label = `${format_num(hover_v)}${unit}`;
9745
+ const date = dates[hover_idx] ?? "";
9746
+ const bubble_text_w = Math.max(label.length, date.length) * 5.5 + 12;
9747
+ const bubble_w = Math.max(bubble_text_w, 40);
9748
+ const bubble_h = 26;
9749
+ const flip = x + bubble_w + 6 > geo.vbox_w - PAD_RIGHT;
9750
+ const bubble_x = flip ? x - bubble_w - 6 : x + 6;
9751
+ const bubble_y = Math.max(PAD_TOP, Math.min(y - bubble_h / 2, geo.vbox_h - PAD_BOTTOM - bubble_h));
9752
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
9753
+ /* @__PURE__ */ jsx(
9754
+ "line",
9755
+ {
9756
+ x1: x,
9757
+ x2: x,
9758
+ y1: PAD_TOP,
9759
+ y2: geo.vbox_h - PAD_BOTTOM,
9760
+ stroke: color2,
9761
+ strokeWidth: 0.5,
9762
+ strokeDasharray: "2,2",
9763
+ opacity: 0.6
9764
+ }
9765
+ ),
9766
+ /* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: 3, fill: color2 }),
9767
+ /* @__PURE__ */ jsx(
9768
+ "rect",
9769
+ {
9770
+ x: bubble_x,
9771
+ y: bubble_y,
9772
+ width: bubble_w,
9773
+ height: bubble_h,
9774
+ rx: 3,
9775
+ fill: "#0d1117",
9776
+ stroke: color2,
9777
+ strokeWidth: 0.5,
9778
+ fillOpacity: 0.92
9779
+ }
9780
+ ),
9781
+ /* @__PURE__ */ jsx(
9782
+ "text",
9783
+ {
9784
+ x: bubble_x + bubble_w / 2,
9785
+ y: bubble_y + 11,
9786
+ textAnchor: "middle",
9787
+ fill: color2,
9788
+ fontSize: 10,
9789
+ fontWeight: 700,
9790
+ children: label
9791
+ }
9792
+ ),
9793
+ /* @__PURE__ */ jsx(
9794
+ "text",
9795
+ {
9796
+ x: bubble_x + bubble_w / 2,
9797
+ y: bubble_y + 22,
9798
+ textAnchor: "middle",
9799
+ fill: AXIS_LABEL_COLOR,
9800
+ fontSize: 8,
9801
+ children: date
9802
+ }
9803
+ )
9804
+ ] });
9805
+ })()
9806
+ ]
9807
+ }
9808
+ );
9809
+ }
9810
+ var PAD_LEFT2 = 38;
9811
+ var PAD_RIGHT2 = 14;
9812
+ var PAD_TOP2 = 12;
9813
+ var PAD_BOTTOM2 = 22;
9814
+ var AXIS_LABEL_COLOR2 = "#8b949e";
9815
+ var GRIDLINE_COLOR2 = "#2a3441";
9816
+ function compute_geometry2(series, width, height) {
9817
+ const all_vals = [];
9818
+ let n = 0;
9819
+ for (const s of series) {
9820
+ n = Math.max(n, s.data.length);
9821
+ for (const v of s.data) if (v !== null && !Number.isNaN(v)) all_vals.push(v);
9822
+ }
9823
+ if (all_vals.length === 0 || n === 0) return null;
9824
+ const mn = Math.min(...all_vals);
9825
+ const mx = Math.max(...all_vals);
9826
+ const rng = mx - mn || mx * 0.1 + 1;
9827
+ const y_min = Math.max(0, mn - rng * 0.05);
9828
+ const y_max = mx + rng * 0.05;
9829
+ const y_rng = y_max - y_min || 1;
9830
+ const plot_w = width - PAD_LEFT2 - PAD_RIGHT2;
9831
+ const plot_h = height - PAD_TOP2 - PAD_BOTTOM2;
9832
+ return {
9833
+ vbox_w: width,
9834
+ vbox_h: height,
9835
+ y_min,
9836
+ y_max,
9837
+ point_count: n,
9838
+ cx: (i) => n <= 1 ? PAD_LEFT2 + plot_w / 2 : PAD_LEFT2 + i * plot_w / (n - 1),
9839
+ cy: (v) => PAD_TOP2 + (1 - (v - y_min) / y_rng) * plot_h
9840
+ };
9841
+ }
9842
+ function MultiLineChart({
9843
+ series,
9844
+ dates,
9845
+ width = 360,
9846
+ height = 140,
9847
+ showTooltip = true,
9848
+ showLegend = true,
9849
+ className
9850
+ }) {
9851
+ const geo = compute_geometry2(series, width, height);
9852
+ const [hover_idx, set_hover_idx] = React25.useState(null);
9853
+ const handle_mouse_move = React25.useCallback(
9854
+ (e) => {
9855
+ if (!geo) return;
9856
+ const rect = e.currentTarget.getBoundingClientRect();
9857
+ if (rect.width === 0) return;
9858
+ const vbox_x = (e.clientX - rect.left) / rect.width * geo.vbox_w;
9859
+ const plot_w = geo.vbox_w - PAD_LEFT2 - PAD_RIGHT2;
9860
+ if (vbox_x < PAD_LEFT2 || vbox_x > geo.vbox_w - PAD_RIGHT2) {
9861
+ set_hover_idx(null);
9862
+ return;
9863
+ }
9864
+ const ratio = (vbox_x - PAD_LEFT2) / plot_w;
9865
+ const idx = Math.round(ratio * (geo.point_count - 1));
9866
+ set_hover_idx(Math.max(0, Math.min(geo.point_count - 1, idx)));
9867
+ },
9868
+ [geo]
9869
+ );
9870
+ const handle_mouse_leave = React25.useCallback(() => set_hover_idx(null), []);
9871
+ if (!geo) {
9872
+ return /* @__PURE__ */ jsx(
9873
+ "svg",
9874
+ {
9875
+ viewBox: `0 0 ${width} ${height}`,
9876
+ className: cn("cls_hazo_chart cls_hazo_chart_empty", className),
9877
+ style: { width: "100%", height: "auto", display: "block", maxHeight: `${height + 10}px` }
9878
+ }
9879
+ );
9880
+ }
9881
+ const x_label_idx = pick_x_label_indices(geo.point_count);
9882
+ return /* @__PURE__ */ jsxs("div", { className: cn("cls_hazo_chart_wrapper", className), children: [
9883
+ /* @__PURE__ */ jsxs(
9884
+ "svg",
9885
+ {
9886
+ viewBox: `0 0 ${width} ${height}`,
9887
+ onMouseMove: showTooltip ? handle_mouse_move : void 0,
9888
+ onMouseLeave: showTooltip ? handle_mouse_leave : void 0,
9889
+ className: "cls_hazo_chart cls_hazo_chart_multi",
9890
+ style: {
9891
+ width: "100%",
9892
+ height: "auto",
9893
+ display: "block",
9894
+ maxHeight: `${height + 10}px`,
9895
+ cursor: showTooltip ? "crosshair" : "default"
9896
+ },
9897
+ children: [
9898
+ [0, 1, 2].map((i) => {
9899
+ const y = PAD_TOP2 + i / 2 * (geo.vbox_h - PAD_TOP2 - PAD_BOTTOM2);
9900
+ return /* @__PURE__ */ jsx(
9901
+ "line",
9902
+ {
9903
+ x1: PAD_LEFT2,
9904
+ x2: geo.vbox_w - PAD_RIGHT2,
9905
+ y1: y,
9906
+ y2: y,
9907
+ stroke: GRIDLINE_COLOR2,
9908
+ strokeWidth: 0.5,
9909
+ strokeDasharray: "2,3"
9910
+ },
9911
+ i
9912
+ );
9913
+ }),
9914
+ /* @__PURE__ */ jsx("text", { x: PAD_LEFT2 - 4, y: PAD_TOP2 + 3, textAnchor: "end", fill: AXIS_LABEL_COLOR2, fontSize: 9, children: format_num(geo.y_max) }),
9915
+ /* @__PURE__ */ jsx(
9916
+ "text",
9917
+ {
9918
+ x: PAD_LEFT2 - 4,
9919
+ y: PAD_TOP2 + (geo.vbox_h - PAD_TOP2 - PAD_BOTTOM2) / 2 + 3,
9920
+ textAnchor: "end",
9921
+ fill: AXIS_LABEL_COLOR2,
9922
+ fontSize: 9,
9923
+ children: format_num((geo.y_max + geo.y_min) / 2)
9924
+ }
9925
+ ),
9926
+ /* @__PURE__ */ jsx("text", { x: PAD_LEFT2 - 4, y: geo.vbox_h - PAD_BOTTOM2 + 3, textAnchor: "end", fill: AXIS_LABEL_COLOR2, fontSize: 9, children: format_num(geo.y_min) }),
9927
+ x_label_idx.map((idx, k) => {
9928
+ const anchor = k === 0 ? "start" : k === 1 ? "middle" : "end";
9929
+ return /* @__PURE__ */ jsx(
9930
+ "text",
9931
+ {
9932
+ x: geo.cx(idx),
9933
+ y: geo.vbox_h - 6,
9934
+ textAnchor: anchor,
9935
+ fill: AXIS_LABEL_COLOR2,
9936
+ fontSize: 9,
9937
+ children: dates[idx] ?? ""
9938
+ },
9939
+ `x_${k}`
9940
+ );
9941
+ }),
9942
+ series.map((s, s_idx) => {
9943
+ let d = "";
9944
+ s.data.forEach((v, i) => {
9945
+ if (v === null || Number.isNaN(v)) return;
9946
+ d += `${d ? " L" : "M"}${geo.cx(i).toFixed(1)},${geo.cy(v).toFixed(1)}`;
9947
+ });
9948
+ const last_idx = s.data.length - 1;
9949
+ const last_v = s.data[last_idx];
9950
+ const has_last = last_v !== null && last_v !== void 0 && !Number.isNaN(last_v);
9951
+ return /* @__PURE__ */ jsxs("g", { children: [
9952
+ d && /* @__PURE__ */ jsx("path", { d, stroke: s.color, strokeWidth: 1.7, fill: "none" }),
9953
+ has_last && hover_idx === null && /* @__PURE__ */ jsxs(Fragment$1, { children: [
9954
+ /* @__PURE__ */ jsx(
9955
+ "circle",
9956
+ {
9957
+ cx: geo.cx(last_idx),
9958
+ cy: geo.cy(last_v),
9959
+ r: 3,
9960
+ fill: s.color,
9961
+ fillOpacity: 0.3,
9962
+ stroke: s.color,
9963
+ strokeWidth: 1.5
9964
+ }
9965
+ ),
9966
+ /* @__PURE__ */ jsx(
9967
+ "text",
9968
+ {
9969
+ x: geo.cx(last_idx) - 5,
9970
+ y: geo.cy(last_v) - 5,
9971
+ textAnchor: "end",
9972
+ fill: s.color,
9973
+ fontSize: 9,
9974
+ fontWeight: 700,
9975
+ children: format_num(last_v)
9976
+ }
9977
+ )
9978
+ ] })
9979
+ ] }, `series_${s_idx}`);
9980
+ }),
9981
+ showTooltip && hover_idx !== null && (() => {
9982
+ const x = geo.cx(hover_idx);
9983
+ const items = series.map((s) => ({
9984
+ label: s.label,
9985
+ color: s.color,
9986
+ value: s.data[hover_idx] ?? null
9987
+ })).filter((it) => it.value !== null && !Number.isNaN(it.value));
9988
+ if (items.length === 0) return null;
9989
+ const bubble_w = 70;
9990
+ const row_h = 12;
9991
+ const bubble_h = items.length * row_h + 18;
9992
+ const flip = x + bubble_w + 6 > geo.vbox_w - PAD_RIGHT2;
9993
+ const bubble_x = flip ? x - bubble_w - 6 : x + 6;
9994
+ const bubble_y = Math.max(PAD_TOP2, Math.min(PAD_TOP2 + 5, geo.vbox_h - PAD_BOTTOM2 - bubble_h));
9995
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
9996
+ /* @__PURE__ */ jsx(
9997
+ "line",
9998
+ {
9999
+ x1: x,
10000
+ x2: x,
10001
+ y1: PAD_TOP2,
10002
+ y2: geo.vbox_h - PAD_BOTTOM2,
10003
+ stroke: AXIS_LABEL_COLOR2,
10004
+ strokeWidth: 0.5,
10005
+ strokeDasharray: "2,2",
10006
+ opacity: 0.6
10007
+ }
10008
+ ),
10009
+ items.map((it) => /* @__PURE__ */ jsx(
10010
+ "circle",
10011
+ {
10012
+ cx: x,
10013
+ cy: geo.cy(it.value),
10014
+ r: 3,
10015
+ fill: it.color
10016
+ },
10017
+ `hd_${it.label}`
10018
+ )),
10019
+ /* @__PURE__ */ jsx(
10020
+ "rect",
10021
+ {
10022
+ x: bubble_x,
10023
+ y: bubble_y,
10024
+ width: bubble_w,
10025
+ height: bubble_h,
10026
+ rx: 3,
10027
+ fill: "#0d1117",
10028
+ stroke: AXIS_LABEL_COLOR2,
10029
+ strokeWidth: 0.5,
10030
+ fillOpacity: 0.92
10031
+ }
10032
+ ),
10033
+ /* @__PURE__ */ jsx("text", { x: bubble_x + 6, y: bubble_y + 10, fill: AXIS_LABEL_COLOR2, fontSize: 8, children: dates[hover_idx] ?? "" }),
10034
+ items.map((it, i) => /* @__PURE__ */ jsxs("g", { children: [
10035
+ /* @__PURE__ */ jsx(
10036
+ "rect",
10037
+ {
10038
+ x: bubble_x + 6,
10039
+ y: bubble_y + 14 + i * row_h,
10040
+ width: 6,
10041
+ height: 6,
10042
+ fill: it.color
10043
+ }
10044
+ ),
10045
+ /* @__PURE__ */ jsx(
10046
+ "text",
10047
+ {
10048
+ x: bubble_x + 16,
10049
+ y: bubble_y + 20 + i * row_h,
10050
+ fill: it.color,
10051
+ fontSize: 9,
10052
+ fontWeight: 600,
10053
+ children: format_num(it.value)
10054
+ }
10055
+ )
10056
+ ] }, `row_${i}`))
10057
+ ] });
10058
+ })()
10059
+ ]
10060
+ }
10061
+ ),
10062
+ showLegend && /* @__PURE__ */ jsx(
10063
+ "div",
10064
+ {
10065
+ className: "cls_hazo_chart_legend",
10066
+ style: {
10067
+ display: "flex",
10068
+ gap: "12px",
10069
+ justifyContent: "center",
10070
+ marginTop: "4px",
10071
+ fontSize: "10px",
10072
+ color: AXIS_LABEL_COLOR2,
10073
+ flexWrap: "wrap"
10074
+ },
10075
+ children: series.map((s) => /* @__PURE__ */ jsxs(
10076
+ "span",
10077
+ {
10078
+ style: { display: "inline-flex", alignItems: "center", gap: "4px" },
10079
+ children: [
10080
+ /* @__PURE__ */ jsx(
10081
+ "i",
10082
+ {
10083
+ style: {
10084
+ display: "inline-block",
10085
+ width: "8px",
10086
+ height: "8px",
10087
+ background: s.color,
10088
+ borderRadius: "1px"
10089
+ }
10090
+ }
10091
+ ),
10092
+ s.label
10093
+ ]
10094
+ },
10095
+ s.label
10096
+ ))
10097
+ }
10098
+ )
10099
+ ] });
10100
+ }
10101
+ var PAD_LEFT3 = 32;
10102
+ var PAD_RIGHT3 = 8;
10103
+ var PAD_TOP3 = 10;
10104
+ var PAD_BOTTOM3 = 22;
10105
+ var BAR_GAP_RATIO = 0.25;
10106
+ var AXIS_LABEL_COLOR3 = "#8b949e";
10107
+ function StackedBars({
10108
+ bars,
10109
+ width = 360,
10110
+ height = 140,
10111
+ showYAxis = true,
10112
+ className
10113
+ }) {
10114
+ const totals = bars.map((b) => b.segments.reduce((sum, s) => sum + s.value, 0));
10115
+ const y_max = Math.max(0, ...totals) || 1;
10116
+ const plot_w = width - PAD_LEFT3 - PAD_RIGHT3;
10117
+ const plot_h = height - PAD_TOP3 - PAD_BOTTOM3;
10118
+ const slot_w = bars.length > 0 ? plot_w / bars.length : 0;
10119
+ const bar_w = slot_w * (1 - BAR_GAP_RATIO);
10120
+ const x_for = (i) => PAD_LEFT3 + i * slot_w + (slot_w - bar_w) / 2;
10121
+ const x_label_idx = pick_x_label_indices(bars.length);
10122
+ return /* @__PURE__ */ jsxs(
10123
+ "svg",
10124
+ {
10125
+ viewBox: `0 0 ${width} ${height}`,
10126
+ className: cn("cls_hazo_chart cls_hazo_chart_stacked_bars", className),
10127
+ style: { width: "100%", height: "auto", display: "block", maxHeight: `${height + 10}px` },
10128
+ children: [
10129
+ showYAxis && /* @__PURE__ */ jsxs(Fragment$1, { children: [
10130
+ /* @__PURE__ */ jsx("text", { x: PAD_LEFT3 - 4, y: PAD_TOP3 + 3, textAnchor: "end", fill: AXIS_LABEL_COLOR3, fontSize: 9, children: format_num(y_max) }),
10131
+ /* @__PURE__ */ jsx(
10132
+ "text",
10133
+ {
10134
+ x: PAD_LEFT3 - 4,
10135
+ y: PAD_TOP3 + plot_h / 2 + 3,
10136
+ textAnchor: "end",
10137
+ fill: AXIS_LABEL_COLOR3,
10138
+ fontSize: 9,
10139
+ children: format_num(y_max / 2)
10140
+ }
10141
+ ),
10142
+ /* @__PURE__ */ jsx(
10143
+ "text",
10144
+ {
10145
+ x: PAD_LEFT3 - 4,
10146
+ y: height - PAD_BOTTOM3 + 3,
10147
+ textAnchor: "end",
10148
+ fill: AXIS_LABEL_COLOR3,
10149
+ fontSize: 9,
10150
+ children: "0"
10151
+ }
10152
+ )
10153
+ ] }),
10154
+ bars.map((bar, i) => {
10155
+ let cursor_y = height - PAD_BOTTOM3;
10156
+ return /* @__PURE__ */ jsx("g", { children: bar.segments.map((seg, s_idx) => {
10157
+ if (seg.value <= 0) return null;
10158
+ const seg_h = seg.value / y_max * plot_h;
10159
+ const y = cursor_y - seg_h;
10160
+ cursor_y = y;
10161
+ return /* @__PURE__ */ jsx(
10162
+ "rect",
10163
+ {
10164
+ x: x_for(i),
10165
+ y,
10166
+ width: bar_w,
10167
+ height: seg_h,
10168
+ fill: seg.color
10169
+ },
10170
+ `seg_${s_idx}`
10171
+ );
10172
+ }) }, `bar_${i}`);
10173
+ }),
10174
+ x_label_idx.map((idx, k) => {
10175
+ const anchor = k === 0 ? "start" : k === 1 ? "middle" : "end";
10176
+ const x_pos = x_for(idx) + bar_w / 2;
10177
+ return /* @__PURE__ */ jsx(
10178
+ "text",
10179
+ {
10180
+ x: x_pos,
10181
+ y: height - 6,
10182
+ textAnchor: anchor,
10183
+ fill: AXIS_LABEL_COLOR3,
10184
+ fontSize: 9,
10185
+ children: bars[idx]?.label ?? ""
10186
+ },
10187
+ `x_${k}`
10188
+ );
10189
+ })
10190
+ ]
10191
+ }
10192
+ );
10193
+ }
10194
+ function DateRangeSelector({
10195
+ value,
10196
+ onChange,
10197
+ options,
10198
+ className,
10199
+ ariaLabel = "Date range"
10200
+ }) {
10201
+ return /* @__PURE__ */ jsx(
10202
+ "div",
10203
+ {
10204
+ role: "group",
10205
+ "aria-label": ariaLabel,
10206
+ className: cn(
10207
+ "cls_hazo_date_range_selector inline-flex items-center gap-0 rounded-md border bg-background p-0.5",
10208
+ className
10209
+ ),
10210
+ children: options.map((opt) => {
10211
+ const is_active = opt.value === value;
10212
+ return /* @__PURE__ */ jsx(
10213
+ "button",
10214
+ {
10215
+ type: "button",
10216
+ "aria-pressed": is_active,
10217
+ onClick: () => {
10218
+ if (!is_active) onChange(opt.value);
10219
+ },
10220
+ className: cn(
10221
+ "cls_hazo_date_range_option px-2.5 py-1 text-xs font-medium rounded-sm transition-colors",
10222
+ is_active ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground hover:bg-muted"
10223
+ ),
10224
+ children: opt.label
10225
+ },
10226
+ opt.value
10227
+ );
10228
+ })
10229
+ }
10230
+ );
10231
+ }
10232
+
10233
+ // src/assets/celebration-chime.mp3
10234
+ var celebration_chime_default = "data:text/plain;charset=utf-8,";
10235
+ var CELEBRATION_GRADIENT = "linear-gradient(135deg, #667eea 0%, #764ba2 100%)";
10236
+ var CARD_SIZE = 1080;
10237
+ var PREVIEW_SIZE = 400;
10238
+ var CARD_SCALE = PREVIEW_SIZE / CARD_SIZE;
10239
+ var _enqueue = null;
10240
+ function celebrate(payload) {
10241
+ if (!_enqueue) {
10242
+ if (process.env.NODE_ENV !== "production") {
10243
+ console.warn(
10244
+ "[hazo_ui] celebrate() called before <CelebrationProvider /> was mounted"
10245
+ );
10246
+ }
10247
+ return;
10248
+ }
10249
+ _enqueue(payload);
10250
+ }
10251
+ function CelebrationProvider({ children }) {
10252
+ const [queue, set_queue] = React25.useState([]);
10253
+ const enqueue = React25.useCallback((payload) => {
10254
+ const storage_key = `hazo_ui_celebration_${payload.id}`;
10255
+ if (typeof window !== "undefined" && sessionStorage.getItem(storage_key)) {
10256
+ return;
10257
+ }
10258
+ set_queue((q) => [...q, payload]);
10259
+ }, []);
10260
+ React25.useEffect(() => {
10261
+ _enqueue = enqueue;
10262
+ return () => {
10263
+ _enqueue = null;
10264
+ };
10265
+ }, [enqueue]);
10266
+ const handle_close = React25.useCallback(() => {
10267
+ set_queue((q) => q.slice(1));
10268
+ }, []);
10269
+ const current = queue[0] ?? null;
10270
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
10271
+ children,
10272
+ current && /* @__PURE__ */ jsx(
10273
+ CelebrationModalInner,
10274
+ {
10275
+ payload: current,
10276
+ onClose: handle_close
10277
+ },
10278
+ current.id
10279
+ )
10280
+ ] });
10281
+ }
10282
+ function CelebrationModalInner({
10283
+ payload,
10284
+ onClose
10285
+ }) {
10286
+ const {
10287
+ id,
10288
+ title,
10289
+ subtitle,
10290
+ shareableCard,
10291
+ autoDismiss = true,
10292
+ autoDismissDelay = 8e3,
10293
+ audioChime = false
10294
+ } = payload;
10295
+ const [visible, set_visible] = React25.useState(true);
10296
+ const [is_downloading, set_is_downloading] = React25.useState(false);
10297
+ const canvas_ref = React25.useRef(null);
10298
+ const card_ref = React25.useRef(null);
10299
+ React25.useEffect(() => {
10300
+ sessionStorage.setItem(`hazo_ui_celebration_${id}`, "1");
10301
+ }, [id]);
10302
+ React25.useEffect(() => {
10303
+ if (!canvas_ref.current) return;
10304
+ let confetti_instance = null;
10305
+ import('canvas-confetti').then(({ default: confetti }) => {
10306
+ if (!canvas_ref.current) return;
10307
+ confetti_instance = confetti.create(canvas_ref.current, { resize: true });
10308
+ confetti_instance({
10309
+ particleCount: 120,
10310
+ spread: 70,
10311
+ origin: { y: 0.5 },
10312
+ colors: ["#667eea", "#764ba2", "#f6d365", "#fda085", "#84fab0"]
10313
+ });
10314
+ });
10315
+ return () => {
10316
+ confetti_instance?.reset();
10317
+ };
10318
+ }, []);
10319
+ React25.useEffect(() => {
10320
+ if (!audioChime) return;
10321
+ const audio = new Audio(celebration_chime_default);
10322
+ audio.play().catch(() => {
10323
+ });
10324
+ }, [audioChime]);
10325
+ React25.useEffect(() => {
10326
+ if (!autoDismiss) return;
10327
+ const timer = window.setTimeout(close_modal, autoDismissDelay);
10328
+ return () => window.clearTimeout(timer);
10329
+ }, [autoDismiss, autoDismissDelay]);
10330
+ React25.useEffect(() => {
10331
+ const on_key = (e) => {
10332
+ if (e.key === "Escape") close_modal();
10333
+ };
10334
+ document.addEventListener("keydown", on_key);
10335
+ return () => document.removeEventListener("keydown", on_key);
10336
+ }, []);
10337
+ function close_modal() {
10338
+ set_visible(false);
10339
+ setTimeout(onClose, 150);
10340
+ }
10341
+ async function handle_download() {
10342
+ if (!card_ref.current) return;
10343
+ set_is_downloading(true);
10344
+ try {
10345
+ const { toPng } = await import('html-to-image');
10346
+ const data_url = await toPng(card_ref.current, {
10347
+ width: CARD_SIZE,
10348
+ height: CARD_SIZE
10349
+ });
10350
+ const a = document.createElement("a");
10351
+ a.download = `${id}.png`;
10352
+ a.href = data_url;
10353
+ a.click();
10354
+ } catch (err) {
10355
+ console.error("[hazo_ui] CelebrationModal: download failed", err);
10356
+ } finally {
10357
+ set_is_downloading(false);
10358
+ }
10359
+ }
10360
+ async function handle_share() {
10361
+ if (!card_ref.current || !navigator.share) return;
10362
+ try {
10363
+ const { toPng } = await import('html-to-image');
10364
+ const data_url = await toPng(card_ref.current, {
10365
+ width: CARD_SIZE,
10366
+ height: CARD_SIZE
10367
+ });
10368
+ const blob = await fetch(data_url).then((r) => r.blob());
10369
+ await navigator.share({
10370
+ files: [new File([blob], `${id}.png`, { type: "image/png" })]
10371
+ });
10372
+ } catch (err) {
10373
+ console.error("[hazo_ui] CelebrationModal: share failed", err);
10374
+ }
10375
+ }
10376
+ async function handle_copy() {
10377
+ if (!card_ref.current) return;
10378
+ try {
10379
+ const { toPng } = await import('html-to-image');
10380
+ const data_url = await toPng(card_ref.current, {
10381
+ width: CARD_SIZE,
10382
+ height: CARD_SIZE
10383
+ });
10384
+ const blob = await fetch(data_url).then((r) => r.blob());
10385
+ await navigator.clipboard.write([
10386
+ new ClipboardItem({ "image/png": blob })
10387
+ ]);
10388
+ } catch (err) {
10389
+ console.error("[hazo_ui] CelebrationModal: copy failed", err);
10390
+ }
10391
+ }
10392
+ const resolved_caption = shareableCard?.caption ?? subtitle;
10393
+ const card_bg = shareableCard?.background ?? CELEBRATION_GRADIENT;
10394
+ const can_share = typeof navigator !== "undefined" && "share" in navigator;
10395
+ return /* @__PURE__ */ jsxs(
10396
+ "div",
10397
+ {
10398
+ className: cn(
10399
+ "cls_celebration_modal_overlay",
10400
+ "fixed inset-0 z-50 flex items-center justify-center",
10401
+ "bg-black/30 backdrop-blur-sm",
10402
+ "transition-opacity duration-150",
10403
+ visible ? "opacity-100" : "opacity-0 pointer-events-none"
10404
+ ),
10405
+ onClick: close_modal,
10406
+ children: [
10407
+ /* @__PURE__ */ jsx(
10408
+ "canvas",
10409
+ {
10410
+ ref: canvas_ref,
10411
+ className: "cls_celebration_confetti_canvas absolute inset-0 w-full h-full pointer-events-none"
10412
+ }
10413
+ ),
10414
+ /* @__PURE__ */ jsxs(
10415
+ "div",
10416
+ {
10417
+ className: cn(
10418
+ "cls_celebration_modal_card",
10419
+ "relative bg-white rounded-2xl shadow-2xl",
10420
+ "flex flex-col items-center overflow-hidden",
10421
+ "transition-transform duration-150",
10422
+ visible ? "scale-100" : "scale-95"
10423
+ ),
10424
+ style: { width: 480, maxWidth: "95vw" },
10425
+ onClick: (e) => e.stopPropagation(),
10426
+ children: [
10427
+ /* @__PURE__ */ jsx(
10428
+ "button",
10429
+ {
10430
+ className: "cls_celebration_close_btn absolute top-3 right-3 z-10 p-1.5 rounded-full hover:bg-black/10 transition-colors",
10431
+ onClick: close_modal,
10432
+ "aria-label": "Close celebration",
10433
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4 text-gray-600" })
10434
+ }
10435
+ ),
10436
+ /* @__PURE__ */ jsxs("div", { className: "cls_celebration_header px-8 pt-8 pb-5 text-center", children: [
10437
+ /* @__PURE__ */ jsx("h2", { className: "cls_celebration_title text-2xl font-bold text-gray-900", children: title }),
10438
+ subtitle && /* @__PURE__ */ jsx("p", { className: "cls_celebration_subtitle mt-1.5 text-sm text-gray-500 leading-relaxed", children: subtitle })
10439
+ ] }),
10440
+ shareableCard && /* @__PURE__ */ jsxs(Fragment$1, { children: [
10441
+ /* @__PURE__ */ jsx(
10442
+ "div",
10443
+ {
10444
+ className: "cls_celebration_card_preview_wrapper overflow-hidden rounded-lg mx-8",
10445
+ style: { width: PREVIEW_SIZE, height: PREVIEW_SIZE },
10446
+ children: /* @__PURE__ */ jsxs(
10447
+ "div",
10448
+ {
10449
+ ref: card_ref,
10450
+ className: "cls_celebration_card_inner",
10451
+ style: {
10452
+ width: CARD_SIZE,
10453
+ height: CARD_SIZE,
10454
+ transform: `scale(${CARD_SCALE})`,
10455
+ transformOrigin: "top left",
10456
+ background: card_bg,
10457
+ display: "flex",
10458
+ flexDirection: "column",
10459
+ alignItems: "center",
10460
+ justifyContent: "center",
10461
+ padding: 80,
10462
+ boxSizing: "border-box"
10463
+ },
10464
+ children: [
10465
+ shareableCard.foreground,
10466
+ resolved_caption && /* @__PURE__ */ jsx(
10467
+ "p",
10468
+ {
10469
+ style: {
10470
+ marginTop: 32,
10471
+ fontSize: 36,
10472
+ color: "white",
10473
+ textAlign: "center",
10474
+ fontWeight: 600,
10475
+ lineHeight: 1.3
10476
+ },
10477
+ children: resolved_caption
10478
+ }
10479
+ )
10480
+ ]
10481
+ }
10482
+ )
10483
+ }
10484
+ ),
10485
+ /* @__PURE__ */ jsxs("div", { className: "cls_celebration_card_actions flex flex-wrap gap-2 px-8 py-5", children: [
10486
+ /* @__PURE__ */ jsxs(
10487
+ Button,
10488
+ {
10489
+ className: "cls_celebration_download_btn",
10490
+ size: "sm",
10491
+ onClick: handle_download,
10492
+ disabled: is_downloading,
10493
+ children: [
10494
+ is_downloading ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 mr-1.5 animate-spin" }) : /* @__PURE__ */ jsx(Download, { className: "h-3.5 w-3.5 mr-1.5" }),
10495
+ "Download PNG"
10496
+ ]
10497
+ }
10498
+ ),
10499
+ can_share && /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: handle_share, children: [
10500
+ /* @__PURE__ */ jsx(Share2, { className: "h-3.5 w-3.5 mr-1.5" }),
10501
+ "Share"
10502
+ ] }),
10503
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: handle_copy, children: [
10504
+ /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5 mr-1.5" }),
10505
+ "Copy image"
10506
+ ] })
10507
+ ] })
10508
+ ] }),
10509
+ !shareableCard && /* @__PURE__ */ jsx("div", { className: "cls_celebration_footer pb-8", children: /* @__PURE__ */ jsx(Button, { size: "sm", onClick: close_modal, children: "Dismiss" }) })
10510
+ ]
10511
+ }
10512
+ )
10513
+ ]
10514
+ }
10515
+ );
10516
+ }
9236
10517
 
9237
- export { ANIMATION_PRESETS, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CommandNodeExtension, CommandPill, CommandPopover, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ErrorBanner, ErrorPage, HazoUiConfirmDialog, HazoUiDialog, DialogClose as HazoUiDialogClose, DialogContent as HazoUiDialogContent, DialogDescription as HazoUiDialogDescription, DialogFooter as HazoUiDialogFooter, DialogHeader as HazoUiDialogHeader, DialogOverlay as HazoUiDialogOverlay, DialogPortal as HazoUiDialogPortal, Dialog as HazoUiDialogRoot, DialogTitle as HazoUiDialogTitle, DialogTrigger as HazoUiDialogTrigger, HazoUiFlexInput, HazoUiFlexRadio, HazoUiKanban, HazoUiKanbanFilter, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiPillRadio, HazoUiRte, HazoUiTable, HazoUiTextarea, HazoUiTextbox, HazoUiToaster, HoverCard, HoverCardContent, HoverCardTrigger, Input, Label3 as Label, LoadingTimeout, Popover, PopoverContent, PopoverTrigger, ProgressiveImage, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Command as ShadcnCommand, CommandEmpty as ShadcnCommandEmpty, CommandGroup as ShadcnCommandGroup, CommandInput as ShadcnCommandInput, CommandItem as ShadcnCommandItem, CommandList as ShadcnCommandList, Skeleton, SkeletonBar, SkeletonCircle, SkeletonGroup, SkeletonRect, Spinner, Switch, Table2 as Table, TableBody, TableCaption, TableCell2 as TableCell, TableFooter, TableHead, TableHeader2 as TableHeader, TableRow2 as TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, applyKanbanFilter, buttonGroupVariants, create_command_suggestion_extension, errorToast, get_hazo_ui_config, parse_commands_from_text, reset_hazo_ui_config, resolve_animation_classes, set_hazo_ui_config, successToast, text_to_tiptap_content, toggleVariants, useErrorDisplay, useLoadingState, useMediaQuery };
10518
+ export { ANIMATION_PRESETS, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CELEBRATION_GRADIENT, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CelebrationProvider, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CommandNodeExtension, CommandPill, CommandPopover, DateRangeSelector, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ErrorBanner, ErrorPage, HazoUiConfirmDialog, HazoUiDialog, DialogClose as HazoUiDialogClose, DialogContent as HazoUiDialogContent, DialogDescription as HazoUiDialogDescription, DialogFooter as HazoUiDialogFooter, DialogHeader as HazoUiDialogHeader, DialogOverlay as HazoUiDialogOverlay, DialogPortal as HazoUiDialogPortal, Dialog as HazoUiDialogRoot, DialogTitle as HazoUiDialogTitle, DialogTrigger as HazoUiDialogTrigger, HazoUiFlexInput, HazoUiFlexRadio, HazoUiKanban, HazoUiKanbanFilter, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiPillRadio, HazoUiRte, HazoUiTable, HazoUiTextarea, HazoUiTextbox, HazoUiToaster, HoverCard, HoverCardContent, HoverCardTrigger, Input, InverseSparkline, Label3 as Label, LineChart, LoadingTimeout, MultiLineChart, Popover, PopoverContent, PopoverTrigger, ProgressiveImage, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Command as ShadcnCommand, CommandEmpty as ShadcnCommandEmpty, CommandGroup as ShadcnCommandGroup, CommandInput as ShadcnCommandInput, CommandItem as ShadcnCommandItem, CommandList as ShadcnCommandList, Skeleton, SkeletonBar, SkeletonCircle, SkeletonGroup, SkeletonRect, Sparkline, Spinner, StackedBars, Switch, Table2 as Table, TableBody, TableCaption, TableCell2 as TableCell, TableFooter, TableHead, TableHeader2 as TableHeader, TableRow2 as TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, applyKanbanFilter, buttonGroupVariants, celebrate, create_command_suggestion_extension, errorToast, format_num, get_hazo_ui_config, parse_commands_from_text, pick_x_label_indices, reset_hazo_ui_config, resolve_animation_classes, set_hazo_ui_config, successToast, text_to_tiptap_content, toggleVariants, useClickOutside, useCopyToClipboard, useDebounce, useErrorDisplay, useFullscreen, useIsMobile, useLoadingState, useLocalStorage, useMediaQuery, useSessionStorage, useViewport, useWakeLock };
9238
10519
  //# sourceMappingURL=index.js.map
9239
10520
  //# sourceMappingURL=index.js.map