gotcha-feedback 1.0.19 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -2
- package/dist/index.d.mts +50 -6
- package/dist/index.d.ts +50 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,9 @@ function FeatureCard() {
|
|
|
41
41
|
- **Feedback Mode** - Star rating + text input
|
|
42
42
|
- **Vote Mode** - Thumbs up/down with customizable labels
|
|
43
43
|
- **Poll Mode** - Custom options (single or multi-select)
|
|
44
|
+
- **NPS Mode** - 0-10 Net Promoter Score with optional follow-up
|
|
45
|
+
- **Score Component** - Embeddable `<GotchaScore />` to display aggregate ratings inline
|
|
46
|
+
- **Bug Flagging** - Let users flag feedback as issues/bugs with a single toggle
|
|
44
47
|
- **User Segmentation** - Analyze feedback by custom user attributes
|
|
45
48
|
- **Edit Support** - Users can update their previous submissions
|
|
46
49
|
- **Customizable** - Themes, sizes, positions
|
|
@@ -65,7 +68,7 @@ function FeatureCard() {
|
|
|
65
68
|
| Prop | Type | Default | Description |
|
|
66
69
|
|------|------|---------|-------------|
|
|
67
70
|
| `elementId` | `string` | Required | Unique identifier for this element |
|
|
68
|
-
| `mode` | `'feedback' \| 'vote' \| 'poll'` | `'feedback'` | Feedback mode |
|
|
71
|
+
| `mode` | `'feedback' \| 'vote' \| 'poll' \| 'nps'` | `'feedback'` | Feedback mode |
|
|
69
72
|
| `position` | `'top-right' \| 'top-left' \| 'bottom-right' \| 'bottom-left' \| 'inline'` | `'top-right'` | Button position |
|
|
70
73
|
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size |
|
|
71
74
|
| `theme` | `'light' \| 'dark' \| 'auto'` | `'light'` | Color theme |
|
|
@@ -76,6 +79,13 @@ function FeatureCard() {
|
|
|
76
79
|
| `voteLabels` | `{ up: string, down: string }` | `{ up: 'Like', down: 'Dislike' }` | Custom vote button labels |
|
|
77
80
|
| `options` | `string[]` | - | Poll options (2-6 items, required for poll mode) |
|
|
78
81
|
| `allowMultiple` | `boolean` | `false` | Allow selecting multiple poll options |
|
|
82
|
+
| `npsQuestion` | `string` | `'How likely are you to recommend us?'` | Custom NPS question |
|
|
83
|
+
| `npsFollowUp` | `boolean` | `true` | Show follow-up textarea after NPS score |
|
|
84
|
+
| `npsFollowUpPlaceholder` | `string` | - | Placeholder for NPS follow-up textarea |
|
|
85
|
+
| `npsLowLabel` | `string` | `'Not likely'` | Label for low end of NPS scale |
|
|
86
|
+
| `npsHighLabel` | `string` | `'Very likely'` | Label for high end of NPS scale |
|
|
87
|
+
| `enableBugFlag` | `boolean` | `false` | Show "Report an issue" toggle in feedback form |
|
|
88
|
+
| `bugFlagLabel` | `string` | `'Report an issue'` | Custom label for the bug flag toggle |
|
|
79
89
|
| `user` | `object` | - | User metadata for segmentation |
|
|
80
90
|
| `onSubmit` | `function` | - | Callback after submission |
|
|
81
91
|
| `onOpen` | `function` | - | Callback when modal opens |
|
|
@@ -136,6 +146,40 @@ function FeatureCard() {
|
|
|
136
146
|
/>
|
|
137
147
|
```
|
|
138
148
|
|
|
149
|
+
### NPS Mode
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
<Gotcha
|
|
153
|
+
elementId="nps-survey"
|
|
154
|
+
mode="nps"
|
|
155
|
+
npsQuestion="How likely are you to recommend us?"
|
|
156
|
+
npsLowLabel="Not likely"
|
|
157
|
+
npsHighLabel="Very likely"
|
|
158
|
+
/>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Bug Flagging
|
|
162
|
+
|
|
163
|
+
Add a "Report an issue" toggle to any feedback form. When toggled on, the submission is automatically flagged as a bug and creates a ticket in your dashboard.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
<Gotcha
|
|
167
|
+
elementId="checkout"
|
|
168
|
+
mode="feedback"
|
|
169
|
+
enableBugFlag
|
|
170
|
+
/>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
// Custom label for non-technical users
|
|
175
|
+
<Gotcha
|
|
176
|
+
elementId="portal"
|
|
177
|
+
mode="feedback"
|
|
178
|
+
enableBugFlag
|
|
179
|
+
bugFlagLabel="Something isn't working"
|
|
180
|
+
/>
|
|
181
|
+
```
|
|
182
|
+
|
|
139
183
|
### Feedback Field Options
|
|
140
184
|
|
|
141
185
|
By default, feedback mode shows both a star rating and a text input. Use `showText` and `showRating` to control which fields appear.
|
|
@@ -310,12 +354,41 @@ When you provide a `user.id`, users can update their previous feedback instead o
|
|
|
310
354
|
|
|
311
355
|
The modal will show "Update" instead of "Submit" when editing, and previous values will be pre-filled.
|
|
312
356
|
|
|
357
|
+
## GotchaScore Component
|
|
358
|
+
|
|
359
|
+
Display aggregate feedback scores inline — star ratings, vote percentages, or raw numbers.
|
|
360
|
+
|
|
361
|
+
```tsx
|
|
362
|
+
import { GotchaScore } from 'gotcha-feedback';
|
|
363
|
+
|
|
364
|
+
// Star rating display
|
|
365
|
+
<GotchaScore elementId="feature-card" variant="stars" />
|
|
366
|
+
|
|
367
|
+
// Compact pill (star + number)
|
|
368
|
+
<GotchaScore elementId="feature-card" variant="compact" />
|
|
369
|
+
|
|
370
|
+
// Vote percentage bar
|
|
371
|
+
<GotchaScore elementId="pricing" variant="votes" />
|
|
372
|
+
|
|
373
|
+
// Plain number
|
|
374
|
+
<GotchaScore elementId="feature-card" variant="number" />
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### GotchaScore Props
|
|
378
|
+
|
|
379
|
+
| Prop | Type | Default | Description |
|
|
380
|
+
|------|------|---------|-------------|
|
|
381
|
+
| `elementId` | `string` | Required | Element to show score for |
|
|
382
|
+
| `variant` | `'stars' \| 'number' \| 'compact' \| 'votes'` | `'stars'` | Display variant |
|
|
383
|
+
| `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Color theme |
|
|
384
|
+
| `refreshInterval` | `number` | - | Auto-refresh interval in ms |
|
|
385
|
+
|
|
313
386
|
## TypeScript
|
|
314
387
|
|
|
315
388
|
The package includes full TypeScript definitions:
|
|
316
389
|
|
|
317
390
|
```tsx
|
|
318
|
-
import type { GotchaProps, GotchaProviderProps } from 'gotcha-feedback';
|
|
391
|
+
import type { GotchaProps, GotchaProviderProps, ScoreData } from 'gotcha-feedback';
|
|
319
392
|
```
|
|
320
393
|
|
|
321
394
|
## Requirements
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
3
|
|
|
4
|
-
type ResponseMode = 'feedback' | 'vote' | 'poll';
|
|
4
|
+
type ResponseMode = 'feedback' | 'vote' | 'poll' | 'nps';
|
|
5
5
|
type VoteType = 'up' | 'down';
|
|
6
6
|
interface GotchaUser {
|
|
7
7
|
id?: string;
|
|
@@ -26,6 +26,7 @@ interface SubmitResponsePayload {
|
|
|
26
26
|
vote?: VoteType;
|
|
27
27
|
pollOptions?: string[];
|
|
28
28
|
pollSelected?: string[];
|
|
29
|
+
isBug?: boolean;
|
|
29
30
|
user?: GotchaUser;
|
|
30
31
|
context?: {
|
|
31
32
|
url?: string;
|
|
@@ -57,7 +58,19 @@ interface GotchaError {
|
|
|
57
58
|
message: string;
|
|
58
59
|
status: number;
|
|
59
60
|
}
|
|
60
|
-
type ErrorCode = 'INVALID_API_KEY' | 'ORIGIN_NOT_ALLOWED' | 'RATE_LIMITED' | 'QUOTA_EXCEEDED' | 'INVALID_REQUEST' | 'USER_NOT_FOUND' | 'INTERNAL_ERROR';
|
|
61
|
+
type ErrorCode = 'INVALID_API_KEY' | 'ORIGIN_NOT_ALLOWED' | 'RATE_LIMITED' | 'QUOTA_EXCEEDED' | 'INVALID_REQUEST' | 'USER_NOT_FOUND' | 'INTERNAL_ERROR' | 'PARSE_ERROR';
|
|
62
|
+
interface ScoreData {
|
|
63
|
+
elementId: string;
|
|
64
|
+
averageRating: number | null;
|
|
65
|
+
totalResponses: number;
|
|
66
|
+
ratingCount: number;
|
|
67
|
+
voteCount: {
|
|
68
|
+
up: number;
|
|
69
|
+
down: number;
|
|
70
|
+
};
|
|
71
|
+
positiveRate: number | null;
|
|
72
|
+
npsScore: number | null;
|
|
73
|
+
}
|
|
61
74
|
|
|
62
75
|
interface GotchaProviderProps {
|
|
63
76
|
/** Your Gotcha API key */
|
|
@@ -95,8 +108,16 @@ interface GotchaProps {
|
|
|
95
108
|
options?: string[];
|
|
96
109
|
/** Allow selecting multiple options */
|
|
97
110
|
allowMultiple?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
|
|
111
|
+
/** Custom NPS question (default: "How likely are you to recommend us?") */
|
|
112
|
+
npsQuestion?: string;
|
|
113
|
+
/** Show follow-up textarea after score selection (default: true) */
|
|
114
|
+
npsFollowUp?: boolean;
|
|
115
|
+
/** Placeholder for NPS follow-up textarea */
|
|
116
|
+
npsFollowUpPlaceholder?: string;
|
|
117
|
+
/** Label for low end of NPS scale (default: "Not likely") */
|
|
118
|
+
npsLowLabel?: string;
|
|
119
|
+
/** Label for high end of NPS scale (default: "Very likely") */
|
|
120
|
+
npsHighLabel?: string;
|
|
100
121
|
/** Button position relative to parent */
|
|
101
122
|
position?: Position;
|
|
102
123
|
/** Button size */
|
|
@@ -119,6 +140,12 @@ interface GotchaProps {
|
|
|
119
140
|
submitText?: string;
|
|
120
141
|
/** Post-submission message */
|
|
121
142
|
thankYouMessage?: string;
|
|
143
|
+
/** Show "Report an issue" toggle in feedback form (default: false) */
|
|
144
|
+
enableBugFlag?: boolean;
|
|
145
|
+
/** Custom label for the bug flag toggle (default: "Report an issue") */
|
|
146
|
+
bugFlagLabel?: string;
|
|
147
|
+
/** When true and user has already responded, show submitted state and allow review/edit instead of new submission */
|
|
148
|
+
onePerUser?: boolean;
|
|
122
149
|
/** Called after successful submission */
|
|
123
150
|
onSubmit?: (response: GotchaResponse) => void;
|
|
124
151
|
/** Called when modal opens */
|
|
@@ -128,7 +155,19 @@ interface GotchaProps {
|
|
|
128
155
|
/** Called on error */
|
|
129
156
|
onError?: (error: GotchaError) => void;
|
|
130
157
|
}
|
|
131
|
-
declare function Gotcha({ elementId, user, mode, showText, showRating, voteLabels, options, allowMultiple,
|
|
158
|
+
declare function Gotcha({ elementId, user, mode, showText, showRating, voteLabels, options, allowMultiple, npsQuestion, npsFollowUp, npsFollowUpPlaceholder, npsLowLabel, npsHighLabel, enableBugFlag, bugFlagLabel, onePerUser, position, size, theme, customStyles, visible, showOnHover, touchBehavior, promptText, placeholder, submitText, thankYouMessage, onSubmit, onOpen, onClose, onError, }: GotchaProps): react_jsx_runtime.JSX.Element | null;
|
|
159
|
+
|
|
160
|
+
type ScoreVariant = 'stars' | 'number' | 'compact' | 'votes';
|
|
161
|
+
interface GotchaScoreProps {
|
|
162
|
+
elementId: string;
|
|
163
|
+
variant?: ScoreVariant;
|
|
164
|
+
showCount?: boolean;
|
|
165
|
+
size?: Size;
|
|
166
|
+
theme?: Theme;
|
|
167
|
+
refreshInterval?: number;
|
|
168
|
+
style?: React$1.CSSProperties;
|
|
169
|
+
}
|
|
170
|
+
declare function GotchaScore({ elementId, variant, showCount, size, theme, refreshInterval, style, }: GotchaScoreProps): react_jsx_runtime.JSX.Element | null;
|
|
132
171
|
|
|
133
172
|
/**
|
|
134
173
|
* Hook to access Gotcha context
|
|
@@ -146,6 +185,11 @@ declare function useGotcha(): {
|
|
|
146
185
|
vote?: VoteType;
|
|
147
186
|
pollSelected?: string[];
|
|
148
187
|
}, userId?: string): Promise<GotchaResponse>;
|
|
188
|
+
getScore(elementId: string): Promise<ScoreData>;
|
|
189
|
+
flagAsBug(responseId: string): Promise<{
|
|
190
|
+
ticketId: string;
|
|
191
|
+
status: string;
|
|
192
|
+
}>;
|
|
149
193
|
getBaseUrl(): string;
|
|
150
194
|
};
|
|
151
195
|
/** Whether Gotcha is globally disabled */
|
|
@@ -158,4 +202,4 @@ declare function useGotcha(): {
|
|
|
158
202
|
submitFeedback: (payload: Omit<SubmitResponsePayload, "context">) => Promise<GotchaResponse>;
|
|
159
203
|
};
|
|
160
204
|
|
|
161
|
-
export { Gotcha, type GotchaError, type GotchaProps, GotchaProvider, type GotchaProviderProps, type GotchaResponse, type GotchaStyles, type GotchaUser, type Position, type ResponseMode, type Size, type Theme, type TouchBehavior, type VoteType, useGotcha };
|
|
205
|
+
export { Gotcha, type GotchaError, type GotchaProps, GotchaProvider, type GotchaProviderProps, type GotchaResponse, GotchaScore, type GotchaScoreProps, type GotchaStyles, type GotchaUser, type Position, type ResponseMode, type ScoreData, type Size, type Theme, type TouchBehavior, type VoteType, useGotcha };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
3
|
|
|
4
|
-
type ResponseMode = 'feedback' | 'vote' | 'poll';
|
|
4
|
+
type ResponseMode = 'feedback' | 'vote' | 'poll' | 'nps';
|
|
5
5
|
type VoteType = 'up' | 'down';
|
|
6
6
|
interface GotchaUser {
|
|
7
7
|
id?: string;
|
|
@@ -26,6 +26,7 @@ interface SubmitResponsePayload {
|
|
|
26
26
|
vote?: VoteType;
|
|
27
27
|
pollOptions?: string[];
|
|
28
28
|
pollSelected?: string[];
|
|
29
|
+
isBug?: boolean;
|
|
29
30
|
user?: GotchaUser;
|
|
30
31
|
context?: {
|
|
31
32
|
url?: string;
|
|
@@ -57,7 +58,19 @@ interface GotchaError {
|
|
|
57
58
|
message: string;
|
|
58
59
|
status: number;
|
|
59
60
|
}
|
|
60
|
-
type ErrorCode = 'INVALID_API_KEY' | 'ORIGIN_NOT_ALLOWED' | 'RATE_LIMITED' | 'QUOTA_EXCEEDED' | 'INVALID_REQUEST' | 'USER_NOT_FOUND' | 'INTERNAL_ERROR';
|
|
61
|
+
type ErrorCode = 'INVALID_API_KEY' | 'ORIGIN_NOT_ALLOWED' | 'RATE_LIMITED' | 'QUOTA_EXCEEDED' | 'INVALID_REQUEST' | 'USER_NOT_FOUND' | 'INTERNAL_ERROR' | 'PARSE_ERROR';
|
|
62
|
+
interface ScoreData {
|
|
63
|
+
elementId: string;
|
|
64
|
+
averageRating: number | null;
|
|
65
|
+
totalResponses: number;
|
|
66
|
+
ratingCount: number;
|
|
67
|
+
voteCount: {
|
|
68
|
+
up: number;
|
|
69
|
+
down: number;
|
|
70
|
+
};
|
|
71
|
+
positiveRate: number | null;
|
|
72
|
+
npsScore: number | null;
|
|
73
|
+
}
|
|
61
74
|
|
|
62
75
|
interface GotchaProviderProps {
|
|
63
76
|
/** Your Gotcha API key */
|
|
@@ -95,8 +108,16 @@ interface GotchaProps {
|
|
|
95
108
|
options?: string[];
|
|
96
109
|
/** Allow selecting multiple options */
|
|
97
110
|
allowMultiple?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
|
|
111
|
+
/** Custom NPS question (default: "How likely are you to recommend us?") */
|
|
112
|
+
npsQuestion?: string;
|
|
113
|
+
/** Show follow-up textarea after score selection (default: true) */
|
|
114
|
+
npsFollowUp?: boolean;
|
|
115
|
+
/** Placeholder for NPS follow-up textarea */
|
|
116
|
+
npsFollowUpPlaceholder?: string;
|
|
117
|
+
/** Label for low end of NPS scale (default: "Not likely") */
|
|
118
|
+
npsLowLabel?: string;
|
|
119
|
+
/** Label for high end of NPS scale (default: "Very likely") */
|
|
120
|
+
npsHighLabel?: string;
|
|
100
121
|
/** Button position relative to parent */
|
|
101
122
|
position?: Position;
|
|
102
123
|
/** Button size */
|
|
@@ -119,6 +140,12 @@ interface GotchaProps {
|
|
|
119
140
|
submitText?: string;
|
|
120
141
|
/** Post-submission message */
|
|
121
142
|
thankYouMessage?: string;
|
|
143
|
+
/** Show "Report an issue" toggle in feedback form (default: false) */
|
|
144
|
+
enableBugFlag?: boolean;
|
|
145
|
+
/** Custom label for the bug flag toggle (default: "Report an issue") */
|
|
146
|
+
bugFlagLabel?: string;
|
|
147
|
+
/** When true and user has already responded, show submitted state and allow review/edit instead of new submission */
|
|
148
|
+
onePerUser?: boolean;
|
|
122
149
|
/** Called after successful submission */
|
|
123
150
|
onSubmit?: (response: GotchaResponse) => void;
|
|
124
151
|
/** Called when modal opens */
|
|
@@ -128,7 +155,19 @@ interface GotchaProps {
|
|
|
128
155
|
/** Called on error */
|
|
129
156
|
onError?: (error: GotchaError) => void;
|
|
130
157
|
}
|
|
131
|
-
declare function Gotcha({ elementId, user, mode, showText, showRating, voteLabels, options, allowMultiple,
|
|
158
|
+
declare function Gotcha({ elementId, user, mode, showText, showRating, voteLabels, options, allowMultiple, npsQuestion, npsFollowUp, npsFollowUpPlaceholder, npsLowLabel, npsHighLabel, enableBugFlag, bugFlagLabel, onePerUser, position, size, theme, customStyles, visible, showOnHover, touchBehavior, promptText, placeholder, submitText, thankYouMessage, onSubmit, onOpen, onClose, onError, }: GotchaProps): react_jsx_runtime.JSX.Element | null;
|
|
159
|
+
|
|
160
|
+
type ScoreVariant = 'stars' | 'number' | 'compact' | 'votes';
|
|
161
|
+
interface GotchaScoreProps {
|
|
162
|
+
elementId: string;
|
|
163
|
+
variant?: ScoreVariant;
|
|
164
|
+
showCount?: boolean;
|
|
165
|
+
size?: Size;
|
|
166
|
+
theme?: Theme;
|
|
167
|
+
refreshInterval?: number;
|
|
168
|
+
style?: React$1.CSSProperties;
|
|
169
|
+
}
|
|
170
|
+
declare function GotchaScore({ elementId, variant, showCount, size, theme, refreshInterval, style, }: GotchaScoreProps): react_jsx_runtime.JSX.Element | null;
|
|
132
171
|
|
|
133
172
|
/**
|
|
134
173
|
* Hook to access Gotcha context
|
|
@@ -146,6 +185,11 @@ declare function useGotcha(): {
|
|
|
146
185
|
vote?: VoteType;
|
|
147
186
|
pollSelected?: string[];
|
|
148
187
|
}, userId?: string): Promise<GotchaResponse>;
|
|
188
|
+
getScore(elementId: string): Promise<ScoreData>;
|
|
189
|
+
flagAsBug(responseId: string): Promise<{
|
|
190
|
+
ticketId: string;
|
|
191
|
+
status: string;
|
|
192
|
+
}>;
|
|
149
193
|
getBaseUrl(): string;
|
|
150
194
|
};
|
|
151
195
|
/** Whether Gotcha is globally disabled */
|
|
@@ -158,4 +202,4 @@ declare function useGotcha(): {
|
|
|
158
202
|
submitFeedback: (payload: Omit<SubmitResponsePayload, "context">) => Promise<GotchaResponse>;
|
|
159
203
|
};
|
|
160
204
|
|
|
161
|
-
export { Gotcha, type GotchaError, type GotchaProps, GotchaProvider, type GotchaProviderProps, type GotchaResponse, type GotchaStyles, type GotchaUser, type Position, type ResponseMode, type Size, type Theme, type TouchBehavior, type VoteType, useGotcha };
|
|
205
|
+
export { Gotcha, type GotchaError, type GotchaProps, GotchaProvider, type GotchaProviderProps, type GotchaResponse, GotchaScore, type GotchaScoreProps, type GotchaStyles, type GotchaUser, type Position, type ResponseMode, type ScoreData, type Size, type Theme, type TouchBehavior, type VoteType, useGotcha };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var Fe="https://gotcha.cx/api/v1";var we={ANONYMOUS_ID:"gotcha_anonymous_id",OFFLINE_QUEUE:"gotcha_offline_queue"},N={POSITION:"top-right",SIZE:"md",THEME:"light",SHOW_ON_HOVER:true,TOUCH_BEHAVIOR:"always-visible",SUBMIT_TEXT:"Submit",THANK_YOU_MESSAGE:"Thanks for your feedback!"};var fe={MAX_RETRIES:2,BASE_DELAY_MS:500,MAX_DELAY_MS:5e3};function Ne(){if(typeof window>"u")return `anon_${crypto.randomUUID()}`;try{let e=localStorage.getItem(we.ANONYMOUS_ID);if(e)return e;let r=`anon_${crypto.randomUUID()}`;return localStorage.setItem(we.ANONYMOUS_ID,r),r}catch{return `anon_${crypto.randomUUID()}`}}var Q={maxRetries:fe.MAX_RETRIES,baseDelayMs:fe.BASE_DELAY_MS,maxDelayMs:fe.MAX_DELAY_MS};async function oe(e,r,s=Q,o=false){let b=null;for(let g=0;g<=s.maxRetries;g++){try{o&&g>0&&console.log(`[Gotcha] Retry attempt ${g}/${s.maxRetries}`);let t=await fetch(e,r);if(t.status>=400&&t.status<500&&t.status!==429||t.ok)return t;b=new Error(`HTTP ${t.status}`);}catch(t){b=t,o&&console.log(`[Gotcha] Network error: ${b.message}`);}if(g<s.maxRetries){let t=Math.min(s.baseDelayMs*Math.pow(2,g),s.maxDelayMs);await new Promise(u=>setTimeout(u,t));}}throw b}function He(e){let{apiKey:r,baseUrl:s=Fe,debug:o=false}=e,b={"Content-Type":"application/json",Authorization:`Bearer ${r}`};async function g(t,u,a){let n=`${s}${u}`,l=crypto.randomUUID();o&&console.log(`[Gotcha] ${t} ${u}`,a);let f=await oe(n,{method:t,headers:{...b,"Idempotency-Key":l},body:a?JSON.stringify(a):void 0},Q,o),i;try{i=await f.json();}catch{throw {code:"PARSE_ERROR",message:"Invalid response from server",status:f.status}}if(!f.ok){let d=i.error;throw o&&console.error(`[Gotcha] Error: ${d.code} - ${d.message}`),d}return o&&console.log("[Gotcha] Response:",i),i}return {async submitResponse(t){let u=t.user||{};u.id||(u.id=Ne());let a={...t,user:u,context:{url:typeof window<"u"?window.location.href:void 0,userAgent:typeof navigator<"u"?navigator.userAgent:void 0},...t.isBug?{isBug:true}:{}};return g("POST","/responses",a)},async checkExistingResponse(t,u){let a=`${s}/responses/check?elementId=${encodeURIComponent(t)}&userId=${encodeURIComponent(u)}`;o&&console.log("[Gotcha] GET /responses/check");let n=await oe(a,{method:"GET",headers:b},Q,o),l=await n.json();if(!n.ok){let f=l.error;throw o&&console.error(`[Gotcha] Error: ${f.code} - ${f.message}`),f}return l.exists?(o&&console.log("[Gotcha] Found existing response:",l.response),l.response):null},async updateResponse(t,u,a){let n=`${s}/responses/${t}${a?`?userId=${encodeURIComponent(a)}`:""}`;o&&console.log(`[Gotcha] PATCH /responses/${t}`,u);let l=await oe(n,{method:"PATCH",headers:b,body:JSON.stringify(u)},Q,o),f=await l.json();if(!l.ok){let i=f.error;throw o&&console.error(`[Gotcha] Error: ${i.code} - ${i.message}`),i}return o&&console.log("[Gotcha] Response updated:",f),f},async getScore(t){let u=`${s}/scores/${encodeURIComponent(t)}`;o&&console.log(`[Gotcha] GET /scores/${t}`);let a=await oe(u,{method:"GET",headers:b},Q,o),n=await a.json();if(!a.ok){let l=n.error;throw o&&console.error(`[Gotcha] Error: ${l.code} - ${l.message}`),l}return o&&console.log("[Gotcha] Score:",n),n},async flagAsBug(t){let u=`${s}/responses/${encodeURIComponent(t)}/bug`;o&&console.log(`[Gotcha] POST /responses/${t}/bug`);let a=await oe(u,{method:"POST",headers:b},Q,o),n=await a.json();if(!a.ok){let l=n.error;throw o&&console.error(`[Gotcha] Error: ${l.code} - ${l.message}`),l}return o&&console.log("[Gotcha] Bug flagged:",n),n},getBaseUrl(){return s}}}var Ve=react.createContext(null);function pt({apiKey:e,children:r,baseUrl:s,debug:o=false,disabled:b=false,defaultUser:g={}}){let[t,u]=react.useState(null),a=react.useMemo(()=>He({apiKey:e,baseUrl:s,debug:o}),[e,s,o]),n=react.useCallback(i=>{u(i);},[]),l=react.useCallback(()=>{u(null);},[]),f=react.useMemo(()=>({client:a,disabled:b,defaultUser:g,debug:o,activeModalId:t,openModal:n,closeModal:l}),[a,b,g,o,t,n,l]);return jsxRuntime.jsx(Ve.Provider,{value:f,children:r})}function H(){let e=react.useContext(Ve);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function je(e){let{client:r,defaultUser:s}=H(),[o,b]=react.useState(false),[g,t]=react.useState(false),[u,a]=react.useState(null),[n,l]=react.useState(null);return react.useEffect(()=>{let i=e.user?.id||s?.id;if(!i){l(null);return}let d=false;return (async()=>{t(true);try{let p=await r.checkExistingResponse(e.elementId,i);d||l(p);}catch{d||l(null);}finally{d||t(false);}})(),()=>{d=true;}},[r,e.elementId,e.user?.id,s?.id]),{submit:react.useCallback(async i=>{b(true),a(null);try{let d=e.user?.id||s?.id,y;return n&&d?y=await r.updateResponse(n.id,{content:i.content,title:i.title,rating:i.rating,vote:i.vote,pollSelected:i.pollSelected},d):y=await r.submitResponse({elementId:e.elementId,mode:e.mode,content:i.content,title:i.title,rating:i.rating,vote:i.vote,pollOptions:e.pollOptions,pollSelected:i.pollSelected,isBug:i.isBug,user:{...s,...e.user}}),l({id:y.id,mode:e.mode,content:i.content??null,title:i.title??null,rating:i.rating??null,vote:i.vote??null,pollSelected:i.pollSelected??null,createdAt:y.createdAt}),e.onSuccess?.(y),y}catch(d){let y=d instanceof Error?d.message:"Something went wrong";throw a(y),e.onError?.(d instanceof Error?d:new Error(y)),d}finally{b(false);}},[r,s,e,n]),isLoading:o,isCheckingExisting:g,error:u,existingResponse:n,isEditing:!!n,clearError:()=>a(null)}}function ge(...e){return e.filter(Boolean).join(" ")}var D=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,Ke=(e,r)=>{let s={sm:{desktop:24,mobile:32},md:{desktop:32,mobile:36},lg:{desktop:40,mobile:40}};return r?s[e].mobile:s[e].desktop};function mt(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qe({size:e,theme:r,customStyles:s,showOnHover:o,touchBehavior:b,onClick:g,isOpen:t,isParentHovered:u=false}){let[a,n]=react.useState(false),[l,f]=react.useState(false),[i,d]=react.useState(mt);react.useEffect(()=>{n(D());let h=window.matchMedia("(prefers-color-scheme: dark)"),M=x=>d(x.matches?"dark":"light");return h.addEventListener("change",M),()=>h.removeEventListener("change",M)},[]);let y=t?true:!a&&o?u:a&&b==="tap-to-reveal"?l:true,p=()=>{if(a&&b==="tap-to-reveal"&&!l){f(true);return}g();},c=Ke(e,a),v=(r==="auto"?i:r)==="dark",S={width:c,height:c,borderRadius:"50%",border:v?"1px solid rgba(255,255,255,0.15)":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:v?"linear-gradient(180deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 60%, rgba(0,0,0,0.05) 100%)":"linear-gradient(160deg, rgba(255,255,255,0.7) 0%, rgba(200,210,230,0.4) 40%, rgba(180,192,220,0.5) 100%)",backdropFilter:"blur(16px) saturate(170%)",WebkitBackdropFilter:"blur(16px) saturate(170%)",color:v?"rgba(255,255,255,0.88)":"rgba(0,0,0,0.75)",boxShadow:v?"0 4px 14px rgba(0,0,0,0.45), 0 1px 3px rgba(0,0,0,0.35)":"0 3px 12px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.2)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",opacity:y?1:0,transform:y?"scale(1)":"scale(0.6)",pointerEvents:y?"auto":"none",...s?.button};return jsxRuntime.jsx("button",{type:"button",onClick:p,style:S,className:ge("gotcha-button",t&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":t,"aria-haspopup":"dialog",children:jsxRuntime.jsx(St,{size:c*.65})})}var Qe="gotcha-carter-one";function yt(){react.useEffect(()=>{if(document.getElementById(Qe))return;let e=document.createElement("link");e.id=Qe,e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Carter+One&display=swap",document.head.appendChild(e);},[]);}function St({size:e}){return yt(),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{fontFamily:"'Carter One', cursive",fontSize:e,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",marginTop:e*.05,marginRight:e*.05,userSelect:"none"},children:"G"})}function _({size:e=16,color:r="currentColor"}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{animation:"gotcha-spin 0.8s linear infinite"},children:[jsxRuntime.jsx("style",{children:`
|
|
2
2
|
@keyframes gotcha-spin {
|
|
3
3
|
from { transform: rotate(0deg); }
|
|
4
4
|
to { transform: rotate(360deg); }
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
50% { stroke-dasharray: 40, 62; stroke-dashoffset: -12; }
|
|
9
9
|
100% { stroke-dasharray: 1, 62; stroke-dashoffset: -62; }
|
|
10
10
|
}
|
|
11
|
-
`}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:a,strokeWidth:"2",strokeOpacity:"0.12"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:a,strokeWidth:"2",strokeLinecap:"round",style:{animation:"gotcha-dash 1.2s ease-in-out infinite"}})]})}function ze({theme:e,placeholder:a,submitText:c,isLoading:o,onSubmit:g,customStyles:b,initialValues:t,isEditing:i=false,showText:l=true,showRating:r=true}){let[d,s]=react.useState(t?.content||""),[u,p]=react.useState(t?.rating??null),[m,f]=react.useState(false);react.useEffect(()=>{f(A());},[]),react.useEffect(()=>{t?.content!==void 0&&s(t.content||""),t?.rating!==void 0&&p(t.rating??null);},[t?.content,t?.rating]);let n=e==="dark",S=l&&r?d.trim().length>0||u!==null:l?d.trim().length>0:r?u!==null:false,v=h=>{h.preventDefault(),S&&g({content:l&&d.trim()?d.trim():void 0,rating:r&&u!==null?u:void 0});},C={width:"100%",padding:m?"12px 14px":"10px 12px",border:`1px solid ${n?"rgba(255,255,255,0.08)":"#e2e8f0"}`,borderRadius:8,backgroundColor:n?"rgba(55,65,81,0.5)":"#fafbfc",color:n?"#f9fafb":"#111827",fontSize:m?16:14,resize:"vertical",minHeight:m?100:80,fontFamily:"inherit",outline:"none",transition:"border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1)",lineHeight:1.5,...b?.input},M={width:"100%",padding:m?"14px 16px":"10px 16px",border:"none",borderRadius:8,backgroundColor:n?"#e2e8f0":"#1e293b",color:n?"#1e293b":"#ffffff",fontSize:m?16:14,fontWeight:500,cursor:o?"not-allowed":"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",letterSpacing:"0.01em",...b?.submitButton};return jsxRuntime.jsxs("form",{onSubmit:v,children:[r&&jsxRuntime.jsx("div",{style:{marginBottom:l?m?16:12:0,...l?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsxRuntime.jsx(nt,{value:u,onChange:p,isDark:n,isTouch:m,large:!l})}),l&&jsxRuntime.jsx("textarea",{value:d,onChange:h=>s(h.target.value),placeholder:a||"Share your thoughts...",style:C,disabled:o,"aria-label":"Your feedback",onFocus:h=>{h.currentTarget.style.borderColor="#1e293b",h.currentTarget.style.boxShadow="0 0 0 2px rgba(30,41,59,0.15)",h.currentTarget.style.backgroundColor=n?"rgba(55,65,81,0.7)":"#ffffff";},onBlur:h=>{h.currentTarget.style.borderColor=n?"rgba(255,255,255,0.08)":"#e2e8f0",h.currentTarget.style.boxShadow="none",h.currentTarget.style.backgroundColor=n?"rgba(55,65,81,0.5)":"#fafbfc";}}),jsxRuntime.jsxs("button",{type:"submit",disabled:o||!S,style:{...M,marginTop:12,opacity:o?.8:1,backgroundColor:S?n?"#e2e8f0":"#1e293b":n?"#374151":"#e2e8f0",color:S?n?"#1e293b":"#ffffff":n?"#6b7280":"#94a3b8",display:"flex",alignItems:"center",justifyContent:"center",gap:8},onMouseEnter:h=>{h.currentTarget.disabled||(h.currentTarget.style.backgroundColor=n?"#cbd5e1":"#334155");},onMouseLeave:h=>{h.currentTarget.disabled||(h.currentTarget.style.backgroundColor=n?"#e2e8f0":"#1e293b");},children:[o&&jsxRuntime.jsx(L,{size:m?18:16,color:n?"#1e293b":"#ffffff"}),o?i?"Updating...":"Submitting...":i?"Update":c]})]})}function nt({value:e,onChange:a,isDark:c,isTouch:o,large:g=false}){let[b,t]=react.useState(null),i=g?o?36:28:o?28:18,l=g?o?8:5:o?6:3;return jsxRuntime.jsx("div",{style:{display:"flex",gap:g?o?8:6:o?6:2},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(r=>{let d=(b??e??0)>=r;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(r),onMouseEnter:()=>t(r),onMouseLeave:()=>t(null),"aria-label":`Rate ${r} out of 5`,"aria-pressed":e===r,style:{background:"none",border:"none",cursor:"pointer",padding:l,color:d?"#f59e0b":c?"rgba(255,255,255,0.12)":"#e2e8f0",transition:"color 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1)",transform:b!==null&&b>=r?"scale(1.1)":"scale(1)"},children:jsxRuntime.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})},r)})})}function Ne({theme:e,isLoading:a,onSubmit:c,initialVote:o,isEditing:g=false,labels:b}){let[t,i]=react.useState(false),[l,r]=react.useState(o||null),[d,s]=react.useState(o||null);react.useEffect(()=>{i(A());},[]),react.useEffect(()=>{o!==void 0&&(s(o),r(o));},[o]),react.useEffect(()=>{!a&&!g&&r(null);},[a,g]);let u=n=>{r(n),c({vote:n});},p=e==="dark",m=n=>{let S=d===n;return {flex:1,minWidth:0,overflow:"hidden",padding:t?"14px 18px":"10px 14px",border:`1px solid ${S?n==="up"?p?"rgba(16,185,129,0.3)":"rgba(16,185,129,0.25)":p?"rgba(239,68,68,0.3)":"rgba(239,68,68,0.25)":p?"rgba(255,255,255,0.08)":"#e2e8f0"}`,borderRadius:t?10:8,backgroundColor:S?n==="up"?p?"rgba(16,185,129,0.08)":"rgba(16,185,129,0.06)":p?"rgba(239,68,68,0.08)":"rgba(239,68,68,0.06)":p?"rgba(55,65,81,0.5)":"#fafbfc",color:S?n==="up"?"#10b981":"#ef4444":p?"#d1d5db":"#64748b",fontSize:t?28:24,cursor:a?"not-allowed":"pointer",transition:"background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s",display:"flex",alignItems:"center",justifyContent:"center",gap:t?10:8}},f=t?24:20;return jsxRuntime.jsxs("div",{style:{display:"flex",gap:t?12:10},role:"group","aria-label":"Vote",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>u("up"),disabled:a,style:m("up"),"aria-label":"Vote up - I like this","aria-pressed":d==="up",onMouseEnter:n=>{a||(n.currentTarget.style.transform="translateY(-1px)",n.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)");},onMouseLeave:n=>{n.currentTarget.style.transform="translateY(0)",n.currentTarget.style.boxShadow="none";},children:a&&l==="up"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(L,{size:f,color:p?"#f9fafb":"#111827"}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:g?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(rt,{size:f}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:b?.up||(d==="up"?"Liked":"Like")})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>u("down"),disabled:a,style:m("down"),"aria-label":"Vote down - I don't like this","aria-pressed":d==="down",onMouseEnter:n=>{a||(n.currentTarget.style.transform="translateY(-1px)",n.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)");},onMouseLeave:n=>{n.currentTarget.style.transform="translateY(0)",n.currentTarget.style.boxShadow="none";},children:a&&l==="down"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(L,{size:f,color:p?"#f9fafb":"#111827"}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:g?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(st,{size:f}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:b?.down||(d==="down"?"Disliked":"Dislike")})]})})]})}function rt({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function st({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function $e({theme:e,options:a,allowMultiple:c,isLoading:o,onSubmit:g,initialSelected:b,isEditing:t=false}){let[i,l]=react.useState(b||[]),[r,d]=react.useState(false);react.useEffect(()=>{d(A());},[]),react.useEffect(()=>{b&&l(b);},[b]);let s=e==="dark",u=f=>{l(c?n=>n.includes(f)?n.filter(S=>S!==f):[...n,f]:n=>n.includes(f)?[]:[f]);},p=()=>{i.length!==0&&g({pollSelected:i});},m=f=>{let n=i.includes(f);return {width:"100%",padding:r?"12px 14px":"9px 12px",border:`1px solid ${n?s?"rgba(226,232,240,0.25)":"rgba(30,41,59,0.25)":s?"rgba(255,255,255,0.08)":"#e2e8f0"}`,borderRadius:r?10:8,backgroundColor:n?s?"rgba(226,232,240,0.08)":"rgba(30,41,59,0.05)":s?"rgba(55,65,81,0.5)":"#fafbfc",color:n?s?"#e2e8f0":"#1e293b":s?"#d1d5db":"#374151",fontSize:r?15:13,fontWeight:500,cursor:o?"not-allowed":"pointer",transition:"background-color 0.2s, border-color 0.2s, color 0.2s",textAlign:"left",letterSpacing:"0.01em",display:"flex",alignItems:"center",gap:8}};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:r?8:6},role:"group","aria-label":c?"Select one or more options":"Select an option",children:a.map(f=>{let n=i.includes(f);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>u(f),disabled:o,style:m(f),"aria-pressed":n,children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:c?4:"50%",border:`2px solid ${n?s?"#e2e8f0":"#1e293b":s?"rgba(255,255,255,0.2)":"#cbd5e1"}`,backgroundColor:n?s?"#e2e8f0":"#1e293b":"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.15s"},children:n&&jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),f]},f)})}),jsxRuntime.jsxs("button",{type:"button",onClick:p,disabled:o||i.length===0,style:{width:"100%",marginTop:12,padding:r?"14px 16px":"10px 16px",border:"none",borderRadius:8,backgroundColor:i.length===0?s?"#374151":"#e2e8f0":s?"#e2e8f0":"#1e293b",color:i.length===0?s?"#6b7280":"#94a3b8":s?"#1e293b":"#ffffff",fontSize:r?16:14,fontWeight:500,cursor:o||i.length===0?"not-allowed":"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:o?.8:1},onMouseEnter:f=>{f.currentTarget.disabled||(f.currentTarget.style.backgroundColor=s?"#cbd5e1":"#334155");},onMouseLeave:f=>{f.currentTarget.disabled||(f.currentTarget.style.backgroundColor=i.length===0?s?"#374151":"#e2e8f0":s?"#e2e8f0":"#1e293b");},children:[o&&jsxRuntime.jsx(L,{size:r?18:16,color:s?"#1e293b":"#ffffff"}),o?t?"Updating...":"Submitting...":t?"Update":"Submit"]})]})}function xe({mode:e,theme:a,customStyles:c,promptText:o,placeholder:g,submitText:b,thankYouMessage:t,isLoading:i,isSubmitted:l,error:r,existingResponse:d,isEditing:s=false,showText:u=true,showRating:p=true,voteLabels:m,options:f,allowMultiple:n=false,onSubmit:S,onClose:v,anchorRect:C}){let M=react.useRef(null),h=react.useRef(null),[I,re]=react.useState(false),[R,se]=react.useState(false),[j,U]=react.useState("light");react.useEffect(()=>{se(window.innerWidth<640);let x=window.matchMedia("(prefers-color-scheme: dark)");U(x.matches?"dark":"light");let G=T=>U(T.matches?"dark":"light");return x.addEventListener("change",G),()=>x.removeEventListener("change",G)},[]),react.useEffect(()=>{let x=requestAnimationFrame(()=>re(true));return ()=>cancelAnimationFrame(x)},[]);let _=a==="auto"?j:a,y=_==="dark",H=(C?window.innerHeight-C.bottom:window.innerHeight/2)<280+20;react.useEffect(()=>{let x=M.current;if(!x)return;h.current?.focus();let G=T=>{if(T.key==="Escape"){v();return}if(T.key==="Tab"){let N=x.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),Y=N[0],D=N[N.length-1];T.shiftKey&&document.activeElement===Y?(T.preventDefault(),D?.focus()):!T.shiftKey&&document.activeElement===D&&(T.preventDefault(),Y?.focus());}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[v]);let ie=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":"What do you think of this feature?",$=R?20:16,X=y?"0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.2)":"0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.06)",z=R?{position:"fixed",left:"50%",top:"50%",width:"calc(100vw - 32px)",maxWidth:320,padding:$,borderRadius:12,backgroundColor:y?"#1f2937":"#ffffff",color:y?"#f9fafb":"#111827",boxShadow:X,border:`1px solid ${y?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)"}`,zIndex:9999,transition:"opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1)",opacity:I?1:0,transform:I?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.96)",...c?.modal,textAlign:"left"}:{position:"absolute",left:"50%",width:320,padding:$,borderRadius:10,backgroundColor:y?"#1f2937":"#ffffff",color:y?"#f9fafb":"#111827",boxShadow:X,border:`1px solid ${y?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)"}`,zIndex:9999,...H?{bottom:"100%",marginBottom:8}:{top:"100%",marginTop:8},transition:"opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1)",opacity:I?1:0,transform:I?"translateX(-50%) scale(1) translateY(0)":`translateX(-50%) scale(0.96) translateY(${H?"6px":"-6px"})`,...c?.modal,textAlign:"left"};return jsxRuntime.jsxs("div",{ref:M,role:"dialog","aria-modal":"true","aria-labelledby":"gotcha-modal-title",style:z,className:J("gotcha-modal",y&&"gotcha-modal--dark"),children:[jsxRuntime.jsx("button",{ref:h,type:"button",onClick:v,"aria-label":"Close feedback form",style:{position:"absolute",top:R?12:8,right:R?12:8,width:R?36:28,height:R?36:28,border:"none",background:"transparent",cursor:"pointer",color:y?"#6b7280":"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,transition:"all 0.15s cubic-bezier(0.4, 0, 0.2, 1)"},onMouseEnter:x=>{x.currentTarget.style.backgroundColor=y?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)",x.currentTarget.style.color=y?"#9ca3af":"#6b7280";},onMouseLeave:x=>{x.currentTarget.style.backgroundColor="transparent",x.currentTarget.style.color=y?"#6b7280":"#9ca3af";},children:jsxRuntime.jsx("svg",{width:R?16:12,height:R?16:12,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:R?16:14,fontWeight:600,paddingRight:R?40:32,letterSpacing:"-0.01em",lineHeight:1.4,textAlign:"left"},children:o||ie}),l&&jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"24px 0",color:y?"#10b981":"#059669"},children:[jsxRuntime.jsx("div",{style:{width:44,height:44,borderRadius:"50%",backgroundColor:y?"rgba(16,185,129,0.1)":"rgba(5,150,105,0.08)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 12px"},children:jsxRuntime.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M20 6L9 17L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:13,fontWeight:500,color:y?"#d1d5db":"#374151"},children:t})]}),r&&!l&&jsxRuntime.jsx("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:8,backgroundColor:y?"rgba(127,29,29,0.3)":"#fef2f2",border:`1px solid ${y?"rgba(254,202,202,0.1)":"rgba(220,38,38,0.1)"}`,color:y?"#fecaca":"#dc2626",fontSize:13,lineHeight:1.4},children:r}),!l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e==="feedback"&&jsxRuntime.jsx(ze,{theme:_,placeholder:g,submitText:b,isLoading:i,onSubmit:S,customStyles:c,initialValues:d?{content:d.content,rating:d.rating}:void 0,isEditing:s,showText:u,showRating:p}),e==="vote"&&jsxRuntime.jsx(Ne,{theme:_,isLoading:i,onSubmit:S,initialVote:d?.vote||void 0,isEditing:s,labels:m}),e==="poll"&&f&&f.length>0&&jsxRuntime.jsx($e,{theme:_,options:f,allowMultiple:n,isLoading:i,onSubmit:S,initialSelected:d?.pollSelected||void 0,isEditing:s})]}),jsxRuntime.jsxs("div",{"aria-live":"polite",className:"sr-only",style:{position:"absolute",left:-9999},children:[l&&"Thank you! Your feedback has been submitted.",r&&`Error: ${r}`]})]})}function ct({elementId:e,user:a,mode:c="feedback",showText:o=true,showRating:g=true,voteLabels:b,options:t,allowMultiple:i=false,showResults:l=true,position:r=P.POSITION,size:d=P.SIZE,theme:s=P.THEME,customStyles:u,visible:p=true,showOnHover:m=P.SHOW_ON_HOVER,touchBehavior:f=P.TOUCH_BEHAVIOR,promptText:n,placeholder:S,submitText:v=P.SUBMIT_TEXT,thankYouMessage:C=P.THANK_YOU_MESSAGE,onSubmit:M,onOpen:h,onClose:I,onError:re}){let{disabled:R,activeModalId:se,openModal:j,closeModal:U}=B(),[_,y]=react.useState(false),[ve,ae]=react.useState(false),[H,ie]=react.useState(null),[$,X]=react.useState(false),z=react.useRef(null);react.useEffect(()=>{X(window.innerWidth<640);},[]);let x=se===e;react.useEffect(()=>{if(!m)return;let E=z.current;if(!E)return;let F=E.parentElement;if(!F)return;let Ee=()=>ae(true),Re=()=>ae(false);return F.addEventListener("mouseenter",Ee),F.addEventListener("mouseleave",Re),()=>{F.removeEventListener("mouseenter",Ee),F.removeEventListener("mouseleave",Re);}},[m]);let{submit:G,isLoading:T,error:N,existingResponse:Y,isEditing:D}=Pe({elementId:e,mode:c,pollOptions:t,user:a,onSuccess:E=>{y(true),M?.(E),setTimeout(()=>{U(),y(false);},1500);},onError:E=>{console.warn("[Gotcha] Submission failed:",E instanceof Error?E.message:E),re?.(E);}}),We=react.useCallback(()=>{z.current&&ie(z.current.getBoundingClientRect()),j(e),h?.();},[e,j,h]),le=react.useCallback(()=>{U(),y(false),I?.();},[U,I]),ke=react.useCallback(E=>{G(E);},[G]);return R||!p?null:jsxRuntime.jsxs("div",{ref:z,style:{...{"top-right":{position:"absolute",top:0,right:0,transform:"translate(50%, -50%)"},"top-left":{position:"absolute",top:0,left:0,transform:"translate(-50%, -50%)"},"bottom-right":{position:"absolute",bottom:0,right:0,transform:"translate(50%, 50%)"},"bottom-left":{position:"absolute",bottom:0,left:0,transform:"translate(-50%, 50%)"},inline:{position:"relative",display:"inline-flex"}}[r],zIndex:x?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(De,{size:d,theme:s,customStyles:u,showOnHover:m,touchBehavior:f,onClick:We,isOpen:x,isParentHovered:ve}),x&&!$&&jsxRuntime.jsx(xe,{mode:c,theme:s,customStyles:u,promptText:n,placeholder:S,submitText:v,thankYouMessage:D?"Your feedback has been updated!":C,isLoading:T,isSubmitted:_,error:N,existingResponse:Y,isEditing:D,showText:o,showRating:g,voteLabels:b,options:t,allowMultiple:i,onSubmit:ke,onClose:le,anchorRect:H||void 0}),x&&$&&reactDom.createPortal(jsxRuntime.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:"rgba(0, 0, 0, 0.3)"},onClick:le,"aria-hidden":"true",children:jsxRuntime.jsx("div",{onClick:E=>E.stopPropagation(),children:jsxRuntime.jsx(xe,{mode:c,theme:s,customStyles:u,promptText:n,placeholder:S,submitText:v,thankYouMessage:D?"Your feedback has been updated!":C,isLoading:T,isSubmitted:_,error:N,existingResponse:Y,isEditing:D,showText:o,showRating:g,voteLabels:b,options:t,allowMultiple:i,onSubmit:ke,onClose:le,anchorRect:H||void 0})})}),document.body)]})}function ut(){let{client:e,disabled:a,defaultUser:c,debug:o}=B();return {client:e,disabled:a,defaultUser:c,debug:o,submitFeedback:e.submitResponse.bind(e)}}exports.Gotcha=ct;exports.GotchaProvider=Xe;exports.useGotcha=ut;//# sourceMappingURL=index.js.map
|
|
11
|
+
`}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:r,strokeWidth:"2",strokeOpacity:"0.12"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:r,strokeWidth:"2",strokeLinecap:"round",style:{animation:"gotcha-dash 1.2s ease-in-out infinite"}})]})}function Je({theme:e,placeholder:r,submitText:s,isLoading:o,onSubmit:b,customStyles:g,initialValues:t,isEditing:u=false,showText:a=true,showRating:n=true,enableBugFlag:l=false,bugFlagLabel:f}){let[i,d]=react.useState(t?.content||""),[y,p]=react.useState(t?.rating??null),[c,I]=react.useState(false),[v,S]=react.useState(false);react.useEffect(()=>{S(D());},[]),react.useEffect(()=>{t?.content!==void 0&&d(t.content||""),t?.rating!==void 0&&p(t.rating??null);},[t?.content,t?.rating]);let h=e==="dark",M=a&&n?i.trim().length>0||y!==null:a?i.trim().length>0:n?y!==null:false,x=m=>{m.preventDefault(),M&&b({content:a&&i.trim()?i.trim():void 0,rating:n&&y!==null?y:void 0,isBug:c||void 0});},R={width:"100%",padding:v?"12px 14px":"10px 12px",border:`1px solid ${h?"rgba(255,255,255,0.08)":"#e2e8f0"}`,borderRadius:8,backgroundColor:h?"rgba(55,65,81,0.5)":"#fafbfc",color:h?"#f9fafb":"#111827",fontSize:v?16:14,resize:"vertical",minHeight:v?100:80,fontFamily:"inherit",outline:"none",transition:"border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1)",lineHeight:1.5,...g?.input},w={width:"100%",padding:v?"14px 16px":"10px 16px",border:"none",borderRadius:8,backgroundColor:h?"#e2e8f0":"#1e293b",color:h?"#1e293b":"#ffffff",fontSize:v?16:14,fontWeight:500,cursor:o?"not-allowed":"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",letterSpacing:"0.01em",...g?.submitButton};return jsxRuntime.jsxs("form",{onSubmit:x,children:[n&&jsxRuntime.jsx("div",{style:{marginBottom:a?v?16:12:0,...a?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsxRuntime.jsx(vt,{value:y,onChange:p,isDark:h,isTouch:v,large:!a})}),a&&jsxRuntime.jsx("textarea",{value:i,onChange:m=>d(m.target.value),placeholder:r||"Share your thoughts...",style:R,disabled:o,"aria-label":"Your feedback",onFocus:m=>{m.currentTarget.style.borderColor="#1e293b",m.currentTarget.style.boxShadow="0 0 0 2px rgba(30,41,59,0.15)",m.currentTarget.style.backgroundColor=h?"rgba(55,65,81,0.7)":"#ffffff";},onBlur:m=>{m.currentTarget.style.borderColor=h?"rgba(255,255,255,0.08)":"#e2e8f0",m.currentTarget.style.boxShadow="none",m.currentTarget.style.backgroundColor=h?"rgba(55,65,81,0.5)":"#fafbfc";}}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>I(!c),style:{display:"flex",alignItems:"center",gap:7,width:"100%",marginTop:10,padding:"7px 10px",border:`1px solid ${c?h?"rgba(245,158,11,0.3)":"rgba(217,119,6,0.25)":h?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)"}`,borderRadius:7,backgroundColor:c?h?"rgba(245,158,11,0.08)":"rgba(251,191,36,0.08)":"transparent",cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)"},onMouseEnter:m=>{c||(m.currentTarget.style.backgroundColor=h?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)");},onMouseLeave:m=>{c||(m.currentTarget.style.backgroundColor="transparent");},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:c?h?"#fbbf24":"#d97706":h?"#6b7280":"#9ca3af",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:"stroke 0.2s"},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:c?500:400,color:c?h?"#fbbf24":"#b45309":h?"#6b7280":"#9ca3af",transition:"color 0.2s",letterSpacing:"0.01em"},children:c?"Issue reported":f||"Report an issue"}),jsxRuntime.jsx("div",{style:{marginLeft:"auto",width:28,height:16,borderRadius:8,backgroundColor:c?h?"#f59e0b":"#d97706":h?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",position:"relative",transition:"background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1)",flexShrink:0},children:jsxRuntime.jsx("div",{style:{position:"absolute",top:2,left:c?14:2,width:12,height:12,borderRadius:"50%",backgroundColor:c?"#ffffff":h?"#4b5563":"#d1d5db",transition:"left 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.15)"}})})]}),jsxRuntime.jsxs("button",{type:"submit",disabled:o||!M,style:{...w,marginTop:12,opacity:o?.8:1,backgroundColor:M?h?"#e2e8f0":"#1e293b":h?"#374151":"#e2e8f0",color:M?h?"#1e293b":"#ffffff":h?"#6b7280":"#94a3b8",display:"flex",alignItems:"center",justifyContent:"center",gap:8},onMouseEnter:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=h?"#cbd5e1":"#334155");},onMouseLeave:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=h?"#e2e8f0":"#1e293b");},children:[o&&jsxRuntime.jsx(_,{size:v?18:16,color:h?"#1e293b":"#ffffff"}),o?u?"Updating...":"Submitting...":u?"Update":s]})]})}function vt({value:e,onChange:r,isDark:s,isTouch:o,large:b=false}){let[g,t]=react.useState(null),u=b?o?36:28:o?28:18,a=b?o?8:5:o?6:3;return jsxRuntime.jsx("div",{style:{display:"flex",gap:b?o?8:6:o?6:2},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(n=>{let l=(g??e??0)>=n;return jsxRuntime.jsx("button",{type:"button",onClick:()=>r(n),onMouseEnter:()=>t(n),onMouseLeave:()=>t(null),"aria-label":`Rate ${n} out of 5`,"aria-pressed":e===n,style:{background:"none",border:"none",cursor:"pointer",padding:a,color:l?"#f59e0b":s?"rgba(255,255,255,0.12)":"#e2e8f0",transition:"color 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1)",transform:g!==null&&g>=n?"scale(1.1)":"scale(1)"},children:jsxRuntime.jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})},n)})})}function et({theme:e,isLoading:r,onSubmit:s,initialVote:o,isEditing:b=false,labels:g}){let[t,u]=react.useState(false),[a,n]=react.useState(o||null),[l,f]=react.useState(o||null);react.useEffect(()=>{u(D());},[]),react.useEffect(()=>{o!==void 0&&(f(o),n(o));},[o]),react.useEffect(()=>{!r&&!b&&n(null);},[r,b]);let i=c=>{n(c),s({vote:c});},d=e==="dark",y=c=>{let I=l===c;return {flex:1,minWidth:0,overflow:"hidden",padding:t?"14px 18px":"10px 14px",border:`1px solid ${I?c==="up"?d?"rgba(16,185,129,0.3)":"rgba(16,185,129,0.25)":d?"rgba(239,68,68,0.3)":"rgba(239,68,68,0.25)":d?"rgba(255,255,255,0.08)":"#e2e8f0"}`,borderRadius:t?10:8,backgroundColor:I?c==="up"?d?"rgba(16,185,129,0.08)":"rgba(16,185,129,0.06)":d?"rgba(239,68,68,0.08)":"rgba(239,68,68,0.06)":d?"rgba(55,65,81,0.5)":"#fafbfc",color:I?c==="up"?"#10b981":"#ef4444":d?"#d1d5db":"#64748b",fontSize:t?28:24,cursor:r?"not-allowed":"pointer",transition:"background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s",display:"flex",alignItems:"center",justifyContent:"center",gap:t?10:8}},p=t?24:20;return jsxRuntime.jsxs("div",{style:{display:"flex",gap:t?12:10},role:"group","aria-label":"Vote",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i("up"),disabled:r,style:y("up"),"aria-label":"Vote up - I like this","aria-pressed":l==="up",onMouseEnter:c=>{r||(c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)");},onMouseLeave:c=>{c.currentTarget.style.transform="translateY(0)",c.currentTarget.style.boxShadow="none";},children:r&&a==="up"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(_,{size:p,color:d?"#f9fafb":"#111827"}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:b?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(kt,{size:p}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:g?.up||(l==="up"?"Liked":"Like")})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i("down"),disabled:r,style:y("down"),"aria-label":"Vote down - I don't like this","aria-pressed":l==="down",onMouseEnter:c=>{r||(c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)");},onMouseLeave:c=>{c.currentTarget.style.transform="translateY(0)",c.currentTarget.style.boxShadow="none";},children:r&&a==="down"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(_,{size:p,color:d?"#f9fafb":"#111827"}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:b?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wt,{size:p}),jsxRuntime.jsx("span",{style:{fontSize:t?15:13,fontWeight:500,letterSpacing:"0.01em"},children:g?.down||(l==="down"?"Disliked":"Dislike")})]})})]})}function kt({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function wt({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function nt({theme:e,options:r,allowMultiple:s,isLoading:o,onSubmit:b,initialSelected:g,isEditing:t=false}){let[u,a]=react.useState(g||[]),[n,l]=react.useState(false);react.useEffect(()=>{l(D());},[]),react.useEffect(()=>{g&&a(g);},[g]);let f=e==="dark",i=p=>{a(s?c=>c.includes(p)?c.filter(I=>I!==p):[...c,p]:c=>c.includes(p)?[]:[p]);},d=()=>{u.length!==0&&b({pollSelected:u});},y=p=>{let c=u.includes(p);return {width:"100%",padding:n?"12px 14px":"9px 12px",border:`1px solid ${c?f?"rgba(226,232,240,0.25)":"rgba(30,41,59,0.25)":f?"rgba(255,255,255,0.08)":"#e2e8f0"}`,borderRadius:n?10:8,backgroundColor:c?f?"rgba(226,232,240,0.08)":"rgba(30,41,59,0.05)":f?"rgba(55,65,81,0.5)":"#fafbfc",color:c?f?"#e2e8f0":"#1e293b":f?"#d1d5db":"#374151",fontSize:n?15:13,fontWeight:500,cursor:o?"not-allowed":"pointer",transition:"background-color 0.2s, border-color 0.2s, color 0.2s",textAlign:"left",letterSpacing:"0.01em",display:"flex",alignItems:"center",gap:8}};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:n?8:6},role:"group","aria-label":s?"Select one or more options":"Select an option",children:r.map(p=>{let c=u.includes(p);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>i(p),disabled:o,style:y(p),"aria-pressed":c,children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:s?4:"50%",border:`2px solid ${c?f?"#e2e8f0":"#1e293b":f?"rgba(255,255,255,0.2)":"#cbd5e1"}`,backgroundColor:c?f?"#e2e8f0":"#1e293b":"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.15s"},children:c&&jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),p]},p)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,disabled:o||u.length===0,style:{width:"100%",marginTop:12,padding:n?"14px 16px":"10px 16px",border:"none",borderRadius:8,backgroundColor:u.length===0?f?"#374151":"#e2e8f0":f?"#e2e8f0":"#1e293b",color:u.length===0?f?"#6b7280":"#94a3b8":f?"#1e293b":"#ffffff",fontSize:n?16:14,fontWeight:500,cursor:o||u.length===0?"not-allowed":"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:o?.8:1},onMouseEnter:p=>{p.currentTarget.disabled||(p.currentTarget.style.backgroundColor=f?"#cbd5e1":"#334155");},onMouseLeave:p=>{p.currentTarget.disabled||(p.currentTarget.style.backgroundColor=u.length===0?f?"#374151":"#e2e8f0":f?"#e2e8f0":"#1e293b");},children:[o&&jsxRuntime.jsx(_,{size:n?18:16,color:f?"#1e293b":"#ffffff"}),o?t?"Updating...":"Submitting...":t?"Update":"Submit"]})]})}var Et=["#ef4444","#f05540","#f1663c","#f27738","#f38834","#f59e0b","#d4a30e","#b3a812","#79b841","#45c870","#10b981"];function st({theme:e,submitText:r,isLoading:s,onSubmit:o,customStyles:b,showFollowUp:g=true,followUpPlaceholder:t,lowLabel:u="Not likely",highLabel:a="Very likely",initialValues:n,isEditing:l=false}){let[f,i]=react.useState(n?.rating??null),[d,y]=react.useState(n?.content||""),[p,c]=react.useState(false),[I,v]=react.useState(null);react.useEffect(()=>{c(D());},[]),react.useEffect(()=>{n?.rating!==void 0&&i(n.rating??null),n?.content!==void 0&&y(n.content||"");},[n?.rating,n?.content]);let S=e==="dark",h=f!==null;return jsxRuntime.jsxs("form",{onSubmit:x=>{x.preventDefault(),h&&o({rating:f??void 0,content:g&&d.trim()?d.trim():void 0});},children:[jsxRuntime.jsxs("div",{style:{marginBottom:g&&f!==null?p?14:12:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:p?8:6,justifyContent:"center"},role:"group","aria-label":"NPS Score",children:Array.from({length:11},(x,R)=>{let w=f===R,m=I===R,k=Et[R];return jsxRuntime.jsx("button",{type:"button",onClick:()=>i(R),onMouseEnter:()=>v(R),onMouseLeave:()=>v(null),"aria-label":`Score ${R} out of 10`,"aria-pressed":w,style:{flex:1,height:p?36:32,borderRadius:8,border:w?`2px solid ${k}`:`1.5px solid ${S?`${k}30`:`${k}25`}`,backgroundColor:w?k:m?S?`${k}30`:`${k}18`:S?`${k}15`:`${k}0c`,color:w?"#fff":m?k:S?`${k}cc`:`${k}bb`,fontSize:p?13:12,fontWeight:w?700:600,fontFamily:"inherit",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1)",transform:w?"scale(1.08)":m?"scale(1.04)":"scale(1)",boxShadow:w?`0 2px 8px ${k}40`:"none",flexShrink:0},children:R},R)})}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:10,padding:"0 2px"},children:[jsxRuntime.jsx("span",{style:{fontSize:10,color:S?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)",fontWeight:500},children:u}),jsxRuntime.jsx("span",{style:{fontSize:10,color:S?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)",fontWeight:500},children:a})]})]}),g&&f!==null&&jsxRuntime.jsx("textarea",{value:d,onChange:x=>y(x.target.value),placeholder:t||"What's the main reason for your score?",style:{width:"100%",padding:p?"12px 14px":"10px 12px",border:`1px solid ${S?"rgba(255,255,255,0.08)":"#e2e8f0"}`,borderRadius:8,backgroundColor:S?"rgba(55,65,81,0.5)":"#fafbfc",color:S?"#f9fafb":"#111827",fontSize:p?16:14,resize:"vertical",minHeight:p?80:60,fontFamily:"inherit",outline:"none",transition:"border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1)",lineHeight:1.5,...b?.input},disabled:s,"aria-label":"Follow-up feedback",onFocus:x=>{x.currentTarget.style.borderColor=S?"rgba(255,255,255,0.2)":"#94a3b8",x.currentTarget.style.boxShadow=`0 0 0 2px ${S?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)"}`,x.currentTarget.style.backgroundColor=S?"rgba(55,65,81,0.7)":"#ffffff";},onBlur:x=>{x.currentTarget.style.borderColor=S?"rgba(255,255,255,0.08)":"#e2e8f0",x.currentTarget.style.boxShadow="none",x.currentTarget.style.backgroundColor=S?"rgba(55,65,81,0.5)":"#fafbfc";}}),jsxRuntime.jsxs("button",{type:"submit",disabled:s||!h,style:{width:"100%",padding:p?"14px 16px":"10px 16px",border:"none",borderRadius:8,backgroundColor:h?S?"#e2e8f0":"#1e293b":S?"#374151":"#e2e8f0",color:h?S?"#1e293b":"#ffffff":S?"#6b7280":"#94a3b8",fontSize:p?16:14,fontWeight:500,cursor:s?"not-allowed":"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",letterSpacing:"0.01em",opacity:s?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginTop:12,...b?.submitButton},onMouseEnter:x=>{x.currentTarget.disabled||(x.currentTarget.style.backgroundColor=S?"#cbd5e1":"#334155");},onMouseLeave:x=>{x.currentTarget.disabled||(x.currentTarget.style.backgroundColor=S?"#e2e8f0":"#1e293b");},children:[s&&jsxRuntime.jsx(_,{size:p?18:16,color:S?"#1e293b":"#ffffff"}),s?l?"Updating...":"Submitting...":l?"Update":r]})]})}function Le({mode:e,theme:r,customStyles:s,promptText:o,placeholder:b,submitText:g,thankYouMessage:t,isLoading:u,isSubmitted:a,error:n,existingResponse:l,isEditing:f=false,showText:i=true,showRating:d=true,voteLabels:y,options:p,allowMultiple:c=false,npsQuestion:I,npsFollowUp:v=true,npsFollowUpPlaceholder:S,npsLowLabel:h,npsHighLabel:M,enableBugFlag:x=false,bugFlagLabel:R,onSubmit:w,onClose:m,anchorRect:k}){let U=react.useRef(null),q=react.useRef(null),[W,xe]=react.useState(false),[A,ve]=react.useState(false),[ie,Y]=react.useState("light");react.useEffect(()=>{ve(window.innerWidth<640);let C=window.matchMedia("(prefers-color-scheme: dark)");Y(C.matches?"dark":"light");let B=O=>Y(O.matches?"dark":"light");return C.addEventListener("change",B),()=>C.removeEventListener("change",B)},[]),react.useEffect(()=>{let C=requestAnimationFrame(()=>xe(true));return ()=>cancelAnimationFrame(C)},[]);let V=r==="auto"?ie:r,E=V==="dark",Z=(k?window.innerHeight-k.bottom:window.innerHeight/2)<280+20;react.useEffect(()=>{let C=U.current;if(!C)return;q.current?.focus();let B=O=>{if(O.key==="Escape"){m();return}if(O.key==="Tab"){let K=C.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),ee=K[0],F=K[K.length-1];O.shiftKey&&document.activeElement===ee?(O.preventDefault(),F?.focus()):!O.shiftKey&&document.activeElement===F&&(O.preventDefault(),ee?.focus());}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[m]);let ce=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":e==="nps"?I||"How likely are you to recommend us?":"What do you think of this feature?",ue=A?20:16,J=e==="nps"?420:320,de=E?"0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.2)":"0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.06)",j=A?{position:"fixed",left:"50%",top:"50%",width:"calc(100vw - 32px)",maxWidth:J,padding:ue,borderRadius:12,backgroundColor:E?"#1f2937":"#ffffff",color:E?"#f9fafb":"#111827",boxShadow:de,border:`1px solid ${E?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)"}`,zIndex:9999,transition:"opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1)",opacity:W?1:0,transform:W?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.96)",...s?.modal,textAlign:"left"}:{position:"absolute",left:"50%",width:J,padding:ue,borderRadius:10,backgroundColor:E?"#1f2937":"#ffffff",color:E?"#f9fafb":"#111827",boxShadow:de,border:`1px solid ${E?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)"}`,zIndex:9999,...Z?{bottom:"100%",marginBottom:8}:{top:"100%",marginTop:8},transition:"opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1)",opacity:W?1:0,transform:W?"translateX(-50%) scale(1) translateY(0)":`translateX(-50%) scale(0.96) translateY(${Z?"6px":"-6px"})`,...s?.modal,textAlign:"left"};return jsxRuntime.jsxs("div",{ref:U,role:"dialog","aria-modal":"true","aria-labelledby":"gotcha-modal-title",style:j,className:ge("gotcha-modal",E&&"gotcha-modal--dark"),children:[jsxRuntime.jsx("button",{ref:q,type:"button",onClick:m,"aria-label":"Close feedback form",style:{position:"absolute",top:A?12:8,right:A?12:8,width:A?36:28,height:A?36:28,border:"none",background:"transparent",cursor:"pointer",color:E?"#6b7280":"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,transition:"all 0.15s cubic-bezier(0.4, 0, 0.2, 1)"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=E?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)",C.currentTarget.style.color=E?"#9ca3af":"#6b7280";},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent",C.currentTarget.style.color=E?"#6b7280":"#9ca3af";},children:jsxRuntime.jsx("svg",{width:A?16:12,height:A?16:12,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:A?16:14,fontWeight:600,paddingRight:A?40:32,letterSpacing:"-0.01em",lineHeight:1.4,textAlign:"left"},children:o||ce}),a&&jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"24px 0",color:E?"#10b981":"#059669"},children:[jsxRuntime.jsx("div",{style:{width:44,height:44,borderRadius:"50%",backgroundColor:E?"rgba(16,185,129,0.1)":"rgba(5,150,105,0.08)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 12px"},children:jsxRuntime.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M20 6L9 17L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:13,fontWeight:500,color:E?"#d1d5db":"#374151"},children:t})]}),n&&!a&&jsxRuntime.jsx("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:8,backgroundColor:E?"rgba(127,29,29,0.3)":"#fef2f2",border:`1px solid ${E?"rgba(254,202,202,0.1)":"rgba(220,38,38,0.1)"}`,color:E?"#fecaca":"#dc2626",fontSize:13,lineHeight:1.4},children:n}),!a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e==="feedback"&&jsxRuntime.jsx(Je,{theme:V,placeholder:b,submitText:g,isLoading:u,onSubmit:w,customStyles:s,initialValues:l?{content:l.content,rating:l.rating}:void 0,isEditing:f,showText:i,showRating:d,enableBugFlag:x,bugFlagLabel:R}),e==="vote"&&jsxRuntime.jsx(et,{theme:V,isLoading:u,onSubmit:w,initialVote:l?.vote||void 0,isEditing:f,labels:y}),e==="nps"&&jsxRuntime.jsx(st,{theme:V,submitText:g,isLoading:u,onSubmit:w,showFollowUp:v,followUpPlaceholder:S,lowLabel:h,highLabel:M,customStyles:s,initialValues:l?{rating:l.rating,content:l.content}:void 0,isEditing:f}),e==="poll"&&p&&p.length>0&&jsxRuntime.jsx(nt,{theme:V,options:p,allowMultiple:c,isLoading:u,onSubmit:w,initialSelected:l?.pollSelected||void 0,isEditing:f})]}),jsxRuntime.jsxs("div",{"aria-live":"polite",className:"sr-only",style:{position:"absolute",left:-9999},children:[a&&"Thank you! Your feedback has been submitted.",n&&`Error: ${n}`]})]})}function Mt({elementId:e,user:r,mode:s="feedback",showText:o=true,showRating:b=true,voteLabels:g,options:t,allowMultiple:u=false,npsQuestion:a,npsFollowUp:n=true,npsFollowUpPlaceholder:l,npsLowLabel:f,npsHighLabel:i,enableBugFlag:d=false,bugFlagLabel:y,onePerUser:p=false,position:c=N.POSITION,size:I=N.SIZE,theme:v=N.THEME,customStyles:S,visible:h=true,showOnHover:M=N.SHOW_ON_HOVER,touchBehavior:x=N.TOUCH_BEHAVIOR,promptText:R,placeholder:w,submitText:m=N.SUBMIT_TEXT,thankYouMessage:k=N.THANK_YOU_MESSAGE,onSubmit:U,onOpen:q,onClose:W,onError:xe}){let{disabled:A,activeModalId:ve,openModal:ie,closeModal:Y,client:V}=H(),[E,le]=react.useState(false),[Oe,Z]=react.useState(false),[ce,ue]=react.useState(null),[J,de]=react.useState(false),j=react.useRef(null);react.useEffect(()=>{de(window.innerWidth<640);},[]);let C=ve===e;react.useEffect(()=>{if(!M)return;let G=j.current;if(!G)return;let te=G.parentElement;if(!te)return;let $e=()=>Z(true),Be=()=>Z(false);return te.addEventListener("mouseenter",$e),te.addEventListener("mouseleave",Be),()=>{te.removeEventListener("mouseenter",$e),te.removeEventListener("mouseleave",Be);}},[M]);let{submit:B,isLoading:O,error:K,existingResponse:ee,isEditing:F}=je({elementId:e,mode:s,pollOptions:t,user:r,onSuccess:G=>{le(true),U?.(G),setTimeout(()=>{Y(),le(false);},1500);},onError:G=>{console.warn("[Gotcha] Submission failed:",G instanceof Error?G.message:G),xe?.(G);}}),ct=react.useCallback(()=>{j.current&&ue(j.current.getBoundingClientRect()),ie(e),q?.();},[e,ie,q]),ke=react.useCallback(()=>{Y(),le(false),W?.();},[Y,W]),De=react.useCallback(G=>{B(G);},[B]),_e=F?"Update":m;return A||!h?null:jsxRuntime.jsxs("div",{ref:j,style:{...{"top-right":{position:"absolute",top:0,right:0,transform:"translate(50%, -50%)"},"top-left":{position:"absolute",top:0,left:0,transform:"translate(-50%, -50%)"},"bottom-right":{position:"absolute",bottom:0,right:0,transform:"translate(50%, 50%)"},"bottom-left":{position:"absolute",bottom:0,left:0,transform:"translate(-50%, 50%)"},inline:{position:"relative",display:"inline-flex"}}[c],zIndex:C?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(qe,{size:I,theme:v,customStyles:S,showOnHover:M,touchBehavior:x,onClick:ct,isOpen:C,isParentHovered:Oe}),C&&!J&&jsxRuntime.jsx(Le,{mode:s,theme:v,customStyles:S,promptText:R,placeholder:w,submitText:_e,thankYouMessage:F?"Your feedback has been updated!":k,isLoading:O,isSubmitted:E,error:K,existingResponse:ee,isEditing:F,showText:o,showRating:b,voteLabels:g,options:t,allowMultiple:u,npsQuestion:a,npsFollowUp:n,npsFollowUpPlaceholder:l,npsLowLabel:f,npsHighLabel:i,enableBugFlag:d,bugFlagLabel:y,onSubmit:De,onClose:ke,anchorRect:ce||void 0}),C&&J&&reactDom.createPortal(jsxRuntime.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:"rgba(0, 0, 0, 0.3)"},onClick:ke,children:jsxRuntime.jsx("div",{onClick:G=>G.stopPropagation(),children:jsxRuntime.jsx(Le,{mode:s,theme:v,customStyles:S,promptText:R,placeholder:w,submitText:_e,thankYouMessage:F?"Your feedback has been updated!":k,isLoading:O,isSubmitted:E,error:K,existingResponse:ee,isEditing:F,showText:o,showRating:b,voteLabels:g,options:t,allowMultiple:u,npsQuestion:a,npsFollowUp:n,npsFollowUpPlaceholder:l,npsLowLabel:f,npsHighLabel:i,enableBugFlag:d,bugFlagLabel:y,onSubmit:De,onClose:ke,anchorRect:ce||void 0})})}),document.body)]})}function lt({elementId:e,refreshInterval:r}){let{client:s}=H(),[o,b]=react.useState(null),[g,t]=react.useState(true),[u,a]=react.useState(null);return react.useEffect(()=>{let n=false,l=async()=>{try{let i=await s.getScore(e);n||(b(i),a(null));}catch(i){n||a(i instanceof Error?i.message:"Failed to load score");}finally{n||t(false);}};l();let f;return r&&r>0&&(f=setInterval(l,r)),()=>{n=true,f&&clearInterval(f);}},[s,e,r]),{score:o,isLoading:g,error:u}}var Lt={sm:{fontSize:11,ratingFontSize:13,starSize:13,gap:5,pillPx:8,pillPy:4,barHeight:3,iconSize:12},md:{fontSize:12.5,ratingFontSize:15,starSize:15,gap:6,pillPx:10,pillPy:5,barHeight:4,iconSize:14},lg:{fontSize:14,ratingFontSize:18,starSize:18,gap:8,pillPx:12,pillPy:6,barHeight:5,iconSize:16}};function At(e,r){return e==="auto"?r:e}function Ut({rating:e,size:r,filledColor:s,emptyColor:o}){let b=`gotcha-star-clip-${Math.random().toString(36).slice(2,8)}`,g=[];for(let t=1;t<=5;t++){let u=Math.min(1,Math.max(0,e-(t-1))),a=`${b}-${t}`;g.push(jsxRuntime.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",style:{display:"block"},children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:a,children:jsxRuntime.jsx("rect",{x:"0",y:"0",width:24*u,height:"24"})})}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:o}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:s,clipPath:`url(#${a})`})]},t));}return jsxRuntime.jsx("span",{style:{display:"inline-flex",gap:Math.max(1,r*.08),alignItems:"center"},children:g})}function Ot({rate:e,height:r,filledColor:s,trackColor:o}){return jsxRuntime.jsx("span",{style:{display:"inline-block",width:48,height:r,borderRadius:r,backgroundColor:o,overflow:"hidden",verticalAlign:"middle"},children:jsxRuntime.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:r,background:s,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function Dt({size:e,color:r}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:r,style:{display:"block"},children:jsxRuntime.jsx("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66a4.8 4.8 0 00-.88-1.12L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})})}function _t({elementId:e,variant:r="stars",showCount:s=true,size:o="md",theme:b="auto",refreshInterval:g,style:t}){let{score:u,isLoading:a}=lt({elementId:e,refreshInterval:g}),[n,l]=react.useState("light");if(react.useEffect(()=>{if(typeof window>"u")return;let m=window.matchMedia("(prefers-color-scheme: dark)");l(m.matches?"dark":"light");let k=U=>l(U.matches?"dark":"light");return m.addEventListener("change",k),()=>m.removeEventListener("change",k)},[]),a||!u)return null;let i=At(b,n)==="dark",d=Lt[o],y=i?"#f3f4f6":"#000000",p="#9ca3af",c=i?"#facc15":"#eab308",I=i?"#374151":"#e5e7eb",v=i?"#6ee7b7":"#16a34a",S=i?"#374151":"#e5e7eb",h={display:"inline-flex",alignItems:"center",gap:d.gap,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',lineHeight:1,letterSpacing:"-0.01em",WebkitFontSmoothing:"antialiased",...t},M=(m,k)=>{let U=m===1?k:`${k}s`;return `${m.toLocaleString()} ${U}`};if(r==="votes"){let{voteCount:m,positiveRate:k}=u,U=m.up+m.down;return U===0?null:jsxRuntime.jsxs("span",{style:h,children:[jsxRuntime.jsx(Dt,{size:d.iconSize,color:v}),jsxRuntime.jsxs("span",{style:{fontSize:d.ratingFontSize,fontWeight:600,color:v,fontVariantNumeric:"tabular-nums"},children:[k,"%"]}),jsxRuntime.jsx(Ot,{rate:k??0,height:d.barHeight,filledColor:v,trackColor:S}),s&&jsxRuntime.jsx("span",{style:{fontSize:d.fontSize,color:p,fontWeight:400},children:M(U,"vote")})]})}let{averageRating:x,totalResponses:R}=u;if(x===null||R===0)return null;let w=x.toFixed(1);return r==="compact"?jsxRuntime.jsxs("span",{style:h,children:[jsxRuntime.jsx("svg",{width:d.starSize,height:d.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:c})}),jsxRuntime.jsx("span",{style:{fontSize:d.ratingFontSize,fontWeight:700,color:y,fontVariantNumeric:"tabular-nums"},children:w}),s&&jsxRuntime.jsxs("span",{style:{fontSize:d.fontSize,color:p,fontWeight:400},children:["(",R.toLocaleString(),")"]})]}):r==="number"?jsxRuntime.jsxs("span",{style:h,children:[jsxRuntime.jsx("span",{style:{fontSize:d.ratingFontSize,fontWeight:700,color:y,fontVariantNumeric:"tabular-nums"},children:w}),jsxRuntime.jsx("span",{style:{fontSize:d.fontSize,color:p,fontWeight:400},children:"/ 5"}),s&&jsxRuntime.jsxs("span",{style:{fontSize:d.fontSize,color:p,fontWeight:400,marginLeft:2},children:["(",M(R,"response"),")"]})]}):jsxRuntime.jsxs("span",{style:h,children:[jsxRuntime.jsx(Ut,{rating:x,size:d.starSize,filledColor:c,emptyColor:I}),jsxRuntime.jsx("span",{style:{fontSize:d.ratingFontSize,fontWeight:700,color:y,fontVariantNumeric:"tabular-nums"},children:w}),s&&jsxRuntime.jsxs("span",{style:{fontSize:d.fontSize,color:p,fontWeight:400},children:["(",M(R,"response"),")"]})]})}function $t(){let{client:e,disabled:r,defaultUser:s,debug:o}=H();return {client:e,disabled:r,defaultUser:s,debug:o,submitFeedback:e.submitResponse.bind(e)}}exports.Gotcha=Mt;exports.GotchaProvider=pt;exports.GotchaScore=_t;exports.useGotcha=$t;//# sourceMappingURL=index.js.map
|
|
12
12
|
//# sourceMappingURL=index.js.map
|