@opengovsg/confetti 0.3.4 → 0.5.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/build/index.d.ts CHANGED
@@ -1,403 +1,108 @@
1
- import { n as ModalContainerProps, t as ModalContainer } from "./ModalContainer-BT1Bys9H.js";
2
- import { a as MultiSelectQuestionProperties, c as StatementQuestionProperties, i as PublicGetSurveyOutput, l as TextQuestionProperties, n as ConfettiState, o as RatingQuestionProperties, r as Question, s as SingleSelectQuestionProperties, t as Answer } from "./types-CJY8TUUa.js";
3
- import { HTMLAttributes, PropsWithChildren, SVGProps } from "react";
1
+ import { a as Finishable, i as Dismissable, n as Closable, o as OptionallyDismissable, s as Proxyable } from "./types-Sf4fgrFJ.js";
2
+ import { t as BaseConfettiProps } from "./Confetti-gIat3060.js";
4
3
 
5
- //#region src/core/ConfettiController.d.ts
6
- interface ConfettiControllerProps {
7
- children: (props: ConfettiState) => React.ReactElement;
8
- /**
9
- * Control the current question index that is being displayed.
10
- * If not provided, the component will manage it internally.
11
- */
12
- current?: number;
13
- shouldAutoSubmit?: boolean;
14
- onFinished?: () => void;
15
- }
16
- declare const ConfettiController: ({
17
- current: currentProp,
18
- shouldAutoSubmit,
19
- onFinished,
20
- children
21
- }: ConfettiControllerProps) => import("react/jsx-runtime").JSX.Element;
22
- //#endregion
23
- //#region src/contracts/state.d.ts
24
- interface ConfettiRespondentState {
25
- lastRespondedAt: Date | null;
26
- lastDismissedAt: Date | null;
4
+ //#region src/contracts/api.d.ts
5
+ type Template = 'TriggerPopover' | 'Popover' | 'Modal' | 'Embedded' | 'Stepper';
6
+ interface MountHandle {
7
+ readonly id: number;
27
8
  }
28
- //#endregion
29
- //#region src/core/logic/is-visible.d.ts
30
- type IsSurveyVisible = boolean | ((s: ConfettiRespondentState) => boolean) | undefined;
31
- //#endregion
32
- //#region src/core/ConfettiProvider.d.ts
33
- interface ConfettiContextValue {
34
- surveyId: string;
35
- metadata: Record<string, string>;
36
- submit: ({
37
- answers
38
- }: {
39
- answers: Record<Question['id'], Answer>;
40
- }) => Promise<void>;
41
- dismiss: () => Promise<void> | void;
42
- survey: PublicGetSurveyOutput | undefined;
43
- isVisible: boolean;
44
- }
45
- declare const ConfettiContext: import("react").Context<ConfettiContextValue | null>;
46
- interface ConfettiProviderProps {
47
- children: React.ReactNode;
9
+ interface MountPropsBase extends Finishable {
48
10
  surveyId: string;
49
11
  publishableKey: string;
50
- respondent?: string;
12
+ respondent: string;
51
13
  metadata?: Record<string, string>;
52
14
  apiBaseUrl?: string;
53
- isSurveyVisible?: IsSurveyVisible;
54
- alwaysRenderChildren?: boolean;
55
- }
56
- declare const ConfettiProvider: (props: ConfettiProviderProps) => import("react/jsx-runtime").JSX.Element;
57
- declare const useConfetti: () => ConfettiContextValue;
58
- //#endregion
59
- //#region src/components/questions/types.d.ts
60
- type Question$1 = PublicGetSurveyOutput['questions'][number];
61
- interface BaseFieldProps {
62
- id: string;
63
- title: string | null | undefined;
64
- description?: string | null | undefined;
65
- required?: boolean;
66
- onChange: (answer: Answer) => void;
67
- error?: string;
68
- }
69
- //#endregion
70
- //#region src/components/questions/BugReport/BugReport.d.ts
71
- interface BugReportOptions {
72
- maskAllInputs?: boolean;
73
- }
74
- //#endregion
75
- //#region src/components/Confetti.d.ts
76
- interface ConfettiProps extends Omit<ConfettiProviderProps, 'children'>, Pick<ConfettiControllerProps, 'onFinished' | 'shouldAutoSubmit'> {
77
- options?: {
78
- bugReport?: BugReportOptions;
79
- };
80
- }
81
- declare const Confetti: ({
82
- children,
83
- onFinished,
84
- shouldAutoSubmit,
85
- ...props
86
- }: ConfettiProps & Pick<ConfettiControllerProps, "children" | "shouldAutoSubmit">) => import("react/jsx-runtime").JSX.Element;
87
- //#endregion
88
- //#region src/components/ThankYouMessage.d.ts
89
- interface ThankYouMessageProps {
90
- title?: string;
91
- description?: string;
92
- classNames?: {
93
- question?: string;
94
- header?: string;
95
- title?: string;
96
- description?: string;
97
- };
98
- }
99
- declare const ThankYouMessage: ({
100
- title,
101
- description,
102
- classNames
103
- }: ThankYouMessageProps) => import("react/jsx-runtime").JSX.Element | null;
104
- //#endregion
105
- //#region src/components/container/PopoverContainer.d.ts
106
- interface PopoverContainerProps {
107
- closeOnFinishMs?: number | null;
108
- classNames?: {
109
- dialog?: string;
110
- closeButton?: string;
111
- icon?: string;
112
- };
113
- onDismiss?: () => void;
114
- containerProps?: Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
115
- children: React.ReactNode | ((props: {
116
- setIsFinished: () => void;
117
- }) => React.ReactNode);
118
- }
119
- declare const PopoverContainer: ({
120
- children,
121
- classNames,
122
- containerProps,
123
- onDismiss,
124
- closeOnFinishMs
125
- }: PopoverContainerProps) => import("react/jsx-runtime").JSX.Element;
126
- //#endregion
127
- //#region src/components/questions/factory.d.ts
128
- interface SurveyQuestionFactoryProps extends BugReportOptions {
129
- question: Question$1;
130
- onChange: (answer: Answer) => void;
131
- error?: string;
132
- }
133
- declare const SurveyQuestionFactory: ({
134
- question,
135
- onChange,
136
- error,
137
- maskAllInputs
138
- }: SurveyQuestionFactoryProps) => import("react/jsx-runtime").JSX.Element;
139
- //#endregion
140
- //#region src/components/questions/Rating.d.ts
141
- interface RatingProps extends BaseFieldProps {
142
- properties: RatingQuestionProperties;
143
- classNames?: {
144
- question?: string;
145
- header?: string;
146
- title?: string;
147
- description?: string;
148
- optionalLabel?: string;
149
- ratingSection?: string;
150
- ratingDisplay?: string;
151
- ratingText?: string;
152
- ratingTextLower?: string;
153
- ratingTextUpper?: string;
154
- ratingDisplayStar?: string;
155
- ratingStar?: string;
156
- ratingDisplayNumber?: string;
157
- ratingNumber?: string;
158
- ratingDisplayEmoji?: string;
159
- ratingEmoji?: string;
160
- error?: string;
161
- };
162
- }
163
- declare const Rating: ({
164
- properties,
165
- title,
166
- description,
167
- classNames,
168
- onChange,
169
- id,
170
- error,
171
- required
172
- }: RatingProps) => import("react/jsx-runtime").JSX.Element;
173
- //#endregion
174
- //#region src/components/questions/FreeText.d.ts
175
- interface FreeTextProps extends BaseFieldProps {
176
- properties: TextQuestionProperties;
177
- classNames?: {
178
- question?: string;
179
- header?: string;
180
- title?: string;
181
- optionalLabel?: string;
182
- description?: string;
183
- textarea?: string;
184
- error?: string;
185
- };
186
- }
187
- declare const FreeText: ({
188
- id,
189
- title,
190
- description,
191
- properties,
192
- onChange,
193
- classNames,
194
- required,
195
- error
196
- }: FreeTextProps) => import("react/jsx-runtime").JSX.Element;
197
- //#endregion
198
- //#region src/components/questions/SingleChoice.d.ts
199
- interface SingleChoiceProps extends BaseFieldProps {
200
- properties: SingleSelectQuestionProperties;
201
- classNames?: {
202
- question?: string;
203
- header?: string;
204
- label?: string;
205
- title?: string;
206
- description?: string;
207
- optionalLabel?: string;
208
- group?: string;
209
- radio?: string;
210
- indicator?: string;
211
- othersChoice?: string;
212
- othersInput?: string;
213
- choiceDescription?: string;
214
- error?: string;
215
- };
216
- }
217
- declare const SingleChoice: ({
218
- title,
219
- description,
220
- properties,
221
- classNames,
222
- onChange,
223
- id,
224
- required,
225
- error
226
- }: SingleChoiceProps) => import("react/jsx-runtime").JSX.Element;
227
- //#endregion
228
- //#region src/components/questions/MultiChoice.d.ts
229
- interface MultiChoiceProps extends BaseFieldProps {
230
- properties: MultiSelectQuestionProperties;
231
- classNames?: {
232
- question?: string;
233
- header?: string;
234
- label?: string;
235
- title?: string;
236
- description?: string;
237
- optionalLabel?: string;
238
- choiceDescription?: string;
239
- group?: string;
240
- checkbox?: string;
241
- tag?: string;
242
- tagLabel?: string;
243
- indicator?: string;
244
- svg?: string;
245
- othersChoice?: string;
246
- othersInput?: string;
247
- error?: string;
248
- };
249
- }
250
- declare const MultiChoice: ({
251
- title,
252
- description,
253
- properties,
254
- classNames,
255
- onChange,
256
- id,
257
- required,
258
- error
259
- }: MultiChoiceProps) => import("react/jsx-runtime").JSX.Element;
260
- //#endregion
261
- //#region src/components/questions/Statement.d.ts
262
- interface StatementProps extends BaseFieldProps {
263
- properties: StatementQuestionProperties;
264
- classNames?: {
265
- question?: string;
266
- header?: string;
267
- title?: string;
268
- description?: string;
269
- ctaButton?: string;
270
- };
271
- }
272
- declare const Statement: ({
273
- properties: _properties,
274
- title,
275
- description,
276
- classNames
277
- }: StatementProps) => import("react/jsx-runtime").JSX.Element;
278
- //#endregion
279
- //#region src/components/presentation/Flow.d.ts
280
- type ChildField = (_: {
281
- onChange: (answer: Answer) => void;
282
- question: Question$1;
283
- error?: string;
284
- }) => React.ReactNode;
285
- interface FlowProps {
286
- onSubmit: (answer: Answer) => void;
287
- children: ChildField;
288
- question: Question$1;
289
- isLastQuestion: boolean;
15
+ telemetry?: Partial<{
16
+ version?: string;
17
+ }>;
18
+ options?: unknown;
19
+ }
20
+ interface PopoverMountProps extends MountPropsBase, Dismissable {}
21
+ interface ModalMountProps extends MountPropsBase, OptionallyDismissable {}
22
+ interface EmbeddedMountProps extends MountPropsBase, Closable {}
23
+ interface StepperMountProps extends MountPropsBase, Closable {}
24
+ interface TriggerPopoverMountProps extends PopoverMountProps {
25
+ isOpen?: boolean;
26
+ }
27
+ interface MountPropsByTemplate {
28
+ Popover: PopoverMountProps;
29
+ Modal: ModalMountProps;
30
+ Embedded: EmbeddedMountProps;
31
+ Stepper: StepperMountProps;
32
+ TriggerPopover: TriggerPopoverMountProps;
33
+ }
34
+ interface ConfettiApi {
35
+ readonly version: string;
36
+ readonly protocolVersion: typeof EXPECTED_WIRE_PROTOCOL_VERSION;
37
+ readonly channel: 'stable';
38
+ mount<T extends Template>(options: {
39
+ template: T;
40
+ element: HTMLElement;
41
+ props: MountPropsByTemplate[T];
42
+ }): MountHandle;
43
+ update<T extends Template>(handle: MountHandle, props: MountPropsByTemplate[T]): void;
44
+ unmount(handle: MountHandle): void;
45
+ }
46
+ declare const EXPECTED_WIRE_PROTOCOL_VERSION = 1;
47
+ declare global {
48
+ interface Window {
49
+ __confetti?: ConfettiApi;
50
+ }
51
+ }
52
+ //#endregion
53
+ //#region src/loader.d.ts
54
+ type SupportedChannel = 'stable';
55
+ //#endregion
56
+ //#region src/hosted/types.d.ts
57
+ /**
58
+ * Host-side options for loading and gating the hosted CDN bundle, layered on top
59
+ * of the shared survey config (`BaseConfettiProps`) by every hosted shell.
60
+ * `isSurveyVisible` is not declared here: it already arrives through
61
+ * `BaseConfettiProps`, which the shells extend.
62
+ */
63
+ interface HostedLoaderProps extends Proxyable {
64
+ /**
65
+ * Release channel of the hosted bundle and stylesheet to load.
66
+ * @default 'stable'
67
+ */
68
+ channel?: SupportedChannel;
69
+ /** Invoked on script-load failure. Default behaviour is silent no-op. */
70
+ onError?: (error: Error) => void;
290
71
  }
291
- declare const Flow: ({
292
- onSubmit,
293
- children,
294
- question,
295
- isLastQuestion
296
- }: FlowProps) => import("react/jsx-runtime").JSX.Element;
297
72
  //#endregion
298
- //#region src/components/presentation/Embed.d.ts
299
- declare const Embed: ({
300
- isCompleted,
301
- onSubmit,
302
- children
303
- }: PropsWithChildren<{
304
- isCompleted: boolean;
305
- onSubmit: () => void;
306
- }>) => import("react/jsx-runtime").JSX.Element;
73
+ //#region src/hosted/EmbeddedConfetti.d.ts
74
+ interface EmbeddedConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, Closable {}
75
+ declare function EmbeddedConfetti(props: EmbeddedConfettiProps): import("react").JSX.Element | null;
307
76
  //#endregion
308
- //#region src/components/CloseButton.d.ts
309
- interface CloseButtonProps {
310
- className?: string;
311
- iconClassName?: string;
312
- onClose: () => void;
313
- }
314
- declare const CloseButton: ({
315
- className,
316
- iconClassName,
317
- onClose
318
- }: CloseButtonProps) => import("react/jsx-runtime").JSX.Element | null;
77
+ //#region src/hosted/ModalConfetti.d.ts
78
+ interface ModalConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, OptionallyDismissable {}
79
+ declare function ModalConfetti(props: ModalConfettiProps): import("react").JSX.Element | null;
319
80
  //#endregion
320
- //#region src/components/trigger/ConfettiTriggerIcon.d.ts
321
- declare const ConfettiTriggerIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
81
+ //#region src/hosted/PopoverConfetti.d.ts
82
+ interface PopoverConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, Dismissable {}
83
+ declare function PopoverConfetti(props: PopoverConfettiProps): import("react").JSX.Element | null;
322
84
  //#endregion
323
- //#region src/components/trigger/DefaultConfettiTrigger.d.ts
324
- interface DefaultConfettiTriggerProps {
325
- onClick: () => void;
326
- isWidgetOpen: boolean;
327
- label?: string;
328
- classNames?: {
329
- trigger?: string;
330
- icon?: string;
331
- iconWrapper?: string;
332
- label?: string;
333
- };
334
- }
335
- declare const DefaultConfettiTrigger: ({
336
- onClick,
337
- isWidgetOpen,
338
- classNames,
339
- label
340
- }: DefaultConfettiTriggerProps) => import("react/jsx-runtime").JSX.Element | null;
85
+ //#region src/hosted/StepperConfetti.d.ts
86
+ interface StepperConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, Closable {}
87
+ declare function StepperConfetti(props: StepperConfettiProps): import("react").JSX.Element | null;
341
88
  //#endregion
342
- //#region src/templates/ConfettiTrigger.d.ts
89
+ //#region src/hosted/TriggerPopoverConfetti.d.ts
343
90
  interface TriggerRenderProps {
91
+ /** Opens the popover survey. */
344
92
  onClick: () => void;
345
- isWidgetOpen: boolean;
346
- hasSubmitted: boolean;
93
+ /** Whether the popover is currently open. */
94
+ isOpen: boolean;
95
+ /** Whether the respondent has already submitted the survey. */
96
+ isSubmitted: boolean;
347
97
  }
348
- interface TriggerChildProps extends Pick<ConfettiProviderProps, 'publishableKey' | 'surveyId'> {
349
- onDismiss: () => void;
350
- }
351
- interface ConfettiTriggerProps extends Omit<ConfettiProviderProps, 'children' | 'alwaysRenderChildren'> {
352
- surveyId: string;
353
- publishableKey: string;
354
- trigger?: (renderProps: TriggerRenderProps) => React.ReactNode;
355
- children: (triggerProps: TriggerChildProps) => React.ReactNode;
356
- }
357
- declare const ConfettiTrigger: ({
358
- trigger,
359
- children,
360
- ...providerProps
361
- }: ConfettiTriggerProps) => import("react/jsx-runtime").JSX.Element;
362
- //#endregion
363
- //#region src/templates/EmbeddedConfetti.d.ts
364
- declare const EmbeddedConfetti: (props: ConfettiProps) => import("react/jsx-runtime").JSX.Element;
365
- //#endregion
366
- //#region src/templates/ModalConfetti.d.ts
367
- interface ModalConfettiProps extends ConfettiProps {
368
- closeOnFinishMs?: number | null;
369
- onDismiss?: () => void;
370
- isDismissable?: boolean;
371
- }
372
- declare const ModalConfetti: ({
373
- onDismiss,
374
- closeOnFinishMs,
375
- isDismissable,
376
- ...props
377
- }: ModalConfettiProps) => import("react/jsx-runtime").JSX.Element;
378
- //#endregion
379
- //#region src/templates/PopoverConfetti.d.ts
380
- interface PopoverConfettiProps extends ConfettiProps {
381
- /**
382
- * The popover will automatically close this many milliseconds
383
- * after the survey is finished.
384
- * Set to `null` to disable automatic closing.
385
- * @default 3000
386
- */
387
- closeOnFinishMs?: number | null;
98
+ interface TriggerPopoverConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps {
388
99
  /**
389
- * Callback is invoked when the popover is explicitly dismissed.
100
+ * Renders the element that opens the popover. Receives the click handler and
101
+ * the open and submitted state. Defaults to the built-in trigger button.
390
102
  */
391
- onDismiss?: () => void;
103
+ trigger?: (renderProps: TriggerRenderProps) => React.ReactNode;
392
104
  }
393
- declare const PopoverConfetti: ({
394
- onDismiss,
395
- closeOnFinishMs,
396
- ...props
397
- }: PopoverConfettiProps) => import("react/jsx-runtime").JSX.Element;
398
- //#endregion
399
- //#region src/templates/StepperConfetti.d.ts
400
- declare const StepperConfetti: (props: ConfettiProps) => import("react/jsx-runtime").JSX.Element;
105
+ declare function TriggerPopoverConfetti(props: TriggerPopoverConfettiProps): import("react").JSX.Element | null;
401
106
  //#endregion
402
107
  //#region src/hooks/useVisibleAfterDelay.d.ts
403
108
  interface UseVisibleAfterDelayOptions {
@@ -439,4 +144,4 @@ declare const useVisibleAfterScroll: ({
439
144
  isVisible: boolean;
440
145
  };
441
146
  //#endregion
442
- export { type Answer, CloseButton, Confetti, ConfettiContext, ConfettiController, type ConfettiControllerProps, type ConfettiProps, ConfettiProvider, type ConfettiProviderProps, type ConfettiState, ConfettiTrigger, ConfettiTriggerIcon, type ConfettiTriggerProps, DefaultConfettiTrigger, type DefaultConfettiTriggerProps, Embed, EmbeddedConfetti, Flow, FreeText, type FreeTextProps, ModalConfetti, ModalContainer, type ModalContainerProps, MultiChoice, type MultiChoiceProps, PopoverConfetti, PopoverContainer, type PopoverContainerProps, type Question, Rating, type RatingProps, SingleChoice, type SingleChoiceProps, Statement, type StatementProps, StepperConfetti, SurveyQuestionFactory, type SurveyQuestionFactoryProps, ThankYouMessage, type TriggerChildProps, type TriggerRenderProps, useConfetti, useVisibleAfterDelay, useVisibleAfterPageVisits, useVisibleAfterScroll, useVisibleAfterSessionPageVisits };
147
+ export { EmbeddedConfetti, type EmbeddedConfettiProps, ModalConfetti, type ModalConfettiProps, PopoverConfetti, type PopoverConfettiProps, StepperConfetti, type StepperConfettiProps, TriggerPopoverConfetti, type TriggerPopoverConfettiProps, type TriggerRenderProps, useVisibleAfterDelay, useVisibleAfterPageVisits, useVisibleAfterScroll, useVisibleAfterSessionPageVisits };
package/build/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./internals-B5GhpjgM.js";import{A as a,B as o,C as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,O as y,P as b,Q as x,R as S,S as C,T as w,U as T,V as E,W as D,X as ee,Y as te,_ as O,a as k,b as A,c as ne,d as re,f as ie,g as ae,h as oe,i as se,j,k as ce,l as le,m as ue,o as de,p as fe,q as pe,r as me,s as M,t as he,u as ge,v as _e,w as N,x as P,y as ve,z as ye}from"./ModalContainer-Br4sC87A.js";import{ErrorBoundary as F}from"react-error-boundary";import I,{Suspense as be,createContext as L,forwardRef as R,lazy as xe,useCallback as z,useContext as Se,useEffect as B,useMemo as V,useRef as H,useState as U}from"react";import{useLocalStorage as Ce,useSessionStorage as we,useTimeout as Te}from"usehooks-ts";import{Fragment as W,jsx as G,jsxs as K}from"react/jsx-runtime";import q from"clsx";import"react-dom";function Ee(e){return e.issues[0]?.message??`Invalid input`}const J={rating:({scale:e},t)=>pe({scale:e},t),"open-ended":({max:e},t)=>h({maxLength:e},t),"single-select":({editable:e},t)=>m({maxLength:e?.max},t),"multi-select":({editable:e,max:t},n)=>d({maxLength:e?.max,maxSelected:t},n),statement:(e,t)=>te(),"bug-report":(e,t)=>D({},t)},De=(e,t)=>{let n=e.type;switch(n){case`rating`:{let r=J[n];return r(e,t)}case`open-ended`:{let r=J[n];return r(e,t)}case`single-select`:{let r=J[n];return r(e,t)}case`multi-select`:{let r=J[n];return r(e,t)}case`statement`:{let r=J[n];return r(e,t)}case`bug-report`:{let r=J[n];return r(e,t)}default:throw Error(`Unsupported question type`)}},Oe=({originalQuestions:e,answers:t,errors:r,pointer:i=-1})=>{if(!e)return{questions:[],currentIndex:-1};let a=e.sort((e,t)=>e.position-t.position).map(e=>{let t={...e},n=r[e.id];return n&&(t.error=n),{...t,visible:!1}});for(let e=0;e<a.length;e++){let r=a[e];if(!r)continue;let o=n({index:e,questions:a,answers:t});r.visible=i===e||o}let o=a.findIndex((e,n)=>n>i&&e.visible&&t[e.id]===void 0);return o===-1&&(o=a.findLastIndex(e=>!!e.visible)),{questions:a,currentIndex:o}},ke=({questions:e,answers:t})=>{let n=Ae({questions:e,answers:t});return Object.fromEntries(Object.entries(n).filter(([,e])=>e!==null))},Ae=({questions:e,answers:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),je=({questions:e,errors:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Me=({current:e,shouldAutoSubmit:t,onFinished:n,children:r})=>{let{survey:a,submit:o}=f(),[s,c]=U({}),[l,u]=U({}),d=V(()=>Oe({originalQuestions:a?.questions,answers:s,errors:l,pointer:e}),[a?.questions,s,l,e]),p=V(()=>!!d.questions.filter(({required:e,visible:t})=>!!e&&!!t).every(({id:e})=>s[e]!==void 0),[s,d.questions]),[m,h]=U(!1),g=z(({answers:e})=>{o({answers:e}).finally(()=>{n?.()})},[n,o]),_=z(()=>{g({answers:ke({questions:d.questions,answers:s})}),h(!0)},[s,d.questions,g]),v=z(({question:n,answer:r})=>{let i=d.questions.at(n);if(!i)return{error:`Question index is invalid`};let o=De(i.properties,{required:i.required}).safeParse(r);if(!o.success){let e=Ee(o.error);return u(t=>{if(t[i.id]===e)return t;let n={...t};return n[i.id]=e,n}),c(e=>{if(!(i.id in e))return e;let t={...e};return delete t[i.id],t}),{error:e}}u(e=>{if(!e[i.id])return e;let t={...e};return delete t[i.id],t});let f=!i.required&&!r?null:r,p={...s};if(p[i.id]===f)return{next:Oe({originalQuestions:a?.questions,answers:p,errors:l,pointer:e}).currentIndex};p[i.id]=f;let m=Oe({originalQuestions:a?.questions,answers:p,errors:l,pointer:e});return p=Ae({questions:m.questions,answers:p}),c(p),u(je({questions:m.questions,errors:l})),m.questions.filter(({visible:e})=>!!e).every(({id:e})=>p[e]!==void 0)&&t&&(g({answers:ke({questions:m.questions,answers:p})}),h(!0)),{next:m.currentIndex}},[d.questions,s,a?.questions,l,t,e,g]);return d.questions.length===0?G(W,{}):G(`div`,{className:`confetti ${i}`,children:r({questions:d.questions,current:e??d.currentIndex,update:v,isCompleted:p,submit:_,isSubmitted:m,errors:l})})},Ne=({children:e,onFinished:t,shouldAutoSubmit:n,...r})=>G(F,{fallback:G(W,{}),children:G(E,{...r,children:G(Me,{shouldAutoSubmit:n,onFinished:t,children:e})})});function Pe(e,t,n){let r=c(e=>{n&&!e.defaultPrevented&&n(t)});B(()=>{let t=e?.current?.form;return t?.addEventListener(`reset`,r),()=>{t?.removeEventListener(`reset`,r)}},[e])}function Fe(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:a=`label`}=e;t=p(t);let o=p(),s={};n&&(r=r?`${o} ${r}`:o,s={id:o,htmlFor:a===`label`?t:void 0});let c=ce({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:s,fieldProps:c}}function Ie(e){let{description:t,errorMessage:n,isInvalid:r,validationState:i}=e,{labelProps:a,fieldProps:o}=Fe(e),s=u([!!t,!!n,r,i]),c=u([!!t,!!n,r,i]);return o=j(o,{"aria-describedby":[s,c,e[`aria-describedby`]].filter(Boolean).join(` `)||void 0}),{labelProps:a,fieldProps:o,descriptionProps:{id:s},errorMessageProps:{id:c}}}function Le(e,t,n){let{validationBehavior:r,focus:i}=e;g(()=>{if(r===`native`&&n?.current&&!n.current.disabled){let e=t.realtimeValidation.isInvalid?t.realtimeValidation.validationErrors.join(` `)||`Invalid value.`:``;n.current.setCustomValidity(e),n.current.hasAttribute(`title`)||(n.current.title=``),t.realtimeValidation.isInvalid||t.updateValidation(ze(n.current))}});let a=H(!1),o=c(()=>{a.current||t.resetValidation()}),s=c(e=>{t.displayValidation.isInvalid||t.commitValidation();let r=n?.current?.form;!e.defaultPrevented&&n&&r&&Be(r)===n.current&&(i?i():n.current?.focus(),ae(`keyboard`)),e.preventDefault()}),l=c(()=>{t.commitValidation()});B(()=>{let e=n?.current;if(!e)return;let t=e.form,r=t?.reset;return t&&(t.reset=()=>{a.current=!window.event||window.event.type===`message`&&v(window.event)instanceof MessagePort,r?.call(t),a.current=!1}),e.addEventListener(`invalid`,s),e.addEventListener(`change`,l),t?.addEventListener(`reset`,o),()=>{e.removeEventListener(`invalid`,s),e.removeEventListener(`change`,l),t?.removeEventListener(`reset`,o),t&&(t.reset=r)}},[n,r])}function Re(e){let t=e.validity;return{badInput:t.badInput,customError:t.customError,patternMismatch:t.patternMismatch,rangeOverflow:t.rangeOverflow,rangeUnderflow:t.rangeUnderflow,stepMismatch:t.stepMismatch,tooLong:t.tooLong,tooShort:t.tooShort,typeMismatch:t.typeMismatch,valueMissing:t.valueMissing,valid:t.valid}}function ze(e){return{isInvalid:!e.validity.valid,validationDetails:Re(e),validationErrors:e.validationMessage?[e.validationMessage]:[]}}function Be(e){for(let t=0;t<e.elements.length;t++){let n=e.elements[t];if(n.validity?.valid===!1)return n}return null}const Ve={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},He={...Ve,customError:!0,valid:!1},Y={isInvalid:!1,validationDetails:Ve,validationErrors:[]},Ue=L({}),We=`__reactAriaFormValidationState`;function X(e){if(e.__reactAriaFormValidationState){let{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}=e[We];return{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}}return Ge(e)}function Ge(e){let{isInvalid:t,validationState:n,name:r,value:i,builtinValidation:a,validate:o,validationBehavior:s=`aria`}=e;n&&(t||=n===`invalid`);let c=t===void 0?null:{isInvalid:t,validationErrors:[],validationDetails:He},l=V(()=>!o||i==null?null:Je(qe(o,i)),[o,i]);a?.validationDetails.valid&&(a=void 0);let u=Se(Ue),d=V(()=>r?Array.isArray(r)?r.flatMap(e=>Ke(u[e])):Ke(u[r]):[],[u,r]),[f,p]=U(u),[m,h]=U(!1);u!==f&&(p(u),h(!1));let g=V(()=>Je(m?[]:d),[m,d]),_=H(Y),[v,y]=U(Y),b=H(Y),x=()=>{if(!S)return;C(!1);let e=l||a||_.current;Ye(e,b.current)||(b.current=e,y(e))},[S,C]=U(!1);return B(x),{realtimeValidation:c||g||l||a||Y,displayValidation:s===`native`?c||g||v:c||g||l||a||v,updateValidation(e){s===`aria`&&!Ye(v,e)?y(e):_.current=e},resetValidation(){let e=Y;Ye(e,b.current)||(b.current=e,y(e)),s===`native`&&C(!1),h(!0)},commitValidation(){s===`native`&&C(!0),h(!0)}}}function Ke(e){return e?Array.isArray(e)?e:[e]:[]}function qe(e,t){if(typeof e==`function`){let n=e(t);if(n&&typeof n!=`boolean`)return Ke(n)}return[]}function Je(e){return e.length?{isInvalid:!0,validationErrors:e,validationDetails:He}:null}function Ye(e,t){return e===t?!0:!!e&&!!t&&e.isInvalid===t.isInvalid&&e.validationErrors.length===t.validationErrors.length&&e.validationErrors.every((e,n)=>e===t.validationErrors[n])&&Object.entries(e.validationDetails).every(([e,n])=>t.validationDetails[e]===n)}function Xe(...e){let t=new Set,n=!1,r={...Ve};for(let i of e){for(let e of i.validationErrors)t.add(e);n||=i.isInvalid;for(let e in r)r[e]||=i.validationDetails[e]}return r.valid=!n,{isInvalid:n,validationErrors:[...t],validationDetails:r}}function Ze(e,t){let{inputElementType:n=`input`,isDisabled:r=!1,isRequired:i=!1,isReadOnly:o=!1,type:s=`text`,validationBehavior:c=`aria`}=e,[l,u]=fe(e.value,e.defaultValue||``,e.onChange),{focusableProps:d}=ue(e,t),f=X({...e,value:l}),{isInvalid:p,validationErrors:m,validationDetails:h}=f.displayValidation,{labelProps:g,fieldProps:_,descriptionProps:y,errorMessageProps:b}=Ie({...e,isInvalid:p,errorMessage:e.errorMessage||m}),x=a(e,{labelable:!0}),S={type:s,pattern:e.pattern},[C]=U(l);return Pe(t,e.defaultValue??C,u),Le(e,f,t),{labelProps:g,inputProps:j(x,n===`input`?S:void 0,{disabled:r,readOnly:o,required:i&&c===`native`,"aria-required":i&&c===`aria`||void 0,"aria-invalid":p||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-activedescendant":e[`aria-activedescendant`],"aria-autocomplete":e[`aria-autocomplete`],"aria-haspopup":e[`aria-haspopup`],"aria-controls":e[`aria-controls`],value:l,onChange:e=>u(v(e).value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,form:e.form,placeholder:e.placeholder,inputMode:e.inputMode,autoCorrect:e.autoCorrect,spellCheck:e.spellCheck,[parseInt(I.version,10)>=17?`enterKeyHint`:`enterkeyhint`]:e.enterKeyHint,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...d,..._}),descriptionProps:y,errorMessageProps:b,isInvalid:p,validationErrors:m,validationDetails:h}}function Qe(e,t,n){let{isDisabled:r=!1,isReadOnly:i=!1,value:o,name:s,form:c,children:l,"aria-label":u,"aria-labelledby":d,validationState:f=`valid`,isInvalid:p,onPressStart:m,onPressEnd:h,onPressChange:g,onPress:_,onPressUp:y,onClick:b}=e,x=e=>{e.stopPropagation(),t.setSelected(v(e).checked)},{pressProps:S,isPressed:C}=O({onPressStart:m,onPressEnd:h,onPressChange:g,onPress:_,onPressUp:y,onClick:b,isDisabled:r}),{pressProps:w,isPressed:T}=O({onPressStart:m,onPressEnd:h,onPressChange:g,onPressUp:y,onClick:b,onPress(e){_?.(e),t.toggle(),n.current?.focus()},isDisabled:r||i}),{focusableProps:E}=ue(e,n),D=j(S,E),ee=a(e,{labelable:!0});return Pe(n,t.defaultSelected,t.setSelected),{labelProps:j(w,{onClick:e=>e.preventDefault()}),inputProps:j(ee,{"aria-invalid":p||f===`invalid`||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-controls":e[`aria-controls`],"aria-readonly":i||void 0,onChange:x,disabled:r,...o==null?{}:{value:o},name:s,form:c,type:`checkbox`,...D}),isSelected:t.isSelected,isPressed:C||T,isDisabled:r,isReadOnly:i,isInvalid:p||f===`invalid`}}function $e(e,t,n){let r=X({...e,value:t.isSelected}),{isInvalid:i,validationErrors:a,validationDetails:o}=r.displayValidation,{labelProps:s,inputProps:c,isSelected:l,isPressed:u,isDisabled:d,isReadOnly:f}=Qe({...e,isInvalid:i},t,n);Le(e,r,n);let{isIndeterminate:p,isRequired:m,validationBehavior:h=`aria`}=e;B(()=>{n.current&&(n.current.indeterminate=!!p)});let{pressProps:g}=O({isDisabled:d||f,onPress(){let{[We]:t}=e,{commitValidation:n}=t||r;n()}});return{labelProps:j(s,g,V(()=>({onMouseDown:e=>e.preventDefault()}),[])),inputProps:{...c,checked:l,"aria-required":m&&h===`aria`||void 0,required:m&&h===`native`},isSelected:l,isPressed:u,isDisabled:d,isReadOnly:f,isInvalid:i,validationErrors:a,validationDetails:o}}const et=new WeakMap;function tt(e,t){let{isDisabled:n,name:r,form:i,validationBehavior:o=`aria`}=e,{isInvalid:s,validationErrors:c,validationDetails:l}=t.displayValidation,{labelProps:u,fieldProps:d,descriptionProps:f,errorMessageProps:p}=Ie({...e,labelElementType:`span`,isInvalid:s,errorMessage:e.errorMessage||c});et.set(t,{name:r,form:i,descriptionId:f.id,errorMessageId:p.id,validationBehavior:o});let m=a(e,{labelable:!0}),{focusWithinProps:h}=ie({onBlurWithin:e.onBlur,onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange});return{groupProps:j(m,{role:`group`,"aria-disabled":n||void 0,...d,...h}),labelProps:u,descriptionProps:f,errorMessageProps:p,isInvalid:s,validationErrors:c,validationDetails:l}}function nt(e={}){let{isReadOnly:t}=e,[n,r]=fe(e.isSelected,e.defaultSelected||!1,e.onChange),[i]=U(n);function a(e){t||r(e)}function o(){t||r(!n)}return{isSelected:n,defaultSelected:e.defaultSelected??i,setSelected:a,toggle:o}}function rt(e,t,n){let r=nt({isReadOnly:e.isReadOnly||t.isReadOnly,isSelected:t.isSelected(e.value),defaultSelected:t.defaultValue.includes(e.value),onChange(n){n?t.addValue(e.value):t.removeValue(e.value),e.onChange&&e.onChange(n)}}),{name:i,form:a,descriptionId:o,errorMessageId:s,validationBehavior:c}=et.get(t);c=e.validationBehavior??c;let{realtimeValidation:l}=X({...e,value:r.isSelected,name:void 0,validationBehavior:`aria`}),u=H(Y),d=()=>{t.setInvalid(e.value,l.isInvalid?l:u.current)};B(d);let f=t.realtimeValidation.isInvalid?t.realtimeValidation:l,p=c===`native`?t.displayValidation:f,m=$e({...e,isReadOnly:e.isReadOnly||t.isReadOnly,isDisabled:e.isDisabled||t.isDisabled,name:e.name||i,form:e.form||a,isRequired:e.isRequired??t.isRequired,validationBehavior:c,[We]:{realtimeValidation:f,displayValidation:p,resetValidation:t.resetValidation,commitValidation:t.commitValidation,updateValidation(e){u.current=e,d()}}},r,n);return{...m,inputProps:{...m.inputProps,"aria-describedby":[e[`aria-describedby`],t.isInvalid?s:null,o].filter(Boolean).join(` `)||void 0}}}const it=new WeakMap;function at(e,t,n){let{value:r,children:i,"aria-label":o,"aria-labelledby":s,onPressStart:c,onPressEnd:l,onPressChange:u,onPress:d,onPressUp:f,onClick:p}=e,m=e.isDisabled||t.isDisabled,h=t.selectedValue===r,g=e=>{e.stopPropagation(),t.setSelectedValue(r)},{pressProps:_,isPressed:v}=O({onPressStart:c,onPressEnd:l,onPressChange:u,onPress:d,onPressUp:f,onClick:p,isDisabled:m}),{pressProps:y,isPressed:b}=O({onPressStart:c,onPressEnd:l,onPressChange:u,onPressUp:f,onClick:p,isDisabled:m,onPress(e){d?.(e),t.setSelectedValue(r),n.current?.focus()}}),{focusableProps:x}=ue(j(e,{onFocus:()=>t.setLastFocusedValue(r)}),n),S=j(_,x),C=a(e,{labelable:!0}),w=-1;t.selectedValue==null?(t.lastFocusedValue===r||t.lastFocusedValue==null)&&(w=0):t.selectedValue===r&&(w=0),m&&(w=void 0);let{name:T,form:E,descriptionId:D,errorMessageId:ee,validationBehavior:te}=it.get(t);return Pe(n,t.defaultSelectedValue,t.setSelectedValue),Le({validationBehavior:te},t,n),{labelProps:j(y,V(()=>({onClick:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault()}),[])),inputProps:j(C,{...S,type:`radio`,name:T,form:E,tabIndex:w,disabled:m,required:t.isRequired&&te===`native`,checked:h,value:r,onChange:g,"aria-describedby":[e[`aria-describedby`],t.isInvalid?ee:null,D].filter(Boolean).join(` `)||void 0}),isDisabled:m,isSelected:h,isPressed:v||b}}function ot(e,t){let{name:n,form:r,isReadOnly:i,isRequired:o,isDisabled:s,orientation:c=`vertical`,validationBehavior:l=`aria`}=e,{direction:u}=_e(),{isInvalid:d,validationErrors:f,validationDetails:m}=t.displayValidation,{labelProps:h,fieldProps:g,descriptionProps:_,errorMessageProps:y}=Ie({...e,labelElementType:`span`,isInvalid:t.isInvalid,errorMessage:e.errorMessage||f}),x=a(e,{labelable:!0}),{focusWithinProps:S}=ie({onBlurWithin(n){e.onBlur?.(n),t.selectedValue||t.setLastFocusedValue(null)},onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange}),C=e=>{let n;switch(e.key){case`ArrowRight`:n=u===`rtl`&&c!==`vertical`?`prev`:`next`;break;case`ArrowLeft`:n=u===`rtl`&&c!==`vertical`?`next`:`prev`;break;case`ArrowDown`:n=`next`;break;case`ArrowUp`:n=`prev`;break;default:return}e.preventDefault();let r=oe(e.currentTarget,{from:v(e),accept:e=>e instanceof b(e).HTMLInputElement&&e.type===`radio`}),i;n===`next`?(i=r.nextNode(),i||=(r.currentNode=e.currentTarget,r.firstChild())):(i=r.previousNode(),i||=(r.currentNode=e.currentTarget,r.lastChild())),i&&(i.focus(),t.setSelectedValue(i.value))},w=p(n);return it.set(t,{name:w,form:r,descriptionId:_.id,errorMessageId:y.id,validationBehavior:l}),{radioGroupProps:j(x,{role:`radiogroup`,onKeyDown:C,"aria-invalid":t.isInvalid||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-readonly":i||void 0,"aria-required":o||void 0,"aria-disabled":s||void 0,"aria-orientation":c,...g,...S}),labelProps:h,descriptionProps:_,errorMessageProps:y,isInvalid:d,validationErrors:f,validationDetails:m}}const st=L({}),Z=R(function(e,t){[e,t]=A(e,t,st);let{elementType:n=`span`,...r}=e,i=N[n];return I.createElement(i,{className:`react-aria-Text`,...r,ref:t})});function ct(e={}){let[t,n]=fe(e.value,e.defaultValue||[],e.onChange),[r]=U(t),i=!!e.isRequired&&t.length===0,a=H(new Map),o=X({...e,value:t}),s=o.displayValidation.isInvalid;return{...o,value:t,defaultValue:e.defaultValue??r,setValue(t){e.isReadOnly||e.isDisabled||n(t)},isDisabled:e.isDisabled||!1,isReadOnly:e.isReadOnly||!1,isSelected(e){return t.includes(e)},addValue(t){e.isReadOnly||e.isDisabled||n(e=>e.includes(t)?e:e.concat(t))},removeValue(r){e.isReadOnly||e.isDisabled||t.includes(r)&&n(t.filter(e=>e!==r))},toggleValue(r){e.isReadOnly||e.isDisabled||(t.includes(r)?n(t.filter(e=>e!==r)):n(t.concat(r)))},setInvalid(e,t){let n=new Map(a.current);t.isInvalid?n.set(e,t):n.delete(e),a.current=n,o.updateValidation(Xe(...n.values()))},validationState:e.validationState??(s?`invalid`:null),isInvalid:s,isRequired:i}}let lt=Math.round(Math.random()*1e10),ut=0;function dt(e){let t=V(()=>e.name||`radio-group-${lt}-${++ut}`,[e.name]),[n,r]=fe(e.value,e.defaultValue??null,e.onChange),[i]=U(n),[a,o]=U(null),s=X({...e,value:n}),c=t=>{!e.isReadOnly&&!e.isDisabled&&(r(t),s.commitValidation())},l=s.displayValidation.isInvalid;return{...s,name:t,selectedValue:n,defaultSelectedValue:e.value===void 0?e.defaultValue??null:i,setSelectedValue:c,lastFocusedValue:a,setLastFocusedValue:o,isDisabled:e.isDisabled||!1,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1,validationState:e.validationState||(l?`invalid`:null),isInvalid:l}}const Q=L(null),$=R(function(e,t){return Se(Q)?.isInvalid?I.createElement(ft,{...e,ref:t}):null}),ft=R((e,t)=>{let n=Se(Q),r=a(e,{global:!0}),i=P({...e,defaultClassName:`react-aria-FieldError`,defaultChildren:n.validationErrors.length===0?void 0:n.validationErrors.join(` `),values:n});return i.children==null?null:I.createElement(Z,{slot:`errorMessage`,...r,...i,ref:t})}),pt=L(null),mt=L(null),ht=L(null),gt=R(function(e,t){[e,t]=A(e,t,mt);let{validationBehavior:n}=l(pt)||{},r=e.validationBehavior??n??`native`,i=ct({...e,validationBehavior:r}),[o,s]=C(!e[`aria-label`]&&!e[`aria-labelledby`]),{groupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=tt({...e,label:s,validationBehavior:r},i),m=P({...e,values:{isDisabled:i.isDisabled,isReadOnly:i.isReadOnly,isRequired:e.isRequired||!1,isInvalid:i.isInvalid,state:i},defaultClassName:`react-aria-CheckboxGroup`}),h=a(e,{global:!0});return I.createElement(N.div,{...j(h,m,c),ref:t,slot:e.slot||void 0,"data-readonly":i.isReadOnly||void 0,"data-required":e.isRequired||void 0,"data-invalid":i.isInvalid||void 0,"data-disabled":e.isDisabled||void 0},I.createElement(ve,{values:[[ht,i],[de,{...u,ref:o,elementType:`span`}],[st,{slots:{description:d,errorMessage:f}}],[Q,p]]},m.children))}),_t=R(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=A(r,t,ye);let{validationBehavior:i}=l(pt)||{},o=e.validationBehavior??i??`native`,s=Se(ht),c=y(V(()=>_(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:u,inputProps:d,isSelected:f,isDisabled:p,isReadOnly:m,isPressed:h,isInvalid:g}=s?rt({...w(e),value:e.value,children:typeof e.children==`function`?!0:e.children},s,c):$e({...w(e),children:typeof e.children==`function`?!0:e.children,validationBehavior:o},nt(e),c),{isFocused:v,isFocusVisible:b,focusProps:x}=re(),S=p||m,{hoverProps:C,isHovered:T}=ge({...e,isDisabled:S}),E=P({...e,defaultClassName:`react-aria-Checkbox`,values:{isSelected:f,isIndeterminate:e.isIndeterminate||!1,isPressed:h,isHovered:T,isFocused:v,isFocusVisible:b,isDisabled:p,isReadOnly:m,isInvalid:g,isRequired:e.isRequired||!1}}),D=a(e,{global:!0});return delete D.id,delete D.onClick,I.createElement(N.label,{...j(D,u,C,E),ref:t,slot:e.slot||void 0,"data-selected":f||void 0,"data-indeterminate":e.isIndeterminate||void 0,"data-pressed":h||void 0,"data-hovered":T||void 0,"data-focused":v||void 0,"data-focus-visible":b||void 0,"data-disabled":p||void 0,"data-readonly":m||void 0,"data-invalid":g||void 0,"data-required":e.isRequired||void 0},I.createElement(ne,{elementType:`span`},I.createElement(`input`,{...j(d,x),ref:c})),E.children)}),vt=L({}),yt=L({});let bt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const xt=le(function(e,t){[e,t]=A(e,t,yt);let{hoverProps:n,isHovered:r}=ge({...e,isDisabled:e.disabled}),{isFocused:i,isFocusVisible:a,focusProps:o}=re({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=P({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-Input`});return I.createElement(N.input,{...j(bt(e),o,n),...c,ref:t,"data-focused":i||void 0,"data-disabled":e.disabled||void 0,"data-hovered":r||void 0,"data-focus-visible":a||void 0,"data-invalid":s||void 0})}),St=L(null);function Ct(e){let t=H({});return I.createElement(St.Provider,{value:t},e.children)}const wt=L({isSelected:!1}),Tt=L(null),Et=L(null),Dt=L(null),Ot=R(function(e,t){[e,t]=A(e,t,Tt);let{validationBehavior:n}=l(pt)||{},r=e.validationBehavior??n??`native`,i=dt({...e,validationBehavior:r}),[o,s]=C(!e[`aria-label`]&&!e[`aria-labelledby`]),{radioGroupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=ot({...e,label:s,validationBehavior:r},i),m=P({...e,values:{orientation:e.orientation||`vertical`,isDisabled:i.isDisabled,isReadOnly:i.isReadOnly,isRequired:i.isRequired,isInvalid:i.isInvalid,state:i},defaultClassName:`react-aria-RadioGroup`}),h=a(e,{global:!0});return I.createElement(N.div,{...j(h,m,c),ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||`vertical`,"data-invalid":i.isInvalid||void 0,"data-disabled":i.isDisabled||void 0,"data-readonly":i.isReadOnly||void 0,"data-required":i.isRequired||void 0},I.createElement(ve,{values:[[Dt,i],[de,{...u,ref:o,elementType:`span`}],[st,{slots:{description:d,errorMessage:f}}],[Q,p]]},I.createElement(Ct,null,m.children)))}),kt=R(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=A(r,t,Et);let i=I.useContext(Dt),o=y(V(()=>_(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:s,inputProps:c,isSelected:l,isDisabled:u,isPressed:d}=at({...w(e),children:typeof e.children==`function`?!0:e.children},i,o),{isFocused:f,isFocusVisible:p,focusProps:m}=re(),h=u||i.isReadOnly,{hoverProps:g,isHovered:v}=ge({...e,isDisabled:h}),b=P({...e,defaultClassName:`react-aria-Radio`,values:{isSelected:l,isPressed:d,isHovered:v,isFocused:f,isFocusVisible:p,isDisabled:u,isReadOnly:i.isReadOnly,isInvalid:i.isInvalid,isRequired:i.isRequired}}),x=a(e,{global:!0});return delete x.id,delete x.onClick,I.createElement(N.label,{...j(x,s,g,b),ref:t,"data-selected":l||void 0,"data-pressed":d||void 0,"data-hovered":v||void 0,"data-focused":f||void 0,"data-focus-visible":p||void 0,"data-disabled":u||void 0,"data-readonly":i.isReadOnly||void 0,"data-invalid":i.isInvalid||void 0,"data-required":i.isRequired||void 0},I.createElement(ne,{elementType:`span`},I.createElement(`input`,{...j(c,m),ref:o})),I.createElement(wt.Provider,{value:{isSelected:l}},b.children))}),At=L({});let jt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const Mt=R(function(e,t){[e,t]=A(e,t,At);let{hoverProps:n,isHovered:r}=ge(e),{isFocused:i,isFocusVisible:a,focusProps:o}=re({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=P({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-TextArea`});return I.createElement(N.textarea,{...j(jt(e),o,n),...c,ref:t,"data-focused":i||void 0,"data-disabled":e.disabled||void 0,"data-hovered":r||void 0,"data-focus-visible":a||void 0,"data-invalid":s||void 0})}),Nt=L(null),Pt=le(function(e,t){[e,t]=A(e,t,Nt);let{validationBehavior:n}=l(pt)||{},r=e.validationBehavior??n??`native`,i=H(null);[e,i]=A(e,i,S);let[o,s]=C(!e[`aria-label`]&&!e[`aria-labelledby`]),[c,u]=U(`input`),{labelProps:d,inputProps:f,descriptionProps:p,errorMessageProps:m,...h}=Ze({...w(e),inputElementType:c,label:s,validationBehavior:r},i),g=z(e=>{i.current=e,e&&u(e instanceof HTMLTextAreaElement?`textarea`:`input`)},[i]),_=P({...e,values:{isDisabled:e.isDisabled||!1,isInvalid:h.isInvalid,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1},defaultClassName:`react-aria-TextField`}),v=a(e,{global:!0});return delete v.id,I.createElement(N.div,{...v,..._,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-invalid":h.isInvalid||void 0,"data-readonly":e.isReadOnly||void 0,"data-required":e.isRequired||void 0},I.createElement(ve,{values:[[de,{...d,ref:o}],[yt,{...f,ref:g}],[At,{...f,ref:g}],[vt,{role:`presentation`,isInvalid:h.isInvalid,isDisabled:e.isDisabled||!1}],[st,{slots:{description:p,errorMessage:m}}],[Q,h]]},_.children))}),Ft=({title:e,description:t,classNames:n})=>{let{survey:r,dismiss:i}=f();if(!r)return null;let a=t||r.confirmation.description;return K(W,{children:[G(`div`,{className:q(`cf-question`,n?.question),children:K(`div`,{className:q(`cf-header`,n?.header),children:[G(M,{className:q(`cf-title`,n?.title),children:e||r.confirmation.title||`Feedback submitted!`}),a&&G(Z,{slot:`description`,className:q(`cf-description`,n?.description),children:a})]})}),G(k,{className:`cf-submit-button`,onPress:i,children:r.confirmation.buttonText||`Close`})]})},It=({children:e,classNames:t,containerProps:n,onDismiss:r,closeOnFinishMs:a=3e3})=>{let{surveyId:o,survey:s,dismiss:c}=f(),[l,u]=U(!1),[d,p]=U(!1),[m,h]=U(!1);return Te(()=>{s&&c()},l&&!(d||m)?a:null),K(`div`,{className:q(`confetti-dialog ${i}`,t?.dialog),id:`${o}-popover`,...n,onMouseEnter:e=>{n?.onMouseEnter?.(e),p(!0)},onMouseLeave:e=>{n?.onMouseLeave?.(e),p(!1)},onFocusCapture:e=>{n?.onFocusCapture?.(e),h(!0)},onBlurCapture:e=>{n?.onBlurCapture?.(e),e.currentTarget.contains(e.relatedTarget)||h(!1)},children:[G(me,{className:q(`confetti-dialog-close`,t?.closeButton),iconClassName:t?.icon,onClose:async()=>{await c(),r?.()}}),typeof e==`function`?e({setIsFinished:()=>u(!0)}):e]})},Lt=3e4,Rt=({maskAllInputs:e}={})=>{let[t,n]=U(null),[i,a]=U(!1),[o,s]=U(null),[c,l]=U(30),u=H(null),d=H(null),f=H(null),p=H([]);B(()=>{let e=new CustomEvent(r,{detail:{isRecording:i}});document.dispatchEvent(e)},[i]);let m=z(()=>{d.current&&=(clearInterval(d.current),null),f.current&&=(clearTimeout(f.current),null),u.current=null,l(Lt/1e3)},[]),h=z(()=>{u.current?.(),m(),a(!1),n(JSON.stringify(p.current))},[m]);return{recordingEventsJson:t,isRecording:i,recordingError:o,remainingSeconds:c,startRecording:z(async()=>{a(!0),s(null),n(null),p.current=[];try{let{record:t}=await import(`./record-BZwNFiEW.js`);u.current=t({slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0},sampling:{mousemove:50,scroll:100,input:`last`},emit:e=>{p.current.push(e)},blockClass:`cfti-block`,maskTextClass:`cfti-mask`,maskAllInputs:e})??null;let n=Lt/1e3;l(n),d.current=setInterval(()=>{--n,l(n)},1e3),f.current=setTimeout(()=>{h()},Lt)}catch{s(`Failed to start recording. Please try again.`),a(!1),m()}},[e,h,m]),stopRecording:h,clear:z(()=>{m(),a(!1),n(null),s(null),p.current=[]},[m])}},zt=e=>e.replace(/\S/g,`*`),Bt=e=>`*`.repeat(e.length),Vt=(e,t)=>{for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t(n):Vt(n,t)},Ht=e=>{if(e instanceof HTMLInputElement)e.setAttribute(`value`,Bt(e.getAttribute(`value`)??``));else if(e instanceof HTMLTextAreaElement)e.textContent=Bt(e.textContent);else if(e instanceof HTMLSelectElement)for(let t of e.querySelectorAll(`option`))t.textContent=Bt(t.textContent)},Ut=({maskInputs:e})=>({name:`cfti-redact`,afterClone:n=>{let{clone:r}=n;if(r instanceof HTMLElement){for(let e of r.querySelectorAll(`.${t}`)){Vt(e,e=>{e.data=zt(e.data)}),Ht(e);for(let t of e.querySelectorAll(`input, textarea, select`))Ht(t)}if(e)for(let e of r.querySelectorAll(`input, textarea, select`))Ht(e)}}}),Wt=({maskAllInputs:e}={})=>{let[t,n]=U(null),[r,a]=U(!1),[o,s]=U(null);return{screenshotDataUrl:t,isCapturing:r,captureError:o,capture:z(async()=>{a(!0),s(null);try{let{snapdom:t}=await import(`./snapdom-BQZEILL6.js`),r=await(await t(document.documentElement,{embedFonts:!0,exclude:[`.${i}`],excludeMode:`hide`,plugins:[Ut({maskInputs:!!e})],fast:!1})).toCanvas(),a=window.devicePixelRatio||1,o=Math.min(Math.round(window.innerWidth*a),r.width),s=Math.min(Math.round(window.innerHeight*a),r.height),c=document.createElement(`canvas`);c.width=o,c.height=s;let l=c.getContext(`2d`);if(!l)throw Error(`Failed to get 2D context for cropping`);l.drawImage(r,0,0,o,s,0,0,o,s),n(c.toDataURL(`image/png`))}catch{s(`Failed to capture screenshot. Please try again.`)}finally{a(!1)}},[e]),clear:z(()=>{n(null),s(null)},[])}},Gt=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[G(`circle`,{cx:`12`,cy:`12`,r:`10`}),G(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`})]}),Kt=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[G(`path`,{d:`M10 11v6`}),G(`path`,{d:`M14 11v6`}),G(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),G(`path`,{d:`M3 6h18`}),G(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]});function qt(){if(window.DD_RUM&&typeof window.DD_RUM?.getInternalContext==`function`&&typeof window.DD_RUM?.getSessionReplayLink==`function`)try{let e=window.DD_RUM?.getInternalContext?.(),t=window.DD_RUM?.getSessionReplayLink?.();return{sessionId:e?.session_id,sessionReplayLink:t}}catch{return null}return null}function Jt(){if(typeof window>`u`||typeof navigator>`u`)return;let e=navigator,t=window.screen,n=qt();return{userAgent:e.userAgent,screenResolution:`${t.width}x${t.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,pageUrl:window.location.href,pageTitle:document.title,referrer:document.referrer,language:e.language,timestamp:new Date().toISOString(),datadogTraceId:n?.traceId,datadogSessionId:n?.sessionId,datadogSessionReplayLink:n?.sessionReplayLink}}const Yt=xe(()=>import(`./RecordingReplayer-BvU_CHwb.js`)),Xt=({id:e,title:t,description:n,properties:r,onChange:i,required:a,error:o,classNames:s,maskAllInputs:c})=>{let l=V(()=>Jt(),[]),[u,d]=U(``),[f,p]=U(``),{screenshotDataUrl:m,isCapturing:h,captureError:g,capture:_,clear:v}=Wt({maskAllInputs:c}),{recordingEventsJson:y,isRecording:b,recordingError:x,remainingSeconds:S,startRecording:C,stopRecording:w,clear:T}=Rt({maskAllInputs:c}),E=V(()=>({title:u,...f?{description:f}:{},...m?{screenshotDataUrl:m}:{},...y?{recordingEventsJson:y}:{},metadata:l}),[f,l,y,m,u]);B(()=>{i(E)},[E,i]),B(()=>()=>{w()},[w]);let D=V(()=>y?JSON.parse(y):[],[y]);return G(W,{children:b?K(k,{className:q(`cf-bug-report-button`,`cf-bug-report-record-button`,s?.button,s?.recordButton),onPress:w,children:[G(Gt,{}),K(`span`,{children:[30-S,`s /`,` `,30,`s`]})]}):K(`div`,{className:q(`cf-bug-report`,s?.base),children:[K(Pt,{isRequired:a,isInvalid:!!o,name:`${e}-title`,value:u,onChange:d,className:q(`cf-question`,s?.question),children:[K(`div`,{className:q(`cf-header`,s?.header),children:[K(M,{className:q(`cf-title`,s?.title),children:[t,!a&&K(`span`,{className:q(`cf-label-optional`,s?.optionalLabel),children:[` `,`(optional)`]})]}),n&&G(Z,{slot:`description`,className:q(`cf-description`,s?.description),children:n})]}),G(xt,{placeholder:r.placeholder||`Brief description of the issue`,className:q(`cf-input`,s?.input)})]}),K(Pt,{name:`${e}-description`,value:f,onChange:p,className:q(`cf-question`,s?.question),children:[G(M,{className:q(`cf-title`,s?.title),children:r.detailsLabel}),G(Mt,{placeholder:r.detailsPlaceholder||`Steps to reproduce, expected vs actual behavior, etc.`,className:q(`cf-textarea`,s?.textArea),rows:4})]}),r.enableScreenshot||r.enableRecording?K(`section`,{className:q(`cf-question`,s?.question),children:[G(M,{className:q(`cf-title`,s?.title),children:`Attachments`}),K(`div`,{className:q(`cf-bug-report-actions`,s?.actions),children:[r.enableScreenshot&&K(`div`,{className:q(`cf-bug-report-screenshot-section`,s?.screenshotSection),children:[m?K(`div`,{className:q(`cf-bug-report-media-preview`,s?.mediaPreview),children:[G(`img`,{src:m,alt:`Screenshot preview`,className:q(`cf-bug-report-screenshot-img`,s?.screenshotImg)}),G(`div`,{className:q(`cf-bug-report-media-actions`,s?.mediaActions),children:G(k,{className:q(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:v,"aria-label":`Remove screenshot`,children:G(Kt,{})})})]}):G(k,{className:q(`cf-bug-report-button`,s?.button),onPress:_,isDisabled:h,children:h?`Capturing...`:`Screenshot`}),g&&G(`div`,{className:q(`cf-error`,s?.error),children:g})]}),r.enableRecording&&K(`div`,{className:q(`cf-bug-report-recording-section`,s?.recordingSection),children:[D.length>0?K(`div`,{className:q(`cf-bug-report-media-preview`,s?.mediaPreview),children:[G(be,{fallback:G(`span`,{className:q(`cf-bug-report-player-loading`,s?.playerLoading),"aria-label":`Loading recording preview...`}),children:G(Yt,{events:D})}),G(`div`,{className:q(`cf-bug-report-media-actions`,s?.mediaActions),children:G(k,{className:q(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:T,"aria-label":`Remove recording`,children:G(Kt,{})})})]}):G(k,{className:q(`cf-bug-report-button`,s?.button),onPress:C,children:`Record`}),x&&G(`div`,{className:q(`cf-error`,s?.error),children:x})]})]})]}):null,G($,{className:q(`cf-error`,s?.error),children:o})]})})},Zt=({id:e,title:t,description:n,properties:r,onChange:i,classNames:a,required:o,error:s})=>{let[c,l]=U(``);return B(()=>{i(c)},[i,c]),K(Pt,{isRequired:o,isInvalid:!!s,name:e,className:q(`cf-question`,a?.question),value:c,onChange:e=>{l(e),i(e)},children:[K(`div`,{className:q(`cf-header`,a?.header),children:[K(M,{className:q(`cf-title`,a?.title),children:[t,!o&&K(`span`,{className:q(`cf-label-optional`,a?.optionalLabel),children:[` `,`(optional)`]})]}),n&&G(Z,{slot:`description`,className:q(`cf-description`,a?.description),children:n})]}),G(Mt,{className:q(`cf-textarea`,a?.textarea),maxLength:r.max,rows:4,placeholder:r.placeholder||`Start typing...`}),G($,{className:q(`cf-error`,a?.error),children:s})]})},Qt=({children:e,classNames:t,description:n,...r})=>G(_t,{...r,children:({isIndeterminate:r})=>K(W,{children:[K(`div`,{className:q(`cf-choice-label`,t?.label),children:[G(`div`,{className:q(`cf-checkbox-indicator`,t?.indicator),children:G(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:q(`cf-checkbox-indicator-svg`,t?.svg),children:r?G(`rect`,{x:1,y:7.5,width:16,height:3}):G(`polyline`,{points:`2 9 7 14 16 4`})},r?`indeterminate`:`check`)}),e]}),n&&G(`span`,{className:q(`cf-choice-description`,t?.choiceDescription),children:n})]})}),$t=({children:e,classNames:t,...n})=>G(_t,{...n,children:G(`div`,{className:q(`cf-tag-label`,t?.tagLabel),children:e})}),en=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s})=>{let c=!!n.editable,l=n.display??`checkbox`,[u,d]=U([]),[f,p]=U(``),m=H(null),h=H(null),g=V(()=>{let e=u.indexOf(ee);if(e===-1)return u;let t=[...u];return t[e]=f||`__CONFETTI_CHECKBOX_Others`,t},[f,u]),_=l===`tag`;return B(()=>{i(g)},[i,g]),G(gt,{isRequired:o,isInvalid:!!s,name:a,value:u,onChange:d,className:q(`cf-question`,r?.question),children:({state:i})=>K(W,{children:[K(`div`,{className:q(`cf-header`,r?.header),children:[K(M,{className:q(`cf-title`,r?.title),children:[e,!o&&K(`span`,{className:q(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&G(Z,{slot:`description`,className:q(`cf-description`,r?.description),children:t})]}),K(`div`,{className:q(`cf-response-choices`,l===`tag`&&`cf-response-choices-tag`,r?.group),children:[n.options.map((e,t)=>G(_?$t:Qt,{className:q(`cf-choice`,_&&[`cf-tag`,r?.tag],!_&&[`cf-checkbox`,r?.checkbox]),description:e.description,value:e.value,classNames:{tag:r?.tag,tagLabel:r?.tagLabel,choiceDescription:r?.choiceDescription,label:r?.label,indicator:r?.indicator,svg:r?.svg},children:e.value},t)),c&&(_?K(W,{children:[G($t,{inputRef:m,onChange:e=>{h.current&&e&&requestAnimationFrame(()=>{h.current&&h.current.focus()})},className:q(`cf-choice cf-tag`,r?.tag),value:`__CONFETTI_CHECKBOX_Others`,children:n.editable?.label}),G(xt,{"data-visible":i.value.includes(`__CONFETTI_CHECKBOX_Others`)||void 0,value:f,onChange:e=>{p(e.target.value)},ref:h,className:q(`cf-input cf-tag-input`,r?.othersInput)})]}):K(`div`,{className:q(`cf-choice cf-others-choice`,r?.othersChoice),children:[G(Qt,{inputRef:m,onChange:e=>{h.current&&e&&requestAnimationFrame(()=>{h.current&&h.current.focus()})},className:q(`cf-checkbox`,r?.checkbox),value:`__CONFETTI_CHECKBOX_Others`,classNames:{indicator:r?.indicator,svg:r?.svg},description:n.editable?.description,children:n.editable?.label}),G(xt,{value:f,onChange:e=>{p(e.target.value)},tabIndex:i.value.includes(`__CONFETTI_CHECKBOX_Others`)?0:-1,ref:h,onFocus:()=>{m.current?.checked===!1&&m.current.click()},className:q(`cf-input`,r?.othersInput)})]}))]}),G($,{className:q(`cf-error`,r?.error),children:s})]})})},tn=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[G(`circle`,{cx:12,cy:12,r:10}),G(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M7.5 8 10 9M14 9l2.5-1M9 10h.01M15 10h.01`})]}),nn=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[G(`circle`,{cx:12,cy:12,r:10}),G(`path`,{d:`M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12ZM9 9h.01M15 9h.01`})]}),rn=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[G(`circle`,{cx:12,cy:12,r:10}),G(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M9 9h.01M15 9h.01`})]}),an=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[G(`circle`,{cx:12,cy:12,r:10}),G(`path`,{d:`M8 15h8M9 9h.01M15 9h.01`})]}),on=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[G(`circle`,{cx:12,cy:12,r:10}),G(`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01`})]}),sn=e=>G(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:40,height:40,fill:`none`,...e,children:G(`path`,{fill:`currentColor`,d:`m6.516 14.323-1.49 6.452a.998.998 0 0 0 1.529 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4 4.536-4.082a1 1 0 0 0-.59-1.74l-5.701-.454-2.467-5.461a.998.998 0 0 0-1.822 0L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.214 4.107zm2.853-4.326a.998.998 0 0 0 .832-.586L12 5.43l1.799 3.981a.998.998 0 0 0 .832.586l3.972.315-3.271 2.944c-.284.256-.397.65-.293 1.018l1.253 4.385-3.736-2.491a.995.995 0 0 0-1.109 0l-3.904 2.603 1.05-4.546a1 1 0 0 0-.276-.94l-3.038-2.962 4.09-.326z`})}),cn=e=>G(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,...e,children:G(`path`,{fill:`currentColor`,d:`M21.947 9.179a1.001 1.001 0 0 0-.868-.676l-5.701-.453-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4 4.536-4.082c.297-.268.406-.686.278-1.065z`})}),ln=({state:e,properties:t,classNames:n})=>{let r=e.selectedValue?Number(e.selectedValue):null;return G(`div`,{className:q(`cf-rating-display-star`,n?.ratingDisplayStar),children:Array.from({length:t.scale},(e,t)=>{let i=t+1,a=String(i),o=r&&i<=r;return G(kt,{className:q(`cf-rating-star`,n?.ratingStar),value:a,"data-filled":o?`true`:void 0,children:G(o?cn:sn,{})},t)})})},un=({properties:e,classNames:t})=>G(`div`,{className:q(`cf-rating-display-number`,t?.ratingDisplayNumber),children:Array.from({length:e.scale},(e,n)=>{let r=n+1,i=String(r);return G(kt,{className:q(`cf-rating-number`,t?.ratingNumber),value:i,children:r},n)})}),dn=({properties:e,classNames:t,state:n})=>{let r=V(()=>[tn,rn,an,on,nn],[]),i=V(()=>[rn,an,on],[]);return V(()=>e.scale===3||e.scale===5,[e.scale])?G(`div`,{className:q(`cf-rating-display-emoji`,t?.ratingDisplayEmoji),children:Array.from({length:e.scale},(n,a)=>{let o=a+1,s=String(o),c=e.scale===5?r[a]:i[a];return G(kt,{className:q(`cf-rating-emoji`,t?.ratingEmoji),value:s,children:c&&G(c,{})},a)})}):G(un,{properties:e,classNames:t,state:n})},fn=e=>{switch(e.properties.display??`star`){case`emoji`:return G(dn,{...e});case`number`:return G(un,{...e});case`star`:return G(ln,{...e})}},pn=({properties:e,title:t,description:n,classNames:r,onChange:i,id:a,error:o,required:s})=>{let[c,l]=U(null),u=V(()=>c?Number(c):void 0,[c]);return B(()=>{i(u)},[i,u]),G(Ot,{isRequired:s,isInvalid:!!o,name:a,className:q(`cf-question`,r?.question),value:c,onChange:l,children:({state:i})=>K(W,{children:[K(`div`,{className:q(`cf-header`,r?.header),children:[K(M,{className:q(`cf-title`,r?.title),children:[t,!s&&K(`span`,{className:q(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),n&&G(Z,{slot:`description`,className:q(`cf-description`,r?.description),children:n})]}),K(`div`,{className:q(`cf-rating-section`,r?.ratingSection),children:[G(fn,{state:i,properties:e,classNames:r}),K(`div`,{className:q(`cf-rating-text`,r?.ratingText),children:[G(`span`,{className:q(`cf-rating-text-lower`,r?.ratingTextLower),children:e.labels?.lower}),G(`span`,{className:q(`cf-rating-text-upper`,r?.ratingTextUpper),children:e.labels?.upper})]})]}),G($,{className:q(`cf-error`,r?.error),children:o})]})})},mn=({classNames:e,className:t,description:n,...r})=>G(kt,{...r,className:q(t,e?.radio),children:s(r.children,t=>K(W,{children:[K(`div`,{className:q(`cf-choice-label`,e?.label),children:[G(`div`,{className:q(`cf-radio-indicator`,e?.indicator)}),t]}),n&&G(`span`,{className:q(`cf-choice-description`,e?.choiceDescription),children:n})]}))}),hn=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s})=>{let[c,l]=U(null),[u,d]=U(``),f=!!n.editable,p=H(null),m=H(null),h=V(()=>c===`__CONFETTI_RADIO_Others`?u||`__CONFETTI_RADIO_Others`:c??void 0,[u,c]);return B(()=>{i(h)},[i,h]),G(Ot,{isRequired:o,isInvalid:!!s,name:a,onChange:e=>{l(e),e===`__CONFETTI_RADIO_Others`&&requestAnimationFrame(()=>{m.current&&m.current.focus()})},value:c,className:q(`cf-question`,r?.question),children:({state:i})=>K(W,{children:[K(`div`,{className:q(`cf-header`,r?.header),children:[K(M,{className:q(`cf-title`,r?.title),children:[e,!o&&K(`span`,{className:q(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&G(Z,{slot:`description`,className:q(`cf-description`,r?.description),children:t})]}),K(`div`,{className:q(`cf-response-choices`,r?.group),children:[n.options.map((e,t)=>G(mn,{classNames:{indicator:r?.indicator,radio:q(`cf-choice cf-radio`,r?.radio)},value:e.value,description:e.description,children:e.value},t)),f&&K(`div`,{className:q(`cf-choice cf-others-choice`,r?.othersChoice),children:[G(mn,{inputRef:p,value:`__CONFETTI_RADIO_Others`,classNames:{indicator:r?.indicator,radio:q(`cf-radio`,r?.radio)},description:n.editable?.description,children:n.editable?.label}),G(xt,{tabIndex:i.selectedValue===`__CONFETTI_RADIO_Others`?0:-1,ref:m,value:u,onChange:e=>d(e.target.value),onFocus:()=>{p.current?.checked===!1&&p.current.click()},className:q(`cf-input`,r?.othersInput)})]})]}),G($,{className:q(`cf-error`,r?.error),children:s})]})})},gn=({properties:e,title:t,description:n,classNames:r})=>G(`div`,{className:q(`cf-question`,r?.question),children:K(`div`,{className:q(`cf-header`,r?.header),children:[t&&G(`div`,{className:q(`cf-title`,r?.title),children:t}),n&&G(`div`,{className:q(`cf-description`,r?.description),children:n})]})}),_n=({question:e,onChange:t,error:n,maskAllInputs:r})=>{switch(e.properties.type){case`rating`:return G(pn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`open-ended`:return G(Zt,{...e,properties:e.properties,onChange:t,error:n},e.id);case`single-select`:return G(hn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`multi-select`:return G(en,{...e,properties:e.properties,onChange:t,error:n},e.id);case`statement`:return G(gn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`bug-report`:return G(Xt,{...e,properties:e.properties,onChange:t,error:n,maskAllInputs:r},e.id)}return G(`div`,{children:`Unsupported question type`},e.id)},vn=({onPress:e,isDisabled:t,children:n=`Submit`})=>se()?null:G(k,{isDisabled:t,className:`cf-submit-button`,onPress:e,children:n}),yn=e=>{switch(e){case`multi-select`:return[];case`bug-report`:return{title:``};case`statement`:return;default:return``}},bn=e=>e!==void 0&&e!==``&&!(Array.isArray(e)&&e.length===0),xn=({onSubmit:t,children:n,question:r,isLastQuestion:i})=>{let[a,o]=U(yn(r.properties.type)),s=V(()=>De(r.properties,{required:r.required}),[r.properties,r.required]),c=V(()=>{let e=s.safeParse(a);if(!e.success)return Ee(e.error)},[a,s]),l=V(()=>{let t=r.routingLogic;if(t.type!==`always`&&!bn(a)&&r.required)return!0;let n=t.type===`always`?t.target:t.cases.find(t=>e({answer:a,condition:t}))?.target??t.default;return n.type===`end`?!1:n.type===`next`?!i:!0},[a,i,r.required,r.routingLogic]),u=V(()=>r.properties.buttonLabel?r.properties.buttonLabel:l?!r.required&&!bn(a)?`Skip`:`Next`:`Submit`,[a,l,r.properties.buttonLabel,r.required]),d=z(()=>{switch(r.properties.type){case`statement`:if(r.properties.buttonUrl&&typeof window<`u`){let e=x.safeParse(r.properties.buttonUrl).data;e&&window.open(e,`_blank`)}return t(void 0);default:return t(a)}},[a,t,r.properties]),f=V(()=>{switch(r.properties.type){case`rating`:case`single-select`:return!!r.properties.shouldAutoProgress;default:return!1}},[r.properties]);return K(W,{children:[n({onChange:z(e=>{o(e),f&&bn(e)&&s.safeParse(e).success&&t(e)},[f,s,t]),question:r,error:c}),(!f||!r.required)&&G(vn,{isDisabled:!!c,onPress:d,children:u})]})},Sn=({isCompleted:e,onSubmit:t,children:n})=>K(W,{children:[n,e&&G(vn,{onPress:t})]}),Cn=e=>G(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 44 38`,...e,children:K(`g`,{transform:`translate(-2 -2) scale(1.1)`,children:[G(`path`,{d:`M16.8395 3.2139C8.2208 3.9522 1.8331 11.5311 2.5721 20.1416C3.3111 28.7523 10.897 35.134 19.5157 34.3956L27.1631 33.7406C28.9787 33.585 30.6949 33.1248 32.2669 32.4163L38.7663 35.4396C39.3254 35.6994 39.9048 35.1205 39.6447 34.562L37.0707 29.0396C40.1147 25.8995 41.8336 21.5102 41.4304 16.8128C40.6913 8.2022 33.1054 1.8205 24.4867 2.5588L16.8395 3.2139Z`,fill:`#BAE6FD`}),G(`path`,{d:`M19.6764 24.0307C19.6764 24.0307 20.9773 25.4496 23.5438 25.1228C26.1103 24.7959 27.3642 23.0095 27.3642 23.0095`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`}),G(`path`,{d:`M18.0861 16.4082C18.0861 16.4082 17.1255 18.619 14.8183 18.9139C12.5111 19.2088 11.1697 17.237 11.1697 17.237`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`}),G(`path`,{d:`M32.6296 15.0398C32.6296 15.0398 31.6691 17.2506 29.3619 17.5455C27.0548 17.8404 25.7132 15.8686 25.7132 15.8686`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`})]})}),wn=({onClick:e,isWidgetOpen:t,classNames:n,label:r=`Help us improve`})=>t?null:K(k,{onPress:e,className:q(`confetti-trigger`,n?.trigger),children:[G(`span`,{className:q(`confetti-trigger-icon-wrapper`,n?.iconWrapper),"aria-hidden":!0,children:G(Cn,{className:q(`confetti-trigger-icon`,n?.icon),width:24})}),G(`span`,{className:q(`confetti-trigger-label`,n?.label),children:r})]}),Tn=({trigger:e,children:t,publishableKey:n,surveyId:r})=>{let i=f(),[a,s]=U(!1),[c,l]=U(!1);if(!i.isVisible)return null;let u=()=>{s(!1)};return K(W,{children:[e({onClick:()=>s(!0),isWidgetOpen:a,hasSubmitted:c}),a&&G(o.Provider,{value:{...i,dismiss:()=>{i.dismiss(),u()},submit:async e=>{let t=await i.submit(e);return l(!0),t}},children:t({onDismiss:u,surveyId:r,publishableKey:n})})]})},En=({trigger:e=e=>G(wn,{...e}),children:t,...n})=>G(F,{fallback:G(W,{}),children:G(E,{...n,alwaysRenderChildren:!0,children:G(Tn,{trigger:e,surveyId:n.surveyId,publishableKey:n.publishableKey,children:t})})}),Dn=e=>G(F,{fallback:G(W,{}),children:G(T,{type:`embedded`,children:G(Ne,{...e,shouldAutoSubmit:!1,children:({questions:t,update:n,isCompleted:r,submit:i,isSubmitted:a,errors:o})=>a?G(Ft,{}):G(Sn,{onSubmit:i,isCompleted:r,children:t.filter(({visible:e})=>!!e).map(t=>G(_n,{question:t,error:o[t.id]||``,maskAllInputs:e.options?.bugReport?.maskAllInputs,onChange:e=>n({question:t.position,answer:e})},t.position))})})})}),On=({onDismiss:e,closeOnFinishMs:t,isDismissable:n,...r})=>G(F,{fallback:G(W,{}),children:G(T,{type:`modal`,children:G(E,{...r,children:G(he,{onDismiss:e,closeOnFinishMs:t,isDismissable:n,children:({setIsFinished:e})=>G(Me,{...r,shouldAutoSubmit:!1,onFinished:()=>{e(),r.onFinished?.()},children:({questions:e,update:t,isCompleted:n,errors:i,submit:a,isSubmitted:o})=>o?G(Ft,{}):G(Sn,{onSubmit:a,isCompleted:n,children:e.filter(({visible:e})=>!!e).map(e=>G(_n,{question:e,error:i[e.id]||``,maskAllInputs:r.options?.bugReport?.maskAllInputs,onChange:n=>t({question:e.position,answer:n})},e.position))})})})})})}),kn=({onDismiss:e,closeOnFinishMs:t,...n})=>G(F,{fallback:G(W,{}),children:G(T,{type:`popover`,children:G(E,{...n,children:G(It,{onDismiss:e,closeOnFinishMs:t,children:({setIsFinished:e})=>G(Me,{shouldAutoSubmit:!0,...n,onFinished:()=>{e(),n.onFinished?.()},children:({current:e,questions:t,update:r,isSubmitted:i})=>{let a=e===t.length-1;if(i)return G(Ft,{});let o=t[e];return o?G(xn,{isLastQuestion:a,question:o,onSubmit:t=>r({question:e,answer:t}),children:e=>G(_n,{maskAllInputs:n.options?.bugReport?.maskAllInputs,...e})},o.id):G(W,{})}})})})})}),An=e=>G(Ne,{...e,shouldAutoSubmit:!0,children:({current:t,questions:n,update:r,isSubmitted:i})=>{let a=t===n.length-1;if(i)return G(Ft,{});let o=n[t];return o?G(xn,{isLastQuestion:a,question:o,onSubmit:e=>r({question:t,answer:e}),children:t=>G(_n,{maskAllInputs:e.options?.bugReport?.maskAllInputs,...t})},o.id):G(W,{})}}),jn=({delay:e})=>{let[t,n]=U(!1),r=V(()=>e,[]);return B(()=>{let e=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(e)},[]),{isVisible:t}},Mn=({visits:e,respondent:t})=>{let[n,r]=Ce(`cfti:${V(()=>window.location.pathname,[])}:visits:${t??``}`,0);return B(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:z(()=>r(0),[r])}},Nn=({visits:e,respondent:t})=>{let[n,r]=we(`cfti:${V(()=>window.location.pathname,[])}:visits:${t??``}`,0);return B(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:z(()=>r(0),[r])}},Pn=({threshold:e})=>{let[t,n]=U(()=>typeof window>`u`?!1:window.scrollY>=e);return B(()=>{let t=()=>{window.scrollY>=e&&n(!0)};return window.addEventListener(`scroll`,t,{passive:!0}),()=>window.removeEventListener(`scroll`,t)},[e]),{isVisible:t}};export{me as CloseButton,Ne as Confetti,o as ConfettiContext,Me as ConfettiController,E as ConfettiProvider,En as ConfettiTrigger,Cn as ConfettiTriggerIcon,wn as DefaultConfettiTrigger,Sn as Embed,Dn as EmbeddedConfetti,xn as Flow,Zt as FreeText,On as ModalConfetti,he as ModalContainer,en as MultiChoice,kn as PopoverConfetti,It as PopoverContainer,pn as Rating,hn as SingleChoice,gn as Statement,An as StepperConfetti,_n as SurveyQuestionFactory,Ft as ThankYouMessage,f as useConfetti,jn as useVisibleAfterDelay,Mn as useVisibleAfterPageVisits,Pn as useVisibleAfterScroll,Nn as useVisibleAfterSessionPageVisits};
1
+ import{a as e,i as t,o as n,r,t as i}from"./DefaultConfettiTrigger-DFJBQ35H.js";import{it as a}from"./Button-giwEer5K.js";import{useCallback as o,useEffect as s,useMemo as c,useRef as l,useState as u}from"react";import{ErrorBoundary as d}from"react-error-boundary";import{useLocalStorage as f,useSessionStorage as p}from"usehooks-ts";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";const _=`confetti:ready`,v=`https://confetti.gov.sg`,y={promise:null,channel:null,url:null};function b(){y.promise=null,y.channel=null,y.url=null}function x(){y.promise=null}function S(e){return new URL(``,e).href}function C(e,t,n){let r=new URL(e);return r.pathname.endsWith(`/`)||(r.pathname+=`/`),new URL(`widget/v1/${t}.${n}`,r).href}function w(e=`stable`,t=v){if(typeof window>`u`)return Promise.reject(Error(`[confetti] No window found, SSR environments are not supported`));let n;try{n=S(t)}catch{return Promise.reject(Error(`[confetti] Invalid URL: ${t}`))}if(y.promise)return y.channel===e?y.url===n?y.promise:Promise.reject(Error(`[confetti] Cannot switch baseUrl from ${String(y.url)} to ${n} on the same page`)):Promise.reject(Error(`[confetti] Cannot switch channel from ${String(y.channel)} to ${e} on the same page`));let r=window.__confetti;if(r){let t=String(r.channel);return t===e?y.url!==null&&y.url!==n?Promise.reject(Error(`[confetti] Cannot switch URL from ${y.url} to ${n} on the same page`)):k(r):Promise.reject(Error(`[confetti] Cannot switch channel from ${t} to ${e} on the same page`))}let i=E(n,e);return y.channel=e,y.url=n,y.promise=i,i}function T(e=`stable`,t=v){if(typeof window>`u`)return Promise.resolve();let n;try{n=S(t)}catch{return Promise.reject(Error(`[confetti] Invalid URL: ${t}`))}return D(n,e)}async function E(e,t){let n=!!document.querySelector(`link[data-confetti-loader]`),r,i=new Promise((e,t)=>{r=setTimeout(()=>t(Error(`[confetti] Script load timeout`)),1e4)});try{let[,n]=await Promise.race([i,Promise.all([D(e,t),O(e,t)])]);return clearTimeout(r),x(),n}catch(e){throw clearTimeout(r),n||document.querySelector(`link[data-confetti-loader]`)?.remove(),document.querySelector(`script[data-confetti-loader]`)?.remove(),b(),e}}function D(e,t){return new Promise((n,r)=>{if(document.querySelector(`link[data-confetti-loader]`)){n();return}let i=document.createElement(`link`);i.rel=`stylesheet`,i.href=C(e,t,`css`),i.crossOrigin=`anonymous`,i.dataset.confettiLoader=``,i.onload=()=>n(),i.onerror=e=>{i.remove(),console.error(`[confetti] Stylesheet load failed. If your site uses a Content-Security-Policy, ensure style-src includes https://confetti.gov.sg (and script-src for the bundle).`),r(Error(`[confetti] Stylesheet load failed (check CSP allowlist for confetti.gov.sg)`,{cause:e}))},document.head.appendChild(i)})}function O(e,t){return new Promise((n,r)=>{let i=()=>{let e=window.__confetti;if(!e){r(Error(`[confetti] Ready event fired but global state is missing`));return}k(e).then(n,r)};if(window.addEventListener(_,i,{once:!0}),document.querySelector(`script[data-confetti-loader]`))return;let a=document.createElement(`script`);a.src=C(e,t,`js`),a.async=!0,a.crossOrigin=`anonymous`,a.dataset.confettiLoader=``,a.onerror=e=>{window.removeEventListener(_,i),console.error(`[confetti] Script load failed. If your site uses a Content-Security-Policy, ensure script-src includes https://confetti.gov.sg (and style-src for the CSS).`),r(Error(`[confetti] Script load failed (check CSP allowlist for confetti.gov.sg)`,{cause:e}))},document.head.appendChild(a)})}function k(e){let t=Number(e.protocolVersion);return Number.isFinite(t)?t===1?Promise.resolve(e):Promise.reject(Error(`[confetti] Wire protocol v${t} does not match expected v1`)):Promise.reject(Error(`[confetti] Wire protocol value is not a number (got ${typeof e.protocolVersion})`))}function A(e){let t=l(null),n=l(null),r=l(e.props),i=e.channel??`stable`,a=e.scriptBaseUrl??`https://confetti.gov.sg`;r.current=e.props,s(()=>{if(!e.element)return;let o=!1;return w(i,a).then(i=>{o||!e.element||(n.current=i,t.current=i.mount({template:e.template,element:e.element,props:r.current}))}).catch(t=>e.onError?.(t instanceof Error?t:Error(String(t)))),()=>{o=!0,t.current&&n.current&&n.current.unmount(t.current),t.current=null,n.current=null}},[i,a,e.element,e.template]),s(()=>{t.current&&n.current&&n.current.update(t.current,e.props)},[e.props])}function j(e){let[t,n]=u(null);return A({...e,element:t}),h(d,{fallback:h(m,{}),children:h(`div`,{ref:n,"data-confetti-mount":!0})})}function M(i){let o=e({surveyId:i.surveyId,override:i.respondent}),s=a({publishableKey:i.publishableKey,apiBaseUrl:i.proxyUrl}),{isAvailable:l,isSettled:f}=r({client:s,surveyId:i.surveyId}),{state:p,isSettled:g}=t({client:s,surveyId:i.surveyId,respondent:o}),_=n(p,i.isSurveyVisible),[v,y]=u(!1),b=f&&l&&g&&_&&!v,x=i.onFinished,S=i.onClose,C=c(()=>({surveyId:i.surveyId,publishableKey:i.publishableKey,respondent:o,metadata:i.metadata,apiBaseUrl:i.proxyUrl,telemetry:{version:`0.5.0`},onFinished:x,onClose:()=>{y(!0),S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.options,x,S]);return b?h(d,{fallback:h(m,{}),children:h(j,{template:`Embedded`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:C})}):null}function N(i){let o=e({surveyId:i.surveyId,override:i.respondent}),s=a({publishableKey:i.publishableKey,apiBaseUrl:i.proxyUrl}),{isAvailable:l,isSettled:f}=r({client:s,surveyId:i.surveyId}),{state:p,isSettled:g}=t({client:s,surveyId:i.surveyId,respondent:o}),_=n(p,i.isSurveyVisible),[v,y]=u(!1),b=f&&l&&g&&_&&!v,x=i.onFinished,S=i.onDismiss,C=i.onClose,w=c(()=>({surveyId:i.surveyId,publishableKey:i.publishableKey,respondent:o,metadata:i.metadata,apiBaseUrl:i.proxyUrl,telemetry:{version:`0.5.0`},closeOnFinishMs:i.closeOnFinishMs,isDismissable:i.isDismissable,onFinished:x,onClose:()=>{y(!0),C?.()},onDismiss:()=>{S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.closeOnFinishMs,i.isDismissable,i.options,x,S,C]);return b?h(d,{fallback:h(m,{}),children:h(j,{template:`Modal`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:w})}):null}function P(i){let o=e({surveyId:i.surveyId,override:i.respondent}),s=a({publishableKey:i.publishableKey,apiBaseUrl:i.proxyUrl}),{isAvailable:l,isSettled:f}=r({client:s,surveyId:i.surveyId}),{state:p,isSettled:g}=t({client:s,surveyId:i.surveyId,respondent:o}),_=n(p,i.isSurveyVisible),[v,y]=u(!1),b=f&&l&&g&&_&&!v,x=i.onFinished,S=i.onDismiss,C=i.onClose,w=c(()=>({surveyId:i.surveyId,publishableKey:i.publishableKey,respondent:o,metadata:i.metadata,apiBaseUrl:i.proxyUrl,telemetry:{version:`0.5.0`},closeOnFinishMs:i.closeOnFinishMs,onFinished:x,onClose:()=>{y(!0),C?.()},onDismiss:()=>{S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.closeOnFinishMs,i.options,x,S,C]);return b?h(d,{fallback:h(m,{}),children:h(j,{template:`Popover`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:w})}):null}function F(i){let o=e({surveyId:i.surveyId,override:i.respondent}),s=a({publishableKey:i.publishableKey,apiBaseUrl:i.proxyUrl}),{isAvailable:l,isSettled:f}=r({client:s,surveyId:i.surveyId}),{state:p,isSettled:g}=t({client:s,surveyId:i.surveyId,respondent:o}),_=n(p,i.isSurveyVisible),[v,y]=u(!1),b=f&&l&&g&&_&&!v,x=i.onFinished,S=i.onClose,C=c(()=>({surveyId:i.surveyId,publishableKey:i.publishableKey,respondent:o,metadata:i.metadata,apiBaseUrl:i.proxyUrl,telemetry:{version:`0.5.0`},onFinished:x,onClose:()=>{y(!0),S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.options,x,S]);return b?h(d,{fallback:h(m,{}),children:h(j,{template:`Stepper`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:C})}):null}function I(f){let p=e({surveyId:f.surveyId,override:f.respondent}),_=a({publishableKey:f.publishableKey,apiBaseUrl:f.proxyUrl}),{isAvailable:v,isSettled:y}=r({client:_,surveyId:f.surveyId}),{state:b,isSettled:x}=t({client:_,surveyId:f.surveyId,respondent:p}),[S,C]=u(!1),w=y&&v&&x&&S&&n(b,f.isSurveyVisible),[E,D]=u(!1),[O,k]=u(!1),{onError:A,channel:M,proxyUrl:N}=f,P=l(A);s(()=>{P.current=A},[A]),s(()=>{if(!(y&&v))return;let e=!1;return T(M,N).then(()=>{e||C(!0)}).catch(e=>P.current?.(e instanceof Error?e:Error(String(e)))),()=>{e=!0}},[y,v,M,N]);let F=w&&E,I=o(()=>D(!0),[]),L=f.onFinished,R=c(()=>({surveyId:f.surveyId,publishableKey:f.publishableKey,respondent:p,metadata:f.metadata,apiBaseUrl:f.proxyUrl,telemetry:{version:`0.5.0`},isOpen:E,onFinished:()=>{k(!0),L?.()},onClose:()=>{D(!1)},onDismiss:()=>{D(!1)},options:f.options}),[f.surveyId,f.publishableKey,p,f.metadata,f.proxyUrl,f.options,E,L]);return w?g(d,{fallback:h(m,{}),children:[f.trigger?f.trigger({onClick:I,isOpen:E,isSubmitted:O}):h(i,{onClick:I,isWidgetOpen:E}),F?h(j,{template:`TriggerPopover`,channel:f.channel,scriptBaseUrl:f.proxyUrl,onError:f.onError,props:R}):null]}):null}const L=({delay:e})=>{let[t,n]=u(!1),r=c(()=>e,[]);return s(()=>{let e=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(e)},[]),{isVisible:t}},R=({visits:e,respondent:t})=>{let[n,r]=f(`cfti:${c(()=>window.location.pathname,[])}:visits:${t??``}`,0);return s(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:o(()=>r(0),[r])}},z=({visits:e,respondent:t})=>{let[n,r]=p(`cfti:${c(()=>window.location.pathname,[])}:visits:${t??``}`,0);return s(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:o(()=>r(0),[r])}},B=({threshold:e})=>{let[t,n]=u(()=>typeof window>`u`?!1:window.scrollY>=e);return s(()=>{let t=()=>{window.scrollY>=e&&n(!0)};return window.addEventListener(`scroll`,t,{passive:!0}),()=>window.removeEventListener(`scroll`,t)},[e]),{isVisible:t}};export{M as EmbeddedConfetti,N as ModalConfetti,P as PopoverConfetti,F as StepperConfetti,I as TriggerPopoverConfetti,L as useVisibleAfterDelay,R as useVisibleAfterPageVisits,B as useVisibleAfterScroll,z as useVisibleAfterSessionPageVisits};
@@ -1,4 +1,4 @@
1
- import { t as Answer, u as BinaryOperatorCondition } from "./types-CJY8TUUa.js";
1
+ import { g as BinaryOperatorCondition, t as Answer } from "./types-Sf4fgrFJ.js";
2
2
  import { z } from "zod/mini";
3
3
 
4
4
  //#region src/core/logic/routing.d.ts