@korsolutions/guidon 1.0.1 → 1.0.2
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/commonjs/babel.config.js +15 -0
- package/dist/commonjs/babel.config.js.map +1 -0
- package/dist/commonjs/bob.config.js +11 -0
- package/dist/commonjs/bob.config.js.map +1 -0
- package/dist/commonjs/components/GuidonOverlay.js +206 -0
- package/dist/commonjs/components/GuidonOverlay.js.map +1 -0
- package/dist/commonjs/components/GuidonProvider.js +157 -0
- package/dist/commonjs/components/GuidonProvider.js.map +1 -0
- package/dist/commonjs/components/GuidonTarget.js +108 -0
- package/dist/commonjs/components/GuidonTarget.js.map +1 -0
- package/dist/commonjs/components/GuidonTooltip.js +422 -0
- package/dist/commonjs/components/GuidonTooltip.js.map +1 -0
- package/dist/commonjs/components/index.js +40 -0
- package/dist/commonjs/components/index.js.map +1 -0
- package/dist/commonjs/hooks/index.js +13 -0
- package/dist/commonjs/hooks/index.js.map +1 -0
- package/dist/commonjs/hooks/useGuidonRef.js +132 -0
- package/dist/commonjs/hooks/useGuidonRef.js.map +1 -0
- package/dist/commonjs/index.js +143 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +1 -0
- package/dist/commonjs/persistence/adapters.js +213 -0
- package/dist/commonjs/persistence/adapters.js.map +1 -0
- package/dist/commonjs/persistence/hooks.js +153 -0
- package/dist/commonjs/persistence/hooks.js.map +1 -0
- package/dist/commonjs/persistence/index.js +28 -0
- package/dist/commonjs/persistence/index.js.map +1 -0
- package/dist/commonjs/store.js +305 -0
- package/dist/commonjs/store.js.map +1 -0
- package/dist/commonjs/tsconfig.json +32 -0
- package/dist/commonjs/types.js +6 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/module/babel.config.js +15 -0
- package/dist/module/babel.config.js.map +1 -0
- package/dist/module/bob.config.js +11 -0
- package/dist/module/bob.config.js.map +1 -0
- package/dist/module/components/GuidonOverlay.js +201 -0
- package/dist/module/components/GuidonOverlay.js.map +1 -0
- package/dist/module/components/GuidonProvider.js +152 -0
- package/dist/module/components/GuidonProvider.js.map +1 -0
- package/dist/module/components/GuidonTarget.js +104 -0
- package/dist/module/components/GuidonTarget.js.map +1 -0
- package/dist/module/components/GuidonTooltip.js +417 -0
- package/dist/module/components/GuidonTooltip.js.map +1 -0
- package/dist/module/components/index.js +7 -0
- package/dist/module/components/index.js.map +1 -0
- package/dist/module/hooks/index.js +4 -0
- package/dist/module/hooks/index.js.map +1 -0
- package/dist/module/hooks/useGuidonRef.js +129 -0
- package/dist/module/hooks/useGuidonRef.js.map +1 -0
- package/dist/module/index.js +17 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/persistence/adapters.js +203 -0
- package/dist/module/persistence/adapters.js.map +1 -0
- package/dist/module/persistence/hooks.js +148 -0
- package/dist/module/persistence/hooks.js.map +1 -0
- package/dist/module/persistence/index.js +5 -0
- package/dist/module/persistence/index.js.map +1 -0
- package/dist/module/store.js +295 -0
- package/dist/module/store.js.map +1 -0
- package/dist/module/tsconfig.json +32 -0
- package/dist/module/types.js +4 -0
- package/dist/module/types.js.map +1 -0
- package/dist/typescript/commonjs/components/GuidonOverlay.d.ts +9 -0
- package/dist/typescript/commonjs/components/GuidonOverlay.d.ts.map +1 -0
- package/dist/typescript/commonjs/components/GuidonProvider.d.ts +14 -0
- package/dist/typescript/commonjs/components/GuidonProvider.d.ts.map +1 -0
- package/dist/typescript/commonjs/components/GuidonTarget.d.ts +7 -0
- package/dist/typescript/commonjs/components/GuidonTarget.d.ts.map +1 -0
- package/dist/typescript/commonjs/components/GuidonTooltip.d.ts +24 -0
- package/dist/typescript/commonjs/components/GuidonTooltip.d.ts.map +1 -0
- package/dist/typescript/commonjs/components/index.d.ts +5 -0
- package/dist/typescript/commonjs/components/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/hooks/index.d.ts +2 -0
- package/dist/typescript/commonjs/hooks/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/hooks/useGuidonRef.d.ts +35 -0
- package/dist/typescript/commonjs/hooks/useGuidonRef.d.ts.map +1 -0
- package/dist/typescript/commonjs/index.d.ts +7 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/commonjs/persistence/adapters.d.ts +57 -0
- package/dist/typescript/commonjs/persistence/adapters.d.ts.map +1 -0
- package/dist/typescript/commonjs/persistence/hooks.d.ts +29 -0
- package/dist/typescript/commonjs/persistence/hooks.d.ts.map +1 -0
- package/dist/typescript/commonjs/persistence/index.d.ts +3 -0
- package/dist/typescript/commonjs/persistence/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/store.d.ts +89 -0
- package/dist/typescript/commonjs/store.d.ts.map +1 -0
- package/dist/{index-D_JFvCIg.d.mts → typescript/commonjs/types.d.ts} +40 -104
- package/dist/typescript/commonjs/types.d.ts.map +1 -0
- package/dist/typescript/module/components/GuidonOverlay.d.ts +9 -0
- package/dist/typescript/module/components/GuidonOverlay.d.ts.map +1 -0
- package/dist/typescript/module/components/GuidonProvider.d.ts +14 -0
- package/dist/typescript/module/components/GuidonProvider.d.ts.map +1 -0
- package/dist/typescript/module/components/GuidonTarget.d.ts +7 -0
- package/dist/typescript/module/components/GuidonTarget.d.ts.map +1 -0
- package/dist/typescript/module/components/GuidonTooltip.d.ts +24 -0
- package/dist/typescript/module/components/GuidonTooltip.d.ts.map +1 -0
- package/dist/typescript/module/components/index.d.ts +5 -0
- package/dist/typescript/module/components/index.d.ts.map +1 -0
- package/dist/typescript/module/hooks/index.d.ts +2 -0
- package/dist/typescript/module/hooks/index.d.ts.map +1 -0
- package/dist/typescript/module/hooks/useGuidonRef.d.ts +35 -0
- package/dist/typescript/module/hooks/useGuidonRef.d.ts.map +1 -0
- package/dist/typescript/module/index.d.ts +7 -0
- package/dist/typescript/module/index.d.ts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/dist/typescript/module/persistence/adapters.d.ts +57 -0
- package/dist/typescript/module/persistence/adapters.d.ts.map +1 -0
- package/dist/typescript/module/persistence/hooks.d.ts +29 -0
- package/dist/typescript/module/persistence/hooks.d.ts.map +1 -0
- package/dist/typescript/module/persistence/index.d.ts +3 -0
- package/dist/typescript/module/persistence/index.d.ts.map +1 -0
- package/dist/typescript/module/store.d.ts +89 -0
- package/dist/typescript/module/store.d.ts.map +1 -0
- package/dist/{index-D_JFvCIg.d.ts → typescript/module/types.d.ts} +40 -104
- package/dist/typescript/module/types.d.ts.map +1 -0
- package/package.json +25 -13
- package/src/babel.config.js +18 -0
- package/src/bob.config.js +14 -0
- package/src/components/GuidonOverlay.tsx +60 -4
- package/src/components/GuidonProvider.tsx +29 -1
- package/src/components/GuidonTarget.tsx +26 -16
- package/src/components/GuidonTooltip.tsx +143 -9
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useGuidonRef.ts +154 -0
- package/src/index.ts +6 -0
- package/src/store.ts +40 -0
- package/src/tsconfig.json +32 -0
- package/src/types.ts +32 -2
- package/dist/index.d.mts +0 -128
- package/dist/index.d.ts +0 -128
- package/dist/index.js +0 -1097
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1072
- package/dist/index.mjs.map +0 -1
- package/dist/persistence/index.d.mts +0 -2
- package/dist/persistence/index.d.ts +0 -2
- package/dist/persistence/index.js +0 -300
- package/dist/persistence/index.js.map +0 -1
- package/dist/persistence/index.mjs +0 -291
- package/dist/persistence/index.mjs.map +0 -1
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GuidonTooltip = GuidonTooltip;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
11
|
+
var _store = require("../store.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
const DEFAULT_THEME = {
|
|
15
|
+
tooltipBackgroundColor: '#ffffff',
|
|
16
|
+
tooltipBorderColor: '#e5e5e5',
|
|
17
|
+
tooltipBorderRadius: 12,
|
|
18
|
+
titleColor: '#1a1a1a',
|
|
19
|
+
descriptionColor: '#666666',
|
|
20
|
+
primaryColor: '#007AFF',
|
|
21
|
+
mutedColor: '#999999',
|
|
22
|
+
spotlightPadding: 8
|
|
23
|
+
};
|
|
24
|
+
const TOOLTIP_MARGIN = 16;
|
|
25
|
+
const TOOLTIP_WIDTH = 300;
|
|
26
|
+
const ESTIMATED_TOOLTIP_HEIGHT = 200;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Calculate position for floating tooltips (steps without a target element)
|
|
30
|
+
*/
|
|
31
|
+
function calculateFloatingPosition(floatingPosition, screenWidth, screenHeight, tooltipWidth, insets) {
|
|
32
|
+
const MARGIN = 32;
|
|
33
|
+
const centerX = (screenWidth - tooltipWidth) / 2;
|
|
34
|
+
const centerY = (screenHeight - ESTIMATED_TOOLTIP_HEIGHT) / 2;
|
|
35
|
+
switch (floatingPosition) {
|
|
36
|
+
case 'center':
|
|
37
|
+
return {
|
|
38
|
+
top: centerY,
|
|
39
|
+
left: centerX
|
|
40
|
+
};
|
|
41
|
+
case 'top':
|
|
42
|
+
return {
|
|
43
|
+
top: insets.top + MARGIN,
|
|
44
|
+
left: centerX
|
|
45
|
+
};
|
|
46
|
+
case 'bottom':
|
|
47
|
+
return {
|
|
48
|
+
top: screenHeight - ESTIMATED_TOOLTIP_HEIGHT - insets.bottom - MARGIN,
|
|
49
|
+
left: centerX
|
|
50
|
+
};
|
|
51
|
+
case 'top-left':
|
|
52
|
+
return {
|
|
53
|
+
top: insets.top + MARGIN,
|
|
54
|
+
left: MARGIN
|
|
55
|
+
};
|
|
56
|
+
case 'top-right':
|
|
57
|
+
return {
|
|
58
|
+
top: insets.top + MARGIN,
|
|
59
|
+
left: screenWidth - tooltipWidth - MARGIN
|
|
60
|
+
};
|
|
61
|
+
case 'bottom-left':
|
|
62
|
+
return {
|
|
63
|
+
top: screenHeight - ESTIMATED_TOOLTIP_HEIGHT - insets.bottom - MARGIN,
|
|
64
|
+
left: MARGIN
|
|
65
|
+
};
|
|
66
|
+
case 'bottom-right':
|
|
67
|
+
return {
|
|
68
|
+
top: screenHeight - ESTIMATED_TOOLTIP_HEIGHT - insets.bottom - MARGIN,
|
|
69
|
+
left: screenWidth - tooltipWidth - MARGIN
|
|
70
|
+
};
|
|
71
|
+
default:
|
|
72
|
+
return {
|
|
73
|
+
top: centerY,
|
|
74
|
+
left: centerX
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function GuidonTooltip({
|
|
79
|
+
theme = {},
|
|
80
|
+
animationDuration = 300,
|
|
81
|
+
renderCustomTooltip,
|
|
82
|
+
labels = {}
|
|
83
|
+
}) {
|
|
84
|
+
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
85
|
+
const {
|
|
86
|
+
width: screenWidth,
|
|
87
|
+
height: screenHeight
|
|
88
|
+
} = _reactNative.Dimensions.get('window');
|
|
89
|
+
const isActive = (0, _store.useGuidonStore)(state => state.isActive);
|
|
90
|
+
const config = (0, _store.useGuidonStore)(state => state.config);
|
|
91
|
+
const currentStepIndex = (0, _store.useGuidonStore)(state => state.currentStepIndex);
|
|
92
|
+
const targetMeasurements = (0, _store.useGuidonStore)(state => state.targetMeasurements);
|
|
93
|
+
const next = (0, _store.useGuidonStore)(state => state.next);
|
|
94
|
+
const previous = (0, _store.useGuidonStore)(state => state.previous);
|
|
95
|
+
const skip = (0, _store.useGuidonStore)(state => state.skip);
|
|
96
|
+
|
|
97
|
+
// Check for floating or waiting states
|
|
98
|
+
const isFloatingStep = (0, _store.useIsFloatingStep)();
|
|
99
|
+
const waitingState = (0, _store.useWaitingState)();
|
|
100
|
+
const isWaiting = waitingState?.isWaiting ?? false;
|
|
101
|
+
const mergedTheme = {
|
|
102
|
+
...DEFAULT_THEME,
|
|
103
|
+
...theme
|
|
104
|
+
};
|
|
105
|
+
const mergedLabels = {
|
|
106
|
+
next: labels.next ?? 'Next',
|
|
107
|
+
previous: labels.previous ?? 'Back',
|
|
108
|
+
skip: labels.skip ?? 'Skip',
|
|
109
|
+
finish: labels.finish ?? 'Finish',
|
|
110
|
+
stepOf: labels.stepOf ?? ((c, t) => `${c} of ${t}`),
|
|
111
|
+
waitingDefault: labels.waitingDefault ?? 'Navigate to continue...'
|
|
112
|
+
};
|
|
113
|
+
const currentStep = config?.steps[currentStepIndex];
|
|
114
|
+
const totalSteps = config?.steps.length ?? 0;
|
|
115
|
+
const isFirstStep = currentStepIndex === 0;
|
|
116
|
+
const isLastStep = currentStepIndex === totalSteps - 1;
|
|
117
|
+
const measurements = currentStep?.targetId ? targetMeasurements[currentStep.targetId] : undefined;
|
|
118
|
+
|
|
119
|
+
// Calculate tooltip position
|
|
120
|
+
const tooltipPosition = (0, _react.useMemo)(() => {
|
|
121
|
+
// Handle floating steps (no target element)
|
|
122
|
+
if (isFloatingStep) {
|
|
123
|
+
const floatingPos = currentStep?.floatingPosition ?? 'center';
|
|
124
|
+
return calculateFloatingPosition(floatingPos, screenWidth, screenHeight, TOOLTIP_WIDTH, insets);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Handle waiting state or no measurements - center the tooltip
|
|
128
|
+
if (!measurements) {
|
|
129
|
+
return {
|
|
130
|
+
top: screenHeight / 2 - ESTIMATED_TOOLTIP_HEIGHT / 2,
|
|
131
|
+
left: screenWidth / 2 - TOOLTIP_WIDTH / 2
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const targetBottom = measurements.y + measurements.height + mergedTheme.spotlightPadding;
|
|
135
|
+
const targetTop = measurements.y - mergedTheme.spotlightPadding;
|
|
136
|
+
|
|
137
|
+
// Determine preferred position
|
|
138
|
+
let position = currentStep?.tooltipPosition ?? 'auto';
|
|
139
|
+
if (position === 'auto') {
|
|
140
|
+
// Auto-detect best position
|
|
141
|
+
const spaceAbove = targetTop - insets.top;
|
|
142
|
+
const spaceBelow = screenHeight - targetBottom - insets.bottom;
|
|
143
|
+
position = spaceBelow >= 200 ? 'bottom' : spaceAbove >= 200 ? 'top' : 'bottom';
|
|
144
|
+
}
|
|
145
|
+
let top;
|
|
146
|
+
let left = Math.max(TOOLTIP_MARGIN, Math.min(measurements.x + measurements.width / 2 - TOOLTIP_WIDTH / 2, screenWidth - TOOLTIP_WIDTH - TOOLTIP_MARGIN));
|
|
147
|
+
if (position === 'top') {
|
|
148
|
+
top = targetTop - TOOLTIP_MARGIN - 150; // Approximate tooltip height
|
|
149
|
+
} else {
|
|
150
|
+
top = targetBottom + TOOLTIP_MARGIN;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Ensure tooltip is within screen bounds
|
|
154
|
+
top = Math.max(insets.top + TOOLTIP_MARGIN, Math.min(top, screenHeight - 200 - insets.bottom));
|
|
155
|
+
return {
|
|
156
|
+
top,
|
|
157
|
+
left,
|
|
158
|
+
position
|
|
159
|
+
};
|
|
160
|
+
}, [measurements, screenWidth, screenHeight, insets, currentStep?.tooltipPosition, currentStep?.floatingPosition, mergedTheme.spotlightPadding, isFloatingStep]);
|
|
161
|
+
|
|
162
|
+
// Determine if tooltip should be visible
|
|
163
|
+
// Show for: normal steps with measurements, floating steps, or waiting states
|
|
164
|
+
const shouldShowTooltip = isActive && currentStep && (measurements || isFloatingStep || isWaiting);
|
|
165
|
+
|
|
166
|
+
// Animated styles
|
|
167
|
+
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
168
|
+
return {
|
|
169
|
+
opacity: (0, _reactNativeReanimated.withTiming)(shouldShowTooltip ? 1 : 0, {
|
|
170
|
+
duration: animationDuration,
|
|
171
|
+
easing: _reactNativeReanimated.Easing.inOut(_reactNativeReanimated.Easing.ease)
|
|
172
|
+
}),
|
|
173
|
+
transform: [{
|
|
174
|
+
translateY: (0, _reactNativeReanimated.withSpring)(shouldShowTooltip ? 0 : 20, {
|
|
175
|
+
damping: 15,
|
|
176
|
+
stiffness: 150
|
|
177
|
+
})
|
|
178
|
+
}]
|
|
179
|
+
};
|
|
180
|
+
}, [shouldShowTooltip, animationDuration]);
|
|
181
|
+
if (!isActive || !currentStep) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Show waiting indicator when target element isn't mounted yet
|
|
186
|
+
if (isWaiting) {
|
|
187
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
|
|
188
|
+
style: [styles.tooltipContainer, {
|
|
189
|
+
top: tooltipPosition.top,
|
|
190
|
+
left: tooltipPosition.left,
|
|
191
|
+
width: TOOLTIP_WIDTH,
|
|
192
|
+
backgroundColor: mergedTheme.tooltipBackgroundColor,
|
|
193
|
+
borderColor: mergedTheme.tooltipBorderColor,
|
|
194
|
+
borderRadius: mergedTheme.tooltipBorderRadius
|
|
195
|
+
}, animatedStyle],
|
|
196
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
197
|
+
style: styles.waitingContainer,
|
|
198
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
199
|
+
color: mergedTheme.primaryColor
|
|
200
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
201
|
+
style: [styles.waitingText, {
|
|
202
|
+
color: mergedTheme.descriptionColor
|
|
203
|
+
}],
|
|
204
|
+
children: waitingState?.message || mergedLabels.waitingDefault
|
|
205
|
+
})]
|
|
206
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
207
|
+
onPress: skip,
|
|
208
|
+
style: styles.skipButton,
|
|
209
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
210
|
+
style: [styles.skipText, {
|
|
211
|
+
color: mergedTheme.mutedColor
|
|
212
|
+
}],
|
|
213
|
+
children: mergedLabels.skip
|
|
214
|
+
})
|
|
215
|
+
})]
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// For non-floating steps, we need measurements
|
|
220
|
+
if (!isFloatingStep && !measurements) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Render custom tooltip if provided
|
|
225
|
+
if (renderCustomTooltip) {
|
|
226
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
227
|
+
style: [styles.tooltipContainer, {
|
|
228
|
+
top: tooltipPosition.top,
|
|
229
|
+
left: tooltipPosition.left,
|
|
230
|
+
width: TOOLTIP_WIDTH
|
|
231
|
+
}, animatedStyle],
|
|
232
|
+
children: renderCustomTooltip({
|
|
233
|
+
step: currentStep,
|
|
234
|
+
currentIndex: currentStepIndex,
|
|
235
|
+
totalSteps,
|
|
236
|
+
onNext: next,
|
|
237
|
+
onPrevious: previous,
|
|
238
|
+
onSkip: skip
|
|
239
|
+
})
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Default tooltip UI
|
|
244
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
|
|
245
|
+
style: [styles.tooltipContainer, {
|
|
246
|
+
top: tooltipPosition.top,
|
|
247
|
+
left: tooltipPosition.left,
|
|
248
|
+
width: TOOLTIP_WIDTH,
|
|
249
|
+
backgroundColor: mergedTheme.tooltipBackgroundColor,
|
|
250
|
+
borderColor: mergedTheme.tooltipBorderColor,
|
|
251
|
+
borderRadius: mergedTheme.tooltipBorderRadius
|
|
252
|
+
}, animatedStyle],
|
|
253
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
254
|
+
style: styles.progressContainer,
|
|
255
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
256
|
+
style: [styles.progressText, {
|
|
257
|
+
color: mergedTheme.mutedColor
|
|
258
|
+
}],
|
|
259
|
+
children: mergedLabels.stepOf(currentStepIndex + 1, totalSteps)
|
|
260
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
261
|
+
style: styles.progressDots,
|
|
262
|
+
children: Array.from({
|
|
263
|
+
length: totalSteps
|
|
264
|
+
}).map((_, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
265
|
+
style: [styles.progressDot, {
|
|
266
|
+
backgroundColor: i === currentStepIndex ? mergedTheme.primaryColor : mergedTheme.mutedColor,
|
|
267
|
+
opacity: i === currentStepIndex ? 1 : 0.3
|
|
268
|
+
}]
|
|
269
|
+
}, i))
|
|
270
|
+
})]
|
|
271
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
272
|
+
style: styles.content,
|
|
273
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
274
|
+
style: [styles.title, {
|
|
275
|
+
color: mergedTheme.titleColor
|
|
276
|
+
}],
|
|
277
|
+
children: currentStep.title
|
|
278
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
279
|
+
style: [styles.description, {
|
|
280
|
+
color: mergedTheme.descriptionColor
|
|
281
|
+
}],
|
|
282
|
+
children: currentStep.description
|
|
283
|
+
}), currentStep.customContent]
|
|
284
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
285
|
+
style: styles.buttonContainer,
|
|
286
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
287
|
+
onPress: skip,
|
|
288
|
+
style: styles.skipButton,
|
|
289
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
290
|
+
style: [styles.skipText, {
|
|
291
|
+
color: mergedTheme.mutedColor
|
|
292
|
+
}],
|
|
293
|
+
children: mergedLabels.skip
|
|
294
|
+
})
|
|
295
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
296
|
+
style: styles.navButtons,
|
|
297
|
+
children: [!isFirstStep && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
298
|
+
onPress: previous,
|
|
299
|
+
style: [styles.navButton, styles.backButton],
|
|
300
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
301
|
+
style: [styles.backButtonText, {
|
|
302
|
+
color: mergedTheme.primaryColor
|
|
303
|
+
}],
|
|
304
|
+
children: mergedLabels.previous
|
|
305
|
+
})
|
|
306
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
307
|
+
onPress: next,
|
|
308
|
+
style: [styles.navButton, styles.nextButton, {
|
|
309
|
+
backgroundColor: mergedTheme.primaryColor
|
|
310
|
+
}],
|
|
311
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
312
|
+
style: styles.nextButtonText,
|
|
313
|
+
children: isLastStep ? mergedLabels.finish : mergedLabels.next
|
|
314
|
+
})
|
|
315
|
+
})]
|
|
316
|
+
})]
|
|
317
|
+
})]
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
const styles = _reactNative.StyleSheet.create({
|
|
321
|
+
tooltipContainer: {
|
|
322
|
+
position: 'absolute',
|
|
323
|
+
zIndex: 1000,
|
|
324
|
+
borderWidth: 1,
|
|
325
|
+
padding: 16,
|
|
326
|
+
..._reactNative.Platform.select({
|
|
327
|
+
ios: {
|
|
328
|
+
shadowColor: '#000',
|
|
329
|
+
shadowOffset: {
|
|
330
|
+
width: 0,
|
|
331
|
+
height: 4
|
|
332
|
+
},
|
|
333
|
+
shadowOpacity: 0.15,
|
|
334
|
+
shadowRadius: 12
|
|
335
|
+
},
|
|
336
|
+
android: {
|
|
337
|
+
elevation: 8
|
|
338
|
+
},
|
|
339
|
+
web: {
|
|
340
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)'
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
},
|
|
344
|
+
progressContainer: {
|
|
345
|
+
flexDirection: 'row',
|
|
346
|
+
alignItems: 'center',
|
|
347
|
+
justifyContent: 'space-between',
|
|
348
|
+
marginBottom: 12
|
|
349
|
+
},
|
|
350
|
+
progressText: {
|
|
351
|
+
fontSize: 12,
|
|
352
|
+
fontWeight: '500'
|
|
353
|
+
},
|
|
354
|
+
progressDots: {
|
|
355
|
+
flexDirection: 'row',
|
|
356
|
+
gap: 4
|
|
357
|
+
},
|
|
358
|
+
progressDot: {
|
|
359
|
+
width: 6,
|
|
360
|
+
height: 6,
|
|
361
|
+
borderRadius: 3
|
|
362
|
+
},
|
|
363
|
+
content: {
|
|
364
|
+
marginBottom: 16
|
|
365
|
+
},
|
|
366
|
+
title: {
|
|
367
|
+
fontSize: 18,
|
|
368
|
+
fontWeight: '600',
|
|
369
|
+
marginBottom: 8
|
|
370
|
+
},
|
|
371
|
+
description: {
|
|
372
|
+
fontSize: 14,
|
|
373
|
+
lineHeight: 20
|
|
374
|
+
},
|
|
375
|
+
buttonContainer: {
|
|
376
|
+
flexDirection: 'row',
|
|
377
|
+
alignItems: 'center',
|
|
378
|
+
justifyContent: 'space-between'
|
|
379
|
+
},
|
|
380
|
+
skipButton: {
|
|
381
|
+
paddingVertical: 8,
|
|
382
|
+
paddingHorizontal: 4
|
|
383
|
+
},
|
|
384
|
+
skipText: {
|
|
385
|
+
fontSize: 14
|
|
386
|
+
},
|
|
387
|
+
navButtons: {
|
|
388
|
+
flexDirection: 'row',
|
|
389
|
+
gap: 8
|
|
390
|
+
},
|
|
391
|
+
navButton: {
|
|
392
|
+
paddingVertical: 10,
|
|
393
|
+
paddingHorizontal: 16,
|
|
394
|
+
borderRadius: 8
|
|
395
|
+
},
|
|
396
|
+
backButton: {
|
|
397
|
+
backgroundColor: 'transparent'
|
|
398
|
+
},
|
|
399
|
+
backButtonText: {
|
|
400
|
+
fontSize: 14,
|
|
401
|
+
fontWeight: '600'
|
|
402
|
+
},
|
|
403
|
+
nextButton: {},
|
|
404
|
+
nextButtonText: {
|
|
405
|
+
color: '#ffffff',
|
|
406
|
+
fontSize: 14,
|
|
407
|
+
fontWeight: '600'
|
|
408
|
+
},
|
|
409
|
+
waitingContainer: {
|
|
410
|
+
flexDirection: 'row',
|
|
411
|
+
alignItems: 'center',
|
|
412
|
+
justifyContent: 'center',
|
|
413
|
+
gap: 12,
|
|
414
|
+
paddingVertical: 8,
|
|
415
|
+
marginBottom: 12
|
|
416
|
+
},
|
|
417
|
+
waitingText: {
|
|
418
|
+
fontSize: 14,
|
|
419
|
+
lineHeight: 20
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
//# sourceMappingURL=GuidonTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_interopRequireWildcard","_reactNativeSafeAreaContext","_store","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_THEME","tooltipBackgroundColor","tooltipBorderColor","tooltipBorderRadius","titleColor","descriptionColor","primaryColor","mutedColor","spotlightPadding","TOOLTIP_MARGIN","TOOLTIP_WIDTH","ESTIMATED_TOOLTIP_HEIGHT","calculateFloatingPosition","floatingPosition","screenWidth","screenHeight","tooltipWidth","insets","MARGIN","centerX","centerY","top","left","bottom","GuidonTooltip","theme","animationDuration","renderCustomTooltip","labels","useSafeAreaInsets","width","height","Dimensions","isActive","useGuidonStore","state","config","currentStepIndex","targetMeasurements","next","previous","skip","isFloatingStep","useIsFloatingStep","waitingState","useWaitingState","isWaiting","mergedTheme","mergedLabels","finish","stepOf","c","waitingDefault","currentStep","steps","totalSteps","length","isFirstStep","isLastStep","measurements","targetId","undefined","tooltipPosition","useMemo","floatingPos","targetBottom","y","targetTop","position","spaceAbove","spaceBelow","Math","max","min","x","shouldShowTooltip","animatedStyle","useAnimatedStyle","opacity","withTiming","duration","easing","Easing","inOut","ease","transform","translateY","withSpring","damping","stiffness","jsxs","View","style","styles","tooltipContainer","backgroundColor","borderColor","borderRadius","children","waitingContainer","jsx","ActivityIndicator","color","Text","waitingText","message","TouchableOpacity","onPress","skipButton","skipText","step","currentIndex","onNext","onPrevious","onSkip","progressContainer","progressText","progressDots","Array","from","map","_","progressDot","content","title","description","customContent","buttonContainer","navButtons","navButton","backButton","backButtonText","nextButton","nextButtonText","StyleSheet","create","zIndex","borderWidth","padding","Platform","select","ios","shadowColor","shadowOffset","shadowOpacity","shadowRadius","android","elevation","web","boxShadow","flexDirection","alignItems","justifyContent","marginBottom","fontSize","fontWeight","gap","lineHeight","paddingVertical","paddingHorizontal"],"sourceRoot":"../../../src","sources":["components/GuidonTooltip.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,sBAAA,GAAAC,uBAAA,CAAAH,OAAA;AAMA,IAAAI,2BAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;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|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "GuidonOverlay", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _GuidonOverlay.GuidonOverlay;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "GuidonProvider", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _GuidonProvider.GuidonProvider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "GuidonTarget", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _GuidonTarget.GuidonTarget;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "GuidonTooltip", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _GuidonTooltip.GuidonTooltip;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "useGuidonContext", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _GuidonProvider.useGuidonContext;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _GuidonTarget = require("./GuidonTarget.js");
|
|
37
|
+
var _GuidonOverlay = require("./GuidonOverlay.js");
|
|
38
|
+
var _GuidonTooltip = require("./GuidonTooltip.js");
|
|
39
|
+
var _GuidonProvider = require("./GuidonProvider.js");
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_GuidonTarget","require","_GuidonOverlay","_GuidonTooltip","_GuidonProvider"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useGuidonRef", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useGuidonRef.useGuidonRef;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _useGuidonRef = require("./useGuidonRef.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_useGuidonRef","require"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGuidonRef = useGuidonRef;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _store = require("../store.js");
|
|
10
|
+
/**
|
|
11
|
+
* Element type that can be measured
|
|
12
|
+
* Supports both web elements and React Native Views
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Hook that returns a ref to attach to an element for guidon targeting.
|
|
17
|
+
* Alternative to the GuidonTarget wrapper component.
|
|
18
|
+
*
|
|
19
|
+
* @param targetId - The target ID that matches a step's targetId
|
|
20
|
+
* @returns A ref to attach to the target element
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* function MyComponent() {
|
|
25
|
+
* const buttonRef = useGuidonRef<View>('my-button');
|
|
26
|
+
* return <Button ref={buttonRef}>Click me</Button>;
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Web usage
|
|
31
|
+
* ```tsx
|
|
32
|
+
* function MyComponent() {
|
|
33
|
+
* const divRef = useGuidonRef<HTMLDivElement>('my-div');
|
|
34
|
+
* return <div ref={divRef}>Highlight me</div>;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function useGuidonRef(targetId) {
|
|
39
|
+
const ref = (0, _react.useRef)(null);
|
|
40
|
+
const measurementFrameRef = (0, _react.useRef)(null);
|
|
41
|
+
const registerTarget = (0, _store.useGuidonStore)(state => state.registerTarget);
|
|
42
|
+
const unregisterTarget = (0, _store.useGuidonStore)(state => state.unregisterTarget);
|
|
43
|
+
const isActive = (0, _store.useGuidonStore)(state => state.isActive);
|
|
44
|
+
const config = (0, _store.useGuidonStore)(state => state.config);
|
|
45
|
+
const currentStepIndex = (0, _store.useGuidonStore)(state => state.currentStepIndex);
|
|
46
|
+
|
|
47
|
+
// Check if this target is needed anywhere in the walkthrough
|
|
48
|
+
const isTargetNeeded = isActive && config?.steps.some(step => step.targetId === targetId);
|
|
49
|
+
|
|
50
|
+
// Check if this specific target is needed for the current step
|
|
51
|
+
const isCurrentTarget = config?.steps[currentStepIndex]?.targetId === targetId;
|
|
52
|
+
const measureElement = (0, _react.useCallback)(() => {
|
|
53
|
+
if (!ref.current || !isTargetNeeded) return;
|
|
54
|
+
if (_reactNative.Platform.OS === 'web') {
|
|
55
|
+
// Web measurement using getBoundingClientRect
|
|
56
|
+
const element = ref.current;
|
|
57
|
+
if (element && typeof element.getBoundingClientRect === 'function') {
|
|
58
|
+
const rect = element.getBoundingClientRect();
|
|
59
|
+
const measurements = {
|
|
60
|
+
x: rect.left + window.scrollX,
|
|
61
|
+
y: rect.top + window.scrollY,
|
|
62
|
+
width: rect.width,
|
|
63
|
+
height: rect.height
|
|
64
|
+
};
|
|
65
|
+
registerTarget(targetId, measurements);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
// Native measurement using measureInWindow
|
|
69
|
+
const nativeRef = ref.current;
|
|
70
|
+
if (nativeRef && typeof nativeRef.measureInWindow === 'function') {
|
|
71
|
+
nativeRef.measureInWindow((x, y, width, height) => {
|
|
72
|
+
if (width > 0 && height > 0) {
|
|
73
|
+
const measurements = {
|
|
74
|
+
x,
|
|
75
|
+
y,
|
|
76
|
+
width,
|
|
77
|
+
height
|
|
78
|
+
};
|
|
79
|
+
registerTarget(targetId, measurements);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [targetId, isTargetNeeded, registerTarget]);
|
|
85
|
+
|
|
86
|
+
// Measure when guidon becomes active or when this target becomes relevant
|
|
87
|
+
(0, _react.useEffect)(() => {
|
|
88
|
+
if (!isTargetNeeded) return;
|
|
89
|
+
|
|
90
|
+
// Use requestAnimationFrame to ensure layout is complete
|
|
91
|
+
measurementFrameRef.current = requestAnimationFrame(() => {
|
|
92
|
+
measureElement();
|
|
93
|
+
});
|
|
94
|
+
return () => {
|
|
95
|
+
if (measurementFrameRef.current) {
|
|
96
|
+
cancelAnimationFrame(measurementFrameRef.current);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}, [isTargetNeeded, measureElement]);
|
|
100
|
+
|
|
101
|
+
// Re-measure when this target becomes the current step
|
|
102
|
+
(0, _react.useEffect)(() => {
|
|
103
|
+
if (!isCurrentTarget) return;
|
|
104
|
+
const timer = setTimeout(() => {
|
|
105
|
+
measureElement();
|
|
106
|
+
}, 50);
|
|
107
|
+
return () => clearTimeout(timer);
|
|
108
|
+
}, [isCurrentTarget, measureElement]);
|
|
109
|
+
|
|
110
|
+
// Web: handle scroll and resize
|
|
111
|
+
(0, _react.useEffect)(() => {
|
|
112
|
+
if (_reactNative.Platform.OS !== 'web' || !isTargetNeeded) return;
|
|
113
|
+
const handleScrollOrResize = () => {
|
|
114
|
+
measureElement();
|
|
115
|
+
};
|
|
116
|
+
window.addEventListener('scroll', handleScrollOrResize, true);
|
|
117
|
+
window.addEventListener('resize', handleScrollOrResize);
|
|
118
|
+
return () => {
|
|
119
|
+
window.removeEventListener('scroll', handleScrollOrResize, true);
|
|
120
|
+
window.removeEventListener('resize', handleScrollOrResize);
|
|
121
|
+
};
|
|
122
|
+
}, [isTargetNeeded, measureElement]);
|
|
123
|
+
|
|
124
|
+
// Unregister on unmount
|
|
125
|
+
(0, _react.useEffect)(() => {
|
|
126
|
+
return () => {
|
|
127
|
+
unregisterTarget(targetId);
|
|
128
|
+
};
|
|
129
|
+
}, [targetId, unregisterTarget]);
|
|
130
|
+
return ref;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=useGuidonRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_store","useGuidonRef","targetId","ref","useRef","measurementFrameRef","registerTarget","useGuidonStore","state","unregisterTarget","isActive","config","currentStepIndex","isTargetNeeded","steps","some","step","isCurrentTarget","measureElement","useCallback","current","Platform","OS","element","getBoundingClientRect","rect","measurements","x","left","window","scrollX","y","top","scrollY","width","height","nativeRef","measureInWindow","useEffect","requestAnimationFrame","cancelAnimationFrame","timer","setTimeout","clearTimeout","handleScrollOrResize","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useGuidonRef.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAC1BC,QAAgB,EACK;EACrB,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAAI,IAAI,CAAC;EAC3B,MAAMC,mBAAmB,GAAG,IAAAD,aAAM,EAAgB,IAAI,CAAC;EA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