@knocklabs/react 0.11.18 → 0.11.19

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 (23) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/modules/guide/components/Toolbar/V2/FocusChin.js +1 -1
  3. package/dist/cjs/modules/guide/components/Toolbar/V2/FocusChin.js.map +1 -1
  4. package/dist/cjs/modules/guide/components/Toolbar/V2/Kbd.js +2 -0
  5. package/dist/cjs/modules/guide/components/Toolbar/V2/Kbd.js.map +1 -0
  6. package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js +1 -1
  7. package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js.map +1 -1
  8. package/dist/cjs/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.js +1 -1
  9. package/dist/cjs/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.js.map +1 -1
  10. package/dist/esm/modules/guide/components/Toolbar/V2/FocusChin.mjs +89 -57
  11. package/dist/esm/modules/guide/components/Toolbar/V2/FocusChin.mjs.map +1 -1
  12. package/dist/esm/modules/guide/components/Toolbar/V2/Kbd.mjs +14 -0
  13. package/dist/esm/modules/guide/components/Toolbar/V2/Kbd.mjs.map +1 -0
  14. package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs +39 -46
  15. package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs.map +1 -1
  16. package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs +69 -65
  17. package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs.map +1 -1
  18. package/dist/types/modules/guide/components/Toolbar/V2/FocusChin.d.ts.map +1 -1
  19. package/dist/types/modules/guide/components/Toolbar/V2/Kbd.d.ts +5 -0
  20. package/dist/types/modules/guide/components/Toolbar/V2/Kbd.d.ts.map +1 -0
  21. package/dist/types/modules/guide/components/Toolbar/V2/V2.d.ts.map +1 -1
  22. package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts.map +1 -1
  23. package/package.json +1 -1
@@ -1,80 +1,112 @@
1
- import { useGuideContext as h, useStore as y } from "@knocklabs/react-core";
2
- import { Button as d } from "@telegraph/button";
3
- import { Box as x, Stack as f } from "@telegraph/layout";
4
- import { Tooltip as m } from "@telegraph/tooltip";
5
- import { Text as E } from "@telegraph/typography";
6
- import { ChevronLeft as v, ChevronRight as k, X as C } from "lucide-react";
7
- import * as t from "react";
8
- import { GUIDE_ROW_DATA_SELECTOR as T } from "./GuideRow.mjs";
9
- import { sharedTooltipProps as p } from "./helpers.mjs";
10
- const b = 60, g = (o, i) => {
1
+ import { useGuideContext as v, useStore as x } from "@knocklabs/react-core";
2
+ import { Button as f } from "@telegraph/button";
3
+ import { Box as C, Stack as m } from "@telegraph/layout";
4
+ import { Tooltip as p } from "@telegraph/tooltip";
5
+ import { Text as b } from "@telegraph/typography";
6
+ import { ChevronLeft as w, ChevronRight as T, X as S } from "lucide-react";
7
+ import * as e from "react";
8
+ import { GUIDE_ROW_DATA_SELECTOR as O } from "./GuideRow.mjs";
9
+ import { Kbd as d } from "./Kbd.mjs";
10
+ import { sharedTooltipProps as E } from "./helpers.mjs";
11
+ const h = 60, R = ",", G = "/", I = (r, l) => {
11
12
  requestAnimationFrame(() => {
12
- const r = o.querySelector(`[${T}="${CSS.escape(i)}"]`);
13
- if (!r || !(r instanceof HTMLElement)) return;
14
- const e = o.getBoundingClientRect(), c = r.getBoundingClientRect();
15
- c.top < e.top ? o.scrollTo({
16
- top: o.scrollTop - (e.top - c.top) - b,
13
+ const o = r.querySelector(`[${O}="${CSS.escape(l)}"]`);
14
+ if (!o || !(o instanceof HTMLElement)) return;
15
+ const t = r.getBoundingClientRect(), n = o.getBoundingClientRect();
16
+ n.top < t.top ? r.scrollTo({
17
+ top: r.scrollTop - (t.top - n.top) - h,
17
18
  behavior: "smooth"
18
- }) : c.bottom > e.bottom && o.scrollTo({
19
- top: o.scrollTop + (c.bottom - e.bottom) + b,
19
+ }) : n.bottom > t.bottom && r.scrollTo({
20
+ top: r.scrollTop + (n.bottom - t.bottom) + h,
20
21
  behavior: "smooth"
21
22
  });
22
23
  });
23
- }, z = ({
24
- guides: o,
25
- guideListRef: i
24
+ }, y = ({
25
+ guides: r,
26
+ currentKey: l,
27
+ focusGuide: o
28
+ }) => {
29
+ const t = r.filter((c) => !!c.annotation.selectable.status);
30
+ if (t.length === 0) return;
31
+ if (!l) {
32
+ o(t[t.length - 1].key);
33
+ return;
34
+ }
35
+ const n = t.findIndex((c) => c.key === l), s = n <= 0 ? void 0 : t[n - 1];
36
+ s && o(s.key);
37
+ }, k = ({
38
+ guides: r,
39
+ currentKey: l,
40
+ focusGuide: o
41
+ }) => {
42
+ const t = r.filter((c) => !!c.annotation.selectable.status);
43
+ if (t.length === 0) return;
44
+ if (!l) {
45
+ o(t[0].key);
46
+ return;
47
+ }
48
+ const n = t.findIndex((c) => c.key === l), s = n < 0 || n + 1 > t.length - 1 ? void 0 : t[n + 1];
49
+ s && o(s.key);
50
+ }, A = ({
51
+ guides: r,
52
+ guideListRef: l
26
53
  }) => {
27
54
  const {
28
- client: r
29
- } = h(), {
30
- debugSettings: e
31
- } = y(r.store, (n) => ({
32
- debugSettings: n.debug
33
- })), c = Object.keys((e == null ? void 0 : e.focusedGuideKeys) || {});
34
- if (!(c.length > 0))
35
- return null;
36
- const a = c[0];
37
- return /* @__PURE__ */ t.createElement(x, { borderTop: "px", px: "3", py: "1", overflow: "hidden", backgroundColor: "blue-2" }, /* @__PURE__ */ t.createElement(f, { align: "center", justify: "space-between", gap: "4" }, /* @__PURE__ */ t.createElement(E, { as: "span", size: "1", weight: "medium", color: "blue", style: {
55
+ client: o
56
+ } = v(), {
57
+ debugSettings: t
58
+ } = x(o.store, (i) => ({
59
+ debugSettings: i.debug
60
+ })), n = Object.keys((t == null ? void 0 : t.focusedGuideKeys) || {}), s = n.length > 0, c = n[0], g = e.useCallback((i) => {
61
+ o.setDebug({
62
+ ...o.store.state.debug,
63
+ focusedGuideKeys: {
64
+ [i]: !0
65
+ }
66
+ }), l.current && I(l.current, i);
67
+ }, [o, l]), u = e.useRef({
68
+ guides: r,
69
+ currentKey: c,
70
+ focusGuide: g
71
+ });
72
+ return e.useEffect(() => {
73
+ u.current = {
74
+ guides: r,
75
+ currentKey: c,
76
+ focusGuide: g
77
+ };
78
+ }), e.useEffect(() => {
79
+ const i = (a) => {
80
+ !a.ctrlKey || a.repeat || (a.key === R ? (a.preventDefault(), y(u.current)) : a.key === G && (a.preventDefault(), k(u.current)));
81
+ };
82
+ return window.addEventListener("keydown", i), () => {
83
+ window.removeEventListener("keydown", i);
84
+ };
85
+ }, []), s ? /* @__PURE__ */ e.createElement(C, { borderTop: "px", px: "3", py: "1", overflow: "hidden", backgroundColor: "blue-2" }, /* @__PURE__ */ e.createElement(m, { align: "center", justify: "space-between", gap: "4" }, /* @__PURE__ */ e.createElement(b, { as: "span", size: "1", weight: "medium", color: "blue", style: {
38
86
  display: "block",
39
87
  overflow: "hidden",
40
88
  textOverflow: "ellipsis",
41
89
  whiteSpace: "nowrap",
42
90
  minWidth: 0
43
- } }, "Focus mode: ", a), /* @__PURE__ */ t.createElement(f, { align: "center", gap: "1", style: {
91
+ } }, "Focus mode: ", c), /* @__PURE__ */ e.createElement(m, { align: "center", gap: "1", style: {
44
92
  flexShrink: 0
45
- } }, /* @__PURE__ */ t.createElement(m, { label: "Focus previous guide", ...p }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
46
- icon: v,
93
+ } }, /* @__PURE__ */ e.createElement(p, { label: /* @__PURE__ */ e.createElement(b, { as: "span", size: "1" }, "Focus previous guide", /* @__PURE__ */ e.createElement(m, { display: "inline-block", ml: "3" }, /* @__PURE__ */ e.createElement(d, null, "ctrl"), " + ", /* @__PURE__ */ e.createElement(d, null, ","))), ...E }, /* @__PURE__ */ e.createElement(f, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
94
+ icon: w,
47
95
  alt: "Previous guide"
48
- }, onClick: () => {
49
- const n = o.filter((s) => !!s.annotation.selectable.status), u = n.findIndex((s) => s.key === a), l = u <= 0 ? void 0 : n[u - 1];
50
- l && (r.setDebug({
51
- ...e,
52
- focusedGuideKeys: {
53
- [l.key]: !0
54
- }
55
- }), i.current && g(i.current, l.key));
56
- } })), /* @__PURE__ */ t.createElement(m, { label: "Focus next guide", ...p }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
57
- icon: k,
96
+ }, onClick: () => y(u.current) })), /* @__PURE__ */ e.createElement(p, { label: /* @__PURE__ */ e.createElement(b, { as: "span", size: "1" }, "Focus next guide", /* @__PURE__ */ e.createElement(m, { display: "inline-block", ml: "3" }, /* @__PURE__ */ e.createElement(d, null, "ctrl"), " + ", /* @__PURE__ */ e.createElement(d, null, "/"))), ...E }, /* @__PURE__ */ e.createElement(f, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
97
+ icon: T,
58
98
  alt: "Next guide"
59
- }, onClick: () => {
60
- const n = o.filter((s) => !!s.annotation.selectable.status), u = n.findIndex((s) => s.key === a), l = u < 0 || u + 1 > n.length - 1 ? void 0 : n[u + 1];
61
- l && (r.setDebug({
62
- ...e,
63
- focusedGuideKeys: {
64
- [l.key]: !0
65
- }
66
- }), i.current && g(i.current, l.key));
67
- } })), /* @__PURE__ */ t.createElement(m, { label: "Exit focus mode", ...p }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
68
- icon: C,
99
+ }, onClick: () => k(u.current) })), /* @__PURE__ */ e.createElement(p, { label: "Exit focus mode", ...E }, /* @__PURE__ */ e.createElement(f, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
100
+ icon: S,
69
101
  alt: "Clear focus"
70
102
  }, onClick: () => {
71
- r.setDebug({
72
- ...e,
103
+ o.setDebug({
104
+ ...t,
73
105
  focusedGuideKeys: {}
74
106
  });
75
- } })))));
107
+ } }))))) : null;
76
108
  };
77
109
  export {
78
- z as FocusChin
110
+ A as FocusChin
79
111
  };
80
112
  //# sourceMappingURL=FocusChin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FocusChin.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/FocusChin.tsx"],"sourcesContent":["import { useGuideContext, useStore } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport { ChevronLeft, ChevronRight, X } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { GUIDE_ROW_DATA_SELECTOR } from \"./GuideRow\";\nimport { sharedTooltipProps } from \"./helpers\";\nimport { InspectionResultOk } from \"./useInspectGuideClientStore\";\n\n// Extra scroll overshoot so the focused guide plus ~1-2 neighbors are visible,\n// reducing how often consecutive next/prev clicks trigger a scroll.\nconst SCROLL_OVERSHOOT = 60;\n\nconst maybeScrollGuideIntoView = (container: HTMLElement, guideKey: string) => {\n requestAnimationFrame(() => {\n const el = container.querySelector(\n `[${GUIDE_ROW_DATA_SELECTOR}=\"${CSS.escape(guideKey)}\"]`,\n );\n if (!el || !(el instanceof HTMLElement)) return;\n\n const containerRect = container.getBoundingClientRect();\n const elRect = el.getBoundingClientRect();\n\n if (elRect.top < containerRect.top) {\n container.scrollTo({\n top:\n container.scrollTop -\n (containerRect.top - elRect.top) -\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n } else if (elRect.bottom > containerRect.bottom) {\n container.scrollTo({\n top:\n container.scrollTop +\n (elRect.bottom - containerRect.bottom) +\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n }\n });\n};\n\ntype Props = {\n guides: InspectionResultOk[\"guides\"];\n guideListRef: React.RefObject<HTMLDivElement | null>;\n};\n\nexport const FocusChin = ({ guides, guideListRef }: Props) => {\n const { client } = useGuideContext();\n const { debugSettings } = useStore(client.store, (state) => ({\n debugSettings: state.debug,\n }));\n\n const focusedKeys = Object.keys(debugSettings?.focusedGuideKeys || {});\n\n const isFocused = focusedKeys.length > 0;\n if (!isFocused) {\n return null;\n }\n\n const currentKey = focusedKeys[0]!;\n\n return (\n <Box\n borderTop=\"px\"\n px=\"3\"\n py=\"1\"\n overflow=\"hidden\"\n backgroundColor=\"blue-2\"\n >\n <Stack align=\"center\" justify=\"space-between\" gap=\"4\">\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color=\"blue\"\n style={{\n display: \"block\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n minWidth: 0,\n }}\n >\n Focus mode: {currentKey}\n </Text>\n <Stack align=\"center\" gap=\"1\" style={{ flexShrink: 0 }}>\n <Tooltip label=\"Focus previous guide\" {...sharedTooltipProps}>\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronLeft, alt: \"Previous guide\" }}\n onClick={() => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n const currIndex = selectableGuides.findIndex(\n (g) => g.key === currentKey,\n );\n const prevGuide =\n currIndex <= 0 ? undefined : selectableGuides[currIndex - 1];\n\n if (!prevGuide) return;\n\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: { [prevGuide.key]: true },\n });\n\n if (guideListRef.current) {\n maybeScrollGuideIntoView(guideListRef.current, prevGuide.key);\n }\n }}\n />\n </Tooltip>\n <Tooltip label=\"Focus next guide\" {...sharedTooltipProps}>\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronRight, alt: \"Next guide\" }}\n onClick={() => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n const currIndex = selectableGuides.findIndex(\n (g) => g.key === currentKey,\n );\n const nextGuide =\n currIndex < 0 || currIndex + 1 > selectableGuides.length - 1\n ? undefined\n : selectableGuides[currIndex + 1];\n\n if (!nextGuide) return;\n\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: { [nextGuide.key]: true },\n });\n\n if (guideListRef.current) {\n maybeScrollGuideIntoView(guideListRef.current, nextGuide.key);\n }\n }}\n />\n </Tooltip>\n <Tooltip label=\"Exit focus mode\" {...sharedTooltipProps}>\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: X, alt: \"Clear focus\" }}\n onClick={() => {\n client.setDebug({ ...debugSettings, focusedGuideKeys: {} });\n }}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Box>\n );\n};\n"],"names":["SCROLL_OVERSHOOT","maybeScrollGuideIntoView","container","guideKey","requestAnimationFrame","el","querySelector","GUIDE_ROW_DATA_SELECTOR","CSS","escape","HTMLElement","containerRect","getBoundingClientRect","elRect","top","scrollTo","scrollTop","behavior","bottom","FocusChin","guides","guideListRef","client","useGuideContext","debugSettings","useStore","store","state","debug","focusedKeys","Object","keys","focusedGuideKeys","length","currentKey","React","Box","Stack","Text","display","overflow","textOverflow","whiteSpace","minWidth","flexShrink","Tooltip","sharedTooltipProps","Button","icon","ChevronLeft","alt","selectableGuides","filter","g","annotation","selectable","status","currIndex","findIndex","key","prevGuide","undefined","setDebug","current","ChevronRight","nextGuide","X"],"mappings":";;;;;;;;;AAcA,MAAMA,IAAmB,IAEnBC,IAA2BA,CAACC,GAAwBC,MAAqB;AAC7EC,wBAAsB,MAAM;AACpBC,UAAAA,IAAKH,EAAUI,cACnB,IAAIC,CAAuB,KAAKC,IAAIC,OAAON,CAAQ,CAAC,IACtD;AACA,QAAI,CAACE,KAAM,EAAEA,aAAcK,aAAc;AAEnCC,UAAAA,IAAgBT,EAAUU,sBAAsB,GAChDC,IAASR,EAAGO,sBAAsB;AAEpCC,IAAAA,EAAOC,MAAMH,EAAcG,MAC7BZ,EAAUa,SAAS;AAAA,MACjBD,KACEZ,EAAUc,aACTL,EAAcG,MAAMD,EAAOC,OAC5Bd;AAAAA,MACFiB,UAAU;AAAA,IA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GAAAA,EACnC,GAAA,gBAAAX,EAAA,cAACY,KACC,MAAK,KACL,SAAQ,SACR,OAAM,QACN,aAAa;AAAA,IAAEC,MAAMkB;AAAAA,IAAGhB,KAAK;AAAA,EAAc,GAC3C,SAAS,MAAM;AACb5B,IAAAA,EAAOwC,SAAS;AAAA,MAAE,GAAGtC;AAAAA,MAAeQ,kBAAkB,CAAA;AAAA,IAAC,CAAG;AAAA,EAAA,EAC1D,CAAA,CAEN,CACF,CACF,CACF;AAEJ;"}
1
+ {"version":3,"file":"FocusChin.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/FocusChin.tsx"],"sourcesContent":["import { useGuideContext, useStore } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport { ChevronLeft, ChevronRight, X } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { GUIDE_ROW_DATA_SELECTOR } from \"./GuideRow\";\nimport { Kbd } from \"./Kbd\";\nimport { sharedTooltipProps } from \"./helpers\";\nimport { InspectionResultOk } from \"./useInspectGuideClientStore\";\n\n// Extra scroll overshoot so the focused guide plus ~1-2 neighbors are visible,\n// reducing how often consecutive next/prev clicks trigger a scroll.\nconst SCROLL_OVERSHOOT = 60;\n\nconst FOCUS_PREV_HOTKEY = \",\";\nconst FOCUS_NEXT_HOTKEY = \"/\";\n\nconst maybeScrollGuideIntoView = (container: HTMLElement, guideKey: string) => {\n requestAnimationFrame(() => {\n const el = container.querySelector(\n `[${GUIDE_ROW_DATA_SELECTOR}=\"${CSS.escape(guideKey)}\"]`,\n );\n if (!el || !(el instanceof HTMLElement)) return;\n\n const containerRect = container.getBoundingClientRect();\n const elRect = el.getBoundingClientRect();\n\n if (elRect.top < containerRect.top) {\n container.scrollTo({\n top:\n container.scrollTop -\n (containerRect.top - elRect.top) -\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n } else if (elRect.bottom > containerRect.bottom) {\n container.scrollTo({\n top:\n container.scrollTop +\n (elRect.bottom - containerRect.bottom) +\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n }\n });\n};\n\ntype FocusNav = {\n guides: InspectionResultOk[\"guides\"];\n currentKey: string | undefined;\n focusGuide: (guideKey: string) => void;\n};\n\nconst focusPrev = ({ guides, currentKey, focusGuide }: FocusNav) => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n if (selectableGuides.length === 0) return;\n\n if (!currentKey) {\n focusGuide(selectableGuides[selectableGuides.length - 1]!.key);\n return;\n }\n\n const currIndex = selectableGuides.findIndex((g) => g.key === currentKey);\n const prevGuide =\n currIndex <= 0 ? undefined : selectableGuides[currIndex - 1];\n if (!prevGuide) return;\n focusGuide(prevGuide.key);\n};\n\nconst focusNext = ({ guides, currentKey, focusGuide }: FocusNav) => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n if (selectableGuides.length === 0) return;\n\n if (!currentKey) {\n focusGuide(selectableGuides[0]!.key);\n return;\n }\n\n const currIndex = selectableGuides.findIndex((g) => g.key === currentKey);\n const nextGuide =\n currIndex < 0 || currIndex + 1 > selectableGuides.length - 1\n ? undefined\n : selectableGuides[currIndex + 1];\n if (!nextGuide) return;\n focusGuide(nextGuide.key);\n};\n\ntype Props = {\n guides: InspectionResultOk[\"guides\"];\n guideListRef: React.RefObject<HTMLDivElement | null>;\n};\n\nexport const FocusChin = ({ guides, guideListRef }: Props) => {\n const { client } = useGuideContext();\n const { debugSettings } = useStore(client.store, (state) => ({\n debugSettings: state.debug,\n }));\n\n const focusedKeys = Object.keys(debugSettings?.focusedGuideKeys || {});\n const isFocused = focusedKeys.length > 0;\n const currentKey = focusedKeys[0];\n\n const focusGuide = React.useCallback(\n (guideKey: string) => {\n client.setDebug({\n ...client.store.state.debug,\n focusedGuideKeys: { [guideKey]: true },\n });\n if (guideListRef.current) {\n maybeScrollGuideIntoView(guideListRef.current, guideKey);\n }\n },\n [client, guideListRef],\n );\n\n // Latest-ref so the window keydown listener below can attach once and always\n // read the current guides / focused key without needing to re-subscribe.\n const latestRef = React.useRef<FocusNav>({ guides, currentKey, focusGuide });\n React.useEffect(() => {\n latestRef.current = { guides, currentKey, focusGuide };\n });\n\n React.useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (!e.ctrlKey || e.repeat) return;\n if (e.key === FOCUS_PREV_HOTKEY) {\n e.preventDefault();\n focusPrev(latestRef.current);\n } else if (e.key === FOCUS_NEXT_HOTKEY) {\n e.preventDefault();\n focusNext(latestRef.current);\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, []);\n\n if (!isFocused) {\n return null;\n }\n\n return (\n <Box\n borderTop=\"px\"\n px=\"3\"\n py=\"1\"\n overflow=\"hidden\"\n backgroundColor=\"blue-2\"\n >\n <Stack align=\"center\" justify=\"space-between\" gap=\"4\">\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color=\"blue\"\n style={{\n display: \"block\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n minWidth: 0,\n }}\n >\n Focus mode: {currentKey}\n </Text>\n <Stack align=\"center\" gap=\"1\" style={{ flexShrink: 0 }}>\n <Tooltip\n label={\n <Text as=\"span\" size=\"1\">\n Focus previous guide\n <Stack display=\"inline-block\" ml=\"3\">\n <Kbd>ctrl</Kbd> + <Kbd>,</Kbd>\n </Stack>\n </Text>\n }\n {...sharedTooltipProps}\n >\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronLeft, alt: \"Previous guide\" }}\n onClick={() => focusPrev(latestRef.current)}\n />\n </Tooltip>\n <Tooltip\n label={\n <Text as=\"span\" size=\"1\">\n Focus next guide\n <Stack display=\"inline-block\" ml=\"3\">\n <Kbd>ctrl</Kbd> + <Kbd>/</Kbd>\n </Stack>\n </Text>\n }\n {...sharedTooltipProps}\n >\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronRight, alt: \"Next guide\" }}\n onClick={() => focusNext(latestRef.current)}\n />\n </Tooltip>\n <Tooltip label=\"Exit focus mode\" {...sharedTooltipProps}>\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: X, alt: \"Clear focus\" }}\n onClick={() => {\n client.setDebug({ ...debugSettings, focusedGuideKeys: {} });\n }}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Box>\n );\n};\n"],"names":["SCROLL_OVERSHOOT","FOCUS_PREV_HOTKEY","FOCUS_NEXT_HOTKEY","maybeScrollGuideIntoView","container","guideKey","requestAnimationFrame","el","querySelector","GUIDE_ROW_DATA_SELECTOR","CSS","escape","HTMLElement","containerRect","getBoundingClientRect","elRect","top","scrollTo","scrollTop","behavior","bottom","focusPrev","guides","currentKey","focusGuide","selectableGuides","filter","g","annotation","selectable","status","length","key","currIndex","findIndex","prevGuide","undefined","focusNext","nextGuide","FocusChin","guideListRef","client","useGuideContext","debugSettings","useStore","store","state","debug","focusedKeys","Object","keys","focusedGuideKeys","isFocused","React","useCallback","setDebug","current","latestRef","useRef","useEffect","handleKeyDown","e","ctrlKey","repeat","preventDefault","addEventListener","removeEventListener","Box","Stack","Text","display","overflow","textOverflow","whiteSpace","minWidth","flexShrink","Tooltip","Kbd","sharedTooltipProps","Button","icon","ChevronLeft","alt","ChevronRight","X"],"mappings":";;;;;;;;;;AAeA,MAAMA,IAAmB,IAEnBC,IAAoB,KACpBC,IAAoB,KAEpBC,IAA2BA,CAACC,GAAwBC,MAAqB;AAC7EC,wBAAsB,MAAM;AACpBC,UAAAA,IAAKH,EAAUI,cACnB,IAAIC,CAAuB,KAAKC,IAAIC,OAAON,CAAQ,CAAC,IACtD;AACA,QAAI,CAACE,KAAM,EAAEA,aAAcK,aAAc;AAEn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UD,OAAO,EAAA,CAAE,CAEhD,GACA,gBAAAH,EAAA,cAACuB,KACC,OACE,gBAAAvB,EAAA,cAACgB,KAAK,IAAG,QAAO,MAAK,IAAG,GAAA,oBAErB,gBAAAhB,EAAA,cAAAe,GAAA,EAAM,SAAQ,gBAAe,IAAG,IAC/B,GAAA,gBAAAf,EAAA,cAACwB,SAAI,MAAI,GAAM,OAAI,gBAAAxB,EAAA,cAAAwB,GAAA,MAAI,GAAC,CAC1B,CACF,GAEF,GAAIC,EAAAA,mCAEHC,GACC,EAAA,MAAK,KACL,SAAQ,SACR,OAAM,QACN,aAAa;AAAA,IAAEC,MAAMG;AAAAA,IAAcD,KAAK;AAAA,EAAa,GACrD,SAAS,MAAM7C,EAAUoB,EAAUD,OAAO,EAAA,CAAE,CAEhD,GACC,gBAAAH,EAAA,cAAAuB,GAAA,EAAQ,OAAM,mBAAsBE,GAAAA,KACnC,gBAAAzB,EAAA,cAAC0B,GACC,EAAA,MAAK,KACL,SAAQ,SACR,OAAM,QACN,aAAa;AAAA,IAAEC,MAAMI;AAAAA,IAAGF,KAAK;AAAA,EAAc,GAC3C,SAAS,MAAM;AACbzC,IAAAA,EAAOc,SAAS;AAAA,MAAE,GAAGZ;AAAAA,MAAeQ,kBAAkB,CAAA;AAAA,IAAC,CAAG;AAAA,EAAA,EAC1D,CAAA,CAEN,CACF,CACF,CACF,IA/EO;AAiFX;"}
@@ -0,0 +1,14 @@
1
+ import * as d from "react";
2
+ const e = ({
3
+ children: r
4
+ }) => /* @__PURE__ */ d.createElement("kbd", { style: {
5
+ display: "inline-block",
6
+ padding: "1px 4px",
7
+ borderRadius: "var(--tgph-rounded-2)",
8
+ border: "1px solid rgba(255, 255, 255, 0.3)",
9
+ backgroundColor: "rgba(255, 255, 255, 0.15)"
10
+ } }, r);
11
+ export {
12
+ e as Kbd
13
+ };
14
+ //# sourceMappingURL=Kbd.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Kbd.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/Kbd.tsx"],"sourcesContent":["import * as React from \"react\";\n\nexport const Kbd = ({ children }: { children: React.ReactNode }) => {\n return (\n <kbd\n style={{\n display: \"inline-block\",\n padding: \"1px 4px\",\n borderRadius: \"var(--tgph-rounded-2)\",\n border: \"1px solid rgba(255, 255, 255, 0.3)\",\n backgroundColor: \"rgba(255, 255, 255, 0.15)\",\n }}\n >\n {children}\n </kbd>\n );\n};\n"],"names":["Kbd","children","React","display","padding","borderRadius","border","backgroundColor"],"mappings":";AAEO,MAAMA,IAAMA,CAAC;AAAA,EAAEC,UAAAA;AAAwC,MAE1D,gBAAAC,EAAA,cAAC,SACC,OAAO;AAAA,EACLC,SAAS;AAAA,EACTC,SAAS;AAAA,EACTC,cAAc;AAAA,EACdC,QAAQ;AAAA,EACRC,iBAAiB;KAGlBN,CACH;"}
@@ -3,7 +3,7 @@ import { useGuideContext as T } from "@knocklabs/react-core";
3
3
  import { Button as w } from "@telegraph/button";
4
4
  import { Icon as B } from "@telegraph/icon";
5
5
  import { Box as u, Stack as i } from "@telegraph/layout";
6
- import { SegmentedControl as m } from "@telegraph/segmented-control";
6
+ import { SegmentedControl as p } from "@telegraph/segmented-control";
7
7
  import { Tooltip as k } from "@telegraph/tooltip";
8
8
  import { Text as v } from "@telegraph/typography";
9
9
  import { GripVertical as H, ChevronDown as V, ChevronRight as j, SlidersHorizontal as M, LogOut as W, Minimize2 as Y } from "lucide-react";
@@ -14,19 +14,12 @@ import { TOOLBAR_Z_INDEX as X } from "../shared.mjs";
14
14
  import { FocusChin as N } from "./FocusChin.mjs";
15
15
  import { GuideContextDetails as Z } from "./GuideContextDetails.mjs";
16
16
  import { GuideRow as q } from "./GuideRow.mjs";
17
+ import { Kbd as _ } from "./Kbd.mjs";
17
18
  import { sharedTooltipProps as D } from "./helpers.mjs";
18
19
  import { useDraggable as J } from "./useDraggable.mjs";
19
20
  import { useInspectGuideClientStore as Q } from "./useInspectGuideClientStore.mjs";
20
- const $ = ".", U = "540px", ee = ["0 0 0 1px rgba(0, 0, 0, 0.06)", "0 0 0 1px rgba(255, 255, 255, 0.10)", "inset 0 1px 0 rgba(255, 255, 255, 0.04)", "0 1px 1px 0 rgba(0, 0, 0, 0.04)", "0 4px 6px -1px rgba(0, 0, 0, 0.05)", "0 8px 16px -4px rgba(0, 0, 0, 0.06)"].join(", "), _ = ({
21
- children: r
22
- }) => /* @__PURE__ */ e.createElement("kbd", { style: {
23
- display: "inline-block",
24
- padding: "1px 4px",
25
- borderRadius: "var(--tgph-rounded-2)",
26
- border: "1px solid rgba(255, 255, 255, 0.3)",
27
- backgroundColor: "rgba(255, 255, 255, 0.15)"
28
- } }, r), te = (r) => {
29
- switch (r) {
21
+ const $ = ".", U = "540px", ee = ["0 0 0 1px rgba(0, 0, 0, 0.06)", "0 0 0 1px rgba(255, 255, 255, 0.10)", "inset 0 1px 0 rgba(255, 255, 255, 0.04)", "0 1px 1px 0 rgba(0, 0, 0, 0.04)", "0 4px 6px -1px rgba(0, 0, 0, 0.05)", "0 8px 16px -4px rgba(0, 0, 0, 0.06)"].join(", "), te = (l) => {
22
+ switch (l) {
30
23
  case "all-guides":
31
24
  return "You have no guides. Get started by creating a guide.";
32
25
  case "only-active":
@@ -34,61 +27,61 @@ const $ = ".", U = "540px", ee = ["0 0 0 1px rgba(0, 0, 0, 0.06)", "0 0 0 1px rg
34
27
  case "only-eligible":
35
28
  return "Your current user is not eligible for any guides.";
36
29
  }
37
- }, z = (r, s) => r.filter((o) => !(s === "only-eligible" && !o.annotation.isEligible || s === "only-active" && !o.annotation.active.status)), we = ({
38
- readyToTarget: r,
30
+ }, z = (l, s) => l.filter((o) => !(s === "only-eligible" && !o.annotation.isEligible || s === "only-active" && !o.annotation.active.status)), ke = ({
31
+ readyToTarget: l,
39
32
  listenForUpdates: s
40
33
  }) => {
41
34
  const {
42
35
  client: o
43
- } = T(), [d, f] = e.useState("only-active"), [c, I] = e.useState(() => L.getToolbarRunConfigFromUrl()), [C, b] = e.useState(!1), [g, P] = e.useState(!1), [K, O] = e.useState();
36
+ } = T(), [m, f] = e.useState("only-active"), [c, I] = e.useState(() => L.getToolbarRunConfigFromUrl()), [C, b] = e.useState(!1), [d, P] = e.useState(!1), [K, O] = e.useState();
44
37
  e.useEffect(() => {
45
38
  O(void 0);
46
- }, [d]), e.useEffect(() => {
39
+ }, [m]), e.useEffect(() => {
47
40
  var h;
48
41
  const {
49
42
  isVisible: t = !1,
50
43
  focusedGuideKeys: n = {}
51
- } = c || {}, l = (h = o.store.state.debug) == null ? void 0 : h.debugging;
52
- return t && !l && r && (o.setDebug({
44
+ } = c || {}, a = (h = o.store.state.debug) == null ? void 0 : h.debugging;
45
+ return t && !a && l && (o.setDebug({
53
46
  focusedGuideKeys: n
54
- }), Object.keys(n).length > 0 && f("all-guides")), !t && l && o.unsetDebug({
47
+ }), Object.keys(n).length > 0 && f("all-guides")), !t && a && o.unsetDebug({
55
48
  listenForUpdates: s
56
49
  }), () => {
57
- var p;
58
- (p = o.store.state.debug) != null && p.debugging && o.unsetDebug({
50
+ var g;
51
+ (g = o.store.state.debug) != null && g.debugging && o.unsetDebug({
59
52
  listenForUpdates: s
60
53
  });
61
54
  };
62
- }, [r, s, c, o, f]), e.useEffect(() => {
55
+ }, [l, s, c, o, f]), e.useEffect(() => {
63
56
  const t = (n) => {
64
- n.ctrlKey && n.key === $ && !n.repeat && (n.preventDefault(), b((l) => !l));
57
+ n.ctrlKey && n.key === $ && !n.repeat && (n.preventDefault(), b((a) => !a));
65
58
  };
66
59
  return window.addEventListener("keydown", t), () => {
67
60
  window.removeEventListener("keydown", t);
68
61
  };
69
62
  }, []);
70
- const R = e.useRef(null), G = e.useRef(null), {
63
+ const G = e.useRef(null), R = e.useRef(null), {
71
64
  position: S,
72
- isDragging: x,
65
+ isDragging: E,
73
66
  handlePointerDown: y,
74
67
  hasDraggedRef: A
75
68
  } = J({
76
- elementRef: R,
69
+ elementRef: G,
77
70
  reclampDeps: [C],
78
71
  initialPosition: {
79
72
  top: 16,
80
73
  right: 16
81
74
  }
82
- }), a = Q(c);
83
- if (!a || !(c != null && c.isVisible))
75
+ }), r = Q(c);
76
+ if (!r || !(c != null && c.isVisible))
84
77
  return null;
85
- const E = a.status === "ok" ? z(a.guides, d) : [];
86
- return /* @__PURE__ */ e.createElement(u, { tgphRef: R, position: "fixed", style: {
78
+ const x = r.status === "ok" ? z(r.guides, m) : [];
79
+ return /* @__PURE__ */ e.createElement(u, { tgphRef: G, position: "fixed", style: {
87
80
  top: S.top + "px",
88
81
  right: S.right + "px",
89
82
  zIndex: X
90
83
  } }, C ? /* @__PURE__ */ e.createElement(k, { side: "left", label: /* @__PURE__ */ e.createElement(v, { as: "span", size: "1" }, "Guide Toolbar", /* @__PURE__ */ e.createElement(i, { display: "inline-block", ml: "3" }, /* @__PURE__ */ e.createElement(_, null, "ctrl"), " + ", /* @__PURE__ */ e.createElement(_, null, "."))), ...D }, /* @__PURE__ */ e.createElement(i, { border: "px", rounded: "4", align: "center", justify: "center", w: "10", h: "10", onPointerDown: y, backgroundColor: "surface-1", style: {
91
- cursor: x ? "grabbing" : "grab",
84
+ cursor: E ? "grabbing" : "grab",
92
85
  touchAction: "none",
93
86
  userSelect: "none",
94
87
  animation: "toolbar-collapse-fade-in 150ms ease-out"
@@ -103,35 +96,35 @@ const $ = ".", U = "540px", ee = ["0 0 0 1px rgba(0, 0, 0, 0.06)", "0 0 0 1px rg
103
96
  animation: "toolbar-expand-fade-in 150ms ease-out"
104
97
  } }, /* @__PURE__ */ e.createElement(i, { w: "full", p: "2", justify: "space-between", direction: "row", align: "center", gap: "2", borderBottom: "px", onPointerDown: y, style: {
105
98
  boxSizing: "border-box",
106
- cursor: x ? "grabbing" : "grab",
99
+ cursor: E ? "grabbing" : "grab",
107
100
  touchAction: "none",
108
101
  userSelect: "none"
109
102
  } }, /* @__PURE__ */ e.createElement(i, { align: "center", gap: "1_5", style: {
110
103
  minWidth: 0,
111
104
  flex: 1
112
105
  } }, /* @__PURE__ */ e.createElement(i, { display: "inline-flex", align: "center", style: {
113
- cursor: x ? "grabbing" : "grab",
106
+ cursor: E ? "grabbing" : "grab",
114
107
  touchAction: "none",
115
108
  userSelect: "none"
116
109
  }, onPointerDown: (t) => {
117
110
  t.stopPropagation(), y(t);
118
- } }, /* @__PURE__ */ e.createElement(B, { color: "gray", size: "1", icon: H, "aria-hidden": !0 })), /* @__PURE__ */ e.createElement(i, { align: "center", gap: "1_5", onPointerDown: (t) => t.stopPropagation() }, /* @__PURE__ */ e.createElement(m.Root, { size: "1", type: "single", value: d, onValueChange: (t) => {
111
+ } }, /* @__PURE__ */ e.createElement(B, { color: "gray", size: "1", icon: H, "aria-hidden": !0 })), /* @__PURE__ */ e.createElement(i, { align: "center", gap: "1_5", onPointerDown: (t) => t.stopPropagation() }, /* @__PURE__ */ e.createElement(p.Root, { size: "1", type: "single", value: m, onValueChange: (t) => {
119
112
  if (!t) return;
120
- const n = o.store.state.debug, l = Object.keys((n == null ? void 0 : n.focusedGuideKeys) || {});
121
- a.status === "ok" && l.length > 0 && (z(a.guides, t).find((p) => p.key === l[0]) || o.setDebug({
113
+ const n = o.store.state.debug, a = Object.keys((n == null ? void 0 : n.focusedGuideKeys) || {});
114
+ r.status === "ok" && a.length > 0 && (z(r.guides, t).find((g) => g.key === a[0]) || o.setDebug({
122
115
  ...n,
123
116
  focusedGuideKeys: {}
124
117
  })), f(t);
125
- } }, /* @__PURE__ */ e.createElement(m.Option, { value: "all-guides", style: {
118
+ } }, /* @__PURE__ */ e.createElement(p.Option, { value: "all-guides", style: {
126
119
  width: "54px"
127
- } }, "All"), /* @__PURE__ */ e.createElement(m.Option, { value: "only-active", style: {
120
+ } }, "All"), /* @__PURE__ */ e.createElement(p.Option, { value: "only-active", style: {
128
121
  width: "54px"
129
- } }, "Active"), /* @__PURE__ */ e.createElement(m.Option, { value: "only-eligible", style: {
122
+ } }, "Active"), /* @__PURE__ */ e.createElement(p.Option, { value: "only-eligible", style: {
130
123
  width: "54px"
131
- } }, "Eligible")), /* @__PURE__ */ e.createElement(k, { label: "Settings", ...D }, /* @__PURE__ */ e.createElement(w, { size: "1", variant: g ? "outline" : "ghost", color: g ? "blue" : "gray", leadingIcon: {
124
+ } }, "Eligible")), /* @__PURE__ */ e.createElement(k, { label: "Settings", ...D }, /* @__PURE__ */ e.createElement(w, { size: "1", variant: d ? "outline" : "ghost", color: d ? "blue" : "gray", leadingIcon: {
132
125
  icon: M,
133
126
  alt: "Inspect target params"
134
- }, trailingIcon: g ? {
127
+ }, trailingIcon: d ? {
135
128
  icon: V,
136
129
  alt: "Hide context data"
137
130
  } : {
@@ -150,17 +143,17 @@ const $ = ".", U = "540px", ee = ["0 0 0 1px rgba(0, 0, 0, 0.06)", "0 0 0 1px rg
150
143
  } }, "Exit"), /* @__PURE__ */ e.createElement(k, { label: "Minimize toolbar", ...D }, /* @__PURE__ */ e.createElement(w, { size: "1", variant: "outline", leadingIcon: {
151
144
  icon: Y,
152
145
  alt: "Minimize"
153
- }, onClick: () => b(!0) }))))), g && /* @__PURE__ */ e.createElement(u, { borderBottom: "px" }, /* @__PURE__ */ e.createElement(Z, null)), /* @__PURE__ */ e.createElement(u, { tgphRef: G, p: "1", overflow: "auto", style: {
146
+ }, onClick: () => b(!0) }))))), d && /* @__PURE__ */ e.createElement(u, { borderBottom: "px" }, /* @__PURE__ */ e.createElement(Z, null)), /* @__PURE__ */ e.createElement(u, { tgphRef: R, p: "1", overflow: "auto", style: {
154
147
  maxHeight: "calc(80vh - 96px)"
155
- } }, a.status === "error" ? /* @__PURE__ */ e.createElement(u, { px: "2", pb: "1", style: {
148
+ } }, r.status === "error" ? /* @__PURE__ */ e.createElement(u, { px: "2", pb: "1", style: {
156
149
  lineHeight: "1.2"
157
- } }, /* @__PURE__ */ e.createElement(v, { as: "span", size: "1", weight: "medium", color: a.error === "no_guides_fetched" ? "default" : "red" }, a.message)) : E.length === 0 ? /* @__PURE__ */ e.createElement(u, { px: "2", pb: "1", style: {
150
+ } }, /* @__PURE__ */ e.createElement(v, { as: "span", size: "1", weight: "medium", color: r.error === "no_guides_fetched" ? "default" : "red" }, r.message)) : x.length === 0 ? /* @__PURE__ */ e.createElement(u, { px: "2", pb: "1", style: {
158
151
  lineHeight: "1.2"
159
- } }, /* @__PURE__ */ e.createElement(v, { as: "span", size: "1", weight: "medium", color: "default" }, te(d))) : E.map((t) => /* @__PURE__ */ e.createElement(q, { key: t.key, guide: t, orderIndex: t.orderIndex, isExpanded: t.key === K, onClick: () => {
152
+ } }, /* @__PURE__ */ e.createElement(v, { as: "span", size: "1", weight: "medium", color: "default" }, te(m))) : x.map((t) => /* @__PURE__ */ e.createElement(q, { key: t.key, guide: t, orderIndex: t.orderIndex, isExpanded: t.key === K, onClick: () => {
160
153
  O((n) => n && n === t.key ? void 0 : t.key);
161
- } }))), /* @__PURE__ */ e.createElement(N, { guides: E, guideListRef: G })));
154
+ } }))), /* @__PURE__ */ e.createElement(N, { guides: x, guideListRef: R })));
162
155
  };
163
156
  export {
164
- we as V2
157
+ ke as V2
165
158
  };
166
159
  //# sourceMappingURL=V2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"V2.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/V2.tsx"],"sourcesContent":["import { KnockGuideClient } from \"@knocklabs/client\";\nimport { useGuideContext } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Icon } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { SegmentedControl } from \"@telegraph/segmented-control\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport {\n ChevronDown,\n ChevronRight,\n GripVertical,\n LogOut,\n Minimize2,\n SlidersHorizontal,\n} from \"lucide-react\";\nimport React from \"react\";\n\nimport { KnockButton } from \"../KnockButton\";\nimport { TOOLBAR_Z_INDEX } from \"../shared\";\nimport \"../styles.css\";\n\nimport { FocusChin } from \"./FocusChin\";\nimport { GuideContextDetails } from \"./GuideContextDetails\";\nimport { GuideRow } from \"./GuideRow\";\nimport { DisplayOption, sharedTooltipProps } from \"./helpers\";\nimport { useDraggable } from \"./useDraggable\";\nimport {\n InspectionResultOk,\n useInspectGuideClientStore,\n} from \"./useInspectGuideClientStore\";\n\nconst TOGGLE_COLLAPSED_HOTKEY = \".\";\n\nconst TOOLBAR_WIDTH = \"540px\";\n\nconst TOOLBAR_BOX_SHADOW = [\n \"0 0 0 1px rgba(0, 0, 0, 0.06)\",\n \"0 0 0 1px rgba(255, 255, 255, 0.10)\",\n \"inset 0 1px 0 rgba(255, 255, 255, 0.04)\",\n \"0 1px 1px 0 rgba(0, 0, 0, 0.04)\",\n \"0 4px 6px -1px rgba(0, 0, 0, 0.05)\",\n \"0 8px 16px -4px rgba(0, 0, 0, 0.06)\",\n].join(\", \");\n\nconst Kbd = ({ children }: { children: React.ReactNode }) => {\n return (\n <kbd\n style={{\n display: \"inline-block\",\n padding: \"1px 4px\",\n borderRadius: \"var(--tgph-rounded-2)\",\n border: \"1px solid rgba(255, 255, 255, 0.3)\",\n backgroundColor: \"rgba(255, 255, 255, 0.15)\",\n }}\n >\n {children}\n </kbd>\n );\n};\n\nconst getEmptyStateMessage = (displayOption: DisplayOption) => {\n switch (displayOption) {\n case \"all-guides\":\n return \"You have no guides. Get started by creating a guide.\";\n case \"only-active\":\n return \"There are no active guides.\";\n case \"only-eligible\":\n return \"Your current user is not eligible for any guides.\";\n }\n};\n\nconst filterGuides = (\n guides: InspectionResultOk[\"guides\"],\n displayOption: DisplayOption,\n) => {\n return guides.filter((guide) => {\n if (displayOption === \"only-eligible\" && !guide.annotation.isEligible) {\n return false;\n }\n if (displayOption === \"only-active\" && !guide.annotation.active.status) {\n return false;\n }\n return true;\n });\n};\n\ntype Props = {\n readyToTarget: boolean;\n listenForUpdates: boolean;\n};\n\nexport const V2 = ({ readyToTarget, listenForUpdates }: Props) => {\n const { client } = useGuideContext();\n\n const [displayOption, setDisplayOption] =\n React.useState<DisplayOption>(\"only-active\");\n const [runConfig, setRunConfig] = React.useState(() =>\n KnockGuideClient.getToolbarRunConfigFromUrl(),\n );\n const [isCollapsed, setIsCollapsed] = React.useState(false);\n const [isContextPanelOpen, setIsContextPanelOpen] = React.useState(false);\n\n const [expandedGuideRowKey, setExpandedGuideRowKey] = React.useState<\n string | undefined\n >();\n\n React.useEffect(() => {\n setExpandedGuideRowKey(undefined);\n }, [displayOption]);\n\n React.useEffect(() => {\n const { isVisible = false, focusedGuideKeys = {} } = runConfig || {};\n const isDebugging = client.store.state.debug?.debugging;\n\n if (isVisible && !isDebugging && readyToTarget) {\n client.setDebug({ focusedGuideKeys });\n\n // If focused, switch to all guides so you can see in the list.\n if (Object.keys(focusedGuideKeys).length > 0) {\n setDisplayOption(\"all-guides\");\n }\n }\n\n if (!isVisible && isDebugging) {\n client.unsetDebug({ listenForUpdates });\n }\n\n return () => {\n if (client.store.state.debug?.debugging) {\n client.unsetDebug({ listenForUpdates });\n }\n };\n }, [readyToTarget, listenForUpdates, runConfig, client, setDisplayOption]);\n\n // Toggle collapsed state with Ctrl + .\n React.useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.ctrlKey && e.key === TOGGLE_COLLAPSED_HOTKEY && !e.repeat) {\n e.preventDefault();\n setIsCollapsed((prev) => !prev);\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, []);\n\n const containerRef = React.useRef<HTMLDivElement>(null);\n const guideListRef = React.useRef<HTMLDivElement>(null);\n const { position, isDragging, handlePointerDown, hasDraggedRef } =\n useDraggable({\n elementRef: containerRef,\n reclampDeps: [isCollapsed],\n initialPosition: { top: 16, right: 16 },\n });\n\n const result = useInspectGuideClientStore(runConfig);\n if (!result || !runConfig?.isVisible) {\n return null;\n }\n\n const guides =\n result.status === \"ok\" ? filterGuides(result.guides, displayOption) : [];\n\n return (\n <Box\n tgphRef={containerRef}\n position=\"fixed\"\n style={{\n top: position.top + \"px\",\n right: position.right + \"px\",\n zIndex: TOOLBAR_Z_INDEX,\n }}\n >\n {isCollapsed ? (\n <Tooltip\n side=\"left\"\n label={\n <Text as=\"span\" size=\"1\">\n Guide Toolbar\n <Stack display=\"inline-block\" ml=\"3\">\n <Kbd>ctrl</Kbd> + <Kbd>.</Kbd>\n </Stack>\n </Text>\n }\n {...sharedTooltipProps}\n >\n <Stack\n border=\"px\"\n rounded=\"4\"\n align=\"center\"\n justify=\"center\"\n w=\"10\"\n h=\"10\"\n onPointerDown={handlePointerDown}\n backgroundColor=\"surface-1\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n animation: \"toolbar-collapse-fade-in 150ms ease-out\",\n }}\n >\n <Box\n style={{\n transform: \"scale(0.7)\",\n transformOrigin: \"center center\",\n }}\n >\n <KnockButton\n onClick={() => {\n if (!hasDraggedRef.current) {\n setIsCollapsed(false);\n }\n }}\n positioned={false}\n />\n </Box>\n </Stack>\n </Tooltip>\n ) : (\n <Stack\n direction=\"column\"\n backgroundColor=\"surface-1\"\n rounded=\"4\"\n overflow=\"hidden\"\n style={{\n width: TOOLBAR_WIDTH,\n boxShadow: TOOLBAR_BOX_SHADOW,\n animation: \"toolbar-expand-fade-in 150ms ease-out\",\n }}\n >\n {/* Header — also acts as drag handle area */}\n <Stack\n w=\"full\"\n p=\"2\"\n justify=\"space-between\"\n direction=\"row\"\n align=\"center\"\n gap=\"2\"\n borderBottom=\"px\"\n onPointerDown={handlePointerDown}\n style={{\n boxSizing: \"border-box\",\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n >\n {/* Left: drag icon + segmented control + settings */}\n <Stack align=\"center\" gap=\"1_5\" style={{ minWidth: 0, flex: 1 }}>\n <Stack\n display=\"inline-flex\"\n align=\"center\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n onPointerDown={(e: React.PointerEvent) => {\n // Already handled by parent, prevent double-fire\n e.stopPropagation();\n handlePointerDown(e);\n }}\n >\n <Icon color=\"gray\" size=\"1\" icon={GripVertical} aria-hidden />\n </Stack>\n <Stack\n align=\"center\"\n gap=\"1_5\"\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <SegmentedControl.Root\n size=\"1\"\n type=\"single\"\n value={displayOption}\n onValueChange={(val: DisplayOption) => {\n if (!val) return;\n\n const debugSettings = client.store.state.debug;\n\n const focusedGuideKeys = Object.keys(\n debugSettings?.focusedGuideKeys || {},\n );\n\n // Exit out of focus if the currently focused guide is not\n // part of the selected list filter.\n if (result.status === \"ok\" && focusedGuideKeys.length > 0) {\n const currFocusedGuide = filterGuides(\n result.guides,\n val,\n ).find((g) => g.key === focusedGuideKeys[0]);\n\n if (!currFocusedGuide) {\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: {},\n });\n }\n }\n\n setDisplayOption(val);\n }}\n >\n <SegmentedControl.Option\n value=\"all-guides\"\n style={{ width: \"54px\" }}\n >\n All\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-active\"\n style={{ width: \"54px\" }}\n >\n Active\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-eligible\"\n style={{ width: \"54px\" }}\n >\n Eligible\n </SegmentedControl.Option>\n </SegmentedControl.Root>\n\n <Tooltip label=\"Settings\" {...sharedTooltipProps}>\n <Button\n size=\"1\"\n variant={isContextPanelOpen ? \"outline\" : \"ghost\"}\n color={isContextPanelOpen ? \"blue\" : \"gray\"}\n leadingIcon={{\n icon: SlidersHorizontal,\n alt: \"Inspect target params\",\n }}\n trailingIcon={\n isContextPanelOpen\n ? { icon: ChevronDown, alt: \"Hide context data\" }\n : { icon: ChevronRight, alt: \"Show context data\" }\n }\n onClick={() => setIsContextPanelOpen((v) => !v)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n\n {/* Right: exit + minimize buttons */}\n <Stack\n align=\"center\"\n gap=\"1_5\"\n style={{ flexShrink: 0 }}\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <Stack align=\"center\" gap=\"1_5\">\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: LogOut, alt: \"Exit\" }}\n onClick={() => {\n setRunConfig((curr) => ({ ...curr, isVisible: false }));\n }}\n >\n Exit\n </Button>\n <Tooltip label=\"Minimize toolbar\" {...sharedTooltipProps}>\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: Minimize2, alt: \"Minimize\" }}\n onClick={() => setIsCollapsed(true)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Stack>\n\n {/* Collapsible panel to show context data */}\n {isContextPanelOpen && (\n <Box borderBottom=\"px\">\n <GuideContextDetails />\n </Box>\n )}\n\n {/* Guide list content area */}\n <Box\n tgphRef={guideListRef}\n p=\"1\"\n overflow=\"auto\"\n style={{ maxHeight: \"calc(80vh - 96px)\" }}\n >\n {result.status === \"error\" ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color={\n result.error === \"no_guides_fetched\" ? \"default\" : \"red\"\n }\n >\n {result.message}\n </Text>\n </Box>\n ) : guides.length === 0 ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text as=\"span\" size=\"1\" weight=\"medium\" color=\"default\">\n {getEmptyStateMessage(displayOption)}\n </Text>\n </Box>\n ) : (\n guides.map((guide) => (\n <GuideRow\n key={guide.key}\n guide={guide}\n orderIndex={guide.orderIndex}\n isExpanded={guide.key === expandedGuideRowKey}\n onClick={() => {\n setExpandedGuideRowKey((k) =>\n k && k === guide.key ? undefined : guide.key,\n );\n }}\n />\n ))\n )}\n </Box>\n\n {/* Focus chin with dedicated controls */}\n <FocusChin guides={guides} guideListRef={guideListRef} />\n </Stack>\n )}\n </Box>\n );\n};\n"],"names":["TOGGLE_COLLAPSED_HOTKEY","TOOLBAR_WIDTH","TOOLBAR_BOX_SHADOW","join","Kbd","children","React","display","padding","borderRadius","border","backgroundColor","getEmptyStateMessage","displayOption","filterGuides","guides","filter","guide","annotation","isEligible","active","status","V2","readyToTarget","listenForUpdates","client","useGuideContext","setDisplayOption","useState","runConfig","setRunConfig","KnockGuideClient","getToolbarRunConfigFromUrl","isCollapsed","setIsCollapsed","isContextPanelOpen","setIsContextPanelOpen","expandedGuideRowKey","setExpandedGuideRowKey","useEffect","undefined","isVisible","focusedGuideKeys","isDebugging","store","state","debug","debugging","setDebug","Object","keys","length","unsetDebug","handleKeyDown","e","ctrlKey","key","repeat","preventDefault","prev","addEventListener","removeEventListener","containerRef","useRef","guideListRef","position","isDragging","handlePointerDown","hasDraggedRef","useDraggable","elementRef","reclampDeps","initialPosition","top","right","result","useInspectGuideClientStore","Box","zIndex","TOOLBAR_Z_INDEX","Tooltip","Text","Stack","sharedTooltipProps","cursor","touchAction","userSelect","animation","transform","transformOrigin","KnockButton","current","width","boxShadow","boxSizing","minWidth","flex","stopPropagation","Icon","GripVertical","SegmentedControl","val","debugSettings","find","g","Button","icon","SlidersHorizontal","alt","ChevronDown","ChevronRight","v","flexShrink","LogOut","curr","Minimize2","GuideContextDetails","maxHeight","lineHeight","error","message","map","GuideRow","orderIndex","k","FocusChin"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAMA,IAA0B,KAE1BC,IAAgB,SAEhBC,KAAqB,CACzB,iCACA,uCACA,2CACA,mCACA,sCACA,qCAAqC,EACrCC,KAAK,IAAI,GAELC,IAAMA,CAAC;AAAA,EAAEC,UAAAA;AAAwC,MAEnDC,gBAAAA,EAAA,cAAC,SACC,OAAO;AAAA,EACLC,SAAS;AAAA,EACTC,SAAS;AAAA,EACTC,cAAc;AAAA,EACdC,QAAQ;AAAA,EACRC,iBAAiB;KAGlBN,CACH,GAIEO,KAAuBA,CAACC,MAAiC;AAC7D,UAAQA,GAAa;AAAA,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 {"version":3,"file":"V2.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/V2.tsx"],"sourcesContent":["import { KnockGuideClient } from \"@knocklabs/client\";\nimport { useGuideContext } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Icon } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { SegmentedControl } from \"@telegraph/segmented-control\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport {\n ChevronDown,\n ChevronRight,\n GripVertical,\n LogOut,\n Minimize2,\n SlidersHorizontal,\n} from \"lucide-react\";\nimport React from \"react\";\n\nimport { KnockButton } from \"../KnockButton\";\nimport { TOOLBAR_Z_INDEX } from \"../shared\";\nimport \"../styles.css\";\n\nimport { FocusChin } from \"./FocusChin\";\nimport { GuideContextDetails } from \"./GuideContextDetails\";\nimport { GuideRow } from \"./GuideRow\";\nimport { Kbd } from \"./Kbd\";\nimport { DisplayOption, sharedTooltipProps } from \"./helpers\";\nimport { useDraggable } from \"./useDraggable\";\nimport {\n InspectionResultOk,\n useInspectGuideClientStore,\n} from \"./useInspectGuideClientStore\";\n\nconst TOGGLE_COLLAPSED_HOTKEY = \".\";\n\nconst TOOLBAR_WIDTH = \"540px\";\n\nconst TOOLBAR_BOX_SHADOW = [\n \"0 0 0 1px rgba(0, 0, 0, 0.06)\",\n \"0 0 0 1px rgba(255, 255, 255, 0.10)\",\n \"inset 0 1px 0 rgba(255, 255, 255, 0.04)\",\n \"0 1px 1px 0 rgba(0, 0, 0, 0.04)\",\n \"0 4px 6px -1px rgba(0, 0, 0, 0.05)\",\n \"0 8px 16px -4px rgba(0, 0, 0, 0.06)\",\n].join(\", \");\n\nconst getEmptyStateMessage = (displayOption: DisplayOption) => {\n switch (displayOption) {\n case \"all-guides\":\n return \"You have no guides. Get started by creating a guide.\";\n case \"only-active\":\n return \"There are no active guides.\";\n case \"only-eligible\":\n return \"Your current user is not eligible for any guides.\";\n }\n};\n\nconst filterGuides = (\n guides: InspectionResultOk[\"guides\"],\n displayOption: DisplayOption,\n) => {\n return guides.filter((guide) => {\n if (displayOption === \"only-eligible\" && !guide.annotation.isEligible) {\n return false;\n }\n if (displayOption === \"only-active\" && !guide.annotation.active.status) {\n return false;\n }\n return true;\n });\n};\n\ntype Props = {\n readyToTarget: boolean;\n listenForUpdates: boolean;\n};\n\nexport const V2 = ({ readyToTarget, listenForUpdates }: Props) => {\n const { client } = useGuideContext();\n\n const [displayOption, setDisplayOption] =\n React.useState<DisplayOption>(\"only-active\");\n const [runConfig, setRunConfig] = React.useState(() =>\n KnockGuideClient.getToolbarRunConfigFromUrl(),\n );\n const [isCollapsed, setIsCollapsed] = React.useState(false);\n const [isContextPanelOpen, setIsContextPanelOpen] = React.useState(false);\n\n const [expandedGuideRowKey, setExpandedGuideRowKey] = React.useState<\n string | undefined\n >();\n\n React.useEffect(() => {\n setExpandedGuideRowKey(undefined);\n }, [displayOption]);\n\n React.useEffect(() => {\n const { isVisible = false, focusedGuideKeys = {} } = runConfig || {};\n const isDebugging = client.store.state.debug?.debugging;\n\n if (isVisible && !isDebugging && readyToTarget) {\n client.setDebug({ focusedGuideKeys });\n\n // If focused, switch to all guides so you can see in the list.\n if (Object.keys(focusedGuideKeys).length > 0) {\n setDisplayOption(\"all-guides\");\n }\n }\n\n if (!isVisible && isDebugging) {\n client.unsetDebug({ listenForUpdates });\n }\n\n return () => {\n if (client.store.state.debug?.debugging) {\n client.unsetDebug({ listenForUpdates });\n }\n };\n }, [readyToTarget, listenForUpdates, runConfig, client, setDisplayOption]);\n\n // Toggle collapsed state with Ctrl + .\n React.useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.ctrlKey && e.key === TOGGLE_COLLAPSED_HOTKEY && !e.repeat) {\n e.preventDefault();\n setIsCollapsed((prev) => !prev);\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, []);\n\n const containerRef = React.useRef<HTMLDivElement>(null);\n const guideListRef = React.useRef<HTMLDivElement>(null);\n const { position, isDragging, handlePointerDown, hasDraggedRef } =\n useDraggable({\n elementRef: containerRef,\n reclampDeps: [isCollapsed],\n initialPosition: { top: 16, right: 16 },\n });\n\n const result = useInspectGuideClientStore(runConfig);\n if (!result || !runConfig?.isVisible) {\n return null;\n }\n\n const guides =\n result.status === \"ok\" ? filterGuides(result.guides, displayOption) : [];\n\n return (\n <Box\n tgphRef={containerRef}\n position=\"fixed\"\n style={{\n top: position.top + \"px\",\n right: position.right + \"px\",\n zIndex: TOOLBAR_Z_INDEX,\n }}\n >\n {isCollapsed ? (\n <Tooltip\n side=\"left\"\n label={\n <Text as=\"span\" size=\"1\">\n Guide Toolbar\n <Stack display=\"inline-block\" ml=\"3\">\n <Kbd>ctrl</Kbd> + <Kbd>.</Kbd>\n </Stack>\n </Text>\n }\n {...sharedTooltipProps}\n >\n <Stack\n border=\"px\"\n rounded=\"4\"\n align=\"center\"\n justify=\"center\"\n w=\"10\"\n h=\"10\"\n onPointerDown={handlePointerDown}\n backgroundColor=\"surface-1\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n animation: \"toolbar-collapse-fade-in 150ms ease-out\",\n }}\n >\n <Box\n style={{\n transform: \"scale(0.7)\",\n transformOrigin: \"center center\",\n }}\n >\n <KnockButton\n onClick={() => {\n if (!hasDraggedRef.current) {\n setIsCollapsed(false);\n }\n }}\n positioned={false}\n />\n </Box>\n </Stack>\n </Tooltip>\n ) : (\n <Stack\n direction=\"column\"\n backgroundColor=\"surface-1\"\n rounded=\"4\"\n overflow=\"hidden\"\n style={{\n width: TOOLBAR_WIDTH,\n boxShadow: TOOLBAR_BOX_SHADOW,\n animation: \"toolbar-expand-fade-in 150ms ease-out\",\n }}\n >\n {/* Header — also acts as drag handle area */}\n <Stack\n w=\"full\"\n p=\"2\"\n justify=\"space-between\"\n direction=\"row\"\n align=\"center\"\n gap=\"2\"\n borderBottom=\"px\"\n onPointerDown={handlePointerDown}\n style={{\n boxSizing: \"border-box\",\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n >\n {/* Left: drag icon + segmented control + settings */}\n <Stack align=\"center\" gap=\"1_5\" style={{ minWidth: 0, flex: 1 }}>\n <Stack\n display=\"inline-flex\"\n align=\"center\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n onPointerDown={(e: React.PointerEvent) => {\n // Already handled by parent, prevent double-fire\n e.stopPropagation();\n handlePointerDown(e);\n }}\n >\n <Icon color=\"gray\" size=\"1\" icon={GripVertical} aria-hidden />\n </Stack>\n <Stack\n align=\"center\"\n gap=\"1_5\"\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <SegmentedControl.Root\n size=\"1\"\n type=\"single\"\n value={displayOption}\n onValueChange={(val: DisplayOption) => {\n if (!val) return;\n\n const debugSettings = client.store.state.debug;\n\n const focusedGuideKeys = Object.keys(\n debugSettings?.focusedGuideKeys || {},\n );\n\n // Exit out of focus if the currently focused guide is not\n // part of the selected list filter.\n if (result.status === \"ok\" && focusedGuideKeys.length > 0) {\n const currFocusedGuide = filterGuides(\n result.guides,\n val,\n ).find((g) => g.key === focusedGuideKeys[0]);\n\n if (!currFocusedGuide) {\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: {},\n });\n }\n }\n\n setDisplayOption(val);\n }}\n >\n <SegmentedControl.Option\n value=\"all-guides\"\n style={{ width: \"54px\" }}\n >\n All\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-active\"\n style={{ width: \"54px\" }}\n >\n Active\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-eligible\"\n style={{ width: \"54px\" }}\n >\n Eligible\n </SegmentedControl.Option>\n </SegmentedControl.Root>\n\n <Tooltip label=\"Settings\" {...sharedTooltipProps}>\n <Button\n size=\"1\"\n variant={isContextPanelOpen ? \"outline\" : \"ghost\"}\n color={isContextPanelOpen ? \"blue\" : \"gray\"}\n leadingIcon={{\n icon: SlidersHorizontal,\n alt: \"Inspect target params\",\n }}\n trailingIcon={\n isContextPanelOpen\n ? { icon: ChevronDown, alt: \"Hide context data\" }\n : { icon: ChevronRight, alt: \"Show context data\" }\n }\n onClick={() => setIsContextPanelOpen((v) => !v)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n\n {/* Right: exit + minimize buttons */}\n <Stack\n align=\"center\"\n gap=\"1_5\"\n style={{ flexShrink: 0 }}\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <Stack align=\"center\" gap=\"1_5\">\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: LogOut, alt: \"Exit\" }}\n onClick={() => {\n setRunConfig((curr) => ({ ...curr, isVisible: false }));\n }}\n >\n Exit\n </Button>\n <Tooltip label=\"Minimize toolbar\" {...sharedTooltipProps}>\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: Minimize2, alt: \"Minimize\" }}\n onClick={() => setIsCollapsed(true)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Stack>\n\n {/* Collapsible panel to show context data */}\n {isContextPanelOpen && (\n <Box borderBottom=\"px\">\n <GuideContextDetails />\n </Box>\n )}\n\n {/* Guide list content area */}\n <Box\n tgphRef={guideListRef}\n p=\"1\"\n overflow=\"auto\"\n style={{ maxHeight: \"calc(80vh - 96px)\" }}\n >\n {result.status === \"error\" ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color={\n result.error === \"no_guides_fetched\" ? \"default\" : \"red\"\n }\n >\n {result.message}\n </Text>\n </Box>\n ) : guides.length === 0 ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text as=\"span\" size=\"1\" weight=\"medium\" color=\"default\">\n {getEmptyStateMessage(displayOption)}\n </Text>\n </Box>\n ) : (\n guides.map((guide) => (\n <GuideRow\n key={guide.key}\n guide={guide}\n orderIndex={guide.orderIndex}\n isExpanded={guide.key === expandedGuideRowKey}\n onClick={() => {\n setExpandedGuideRowKey((k) =>\n k && k === guide.key ? undefined : guide.key,\n );\n }}\n />\n ))\n )}\n </Box>\n\n {/* Focus chin with dedicated controls */}\n <FocusChin guides={guides} guideListRef={guideListRef} />\n </Stack>\n )}\n </Box>\n );\n};\n"],"names":["TOGGLE_COLLAPSED_HOTKEY","TOOLBAR_WIDTH","TOOLBAR_BOX_SHADOW","join","getEmptyStateMessage","displayOption","filterGuides","guides","filter","guide","annotation","isEligible","active","status","V2","readyToTarget","listenForUpdates","client","useGuideContext","setDisplayOption","React","useState","runConfig","setRunConfig","KnockGuideClient","getToolbarRunConfigFromUrl","isCollapsed","setIsCollapsed","isContextPanelOpen","setIsContextPanelOpen","expandedGuideRowKey","setExpandedGuideRowKey","useEffect","undefined","isVisible","focusedGuideKeys","isDebugging","store","state","debug","debugging","setDebug","Object","keys","length","unsetDebug","handleKeyDown","e","ctrlKey","key","repeat","preventDefault","prev","addEventListener","removeEventListener","containerRef","useRef","guideListRef","position","isDragging","handlePointerDown","hasDraggedRef","useDraggable","elementRef","reclampDeps","initialPosition","top","right","result","useInspectGuideClientStore","Box","zIndex","TOOLBAR_Z_INDEX","Tooltip","Text","Stack","Kbd","sharedTooltipProps","cursor","touchAction","userSelect","animation","transform","transformOrigin","KnockButton","current","width","boxShadow","boxSizing","minWidth","flex","stopPropagation","Icon","GripVertical","SegmentedControl","val","debugSettings","find","g","Button","icon","SlidersHorizontal","alt","ChevronDown","ChevronRight","v","flexShrink","LogOut","curr","Minimize2","GuideContextDetails","maxHeight","lineHeight","error","message","map","GuideRow","orderIndex","k","FocusChin"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,MAAMA,IAA0B,KAE1BC,IAAgB,SAEhBC,KAAqB,CAC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