@opengovsg/confetti 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -71,6 +71,21 @@ and stylesheet from `{proxyUrl}/widget/v1/...`. Use this to route widget
71
71
  traffic through your own origin, for example when your CSP disallows third
72
72
  party hosts.
73
73
 
74
+ Confetti Cloud teams can provision a managed proxy from **Team settings**.
75
+ Create the DNS-only CNAME shown there and wait for it to become live, then pass
76
+ the resulting URL:
77
+
78
+ ```tsx
79
+ <PopoverConfetti
80
+ proxyUrl="https://c.example.gov.sg"
81
+ surveyId="..."
82
+ publishableKey="cfti_pk_..."
83
+ />
84
+ ```
85
+
86
+ When using a managed proxy, use that origin for all three CSP directives shown
87
+ above instead of `https://confetti.gov.sg`.
88
+
74
89
  ## Template Components
75
90
 
76
91
  Choose the component that best fits your use case:
@@ -148,6 +163,21 @@ import { useVisibleAfterSessionPageVisits } from '@opengovsg/confetti'
148
163
  const { isVisible, reset } = useVisibleAfterSessionPageVisits({ visits: 3 })
149
164
  ```
150
165
 
166
+ ### useRespondentState
167
+
168
+ Read a respondent's response and dismissal times without mounting a template.
169
+ `respondent` is required (this hook does not generate an anonymous id).
170
+
171
+ ```tsx
172
+ import { useRespondentState } from '@opengovsg/confetti'
173
+
174
+ const respondentState = useRespondentState({
175
+ surveyId: '<your-survey-id>',
176
+ publishableKey: '<your-publishable-key>',
177
+ respondent: '<user-id>',
178
+ })
179
+ ```
180
+
151
181
  ## Building Blocks
152
182
 
153
183
  The lower-level primitives that power the [template components](#template-components) are published from the `@opengovsg/confetti/components` subpath. Reach for these to compose your own survey UI.
@@ -1,4 +1,4 @@
1
- import { a as RatingAnswer, i as MultiSelectAnswer, o as SingleSelectAnswer, r as BugReportAnswer, t as PublicGetSurveyOutput } from "./index-rGiNABlG.js";
1
+ import { a as RatingAnswer, i as MultiSelectAnswer, o as SingleSelectAnswer, r as BugReportAnswer, t as PublicGetSurveyOutput } from "./index-CER9nZlw.js";
2
2
  import { PropsWithChildren, ReactNode } from "react";
3
3
 
4
4
  //#region src/core/types.d.ts
@@ -1 +1 @@
1
- import{n as e}from"./Button-LiaNjkvk.js";import{t}from"./src-DAnW22YG.js";import{useEffect as n,useState as r}from"react";import{useLocalStorage as i}from"usehooks-ts";import{jsx as a,jsxs as o}from"react/jsx-runtime";import s from"clsx";function c(e,t){return t===void 0?!0:typeof t==`boolean`?t:t(e)}function l({surveyId:e,override:t}){let[r,a]=i(`cfti:${e}:respondent`,``);return n(()=>{r||a(crypto.randomUUID())},[r,a]),t||r}const u={lastRespondedAt:null,lastDismissedAt:null};async function d({client:e,surveyId:n,respondent:r,signal:i}){try{let a=await e.get(`api/v1/cfti/${n}/respondent/${r}`,{signal:i}).json(),o=t.safeParse(a);return o.success?{lastRespondedAt:o.data.lastRespondedAt?new Date(o.data.lastRespondedAt):null,lastDismissedAt:o.data.lastDismissedAt?new Date(o.data.lastDismissedAt):null}:(console.warn(`[confetti] Respondent response failed schema validation`,o.error),u)}catch{return u}}function f({client:e,surveyId:t,respondent:i}){let[a,o]=r(u),[s,c]=r(!1),[l,f]=r({client:e,surveyId:t,respondent:i});return(l.client!==e||l.surveyId!==t||l.respondent!==i)&&(f({client:e,surveyId:t,respondent:i}),o(u),c(!1)),n(()=>{if(!i||typeof window>`u`||typeof document>`u`)return;let n=null,r=()=>{n?.abort(),n=new AbortController;let r=n;d({client:e,surveyId:t,respondent:i,signal:r.signal}).then(e=>{r.signal.aborted||(o(e),c(!0))})};r();let a=()=>{document.visibilityState===`visible`&&r()};return document.addEventListener(`visibilitychange`,a),()=>{n?.abort(),document.removeEventListener(`visibilitychange`,a)}},[e,t,i]),{state:a,isSettled:s}}function p({client:e,surveyId:t}){let[i,a]=r(!1),[o,s]=r(!1),[c,l]=r({client:e,surveyId:t});return(c.client!==e||c.surveyId!==t)&&(l({client:e,surveyId:t}),a(!1),s(!1)),n(()=>{if(typeof window>`u`)return;let n=new AbortController;return e.head(`api/v1/cfti/${t}`,{signal:n.signal}).then(()=>{n.signal.aborted||a(!0)}).catch(()=>{n.signal.aborted||a(!1)}).finally(()=>{n.signal.aborted||s(!0)}),()=>{n.abort()}},[e,t]),{isAvailable:i,isSettled:o}}const m=e=>a(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 44 38`,...e,children:o(`g`,{transform:`translate(-2 -2) scale(1.1)`,children:[a(`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`}),a(`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`}),a(`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`}),a(`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`})]})}),h=({onClick:t,isWidgetOpen:n,classNames:r,label:i=`Help us improve`})=>n?null:o(e,{onPress:t,className:s(`confetti-trigger`,r?.trigger),children:[a(`span`,{className:s(`confetti-trigger-icon-wrapper`,r?.iconWrapper),"aria-hidden":!0,children:a(m,{className:s(`confetti-trigger-icon`,r?.icon),width:24})}),a(`span`,{className:s(`confetti-trigger-label`,r?.label),children:i})]});export{l as a,f as i,m as n,c as o,p as r,h as t};
1
+ import{n as e}from"./Button-LiaNjkvk.js";import{t}from"./src-BewqzpwC.js";import{useEffect as n,useState as r}from"react";import{useLocalStorage as i}from"usehooks-ts";import{jsx as a,jsxs as o}from"react/jsx-runtime";import s from"clsx";function c(e,t){return t===void 0?!0:typeof t==`boolean`?t:t(e)}function l({surveyId:e,override:t}){let[r,a]=i(`cfti:${e}:respondent`,``);return n(()=>{r||a(crypto.randomUUID())},[r,a]),t||r}const u={lastRespondedAt:null,lastDismissedAt:null};async function d({client:e,surveyId:n,respondent:r,signal:i}){try{let a=await e.get(`api/v1/cfti/${n}/respondent/${r}`,{signal:i}).json(),o=t.safeParse(a);return o.success?{lastRespondedAt:o.data.lastRespondedAt?new Date(o.data.lastRespondedAt):null,lastDismissedAt:o.data.lastDismissedAt?new Date(o.data.lastDismissedAt):null}:(console.warn(`[confetti] Respondent response failed schema validation`,o.error),u)}catch{return u}}function f({client:e,surveyId:t,respondent:i}){let[a,o]=r(u),[s,c]=r(!1),[l,f]=r({client:e,surveyId:t,respondent:i});return(l.client!==e||l.surveyId!==t||l.respondent!==i)&&(f({client:e,surveyId:t,respondent:i}),o(u),c(!1)),n(()=>{if(!i||typeof window>`u`||typeof document>`u`)return;let n=null,r=()=>{n?.abort(),n=new AbortController;let r=n;d({client:e,surveyId:t,respondent:i,signal:r.signal}).then(e=>{r.signal.aborted||(o(e),c(!0))})};r();let a=()=>{document.visibilityState===`visible`&&r()};return document.addEventListener(`visibilitychange`,a),()=>{n?.abort(),document.removeEventListener(`visibilitychange`,a)}},[e,t,i]),{state:a,isSettled:s}}function p({client:e,surveyId:t}){let[i,a]=r(!1),[o,s]=r(!1),[c,l]=r({client:e,surveyId:t});return(c.client!==e||c.surveyId!==t)&&(l({client:e,surveyId:t}),a(!1),s(!1)),n(()=>{if(typeof window>`u`)return;let n=new AbortController;return e.head(`api/v1/cfti/${t}`,{signal:n.signal}).then(()=>{n.signal.aborted||a(!0)}).catch(()=>{n.signal.aborted||a(!1)}).finally(()=>{n.signal.aborted||s(!0)}),()=>{n.abort()}},[e,t]),{isAvailable:i,isSettled:o}}const m=e=>a(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 44 38`,...e,children:o(`g`,{transform:`translate(-2 -2) scale(1.1)`,children:[a(`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`}),a(`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`}),a(`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`}),a(`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`})]})}),h=({onClick:t,isWidgetOpen:n,classNames:r,label:i=`Help us improve`})=>n?null:o(e,{onPress:t,className:s(`confetti-trigger`,r?.trigger),children:[a(`span`,{className:s(`confetti-trigger-icon-wrapper`,r?.iconWrapper),"aria-hidden":!0,children:a(m,{className:s(`confetti-trigger-icon`,r?.icon),width:24})}),a(`span`,{className:s(`confetti-trigger-label`,r?.label),children:i})]});export{l as a,f as i,m as n,c as o,p as r,h as t};
@@ -1 +1 @@
1
- import{a as e,i as t,o as n,r}from"./DefaultConfettiTrigger-C-E0FHJD.js";import{D as i,E as a,G as o,I as s,N as c,O as l,R as u,T as d,V as f,_ as p,a as m,b as h,d as g,g as _,h as v,i as y,k as b,m as x,n as S,o as C,p as w,r as T,s as E,u as D,x as O,y as k,z as A}from"./Button-LiaNjkvk.js";import{a as j,c as M,d as ee,i as te,l as ne,o as re,r as ie,s as ae,u as oe}from"./src-DAnW22YG.js";import{a as se,n as ce,o as le,r as ue,t as de}from"./internals-DMTYF5K8.js";import{d as fe,f as pe,h as me,i as he,l as ge,m as _e,p as ve,r as ye,s as be,u as xe}from"./ModalContainer-BiysurqW.js";import N,{Suspense as Se,cloneElement as Ce,createContext as P,forwardRef as F,isValidElement as we,lazy as Te,useCallback as I,useContext as L,useEffect as R,useMemo as z,useRef as B,useState as V}from"react";import{useTimeout as Ee}from"usehooks-ts";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import G from"clsx";import"react-dom";function De(e,t,n){let r=d(e=>{n&&!e.defaultPrevented&&n(t)});R(()=>{let t=e?.current?.form;return t?.addEventListener(`reset`,r),()=>{t?.removeEventListener(`reset`,r)}},[e])}function Oe(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:a=`label`}=e;t=A(t);let o=A(),s={};n&&(r=r?`${o} ${r}`:o,s={id:o,htmlFor:a===`label`?t:void 0});let c=ve({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:s,fieldProps:c}}function ke(e){let{description:t,errorMessage:n,isInvalid:r,validationState:i}=e,{labelProps:a,fieldProps:o}=Oe(e),s=u([!!t,!!n,r,i]),c=u([!!t,!!n,r,i]);return o=l(o,{"aria-describedby":[s,c,e[`aria-describedby`]].filter(Boolean).join(` `)||void 0}),{labelProps:a,fieldProps:o,descriptionProps:{id:s},errorMessageProps:{id:c}}}function Ae(e,t,n){let{validationBehavior:r,focus:i}=e;f(()=>{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(Me(n.current))}});let a=B(!1),o=d(()=>{a.current||t.resetValidation()}),s=d(e=>{t.displayValidation.isInvalid||t.commitValidation();let r=n?.current?.form;!e.defaultPrevented&&n&&r&&Ne(r)===n.current&&(i?i():n.current?.focus(),D(`keyboard`)),e.preventDefault()}),l=d(()=>{t.commitValidation()});R(()=>{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`&&c(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 je(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 Me(e){return{isInvalid:!e.validity.valid,validationDetails:je(e),validationErrors:e.validationMessage?[e.validationMessage]:[]}}function Ne(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 Pe={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},Fe={...Pe,customError:!0,valid:!1},K={isInvalid:!1,validationDetails:Pe,validationErrors:[]},Ie=P({}),Le=`__reactAriaFormValidationState`;function q(e){if(e.__reactAriaFormValidationState){let{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}=e[Le];return{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}}return Re(e)}function Re(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:Fe},l=z(()=>!o||i==null?null:Ve(Be(o,i)),[o,i]);a?.validationDetails.valid&&(a=void 0);let u=L(Ie),d=z(()=>r?Array.isArray(r)?r.flatMap(e=>ze(u[e])):ze(u[r]):[],[u,r]),[f,p]=V(u),[m,h]=V(!1);u!==f&&(p(u),h(!1));let g=z(()=>Ve(m?[]:d),[m,d]),_=B(K),[v,y]=V(K),b=B(K),x=()=>{if(!S)return;C(!1);let e=l||a||_.current;He(e,b.current)||(b.current=e,y(e))},[S,C]=V(!1);return R(x),{realtimeValidation:c||g||l||a||K,displayValidation:s===`native`?c||g||v:c||g||l||a||v,updateValidation(e){s===`aria`&&!He(v,e)?y(e):_.current=e},resetValidation(){let e=K;He(e,b.current)||(b.current=e,y(e)),s===`native`&&C(!1),h(!0)},commitValidation(){s===`native`&&C(!0),h(!0)}}}function ze(e){return e?Array.isArray(e)?e:[e]:[]}function Be(e,t){if(typeof e==`function`){let n=e(t);if(n&&typeof n!=`boolean`)return ze(n)}return[]}function Ve(e){return e.length?{isInvalid:!0,validationErrors:e,validationDetails:Fe}:null}function He(e,t){return e===t||!!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 Ue(...e){let t=new Set,n=!1,r={...Pe};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 We(e,t){let{inputElementType:n=`input`,isDisabled:r=!1,isRequired:a=!1,isReadOnly:o=!1,type:s=`text`,validationBehavior:u=`aria`}=e,[d,f]=xe(e.value,e.defaultValue||``,e.onChange),{focusableProps:p}=E(e,t),m=q({...e,value:d}),{isInvalid:h,validationErrors:g,validationDetails:_}=m.displayValidation,{labelProps:v,fieldProps:y,descriptionProps:b,errorMessageProps:x}=ke({...e,isInvalid:h,errorMessage:e.errorMessage||g}),S=i(e,{labelable:!0}),C={type:s,pattern:e.pattern},[w]=V(d);return De(t,e.defaultValue??w,f),Ae(e,m,t),{labelProps:v,inputProps:l(S,n===`input`?C:void 0,{disabled:r,readOnly:o,required:a&&u===`native`,"aria-required":a&&u===`aria`||void 0,"aria-invalid":h||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:d,onChange:e=>f(c(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(N.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,...p,...y}),descriptionProps:b,errorMessageProps:x,isInvalid:h,validationErrors:g,validationDetails:_}}function Ge(e,t,n){let{isDisabled:r=!1,isReadOnly:a=!1,value:o,name:s,form:u,children:d,"aria-label":f,"aria-labelledby":p,validationState:m=`valid`,isInvalid:h,onPressStart:_,onPressEnd:v,onPressChange:y,onPress:b,onPressUp:x,onClick:S}=e,C=e=>{e.stopPropagation(),t.setSelected(c(e).checked)},{pressProps:w,isPressed:T}=g({onPressStart:_,onPressEnd:v,onPressChange:y,onPress:b,onPressUp:x,onClick:S,isDisabled:r}),{pressProps:D,isPressed:O}=g({onPressStart:_,onPressEnd:v,onPressChange:y,onPressUp:x,onClick:S,onPress(e){b?.(e),t.toggle(),n.current?.focus()},isDisabled:r||a}),{focusableProps:k}=E(e,n),A=l(w,k),j=i(e,{labelable:!0});return De(n,t.defaultSelected,t.setSelected),{labelProps:l(D,{onClick:e=>e.preventDefault()}),inputProps:l(j,{"aria-invalid":h||m===`invalid`||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-controls":e[`aria-controls`],"aria-readonly":a||void 0,onChange:C,disabled:r,...o==null?{}:{value:o},name:s,form:u,type:`checkbox`,...A}),isSelected:t.isSelected,isPressed:T||O,isDisabled:r,isReadOnly:a,isInvalid:h||m===`invalid`}}function Ke(e,t,n){let r=q({...e,value:t.isSelected}),{isInvalid:i,validationErrors:a,validationDetails:o}=r.displayValidation,{labelProps:s,inputProps:c,isSelected:u,isPressed:d,isDisabled:f,isReadOnly:p}=Ge({...e,isInvalid:i},t,n);Ae(e,r,n);let{isIndeterminate:m,isRequired:h,validationBehavior:_=`aria`}=e;R(()=>{n.current&&(n.current.indeterminate=!!m)});let{pressProps:v}=g({isDisabled:f||p,onPress(){let{[Le]:t}=e,{commitValidation:n}=t||r;n()}});return{labelProps:l(s,v,z(()=>({onMouseDown:e=>e.preventDefault()}),[])),inputProps:{...c,checked:u,"aria-required":h&&_===`aria`||void 0,required:h&&_===`native`},isSelected:u,isPressed:d,isDisabled:f,isReadOnly:p,isInvalid:i,validationErrors:a,validationDetails:o}}const qe=new WeakMap;function Je(e,t){let{isDisabled:n,name:r,form:a,validationBehavior:o=`aria`}=e,{isInvalid:s,validationErrors:c,validationDetails:u}=t.displayValidation,{labelProps:d,fieldProps:f,descriptionProps:p,errorMessageProps:m}=ke({...e,labelElementType:`span`,isInvalid:s,errorMessage:e.errorMessage||c});qe.set(t,{name:r,form:a,descriptionId:p.id,errorMessageId:m.id,validationBehavior:o});let h=i(e,{labelable:!0}),{focusWithinProps:g}=C({onBlurWithin:e.onBlur,onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange});return{groupProps:l(h,{role:`group`,"aria-disabled":n||void 0,...f,...g}),labelProps:d,descriptionProps:p,errorMessageProps:m,isInvalid:s,validationErrors:c,validationDetails:u}}function Ye(e={}){let{isReadOnly:t}=e,[n,r]=xe(e.isSelected,e.defaultSelected||!1,e.onChange),[i]=V(n);function a(e){t||r(e)}function o(){t||r(!n)}return{isSelected:n,defaultSelected:e.defaultSelected??i,setSelected:a,toggle:o}}function Xe(e,t,n){let r=Ye({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}=qe.get(t);c=e.validationBehavior??c;let{realtimeValidation:l}=q({...e,value:r.isSelected,name:void 0,validationBehavior:`aria`}),u=B(K),d=()=>{t.setInvalid(e.value,l.isInvalid?l:u.current)};R(d);let f=t.realtimeValidation.isInvalid?t.realtimeValidation:l,p=c===`native`?t.displayValidation:f,m=Ke({...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,[Le]:{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 Ze=new WeakMap;function Qe(e,t,n){let{value:r,children:a,"aria-label":o,"aria-labelledby":s,onPressStart:c,onPressEnd:u,onPressChange:d,onPress:f,onPressUp:p,onClick:m}=e,h=e.isDisabled||t.isDisabled,_=t.selectedValue===r,v=e=>{e.stopPropagation(),t.setSelectedValue(r)},{pressProps:y,isPressed:b}=g({onPressStart:c,onPressEnd:u,onPressChange:d,onPress:f,onPressUp:p,onClick:m,isDisabled:h}),{pressProps:x,isPressed:S}=g({onPressStart:c,onPressEnd:u,onPressChange:d,onPressUp:p,onClick:m,isDisabled:h,onPress(e){f?.(e),t.setSelectedValue(r),n.current?.focus()}}),{focusableProps:C}=E(l(e,{onFocus:()=>t.setLastFocusedValue(r)}),n),w=l(y,C),T=i(e,{labelable:!0}),D=-1;t.selectedValue==null?(t.lastFocusedValue===r||t.lastFocusedValue==null)&&(D=0):t.selectedValue===r&&(D=0),h&&(D=void 0);let{name:O,form:k,descriptionId:A,errorMessageId:j,validationBehavior:M}=Ze.get(t);return De(n,t.defaultSelectedValue,t.setSelectedValue),Ae({validationBehavior:M},t,n),{labelProps:l(x,z(()=>({onClick:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault()}),[])),inputProps:l(T,{...w,type:`radio`,name:O,form:k,tabIndex:D,disabled:h,required:t.isRequired&&M===`native`,checked:_,value:r,onChange:v,"aria-describedby":[e[`aria-describedby`],t.isInvalid?j:null,A].filter(Boolean).join(` `)||void 0}),isDisabled:h,isSelected:_,isPressed:b||S}}function $e(e,t){let{name:n,form:r,isReadOnly:a,isRequired:o,isDisabled:u,orientation:d=`vertical`,validationBehavior:f=`aria`}=e,{direction:p}=pe(),{isInvalid:m,validationErrors:h,validationDetails:g}=t.displayValidation,{labelProps:_,fieldProps:v,descriptionProps:y,errorMessageProps:b}=ke({...e,labelElementType:`span`,isInvalid:t.isInvalid,errorMessage:e.errorMessage||h}),x=i(e,{labelable:!0}),{focusWithinProps:S}=C({onBlurWithin(n){e.onBlur?.(n),t.selectedValue||t.setLastFocusedValue(null)},onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange}),w=e=>{let n;switch(e.key){case`ArrowRight`:n=p===`rtl`&&d!==`vertical`?`prev`:`next`;break;case`ArrowLeft`:n=p===`rtl`&&d!==`vertical`?`next`:`prev`;break;case`ArrowDown`:n=`next`;break;case`ArrowUp`:n=`prev`;break;default:return}e.preventDefault();let r=fe(e.currentTarget,{from:c(e),accept:e=>e instanceof s(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))},T=A(n);return Ze.set(t,{name:T,form:r,descriptionId:y.id,errorMessageId:b.id,validationBehavior:f}),{radioGroupProps:l(x,{role:`radiogroup`,onKeyDown:w,"aria-invalid":t.isInvalid||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-readonly":a||void 0,"aria-required":o||void 0,"aria-disabled":u||void 0,"aria-orientation":d,...v,...S}),labelProps:_,descriptionProps:y,errorMessageProps:b,isInvalid:m,validationErrors:h,validationDetails:g}}const et=P({}),J=T(function(e,t){[e,t]=x(e,t,et);let{elementType:n=`label`,...r}=e,i=k[n];return N.createElement(i,{className:`react-aria-Label`,...r,ref:t})}),tt=P({}),Y=F(function(e,t){[e,t]=x(e,t,tt);let{elementType:n=`span`,...r}=e,i=k[n];return N.createElement(i,{className:`react-aria-Text`,...r,ref:t})});function nt(e={}){let[t,n]=xe(e.value,e.defaultValue||[],e.onChange),[r]=V(t),i=!!e.isRequired&&t.length===0,a=B(new Map),o=q({...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(Ue(...n.values()))},validationState:e.validationState??(s?`invalid`:null),isInvalid:s,isRequired:i}}let rt=Math.round(Math.random()*1e10),it=0;function at(e){let t=z(()=>e.name||`radio-group-${rt}-${++it}`,[e.name]),[n,r]=xe(e.value,e.defaultValue??null,e.onChange),[i]=V(n),[a,o]=V(null),s=q({...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 X=P(null),Z=F(function(e,t){return L(X)?.isInvalid?N.createElement(ot,{...e,ref:t}):null}),ot=F((e,t)=>{let n=L(X),r=i(e,{global:!0}),a=v({...e,defaultClassName:`react-aria-FieldError`,defaultChildren:n.validationErrors.length===0?void 0:n.validationErrors.join(` `),values:n});return a.children==null?null:N.createElement(Y,{slot:`errorMessage`,...r,...a,ref:t})}),st=P(null),ct=P(null),lt=P(null),ut=F(function(e,t){[e,t]=x(e,t,ct);let{validationBehavior:n}=O(st)||{},r=e.validationBehavior??n??`native`,a=nt({...e,validationBehavior:r}),[o,s]=_(!e[`aria-label`]&&!e[`aria-labelledby`]),{groupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=Je({...e,label:s,validationBehavior:r},a),m=v({...e,values:{isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:e.isRequired||!1,isInvalid:a.isInvalid,state:a},defaultClassName:`react-aria-CheckboxGroup`}),h=i(e,{global:!0});return N.createElement(k.div,{...l(h,m,c),ref:t,slot:e.slot||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":e.isRequired||void 0,"data-invalid":a.isInvalid||void 0,"data-disabled":e.isDisabled||void 0},N.createElement(w,{values:[[lt,a],[et,{...u,ref:o,elementType:`span`}],[tt,{slots:{description:d,errorMessage:f}}],[X,p]]},m.children))}),dt=F(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=x(r,t,me);let{validationBehavior:o}=O(st)||{},s=e.validationBehavior??o??`native`,c=L(lt),u=a(z(()=>b(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:d,inputProps:f,isSelected:p,isDisabled:g,isReadOnly:_,isPressed:S,isInvalid:C}=c?Xe({...h(e),value:e.value,children:typeof e.children==`function`||e.children},c,u):Ke({...h(e),children:typeof e.children==`function`||e.children,validationBehavior:s},Ye(e),u),{isFocused:w,isFocusVisible:T,focusProps:E}=m(),D=g||_,{hoverProps:A,isHovered:j}=y({...e,isDisabled:D}),M=v({...e,defaultClassName:`react-aria-Checkbox`,values:{isSelected:p,isIndeterminate:e.isIndeterminate||!1,isPressed:S,isHovered:j,isFocused:w,isFocusVisible:T,isDisabled:g,isReadOnly:_,isInvalid:C,isRequired:e.isRequired||!1}}),ee=i(e,{global:!0});return delete ee.id,delete ee.onClick,N.createElement(k.label,{...l(ee,d,A,M),ref:t,slot:e.slot||void 0,"data-selected":p||void 0,"data-indeterminate":e.isIndeterminate||void 0,"data-pressed":S||void 0,"data-hovered":j||void 0,"data-focused":w||void 0,"data-focus-visible":T||void 0,"data-disabled":g||void 0,"data-readonly":_||void 0,"data-invalid":C||void 0,"data-required":e.isRequired||void 0},N.createElement(ge,{elementType:`span`},N.createElement(`input`,{...l(f,E),ref:u})),M.children)}),ft=P({}),pt=P({});let mt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const ht=T(function(e,t){[e,t]=x(e,t,pt);let{hoverProps:n,isHovered:r}=y({...e,isDisabled:e.disabled}),{isFocused:i,isFocusVisible:a,focusProps:o}=m({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=v({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-Input`});return N.createElement(k.input,{...l(mt(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})}),gt=P(null);function _t(e){let t=B({});return N.createElement(gt.Provider,{value:t},e.children)}const vt=P({isSelected:!1}),yt=P(null),bt=P(null),xt=P(null),St=F(function(e,t){[e,t]=x(e,t,yt);let{validationBehavior:n}=O(st)||{},r=e.validationBehavior??n??`native`,a=at({...e,validationBehavior:r}),[o,s]=_(!e[`aria-label`]&&!e[`aria-labelledby`]),{radioGroupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=$e({...e,label:s,validationBehavior:r},a),m=v({...e,values:{orientation:e.orientation||`vertical`,isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:a.isRequired,isInvalid:a.isInvalid,state:a},defaultClassName:`react-aria-RadioGroup`}),h=i(e,{global:!0});return N.createElement(k.div,{...l(h,m,c),ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||`vertical`,"data-invalid":a.isInvalid||void 0,"data-disabled":a.isDisabled||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":a.isRequired||void 0},N.createElement(w,{values:[[xt,a],[et,{...u,ref:o,elementType:`span`}],[tt,{slots:{description:d,errorMessage:f}}],[X,p]]},N.createElement(_t,null,m.children)))}),Ct=F(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=x(r,t,bt);let o=N.useContext(xt),s=a(z(()=>b(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:c,inputProps:u,isSelected:d,isDisabled:f,isPressed:p}=Qe({...h(e),children:typeof e.children==`function`||e.children},o,s),{isFocused:g,isFocusVisible:_,focusProps:S}=m(),C=f||o.isReadOnly,{hoverProps:w,isHovered:T}=y({...e,isDisabled:C}),E=v({...e,defaultClassName:`react-aria-Radio`,values:{isSelected:d,isPressed:p,isHovered:T,isFocused:g,isFocusVisible:_,isDisabled:f,isReadOnly:o.isReadOnly,isInvalid:o.isInvalid,isRequired:o.isRequired}}),D=i(e,{global:!0});return delete D.id,delete D.onClick,N.createElement(k.label,{...l(D,c,w,E),ref:t,"data-selected":d||void 0,"data-pressed":p||void 0,"data-hovered":T||void 0,"data-focused":g||void 0,"data-focus-visible":_||void 0,"data-disabled":f||void 0,"data-readonly":o.isReadOnly||void 0,"data-invalid":o.isInvalid||void 0,"data-required":o.isRequired||void 0},N.createElement(ge,{elementType:`span`},N.createElement(`input`,{...l(u,S),ref:s})),N.createElement(vt.Provider,{value:{isSelected:d}},E.children))}),wt=P({});let Tt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const Et=F(function(e,t){[e,t]=x(e,t,wt);let{hoverProps:n,isHovered:r}=y(e),{isFocused:i,isFocusVisible:a,focusProps:o}=m({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=v({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-TextArea`});return N.createElement(k.textarea,{...l(Tt(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})}),Dt=P(null),Ot=T(function(e,t){[e,t]=x(e,t,Dt);let{validationBehavior:n}=O(st)||{},r=e.validationBehavior??n??`native`,a=B(null);[e,a]=x(e,a,_e);let[o,s]=_(!e[`aria-label`]&&!e[`aria-labelledby`]),[c,l]=V(`input`),{labelProps:u,inputProps:d,descriptionProps:f,errorMessageProps:p,...m}=We({...h(e),inputElementType:c,label:s,validationBehavior:r},a),g=I(e=>{a.current=e,e&&l(e instanceof HTMLTextAreaElement?`textarea`:`input`)},[a]),y=v({...e,values:{isDisabled:e.isDisabled||!1,isInvalid:m.isInvalid,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1},defaultClassName:`react-aria-TextField`}),b=i(e,{global:!0});return delete b.id,N.createElement(k.div,{...b,...y,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-invalid":m.isInvalid||void 0,"data-readonly":e.isReadOnly||void 0,"data-required":e.isRequired||void 0},N.createElement(w,{values:[[et,{...u,ref:o}],[pt,{...d,ref:g}],[wt,{...d,ref:g}],[ft,{role:`presentation`,isInvalid:m.isInvalid,isDisabled:e.isDisabled||!1}],[tt,{slots:{description:f,errorMessage:p}}],[X,m]]},y.children))});function kt(e){return e.issues[0]?.message??`Invalid input`}const At=({originalQuestions:e,answers:t,errors:n,pointer:r=-1})=>{if(!e)return{questions:[],currentIndex:-1};let i=[...e].sort((e,t)=>e.position-t.position),a=r>=0?i[r]:void 0,o=le(i,t,{forceReachableIds:a?[a.id]:void 0}),s=i.map((e,t)=>{let i={...e},a=n[e.id];return a&&(i.error=a),{...i,visible:r===t||o.has(e.id)}}),c=s.findIndex((e,n)=>n>r&&e.visible&&t[e.id]===void 0);return c===-1&&(c=s.findLastIndex(e=>!!e.visible)),{questions:s,currentIndex:c}},Q={rating:({scale:e},t)=>re({scale:e},t),"open-ended":({max:e},t)=>j({maxLength:e},t),"single-select":({editable:e},t)=>ae({maxLength:e?.max},t),"multi-select":({editable:e,max:t},n)=>te({maxLength:e?.max,maxSelected:t},n),statement:(e,t)=>M(),"bug-report":(e,t)=>ie({},t)},jt=(e,t)=>{let n=e.type;switch(n){case`rating`:{let r=Q[n];return r(e,t)}case`open-ended`:{let r=Q[n];return r(e,t)}case`single-select`:{let r=Q[n];return r(e,t)}case`multi-select`:{let r=Q[n];return r(e,t)}case`statement`:{let r=Q[n];return r(e,t)}case`bug-report`:{let r=Q[n];return r(e,t)}default:throw Error(`Unsupported question type`)}},Mt=({questions:e,answers:t})=>{let n=Nt({questions:e,answers:t});return Object.fromEntries(Object.entries(n).filter(([,e])=>e!==null))},Nt=({questions:e,answers:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Pt=({questions:e,errors:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Ft={},It=({questions:e,answers:t,errors:n})=>{let r={};for(let i of e){if(!i.visible||!i.required||t[i.id]!==void 0||n[i.id])continue;let e=jt(i.properties,{required:i.required}).safeParse(void 0);e.success||(r[i.id]=kt(e.error))}return r},Lt=e=>{let t=e.querySelector(`[data-invalid]`);if(!t)return;let n=t.getAttribute(`role`);if(n===`radiogroup`||n===`group`){t.tabIndex=-1,t.focus();return}t.querySelector(`textarea, input`)?.focus()},Rt=({current:e,shouldAutoSubmit:t,onSubmitted:n,onFinished:r,children:i})=>{let{survey:a,submit:o}=be(),[s,c]=V({}),[l,u]=V({}),[d,f]=V(null),p=z(()=>At({originalQuestions:a?.questions,answers:s,errors:l,pointer:e}),[a?.questions,s,l,e]),m=e??d??p.currentIndex,h=z(()=>!!a?.isBackNavigationAllowed&&m>0&&p.questions.slice(0,m).some(e=>!!e.visible),[a?.isBackNavigationAllowed,p.questions,m]),g=I((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),_=I(()=>{a?.isBackNavigationAllowed&&f(t=>{let n=t??e??p.currentIndex;for(let e=n-1;e>=0;e--)if(p.questions[e]?.visible)return e;return t})},[a?.isBackNavigationAllowed,p.questions,p.currentIndex,e]),[v,y]=V(0),b=v>0,x=B(null),[S,C]=V(!1);R(()=>{v===0||!x.current||Lt(x.current)},[v]);let w=I(({answers:e})=>{o({answers:e}).finally(()=>{r?.()})},[r,o]),T=I(()=>{let e=Pt({questions:p.questions,errors:l}),t=It({questions:p.questions,answers:s,errors:e}),r=Object.keys(t).length>0;if(Object.keys(e).length>0||r)return r&&u(e=>({...e,...t})),y(e=>e+1),!1;let i=Mt({questions:p.questions,answers:s});return w({answers:i}),C(!0),n?.(),!0},[s,l,p.questions,w,n]),E=I(({question:r,answer:i})=>{let o=p.questions.at(r);if(!o)return{error:`Question index is invalid`};let m=jt(o.properties,{required:o.required}).safeParse(i);if(!m.success){let e=kt(m.error);return u(t=>{if(t[o.id]===e)return t;let n={...t};return n[o.id]=e,n}),c(e=>{if(!(o.id in e))return e;let t={...e};return delete t[o.id],t}),{error:e}}u(e=>{if(!e[o.id])return e;let t={...e};return delete t[o.id],t});let h=!o.required&&!i?null:i,g={...s},_=g[o.id]!==h;g[o.id]=h;let v=At({originalQuestions:a?.questions,answers:g,errors:l,pointer:e});_&&c(g);let y=v.questions.findIndex((e,t)=>t>r&&!!e.visible);if(d!==null&&y!==-1)return f(y),{next:y};if(f(null),v.questions.filter(({visible:e})=>!!e).every(({id:e})=>g[e]!==void 0)&&t){let e=Mt({questions:v.questions,answers:g});w({answers:e}),C(!0),n?.()}return{next:v.currentIndex}},[p.questions,s,a?.questions,l,t,e,d,w,n]);return p.questions.length===0?U(H,{}):U(`div`,{ref:x,className:`confetti ${de}`,"data-show-errors":b||void 0,children:i({questions:p.questions,current:m,answers:s,update:E,back:_,canGoBack:h,backButtonLabel:a?.backButtonLabel??void 0,saveAnswer:g,submit:T,isSubmitted:S,errors:b?l:Ft})})},zt=P(null);function Bt({children:i,surveyId:a,publishableKey:s,apiBaseUrl:c,respondent:l,isSurveyVisible:u}){let d=e({surveyId:a,override:l}),f=o({publishableKey:s,apiBaseUrl:c}),{isAvailable:p,isSettled:m}=r({client:f,surveyId:a}),{state:h,isSettled:g}=t({client:f,surveyId:a,respondent:d}),_=z(()=>({respondent:d}),[d]);return!d||!m||!g||!p||!n(h,u)?null:U(zt.Provider,{value:_,children:i})}function Vt(e){return L(zt)?U(H,{children:e.children}):U(Bt,{...e})}function Ht(){let e=L(zt);if(!e)throw Error(`useRespondentVisibility must be used within a RespondentVisibilityProvider`);return e}const Ut=({children:e,classNames:t,containerProps:n,onDismiss:r,onClose:i,closeOnFinishMs:a=3e3})=>{let{surveyId:o,survey:s,dismiss:c}=be(),[l,u]=V(!1),[d,f]=V(!1),[p,m]=V(!1),[h,g]=V(!1);return Ee(()=>{s&&i?.()},d&&!(p||h)?a:null),W(`div`,{className:G(`confetti-dialog ${de}`,t?.dialog),id:`${o}-popover`,...n,onMouseEnter:e=>{n?.onMouseEnter?.(e),m(!0)},onMouseLeave:e=>{n?.onMouseLeave?.(e),m(!1)},onFocusCapture:e=>{n?.onFocusCapture?.(e),g(!0)},onBlurCapture:e=>{n?.onBlurCapture?.(e),e.currentTarget.contains(e.relatedTarget)||g(!1)},children:[U(ye,{className:G(`confetti-dialog-close`,t?.closeButton),iconClassName:t?.icon,onClose:async()=>{l||(await c(),r?.()),i?.()}}),typeof e==`function`?e({setIsSubmitted:()=>u(!0),setIsFinished:()=>f(!0)}):e]})},Wt=3e4,Gt=({maskAllInputs:e,initialEventsJson:t}={})=>{let[n,r]=V(()=>t??null),[i,a]=V(!1),[o,s]=V(null),[c,l]=V(30),u=B(null),d=B(null),f=B(null),p=B([]);R(()=>{let e=new CustomEvent(ue,{detail:{isRecording:i}});document.dispatchEvent(e)},[i]);let m=I(()=>{d.current&&=(clearInterval(d.current),null),f.current&&=(clearTimeout(f.current),null),u.current=null,l(Wt/1e3)},[]),h=I(()=>{u.current?.(),m(),a(!1),r(JSON.stringify(p.current))},[m]);return{recordingEventsJson:n,isRecording:i,recordingError:o,remainingSeconds:c,startRecording:I(async()=>{a(!0),s(null),r(null),p.current=[];try{let{record:t}=await import(`./record--U99gpCM.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=Wt/1e3;l(n),d.current=setInterval(()=>{--n,l(n)},1e3),f.current=setTimeout(()=>{h()},Wt)}catch{s(`Failed to start recording. Please try again.`),a(!1),m()}},[e,h,m]),stopRecording:h,clear:I(()=>{m(),a(!1),r(null),s(null),p.current=[]},[m])}},Kt=e=>e.replace(/\S/g,`*`),qt=e=>`*`.repeat(e.length),Jt=(e,t)=>{for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t(n):Jt(n,t)},Yt=e=>{if(e instanceof HTMLInputElement)e.setAttribute(`value`,qt(e.getAttribute(`value`)??``));else if(e instanceof HTMLTextAreaElement)e.textContent=qt(e.textContent);else if(e instanceof HTMLSelectElement)for(let t of e.querySelectorAll(`option`))t.textContent=qt(t.textContent)},Xt=({maskInputs:e})=>({name:`cfti-redact`,afterClone:t=>{let{clone:n}=t;if(n instanceof HTMLElement){for(let e of n.querySelectorAll(`.${ce}`)){Jt(e,e=>{e.data=Kt(e.data)}),Yt(e);for(let t of e.querySelectorAll(`input, textarea, select`))Yt(t)}if(e)for(let e of n.querySelectorAll(`input, textarea, select`))Yt(e)}}}),Zt=({maskAllInputs:e,initialDataUrl:t}={})=>{let[n,r]=V(()=>t??null),[i,a]=V(!1),[o,s]=V(null);return{screenshotDataUrl:n,isCapturing:i,captureError:o,capture:I(async()=>{a(!0),s(null);try{let{snapdom:t}=await import(`./snapdom-BbRa4ZYv.js`),n=await(await t(document.documentElement,{embedFonts:!0,exclude:[`.${de}`],excludeMode:`hide`,plugins:[Xt({maskInputs:!!e})],fast:!1})).toCanvas(),i=window.devicePixelRatio||1,a=Math.min(Math.round(window.innerWidth*i),n.width),o=Math.min(Math.round(window.innerHeight*i),n.height),s=document.createElement(`canvas`);s.width=a,s.height=o;let c=s.getContext(`2d`);if(!c)throw Error(`Failed to get 2D context for cropping`);c.drawImage(n,0,0,a,o,0,0,a,o),r(s.toDataURL(`image/png`))}catch{s(`Failed to capture screenshot. Please try again.`)}finally{a(!1)}},[e]),clear:I(()=>{r(null),s(null)},[])}},Qt=e=>W(`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:[U(`circle`,{cx:`12`,cy:`12`,r:`10`}),U(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`})]}),$t=e=>W(`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:[U(`path`,{d:`M10 11v6`}),U(`path`,{d:`M14 11v6`}),U(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),U(`path`,{d:`M3 6h18`}),U(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]});function en(){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 tn(){if(typeof window>`u`||typeof navigator>`u`)return;let e=navigator,t=window.screen,n=en();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 nn=Te(()=>import(`./RecordingReplayer-DNYXhses.js`)),rn=({id:e,title:t,description:n,properties:r,onChange:i,required:a,error:o,classNames:s,maskAllInputs:c,defaultAnswer:l})=>{let u=z(()=>tn(),[]),d=l&&typeof l==`object`&&`title`in l?l:void 0,[f,p]=V(()=>d?.title??``),[m,h]=V(()=>d?.description??``),{screenshotDataUrl:g,isCapturing:_,captureError:v,capture:y,clear:b}=Zt({maskAllInputs:c,initialDataUrl:d?.screenshotDataUrl}),{recordingEventsJson:x,isRecording:C,recordingError:w,remainingSeconds:T,startRecording:E,stopRecording:D,clear:O}=Gt({maskAllInputs:c,initialEventsJson:d?.recordingEventsJson}),k=z(()=>({title:f,...m?{description:m}:{},...g?{screenshotDataUrl:g}:{},...x?{recordingEventsJson:x}:{},metadata:u}),[m,u,x,g,f]);R(()=>{i(k)},[k,i]),R(()=>()=>{D()},[D]);let A=z(()=>x?JSON.parse(x):[],[x]);return U(H,{children:C?W(S,{className:G(`cf-bug-report-button`,`cf-bug-report-record-button`,s?.button,s?.recordButton),onPress:D,children:[U(Qt,{}),W(`span`,{children:[30-T,`s /`,` `,30,`s`]})]}):W(`div`,{className:G(`cf-bug-report`,s?.base),children:[W(Ot,{isRequired:a,isInvalid:!!o,name:`${e}-title`,value:f,onChange:p,className:G(`cf-question`,s?.question),children:[W(`div`,{className:G(`cf-header`,s?.header),children:[W(J,{className:G(`cf-title`,s?.title),children:[t,!a&&W(`span`,{className:G(`cf-label-optional`,s?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,s?.description),children:n})]}),U(ht,{placeholder:r.placeholder||`Brief description of the issue`,className:G(`cf-input`,s?.input)}),U(Z,{className:G(`cf-error`,s?.error),children:o})]}),W(Ot,{name:`${e}-description`,value:m,onChange:h,className:G(`cf-question`,s?.question),children:[U(J,{className:G(`cf-title`,s?.title),children:r.detailsLabel}),U(Et,{placeholder:r.detailsPlaceholder||`Steps to reproduce, expected vs actual behavior, etc.`,className:G(`cf-textarea`,s?.textArea),rows:4})]}),r.enableScreenshot||r.enableRecording?W(`section`,{className:G(`cf-question`,s?.question),children:[U(J,{className:G(`cf-title`,s?.title),children:`Attachments`}),W(`div`,{className:G(`cf-bug-report-actions`,s?.actions),children:[r.enableScreenshot&&W(`div`,{className:G(`cf-bug-report-screenshot-section`,s?.screenshotSection),children:[g?W(`div`,{className:G(`cf-bug-report-media-preview`,s?.mediaPreview),children:[U(`img`,{src:g,alt:`Screenshot preview`,className:G(`cf-bug-report-screenshot-img`,s?.screenshotImg)}),U(`div`,{className:G(`cf-bug-report-media-actions`,s?.mediaActions),children:U(S,{className:G(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:b,"aria-label":`Remove screenshot`,children:U($t,{})})})]}):U(S,{className:G(`cf-bug-report-button`,s?.button),onPress:y,isDisabled:_,children:_?`Capturing...`:`Screenshot`}),v&&U(`div`,{className:G(`cf-error`,s?.error),children:v})]}),r.enableRecording&&W(`div`,{className:G(`cf-bug-report-recording-section`,s?.recordingSection),children:[A.length>0?W(`div`,{className:G(`cf-bug-report-media-preview`,s?.mediaPreview),children:[U(Se,{fallback:U(`span`,{className:G(`cf-bug-report-player-loading`,s?.playerLoading),"aria-label":`Loading recording preview...`}),children:U(nn,{events:A})}),U(`div`,{className:G(`cf-bug-report-media-actions`,s?.mediaActions),children:U(S,{className:G(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:O,"aria-label":`Remove recording`,children:U($t,{})})})]}):U(S,{className:G(`cf-bug-report-button`,s?.button),onPress:E,children:`Record`}),w&&U(`div`,{className:G(`cf-error`,s?.error),children:w})]})]})]}):null]})})},an=({id:e,title:t,description:n,properties:r,onChange:i,classNames:a,required:o,error:s,defaultAnswer:c})=>{let[l,u]=V(()=>typeof c==`string`?c:``);return R(()=>{i(l)},[i,l]),W(Ot,{isRequired:o,isInvalid:!!s,name:e,className:G(`cf-question`,a?.question),value:l,onChange:e=>{u(e),i(e)},children:[W(`div`,{className:G(`cf-header`,a?.header),children:[W(J,{className:G(`cf-title`,a?.title),children:[t,!o&&W(`span`,{className:G(`cf-label-optional`,a?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,a?.description),children:n})]}),U(Et,{className:G(`cf-textarea`,a?.textarea),maxLength:r.max,rows:4,placeholder:r.placeholder||`Start typing...`}),U(Z,{className:G(`cf-error`,a?.error),children:s})]})},on=({children:e,classNames:t,description:n,...r})=>U(dt,{...r,children:({isIndeterminate:r})=>W(H,{children:[W(`div`,{className:G(`cf-choice-label`,t?.label),children:[U(`div`,{className:G(`cf-checkbox-indicator`,t?.indicator),children:U(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:G(`cf-checkbox-indicator-svg`,t?.svg),children:r?U(`rect`,{x:1,y:7.5,width:16,height:3}):U(`polyline`,{points:`2 9 7 14 16 4`})},r?`indeterminate`:`check`)}),e]}),n&&U(`span`,{className:G(`cf-choice-description`,t?.choiceDescription),children:n})]})}),sn=({children:e,classNames:t,...n})=>U(dt,{...n,children:U(`div`,{className:G(`cf-tag-label`,t?.tagLabel),children:e})}),cn=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s,defaultAnswer:c})=>{let l=!!n.editable,u=n.display??`checkbox`,d=Array.isArray(c)?c:[],f=new Set(n.options.map(e=>e.value)),p=d.find(e=>!f.has(e)),[m,h]=V(()=>{let e=d.filter(e=>f.has(e));return p!==void 0&&l&&e.push(ne),e}),[g,_]=V(()=>p!==void 0&&l?p:``),v=B(null),y=B(null),b=z(()=>{let e=m.indexOf(ne);if(e===-1)return m;let t=[...m];return t[e]=g||`__CONFETTI_CHECKBOX_Others`,t},[g,m]),x=u===`tag`;return R(()=>{i(b)},[i,b]),U(ut,{isRequired:o,isInvalid:!!s,name:a,value:m,onChange:h,className:G(`cf-question`,r?.question),children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(J,{className:G(`cf-title`,r?.title),children:[e,!o&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:t})]}),W(`div`,{className:G(`cf-response-choices`,u===`tag`&&`cf-response-choices-tag`,r?.group),children:[n.options.map((e,t)=>U(x?sn:on,{className:G(`cf-choice`,x&&[`cf-tag`,r?.tag],!x&&[`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)),l&&(x?W(H,{children:[U(sn,{inputRef:v,onChange:e=>{y.current&&e&&requestAnimationFrame(()=>{y.current&&y.current.focus()})},className:G(`cf-choice cf-tag`,r?.tag),value:`__CONFETTI_CHECKBOX_Others`,children:n.editable?.label}),U(ht,{"data-visible":i.value.includes(`__CONFETTI_CHECKBOX_Others`)||void 0,value:g,onChange:e=>{_(e.target.value)},ref:y,className:G(`cf-input cf-tag-input`,r?.othersInput)})]}):W(`div`,{className:G(`cf-choice cf-others-choice`,r?.othersChoice),children:[U(on,{inputRef:v,onChange:e=>{y.current&&e&&requestAnimationFrame(()=>{y.current&&y.current.focus()})},className:G(`cf-checkbox`,r?.checkbox),value:`__CONFETTI_CHECKBOX_Others`,classNames:{indicator:r?.indicator,svg:r?.svg},description:n.editable?.description,children:n.editable?.label}),U(ht,{value:g,onChange:e=>{_(e.target.value)},tabIndex:i.value.includes(`__CONFETTI_CHECKBOX_Others`)?0:-1,ref:y,onFocus:()=>{v.current?.checked===!1&&v.current.click()},className:G(`cf-input`,r?.othersInput)})]}))]}),U(Z,{className:G(`cf-error`,r?.error),children:s})]})})},ln=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M7.5 8 10 9M14 9l2.5-1M9 10h.01M15 10h.01`})]}),un=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12ZM9 9h.01M15 9h.01`})]}),dn=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M9 9h.01M15 9h.01`})]}),fn=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M8 15h8M9 9h.01M15 9h.01`})]}),pn=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01`})]}),mn=e=>U(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:40,height:40,fill:`none`,...e,children:U(`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`})}),hn=e=>U(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,...e,children:U(`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`})}),gn=({state:e,properties:t,classNames:n})=>{let r=e.selectedValue?Number(e.selectedValue):null;return U(`div`,{className:G(`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 U(Ct,{className:G(`cf-rating-star`,n?.ratingStar),value:a,"data-filled":o?`true`:void 0,children:U(o?hn:mn,{})},t)})})},_n=({properties:e,classNames:t})=>U(`div`,{className:G(`cf-rating-display-number`,t?.ratingDisplayNumber),children:Array.from({length:e.scale},(e,n)=>{let r=n+1,i=String(r);return U(Ct,{className:G(`cf-rating-number`,t?.ratingNumber),value:i,children:r},n)})}),vn=({properties:e,classNames:t,state:n})=>{let r=z(()=>[ln,dn,fn,pn,un],[]),i=z(()=>[dn,fn,pn],[]);return z(()=>e.scale===3||e.scale===5,[e.scale])?U(`div`,{className:G(`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 U(Ct,{className:G(`cf-rating-emoji`,t?.ratingEmoji),value:s,children:c&&U(c,{})},a)})}):U(_n,{properties:e,classNames:t,state:n})},yn=e=>{switch(e.properties.display??`star`){case`emoji`:return U(vn,{...e});case`number`:return U(_n,{...e});case`star`:return U(gn,{...e})}},bn=({properties:e,title:t,description:n,classNames:r,onChange:i,id:a,error:o,required:s,defaultAnswer:c})=>{let[l,u]=V(()=>typeof c==`number`?String(c):null),d=z(()=>l?Number(l):void 0,[l]);return R(()=>{i(d)},[i,d]),U(St,{isRequired:s,isInvalid:!!o,name:a,className:G(`cf-question`,r?.question),value:l,onChange:u,children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(J,{className:G(`cf-title`,r?.title),children:[t,!s&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:n})]}),W(`div`,{className:G(`cf-rating-section`,r?.ratingSection),children:[U(yn,{state:i,properties:e,classNames:r}),W(`div`,{className:G(`cf-rating-text`,r?.ratingText),children:[U(`span`,{className:G(`cf-rating-text-lower`,r?.ratingTextLower),children:e.labels?.lower}),U(`span`,{className:G(`cf-rating-text-upper`,r?.ratingTextUpper),children:e.labels?.upper})]})]}),U(Z,{className:G(`cf-error`,r?.error),children:o})]})})},xn=({classNames:e,className:t,description:n,...r})=>U(Ct,{...r,className:G(t,e?.radio),children:p(r.children,t=>W(H,{children:[W(`div`,{className:G(`cf-choice-label`,e?.label),children:[U(`div`,{className:G(`cf-radio-indicator`,e?.indicator)}),t]}),n&&U(`span`,{className:G(`cf-choice-description`,e?.choiceDescription),children:n})]}))}),Sn=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s,defaultAnswer:c})=>{let l=!!n.editable,u=typeof c==`string`?c:null,d=u!==null&&n.options.some(e=>e.value===u),[f,p]=V(()=>u===null?null:d?u:l?oe:null),[m,h]=V(()=>u!==null&&!d&&l?u:``),g=B(null),_=B(null),v=z(()=>f===`__CONFETTI_RADIO_Others`?m||`__CONFETTI_RADIO_Others`:f??void 0,[m,f]);return R(()=>{i(v)},[i,v]),U(St,{isRequired:o,isInvalid:!!s,name:a,onChange:e=>{p(e),e===`__CONFETTI_RADIO_Others`&&requestAnimationFrame(()=>{_.current&&_.current.focus()})},value:f,className:G(`cf-question`,r?.question),children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(J,{className:G(`cf-title`,r?.title),children:[e,!o&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:t})]}),W(`div`,{className:G(`cf-response-choices`,r?.group),children:[n.options.map((e,t)=>U(xn,{classNames:{indicator:r?.indicator,radio:G(`cf-choice cf-radio`,r?.radio)},value:e.value,description:e.description,children:e.value},t)),l&&W(`div`,{className:G(`cf-choice cf-others-choice`,r?.othersChoice),children:[U(xn,{inputRef:g,value:`__CONFETTI_RADIO_Others`,classNames:{indicator:r?.indicator,radio:G(`cf-radio`,r?.radio)},description:n.editable?.description,children:n.editable?.label}),U(ht,{tabIndex:i.selectedValue===`__CONFETTI_RADIO_Others`?0:-1,ref:_,value:m,onChange:e=>h(e.target.value),onFocus:()=>{g.current?.checked===!1&&g.current.click()},className:G(`cf-input`,r?.othersInput)})]})]}),U(Z,{className:G(`cf-error`,r?.error),children:s})]})})},Cn=({properties:e,title:t,description:n,classNames:r})=>U(`div`,{className:G(`cf-question`,r?.question),children:W(`div`,{className:G(`cf-header`,r?.header),children:[t&&U(`div`,{className:G(`cf-title`,r?.title),children:t}),n&&U(`div`,{className:G(`cf-description`,r?.description),children:n})]})}),wn=({question:e,onChange:t,error:n,maskAllInputs:r,defaultAnswer:i})=>{switch(e.properties.type){case`rating`:return U(bn,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`open-ended`:return U(an,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`single-select`:return U(Sn,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`multi-select`:return U(cn,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`statement`:return U(Cn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`bug-report`:return U(rn,{...e,properties:e.properties,onChange:t,error:n,maskAllInputs:r,defaultAnswer:i},e.id)}return U(`div`,{children:`Unsupported question type`},e.id)},Tn=({title:e,description:t,classNames:n,onClose:r})=>{let{survey:i}=be();if(!i)return null;let a=t||i.confirmation.description;return W(H,{children:[U(`div`,{className:G(`cf-question`,n?.question),children:W(`div`,{className:G(`cf-header`,n?.header),children:[U(J,{className:G(`cf-title`,n?.title),children:e||i.confirmation.title||`Feedback submitted!`}),a&&U(Y,{slot:`description`,className:G(`cf-description`,n?.description),children:a})]})}),U(S,{className:`cf-submit-button`,onPress:()=>{r?.()},children:i.confirmation.buttonText||`Close`})]})},En=({onPress:e,children:t=`Back`})=>he()?null:U(S,{className:`cf-back-button`,onPress:e,children:t}),Dn=({onPress:e,isDisabled:t,children:n=`Submit`})=>he()?null:U(S,{isDisabled:t,className:`cf-submit-button`,onPress:e,children:n}),On=e=>{switch(e){case`multi-select`:return[];case`bug-report`:return{title:``};case`statement`:return;default:return``}},$=e=>e!==void 0&&e!==``&&!(Array.isArray(e)&&e.length===0),kn=({onSubmit:e,children:t,question:n,isLastQuestion:r,defaultAnswer:i,backButton:a,saveAnswer:o})=>{let s=he(),[c,l]=V(i??On(n.properties.type)),u=z(()=>jt(n.properties,{required:n.required}),[n.properties,n.required]),d=z(()=>{let e=u.safeParse(c);if(!e.success)return kt(e.error)},[c,u]),f=z(()=>{let e=n.routingLogic;if(e.type!==`always`&&!$(c)&&n.required)return!0;let t=e.type===`always`?e.target:e.cases.find(e=>se({answer:c,condition:e}))?.target??e.default;return t.type===`end`?!1:t.type!==`next`||!r},[c,r,n.required,n.routingLogic]),p=z(()=>n.properties.buttonLabel?n.properties.buttonLabel:f?!n.required&&!$(c)?`Skip`:`Next`:`Submit`,[c,f,n.properties.buttonLabel,n.required]),m=I(()=>{switch(n.properties.type){case`statement`:if(n.properties.buttonUrl&&typeof window<`u`){let e=ee.safeParse(n.properties.buttonUrl).data;e&&window.open(e,`_blank`)}return e(void 0);default:return e(c)}},[c,e,n.properties]),h=$(i),g=z(()=>{switch(n.properties.type){case`rating`:case`single-select`:return!!n.properties.shouldAutoProgress;default:return!1}},[n.properties])&&!h,_=I(t=>{l(t),g&&$(t)&&u.safeParse(t).success&&e(t)},[g,u,e]),v=z(()=>{if(!a||!we(a))return a;let e=a;return Ce(e,{onPress:()=>{$(c)&&o?.(c),e.props.onPress?.()}})},[a,c,o]);return W(H,{children:[t({onChange:_,question:n,error:d,defaultAnswer:i}),!s&&W(`div`,{className:`cf-button-row`,children:[v,(!g||!n.required)&&U(Dn,{isDisabled:!!d,onPress:m,children:p})]})]})},An=({onSubmit:e,children:t})=>W(H,{children:[t,U(Dn,{onPress:e})]});export{wn as a,bn as c,Ut as d,zt as f,Rt as h,Tn as i,cn as l,Ht as m,kn as n,Cn as o,Vt as p,En as r,Sn as s,An as t,an as u};
1
+ import{a as e,i as t,o as n,r}from"./DefaultConfettiTrigger-DRQBj9sz.js";import{D as i,E as a,G as o,I as s,N as c,O as l,R as u,T as d,V as f,_ as p,a as m,b as h,d as g,g as _,h as v,i as y,k as b,m as x,n as S,o as C,p as w,r as T,s as E,u as D,x as O,y as k,z as A}from"./Button-LiaNjkvk.js";import{a as j,c as M,d as ee,i as te,l as ne,o as re,r as ie,s as ae,u as oe}from"./src-BewqzpwC.js";import{a as se,n as ce,o as le,r as ue,t as de}from"./internals-Dm8fD0Gh.js";import{d as fe,f as pe,h as me,i as he,l as ge,m as _e,p as ve,r as ye,s as be,u as xe}from"./ModalContainer-Bae3o4wI.js";import N,{Suspense as Se,cloneElement as Ce,createContext as P,forwardRef as F,isValidElement as we,lazy as Te,useCallback as I,useContext as L,useEffect as R,useMemo as z,useRef as B,useState as V}from"react";import{useTimeout as Ee}from"usehooks-ts";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import G from"clsx";import"react-dom";function De(e,t,n){let r=d(e=>{n&&!e.defaultPrevented&&n(t)});R(()=>{let t=e?.current?.form;return t?.addEventListener(`reset`,r),()=>{t?.removeEventListener(`reset`,r)}},[e])}function Oe(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:a=`label`}=e;t=A(t);let o=A(),s={};n&&(r=r?`${o} ${r}`:o,s={id:o,htmlFor:a===`label`?t:void 0});let c=ve({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:s,fieldProps:c}}function ke(e){let{description:t,errorMessage:n,isInvalid:r,validationState:i}=e,{labelProps:a,fieldProps:o}=Oe(e),s=u([!!t,!!n,r,i]),c=u([!!t,!!n,r,i]);return o=l(o,{"aria-describedby":[s,c,e[`aria-describedby`]].filter(Boolean).join(` `)||void 0}),{labelProps:a,fieldProps:o,descriptionProps:{id:s},errorMessageProps:{id:c}}}function Ae(e,t,n){let{validationBehavior:r,focus:i}=e;f(()=>{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(Me(n.current))}});let a=B(!1),o=d(()=>{a.current||t.resetValidation()}),s=d(e=>{t.displayValidation.isInvalid||t.commitValidation();let r=n?.current?.form;!e.defaultPrevented&&n&&r&&Ne(r)===n.current&&(i?i():n.current?.focus(),D(`keyboard`)),e.preventDefault()}),l=d(()=>{t.commitValidation()});R(()=>{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`&&c(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 je(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 Me(e){return{isInvalid:!e.validity.valid,validationDetails:je(e),validationErrors:e.validationMessage?[e.validationMessage]:[]}}function Ne(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 Pe={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},Fe={...Pe,customError:!0,valid:!1},K={isInvalid:!1,validationDetails:Pe,validationErrors:[]},Ie=P({}),Le=`__reactAriaFormValidationState`;function q(e){if(e.__reactAriaFormValidationState){let{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}=e[Le];return{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}}return Re(e)}function Re(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:Fe},l=z(()=>!o||i==null?null:Ve(Be(o,i)),[o,i]);a?.validationDetails.valid&&(a=void 0);let u=L(Ie),d=z(()=>r?Array.isArray(r)?r.flatMap(e=>ze(u[e])):ze(u[r]):[],[u,r]),[f,p]=V(u),[m,h]=V(!1);u!==f&&(p(u),h(!1));let g=z(()=>Ve(m?[]:d),[m,d]),_=B(K),[v,y]=V(K),b=B(K),x=()=>{if(!S)return;C(!1);let e=l||a||_.current;He(e,b.current)||(b.current=e,y(e))},[S,C]=V(!1);return R(x),{realtimeValidation:c||g||l||a||K,displayValidation:s===`native`?c||g||v:c||g||l||a||v,updateValidation(e){s===`aria`&&!He(v,e)?y(e):_.current=e},resetValidation(){let e=K;He(e,b.current)||(b.current=e,y(e)),s===`native`&&C(!1),h(!0)},commitValidation(){s===`native`&&C(!0),h(!0)}}}function ze(e){return e?Array.isArray(e)?e:[e]:[]}function Be(e,t){if(typeof e==`function`){let n=e(t);if(n&&typeof n!=`boolean`)return ze(n)}return[]}function Ve(e){return e.length?{isInvalid:!0,validationErrors:e,validationDetails:Fe}:null}function He(e,t){return e===t||!!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 Ue(...e){let t=new Set,n=!1,r={...Pe};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 We(e,t){let{inputElementType:n=`input`,isDisabled:r=!1,isRequired:a=!1,isReadOnly:o=!1,type:s=`text`,validationBehavior:u=`aria`}=e,[d,f]=xe(e.value,e.defaultValue||``,e.onChange),{focusableProps:p}=E(e,t),m=q({...e,value:d}),{isInvalid:h,validationErrors:g,validationDetails:_}=m.displayValidation,{labelProps:v,fieldProps:y,descriptionProps:b,errorMessageProps:x}=ke({...e,isInvalid:h,errorMessage:e.errorMessage||g}),S=i(e,{labelable:!0}),C={type:s,pattern:e.pattern},[w]=V(d);return De(t,e.defaultValue??w,f),Ae(e,m,t),{labelProps:v,inputProps:l(S,n===`input`?C:void 0,{disabled:r,readOnly:o,required:a&&u===`native`,"aria-required":a&&u===`aria`||void 0,"aria-invalid":h||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:d,onChange:e=>f(c(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(N.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,...p,...y}),descriptionProps:b,errorMessageProps:x,isInvalid:h,validationErrors:g,validationDetails:_}}function Ge(e,t,n){let{isDisabled:r=!1,isReadOnly:a=!1,value:o,name:s,form:u,children:d,"aria-label":f,"aria-labelledby":p,validationState:m=`valid`,isInvalid:h,onPressStart:_,onPressEnd:v,onPressChange:y,onPress:b,onPressUp:x,onClick:S}=e,C=e=>{e.stopPropagation(),t.setSelected(c(e).checked)},{pressProps:w,isPressed:T}=g({onPressStart:_,onPressEnd:v,onPressChange:y,onPress:b,onPressUp:x,onClick:S,isDisabled:r}),{pressProps:D,isPressed:O}=g({onPressStart:_,onPressEnd:v,onPressChange:y,onPressUp:x,onClick:S,onPress(e){b?.(e),t.toggle(),n.current?.focus()},isDisabled:r||a}),{focusableProps:k}=E(e,n),A=l(w,k),j=i(e,{labelable:!0});return De(n,t.defaultSelected,t.setSelected),{labelProps:l(D,{onClick:e=>e.preventDefault()}),inputProps:l(j,{"aria-invalid":h||m===`invalid`||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-controls":e[`aria-controls`],"aria-readonly":a||void 0,onChange:C,disabled:r,...o==null?{}:{value:o},name:s,form:u,type:`checkbox`,...A}),isSelected:t.isSelected,isPressed:T||O,isDisabled:r,isReadOnly:a,isInvalid:h||m===`invalid`}}function Ke(e,t,n){let r=q({...e,value:t.isSelected}),{isInvalid:i,validationErrors:a,validationDetails:o}=r.displayValidation,{labelProps:s,inputProps:c,isSelected:u,isPressed:d,isDisabled:f,isReadOnly:p}=Ge({...e,isInvalid:i},t,n);Ae(e,r,n);let{isIndeterminate:m,isRequired:h,validationBehavior:_=`aria`}=e;R(()=>{n.current&&(n.current.indeterminate=!!m)});let{pressProps:v}=g({isDisabled:f||p,onPress(){let{[Le]:t}=e,{commitValidation:n}=t||r;n()}});return{labelProps:l(s,v,z(()=>({onMouseDown:e=>e.preventDefault()}),[])),inputProps:{...c,checked:u,"aria-required":h&&_===`aria`||void 0,required:h&&_===`native`},isSelected:u,isPressed:d,isDisabled:f,isReadOnly:p,isInvalid:i,validationErrors:a,validationDetails:o}}const qe=new WeakMap;function Je(e,t){let{isDisabled:n,name:r,form:a,validationBehavior:o=`aria`}=e,{isInvalid:s,validationErrors:c,validationDetails:u}=t.displayValidation,{labelProps:d,fieldProps:f,descriptionProps:p,errorMessageProps:m}=ke({...e,labelElementType:`span`,isInvalid:s,errorMessage:e.errorMessage||c});qe.set(t,{name:r,form:a,descriptionId:p.id,errorMessageId:m.id,validationBehavior:o});let h=i(e,{labelable:!0}),{focusWithinProps:g}=C({onBlurWithin:e.onBlur,onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange});return{groupProps:l(h,{role:`group`,"aria-disabled":n||void 0,...f,...g}),labelProps:d,descriptionProps:p,errorMessageProps:m,isInvalid:s,validationErrors:c,validationDetails:u}}function Ye(e={}){let{isReadOnly:t}=e,[n,r]=xe(e.isSelected,e.defaultSelected||!1,e.onChange),[i]=V(n);function a(e){t||r(e)}function o(){t||r(!n)}return{isSelected:n,defaultSelected:e.defaultSelected??i,setSelected:a,toggle:o}}function Xe(e,t,n){let r=Ye({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}=qe.get(t);c=e.validationBehavior??c;let{realtimeValidation:l}=q({...e,value:r.isSelected,name:void 0,validationBehavior:`aria`}),u=B(K),d=()=>{t.setInvalid(e.value,l.isInvalid?l:u.current)};R(d);let f=t.realtimeValidation.isInvalid?t.realtimeValidation:l,p=c===`native`?t.displayValidation:f,m=Ke({...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,[Le]:{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 Ze=new WeakMap;function Qe(e,t,n){let{value:r,children:a,"aria-label":o,"aria-labelledby":s,onPressStart:c,onPressEnd:u,onPressChange:d,onPress:f,onPressUp:p,onClick:m}=e,h=e.isDisabled||t.isDisabled,_=t.selectedValue===r,v=e=>{e.stopPropagation(),t.setSelectedValue(r)},{pressProps:y,isPressed:b}=g({onPressStart:c,onPressEnd:u,onPressChange:d,onPress:f,onPressUp:p,onClick:m,isDisabled:h}),{pressProps:x,isPressed:S}=g({onPressStart:c,onPressEnd:u,onPressChange:d,onPressUp:p,onClick:m,isDisabled:h,onPress(e){f?.(e),t.setSelectedValue(r),n.current?.focus()}}),{focusableProps:C}=E(l(e,{onFocus:()=>t.setLastFocusedValue(r)}),n),w=l(y,C),T=i(e,{labelable:!0}),D=-1;t.selectedValue==null?(t.lastFocusedValue===r||t.lastFocusedValue==null)&&(D=0):t.selectedValue===r&&(D=0),h&&(D=void 0);let{name:O,form:k,descriptionId:A,errorMessageId:j,validationBehavior:M}=Ze.get(t);return De(n,t.defaultSelectedValue,t.setSelectedValue),Ae({validationBehavior:M},t,n),{labelProps:l(x,z(()=>({onClick:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault()}),[])),inputProps:l(T,{...w,type:`radio`,name:O,form:k,tabIndex:D,disabled:h,required:t.isRequired&&M===`native`,checked:_,value:r,onChange:v,"aria-describedby":[e[`aria-describedby`],t.isInvalid?j:null,A].filter(Boolean).join(` `)||void 0}),isDisabled:h,isSelected:_,isPressed:b||S}}function $e(e,t){let{name:n,form:r,isReadOnly:a,isRequired:o,isDisabled:u,orientation:d=`vertical`,validationBehavior:f=`aria`}=e,{direction:p}=pe(),{isInvalid:m,validationErrors:h,validationDetails:g}=t.displayValidation,{labelProps:_,fieldProps:v,descriptionProps:y,errorMessageProps:b}=ke({...e,labelElementType:`span`,isInvalid:t.isInvalid,errorMessage:e.errorMessage||h}),x=i(e,{labelable:!0}),{focusWithinProps:S}=C({onBlurWithin(n){e.onBlur?.(n),t.selectedValue||t.setLastFocusedValue(null)},onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange}),w=e=>{let n;switch(e.key){case`ArrowRight`:n=p===`rtl`&&d!==`vertical`?`prev`:`next`;break;case`ArrowLeft`:n=p===`rtl`&&d!==`vertical`?`next`:`prev`;break;case`ArrowDown`:n=`next`;break;case`ArrowUp`:n=`prev`;break;default:return}e.preventDefault();let r=fe(e.currentTarget,{from:c(e),accept:e=>e instanceof s(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))},T=A(n);return Ze.set(t,{name:T,form:r,descriptionId:y.id,errorMessageId:b.id,validationBehavior:f}),{radioGroupProps:l(x,{role:`radiogroup`,onKeyDown:w,"aria-invalid":t.isInvalid||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-readonly":a||void 0,"aria-required":o||void 0,"aria-disabled":u||void 0,"aria-orientation":d,...v,...S}),labelProps:_,descriptionProps:y,errorMessageProps:b,isInvalid:m,validationErrors:h,validationDetails:g}}const et=P({}),J=T(function(e,t){[e,t]=x(e,t,et);let{elementType:n=`label`,...r}=e,i=k[n];return N.createElement(i,{className:`react-aria-Label`,...r,ref:t})}),tt=P({}),Y=F(function(e,t){[e,t]=x(e,t,tt);let{elementType:n=`span`,...r}=e,i=k[n];return N.createElement(i,{className:`react-aria-Text`,...r,ref:t})});function nt(e={}){let[t,n]=xe(e.value,e.defaultValue||[],e.onChange),[r]=V(t),i=!!e.isRequired&&t.length===0,a=B(new Map),o=q({...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(Ue(...n.values()))},validationState:e.validationState??(s?`invalid`:null),isInvalid:s,isRequired:i}}let rt=Math.round(Math.random()*1e10),it=0;function at(e){let t=z(()=>e.name||`radio-group-${rt}-${++it}`,[e.name]),[n,r]=xe(e.value,e.defaultValue??null,e.onChange),[i]=V(n),[a,o]=V(null),s=q({...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 X=P(null),Z=F(function(e,t){return L(X)?.isInvalid?N.createElement(ot,{...e,ref:t}):null}),ot=F((e,t)=>{let n=L(X),r=i(e,{global:!0}),a=v({...e,defaultClassName:`react-aria-FieldError`,defaultChildren:n.validationErrors.length===0?void 0:n.validationErrors.join(` `),values:n});return a.children==null?null:N.createElement(Y,{slot:`errorMessage`,...r,...a,ref:t})}),st=P(null),ct=P(null),lt=P(null),ut=F(function(e,t){[e,t]=x(e,t,ct);let{validationBehavior:n}=O(st)||{},r=e.validationBehavior??n??`native`,a=nt({...e,validationBehavior:r}),[o,s]=_(!e[`aria-label`]&&!e[`aria-labelledby`]),{groupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=Je({...e,label:s,validationBehavior:r},a),m=v({...e,values:{isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:e.isRequired||!1,isInvalid:a.isInvalid,state:a},defaultClassName:`react-aria-CheckboxGroup`}),h=i(e,{global:!0});return N.createElement(k.div,{...l(h,m,c),ref:t,slot:e.slot||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":e.isRequired||void 0,"data-invalid":a.isInvalid||void 0,"data-disabled":e.isDisabled||void 0},N.createElement(w,{values:[[lt,a],[et,{...u,ref:o,elementType:`span`}],[tt,{slots:{description:d,errorMessage:f}}],[X,p]]},m.children))}),dt=F(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=x(r,t,me);let{validationBehavior:o}=O(st)||{},s=e.validationBehavior??o??`native`,c=L(lt),u=a(z(()=>b(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:d,inputProps:f,isSelected:p,isDisabled:g,isReadOnly:_,isPressed:S,isInvalid:C}=c?Xe({...h(e),value:e.value,children:typeof e.children==`function`||e.children},c,u):Ke({...h(e),children:typeof e.children==`function`||e.children,validationBehavior:s},Ye(e),u),{isFocused:w,isFocusVisible:T,focusProps:E}=m(),D=g||_,{hoverProps:A,isHovered:j}=y({...e,isDisabled:D}),M=v({...e,defaultClassName:`react-aria-Checkbox`,values:{isSelected:p,isIndeterminate:e.isIndeterminate||!1,isPressed:S,isHovered:j,isFocused:w,isFocusVisible:T,isDisabled:g,isReadOnly:_,isInvalid:C,isRequired:e.isRequired||!1}}),ee=i(e,{global:!0});return delete ee.id,delete ee.onClick,N.createElement(k.label,{...l(ee,d,A,M),ref:t,slot:e.slot||void 0,"data-selected":p||void 0,"data-indeterminate":e.isIndeterminate||void 0,"data-pressed":S||void 0,"data-hovered":j||void 0,"data-focused":w||void 0,"data-focus-visible":T||void 0,"data-disabled":g||void 0,"data-readonly":_||void 0,"data-invalid":C||void 0,"data-required":e.isRequired||void 0},N.createElement(ge,{elementType:`span`},N.createElement(`input`,{...l(f,E),ref:u})),M.children)}),ft=P({}),pt=P({});let mt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const ht=T(function(e,t){[e,t]=x(e,t,pt);let{hoverProps:n,isHovered:r}=y({...e,isDisabled:e.disabled}),{isFocused:i,isFocusVisible:a,focusProps:o}=m({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=v({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-Input`});return N.createElement(k.input,{...l(mt(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})}),gt=P(null);function _t(e){let t=B({});return N.createElement(gt.Provider,{value:t},e.children)}const vt=P({isSelected:!1}),yt=P(null),bt=P(null),xt=P(null),St=F(function(e,t){[e,t]=x(e,t,yt);let{validationBehavior:n}=O(st)||{},r=e.validationBehavior??n??`native`,a=at({...e,validationBehavior:r}),[o,s]=_(!e[`aria-label`]&&!e[`aria-labelledby`]),{radioGroupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=$e({...e,label:s,validationBehavior:r},a),m=v({...e,values:{orientation:e.orientation||`vertical`,isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:a.isRequired,isInvalid:a.isInvalid,state:a},defaultClassName:`react-aria-RadioGroup`}),h=i(e,{global:!0});return N.createElement(k.div,{...l(h,m,c),ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||`vertical`,"data-invalid":a.isInvalid||void 0,"data-disabled":a.isDisabled||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":a.isRequired||void 0},N.createElement(w,{values:[[xt,a],[et,{...u,ref:o,elementType:`span`}],[tt,{slots:{description:d,errorMessage:f}}],[X,p]]},N.createElement(_t,null,m.children)))}),Ct=F(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=x(r,t,bt);let o=N.useContext(xt),s=a(z(()=>b(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:c,inputProps:u,isSelected:d,isDisabled:f,isPressed:p}=Qe({...h(e),children:typeof e.children==`function`||e.children},o,s),{isFocused:g,isFocusVisible:_,focusProps:S}=m(),C=f||o.isReadOnly,{hoverProps:w,isHovered:T}=y({...e,isDisabled:C}),E=v({...e,defaultClassName:`react-aria-Radio`,values:{isSelected:d,isPressed:p,isHovered:T,isFocused:g,isFocusVisible:_,isDisabled:f,isReadOnly:o.isReadOnly,isInvalid:o.isInvalid,isRequired:o.isRequired}}),D=i(e,{global:!0});return delete D.id,delete D.onClick,N.createElement(k.label,{...l(D,c,w,E),ref:t,"data-selected":d||void 0,"data-pressed":p||void 0,"data-hovered":T||void 0,"data-focused":g||void 0,"data-focus-visible":_||void 0,"data-disabled":f||void 0,"data-readonly":o.isReadOnly||void 0,"data-invalid":o.isInvalid||void 0,"data-required":o.isRequired||void 0},N.createElement(ge,{elementType:`span`},N.createElement(`input`,{...l(u,S),ref:s})),N.createElement(vt.Provider,{value:{isSelected:d}},E.children))}),wt=P({});let Tt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const Et=F(function(e,t){[e,t]=x(e,t,wt);let{hoverProps:n,isHovered:r}=y(e),{isFocused:i,isFocusVisible:a,focusProps:o}=m({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=v({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-TextArea`});return N.createElement(k.textarea,{...l(Tt(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})}),Dt=P(null),Ot=T(function(e,t){[e,t]=x(e,t,Dt);let{validationBehavior:n}=O(st)||{},r=e.validationBehavior??n??`native`,a=B(null);[e,a]=x(e,a,_e);let[o,s]=_(!e[`aria-label`]&&!e[`aria-labelledby`]),[c,l]=V(`input`),{labelProps:u,inputProps:d,descriptionProps:f,errorMessageProps:p,...m}=We({...h(e),inputElementType:c,label:s,validationBehavior:r},a),g=I(e=>{a.current=e,e&&l(e instanceof HTMLTextAreaElement?`textarea`:`input`)},[a]),y=v({...e,values:{isDisabled:e.isDisabled||!1,isInvalid:m.isInvalid,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1},defaultClassName:`react-aria-TextField`}),b=i(e,{global:!0});return delete b.id,N.createElement(k.div,{...b,...y,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-invalid":m.isInvalid||void 0,"data-readonly":e.isReadOnly||void 0,"data-required":e.isRequired||void 0},N.createElement(w,{values:[[et,{...u,ref:o}],[pt,{...d,ref:g}],[wt,{...d,ref:g}],[ft,{role:`presentation`,isInvalid:m.isInvalid,isDisabled:e.isDisabled||!1}],[tt,{slots:{description:f,errorMessage:p}}],[X,m]]},y.children))});function kt(e){return e.issues[0]?.message??`Invalid input`}const At=({originalQuestions:e,answers:t,errors:n,pointer:r=-1})=>{if(!e)return{questions:[],currentIndex:-1};let i=[...e].sort((e,t)=>e.position-t.position),a=r>=0?i[r]:void 0,o=le(i,t,{forceReachableIds:a?[a.id]:void 0}),s=i.map((e,t)=>{let i={...e},a=n[e.id];return a&&(i.error=a),{...i,visible:r===t||o.has(e.id)}}),c=s.findIndex((e,n)=>n>r&&e.visible&&t[e.id]===void 0);return c===-1&&(c=s.findLastIndex(e=>!!e.visible)),{questions:s,currentIndex:c}},Q={rating:({scale:e},t)=>re({scale:e},t),"open-ended":({max:e},t)=>j({maxLength:e},t),"single-select":({editable:e},t)=>ae({maxLength:e?.max},t),"multi-select":({editable:e,max:t},n)=>te({maxLength:e?.max,maxSelected:t},n),statement:(e,t)=>M(),"bug-report":(e,t)=>ie({},t)},jt=(e,t)=>{let n=e.type;switch(n){case`rating`:{let r=Q[n];return r(e,t)}case`open-ended`:{let r=Q[n];return r(e,t)}case`single-select`:{let r=Q[n];return r(e,t)}case`multi-select`:{let r=Q[n];return r(e,t)}case`statement`:{let r=Q[n];return r(e,t)}case`bug-report`:{let r=Q[n];return r(e,t)}default:throw Error(`Unsupported question type`)}},Mt=({questions:e,answers:t})=>{let n=Nt({questions:e,answers:t});return Object.fromEntries(Object.entries(n).filter(([,e])=>e!==null))},Nt=({questions:e,answers:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Pt=({questions:e,errors:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Ft={},It=({questions:e,answers:t,errors:n})=>{let r={};for(let i of e){if(!i.visible||!i.required||t[i.id]!==void 0||n[i.id])continue;let e=jt(i.properties,{required:i.required}).safeParse(void 0);e.success||(r[i.id]=kt(e.error))}return r},Lt=e=>{let t=e.querySelector(`[data-invalid]`);if(!t)return;let n=t.getAttribute(`role`);if(n===`radiogroup`||n===`group`){t.tabIndex=-1,t.focus();return}t.querySelector(`textarea, input`)?.focus()},Rt=({current:e,shouldAutoSubmit:t,onSubmitted:n,onFinished:r,children:i})=>{let{survey:a,submit:o}=be(),[s,c]=V({}),[l,u]=V({}),[d,f]=V(null),p=z(()=>At({originalQuestions:a?.questions,answers:s,errors:l,pointer:e}),[a?.questions,s,l,e]),m=e??d??p.currentIndex,h=z(()=>!!a?.isBackNavigationAllowed&&m>0&&p.questions.slice(0,m).some(e=>!!e.visible),[a?.isBackNavigationAllowed,p.questions,m]),g=I((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),_=I(()=>{a?.isBackNavigationAllowed&&f(t=>{let n=t??e??p.currentIndex;for(let e=n-1;e>=0;e--)if(p.questions[e]?.visible)return e;return t})},[a?.isBackNavigationAllowed,p.questions,p.currentIndex,e]),[v,y]=V(0),b=v>0,x=B(null),[S,C]=V(!1);R(()=>{v===0||!x.current||Lt(x.current)},[v]);let w=I(({answers:e})=>{o({answers:e}).finally(()=>{r?.()})},[r,o]),T=I(()=>{let e=Pt({questions:p.questions,errors:l}),t=It({questions:p.questions,answers:s,errors:e}),r=Object.keys(t).length>0;if(Object.keys(e).length>0||r)return r&&u(e=>({...e,...t})),y(e=>e+1),!1;let i=Mt({questions:p.questions,answers:s});return w({answers:i}),C(!0),n?.(),!0},[s,l,p.questions,w,n]),E=I(({question:r,answer:i})=>{let o=p.questions.at(r);if(!o)return{error:`Question index is invalid`};let m=jt(o.properties,{required:o.required}).safeParse(i);if(!m.success){let e=kt(m.error);return u(t=>{if(t[o.id]===e)return t;let n={...t};return n[o.id]=e,n}),c(e=>{if(!(o.id in e))return e;let t={...e};return delete t[o.id],t}),{error:e}}u(e=>{if(!e[o.id])return e;let t={...e};return delete t[o.id],t});let h=!i||Array.isArray(i)&&i.length===0,g=!o.required&&h?null:i,_={...s},v=_[o.id]!==g;_[o.id]=g;let y=At({originalQuestions:a?.questions,answers:_,errors:l,pointer:e});v&&c(_);let b=y.questions.findIndex((e,t)=>t>r&&!!e.visible);if(d!==null&&b!==-1)return f(b),{next:b};if(f(null),y.questions.filter(({visible:e})=>!!e).every(({id:e})=>_[e]!==void 0)&&t){let e=Mt({questions:y.questions,answers:_});w({answers:e}),C(!0),n?.()}return{next:y.currentIndex}},[p.questions,s,a?.questions,l,t,e,d,w,n]);return p.questions.length===0?U(H,{}):U(`div`,{ref:x,className:`confetti ${de}`,"data-show-errors":b||void 0,children:i({questions:p.questions,current:m,answers:s,update:E,back:_,canGoBack:h,backButtonLabel:a?.backButtonLabel??void 0,saveAnswer:g,submit:T,isSubmitted:S,errors:b?l:Ft})})},zt=P(null);function Bt({children:i,surveyId:a,publishableKey:s,apiBaseUrl:c,respondent:l,isSurveyVisible:u}){let d=e({surveyId:a,override:l}),f=o({publishableKey:s,apiBaseUrl:c}),{isAvailable:p,isSettled:m}=r({client:f,surveyId:a}),{state:h,isSettled:g}=t({client:f,surveyId:a,respondent:d}),_=z(()=>({respondent:d}),[d]);return!d||!m||!g||!p||!n(h,u)?null:U(zt.Provider,{value:_,children:i})}function Vt(e){return L(zt)?U(H,{children:e.children}):U(Bt,{...e})}function Ht(){let e=L(zt);if(!e)throw Error(`useRespondentVisibility must be used within a RespondentVisibilityProvider`);return e}const Ut=({children:e,classNames:t,containerProps:n,onDismiss:r,onClose:i,closeOnFinishMs:a=3e3})=>{let{surveyId:o,survey:s,dismiss:c}=be(),[l,u]=V(!1),[d,f]=V(!1),[p,m]=V(!1),[h,g]=V(!1);return Ee(()=>{s&&i?.()},d&&!(p||h)?a:null),W(`div`,{className:G(`confetti-dialog ${de}`,t?.dialog),id:`${o}-popover`,...n,onMouseEnter:e=>{n?.onMouseEnter?.(e),m(!0)},onMouseLeave:e=>{n?.onMouseLeave?.(e),m(!1)},onFocusCapture:e=>{n?.onFocusCapture?.(e),g(!0)},onBlurCapture:e=>{n?.onBlurCapture?.(e),e.currentTarget.contains(e.relatedTarget)||g(!1)},children:[U(ye,{className:G(`confetti-dialog-close`,t?.closeButton),iconClassName:t?.icon,onClose:async()=>{l||(await c(),r?.()),i?.()}}),typeof e==`function`?e({setIsSubmitted:()=>u(!0),setIsFinished:()=>f(!0)}):e]})},Wt=3e4,Gt=({maskAllInputs:e,initialEventsJson:t}={})=>{let[n,r]=V(()=>t??null),[i,a]=V(!1),[o,s]=V(null),[c,l]=V(30),u=B(null),d=B(null),f=B(null),p=B([]);R(()=>{let e=new CustomEvent(ue,{detail:{isRecording:i}});document.dispatchEvent(e)},[i]);let m=I(()=>{d.current&&=(clearInterval(d.current),null),f.current&&=(clearTimeout(f.current),null),u.current=null,l(Wt/1e3)},[]),h=I(()=>{u.current?.(),m(),a(!1),r(JSON.stringify(p.current))},[m]);return{recordingEventsJson:n,isRecording:i,recordingError:o,remainingSeconds:c,startRecording:I(async()=>{a(!0),s(null),r(null),p.current=[];try{let{record:t}=await import(`./record--U99gpCM.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=Wt/1e3;l(n),d.current=setInterval(()=>{--n,l(n)},1e3),f.current=setTimeout(()=>{h()},Wt)}catch{s(`Failed to start recording. Please try again.`),a(!1),m()}},[e,h,m]),stopRecording:h,clear:I(()=>{m(),a(!1),r(null),s(null),p.current=[]},[m])}},Kt=e=>e.replace(/\S/g,`*`),qt=e=>`*`.repeat(e.length),Jt=(e,t)=>{for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t(n):Jt(n,t)},Yt=e=>{if(e instanceof HTMLInputElement)e.setAttribute(`value`,qt(e.getAttribute(`value`)??``));else if(e instanceof HTMLTextAreaElement)e.textContent=qt(e.textContent);else if(e instanceof HTMLSelectElement)for(let t of e.querySelectorAll(`option`))t.textContent=qt(t.textContent)},Xt=({maskInputs:e})=>({name:`cfti-redact`,afterClone:t=>{let{clone:n}=t;if(n instanceof HTMLElement){for(let e of n.querySelectorAll(`.${ce}`)){Jt(e,e=>{e.data=Kt(e.data)}),Yt(e);for(let t of e.querySelectorAll(`input, textarea, select`))Yt(t)}if(e)for(let e of n.querySelectorAll(`input, textarea, select`))Yt(e)}}}),Zt=({maskAllInputs:e,initialDataUrl:t}={})=>{let[n,r]=V(()=>t??null),[i,a]=V(!1),[o,s]=V(null);return{screenshotDataUrl:n,isCapturing:i,captureError:o,capture:I(async()=>{a(!0),s(null);try{let{snapdom:t}=await import(`./snapdom-BbRa4ZYv.js`),n=await(await t(document.documentElement,{embedFonts:!0,exclude:[`.${de}`],excludeMode:`hide`,plugins:[Xt({maskInputs:!!e})],fast:!1})).toCanvas(),i=window.devicePixelRatio||1,a=Math.min(Math.round(window.innerWidth*i),n.width),o=Math.min(Math.round(window.innerHeight*i),n.height),s=document.createElement(`canvas`);s.width=a,s.height=o;let c=s.getContext(`2d`);if(!c)throw Error(`Failed to get 2D context for cropping`);c.drawImage(n,0,0,a,o,0,0,a,o),r(s.toDataURL(`image/png`))}catch{s(`Failed to capture screenshot. Please try again.`)}finally{a(!1)}},[e]),clear:I(()=>{r(null),s(null)},[])}},Qt=e=>W(`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:[U(`circle`,{cx:`12`,cy:`12`,r:`10`}),U(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`})]}),$t=e=>W(`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:[U(`path`,{d:`M10 11v6`}),U(`path`,{d:`M14 11v6`}),U(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),U(`path`,{d:`M3 6h18`}),U(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]});function en(){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 tn(){if(typeof window>`u`||typeof navigator>`u`)return;let e=navigator,t=window.screen,n=en();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 nn=Te(()=>import(`./RecordingReplayer-DNYXhses.js`)),rn=({id:e,title:t,description:n,properties:r,onChange:i,required:a,error:o,classNames:s,maskAllInputs:c,defaultAnswer:l})=>{let u=z(()=>tn(),[]),d=l&&typeof l==`object`&&`title`in l?l:void 0,[f,p]=V(()=>d?.title??``),[m,h]=V(()=>d?.description??``),{screenshotDataUrl:g,isCapturing:_,captureError:v,capture:y,clear:b}=Zt({maskAllInputs:c,initialDataUrl:d?.screenshotDataUrl}),{recordingEventsJson:x,isRecording:C,recordingError:w,remainingSeconds:T,startRecording:E,stopRecording:D,clear:O}=Gt({maskAllInputs:c,initialEventsJson:d?.recordingEventsJson}),k=z(()=>({title:f,...m?{description:m}:{},...g?{screenshotDataUrl:g}:{},...x?{recordingEventsJson:x}:{},metadata:u}),[m,u,x,g,f]);R(()=>{i(k)},[k,i]),R(()=>()=>{D()},[D]);let A=z(()=>x?JSON.parse(x):[],[x]);return U(H,{children:C?W(S,{className:G(`cf-bug-report-button`,`cf-bug-report-record-button`,s?.button,s?.recordButton),onPress:D,children:[U(Qt,{}),W(`span`,{children:[30-T,`s /`,` `,30,`s`]})]}):W(`div`,{className:G(`cf-bug-report`,s?.base),children:[W(Ot,{isRequired:a,isInvalid:!!o,name:`${e}-title`,value:f,onChange:p,className:G(`cf-question`,s?.question),children:[W(`div`,{className:G(`cf-header`,s?.header),children:[W(J,{className:G(`cf-title`,s?.title),children:[t,!a&&W(`span`,{className:G(`cf-label-optional`,s?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,s?.description),children:n})]}),U(ht,{placeholder:r.placeholder||`Brief description of the issue`,className:G(`cf-input`,s?.input)}),U(Z,{className:G(`cf-error`,s?.error),children:o})]}),W(Ot,{name:`${e}-description`,value:m,onChange:h,className:G(`cf-question`,s?.question),children:[U(J,{className:G(`cf-title`,s?.title),children:r.detailsLabel}),U(Et,{placeholder:r.detailsPlaceholder||`Steps to reproduce, expected vs actual behavior, etc.`,className:G(`cf-textarea`,s?.textArea),rows:4})]}),r.enableScreenshot||r.enableRecording?W(`section`,{className:G(`cf-question`,s?.question),children:[U(J,{className:G(`cf-title`,s?.title),children:`Attachments`}),W(`div`,{className:G(`cf-bug-report-actions`,s?.actions),children:[r.enableScreenshot&&W(`div`,{className:G(`cf-bug-report-screenshot-section`,s?.screenshotSection),children:[g?W(`div`,{className:G(`cf-bug-report-media-preview`,s?.mediaPreview),children:[U(`img`,{src:g,alt:`Screenshot preview`,className:G(`cf-bug-report-screenshot-img`,s?.screenshotImg)}),U(`div`,{className:G(`cf-bug-report-media-actions`,s?.mediaActions),children:U(S,{className:G(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:b,"aria-label":`Remove screenshot`,children:U($t,{})})})]}):U(S,{className:G(`cf-bug-report-button`,s?.button),onPress:y,isDisabled:_,children:_?`Capturing...`:`Screenshot`}),v&&U(`div`,{className:G(`cf-error`,s?.error),children:v})]}),r.enableRecording&&W(`div`,{className:G(`cf-bug-report-recording-section`,s?.recordingSection),children:[A.length>0?W(`div`,{className:G(`cf-bug-report-media-preview`,s?.mediaPreview),children:[U(Se,{fallback:U(`span`,{className:G(`cf-bug-report-player-loading`,s?.playerLoading),"aria-label":`Loading recording preview...`}),children:U(nn,{events:A})}),U(`div`,{className:G(`cf-bug-report-media-actions`,s?.mediaActions),children:U(S,{className:G(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:O,"aria-label":`Remove recording`,children:U($t,{})})})]}):U(S,{className:G(`cf-bug-report-button`,s?.button),onPress:E,children:`Record`}),w&&U(`div`,{className:G(`cf-error`,s?.error),children:w})]})]})]}):null]})})},an=({id:e,title:t,description:n,properties:r,onChange:i,classNames:a,required:o,error:s,defaultAnswer:c})=>{let[l,u]=V(()=>typeof c==`string`?c:``);return R(()=>{i(l)},[i,l]),W(Ot,{isRequired:o,isInvalid:!!s,name:e,className:G(`cf-question`,a?.question),value:l,onChange:e=>{u(e),i(e)},children:[W(`div`,{className:G(`cf-header`,a?.header),children:[W(J,{className:G(`cf-title`,a?.title),children:[t,!o&&W(`span`,{className:G(`cf-label-optional`,a?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,a?.description),children:n})]}),U(Et,{className:G(`cf-textarea`,a?.textarea),maxLength:r.max,rows:4,placeholder:r.placeholder||`Start typing...`}),U(Z,{className:G(`cf-error`,a?.error),children:s})]})},on=({children:e,classNames:t,description:n,...r})=>U(dt,{...r,children:({isIndeterminate:r})=>W(H,{children:[W(`div`,{className:G(`cf-choice-label`,t?.label),children:[U(`div`,{className:G(`cf-checkbox-indicator`,t?.indicator),children:U(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:G(`cf-checkbox-indicator-svg`,t?.svg),children:r?U(`rect`,{x:1,y:7.5,width:16,height:3}):U(`polyline`,{points:`2 9 7 14 16 4`})},r?`indeterminate`:`check`)}),e]}),n&&U(`span`,{className:G(`cf-choice-description`,t?.choiceDescription),children:n})]})}),sn=({children:e,classNames:t,...n})=>U(dt,{...n,children:U(`div`,{className:G(`cf-tag-label`,t?.tagLabel),children:e})}),cn=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s,defaultAnswer:c})=>{let l=!!n.editable,u=n.display??`checkbox`,d=Array.isArray(c)?c:[],f=new Set(n.options.map(e=>e.value)),p=d.find(e=>!f.has(e)),[m,h]=V(()=>{let e=d.filter(e=>f.has(e));return p!==void 0&&l&&e.push(ne),e}),[g,_]=V(()=>p!==void 0&&l?p:``),v=B(null),y=B(null),b=z(()=>{let e=m.indexOf(ne);if(e===-1)return m;let t=[...m];return t[e]=g||`__CONFETTI_CHECKBOX_Others`,t},[g,m]),x=u===`tag`;return R(()=>{i(b)},[i,b]),U(ut,{isRequired:o,isInvalid:!!s,name:a,value:m,onChange:h,className:G(`cf-question`,r?.question),children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(J,{className:G(`cf-title`,r?.title),children:[e,!o&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:t})]}),W(`div`,{className:G(`cf-response-choices`,u===`tag`&&`cf-response-choices-tag`,r?.group),children:[n.options.map((e,t)=>U(x?sn:on,{className:G(`cf-choice`,x&&[`cf-tag`,r?.tag],!x&&[`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)),l&&(x?W(H,{children:[U(sn,{inputRef:v,onChange:e=>{y.current&&e&&requestAnimationFrame(()=>{y.current&&y.current.focus()})},className:G(`cf-choice cf-tag`,r?.tag),value:`__CONFETTI_CHECKBOX_Others`,children:n.editable?.label}),U(ht,{"data-visible":i.value.includes(`__CONFETTI_CHECKBOX_Others`)||void 0,value:g,onChange:e=>{_(e.target.value)},ref:y,className:G(`cf-input cf-tag-input`,r?.othersInput)})]}):W(`div`,{className:G(`cf-choice cf-others-choice`,r?.othersChoice),children:[U(on,{inputRef:v,onChange:e=>{y.current&&e&&requestAnimationFrame(()=>{y.current&&y.current.focus()})},className:G(`cf-checkbox`,r?.checkbox),value:`__CONFETTI_CHECKBOX_Others`,classNames:{indicator:r?.indicator,svg:r?.svg},description:n.editable?.description,children:n.editable?.label}),U(ht,{value:g,onChange:e=>{_(e.target.value)},tabIndex:i.value.includes(`__CONFETTI_CHECKBOX_Others`)?0:-1,ref:y,onFocus:()=>{v.current?.checked===!1&&v.current.click()},className:G(`cf-input`,r?.othersInput)})]}))]}),U(Z,{className:G(`cf-error`,r?.error),children:s})]})})},ln=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M7.5 8 10 9M14 9l2.5-1M9 10h.01M15 10h.01`})]}),un=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12ZM9 9h.01M15 9h.01`})]}),dn=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M9 9h.01M15 9h.01`})]}),fn=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M8 15h8M9 9h.01M15 9h.01`})]}),pn=e=>W(`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:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01`})]}),mn=e=>U(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:40,height:40,fill:`none`,...e,children:U(`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`})}),hn=e=>U(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,...e,children:U(`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`})}),gn=({state:e,properties:t,classNames:n})=>{let r=e.selectedValue?Number(e.selectedValue):null;return U(`div`,{className:G(`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 U(Ct,{className:G(`cf-rating-star`,n?.ratingStar),value:a,"data-filled":o?`true`:void 0,children:U(o?hn:mn,{})},t)})})},_n=({properties:e,classNames:t})=>U(`div`,{className:G(`cf-rating-display-number`,t?.ratingDisplayNumber),children:Array.from({length:e.scale},(e,n)=>{let r=n+1,i=String(r);return U(Ct,{className:G(`cf-rating-number`,t?.ratingNumber),value:i,children:r},n)})}),vn=({properties:e,classNames:t,state:n})=>{let r=z(()=>[ln,dn,fn,pn,un],[]),i=z(()=>[dn,fn,pn],[]);return z(()=>e.scale===3||e.scale===5,[e.scale])?U(`div`,{className:G(`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 U(Ct,{className:G(`cf-rating-emoji`,t?.ratingEmoji),value:s,children:c&&U(c,{})},a)})}):U(_n,{properties:e,classNames:t,state:n})},yn=e=>{switch(e.properties.display??`star`){case`emoji`:return U(vn,{...e});case`number`:return U(_n,{...e});case`star`:return U(gn,{...e})}},bn=({properties:e,title:t,description:n,classNames:r,onChange:i,id:a,error:o,required:s,defaultAnswer:c})=>{let[l,u]=V(()=>typeof c==`number`?String(c):null),d=z(()=>l?Number(l):void 0,[l]);return R(()=>{i(d)},[i,d]),U(St,{isRequired:s,isInvalid:!!o,name:a,className:G(`cf-question`,r?.question),value:l,onChange:u,children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(J,{className:G(`cf-title`,r?.title),children:[t,!s&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:n})]}),W(`div`,{className:G(`cf-rating-section`,r?.ratingSection),children:[U(yn,{state:i,properties:e,classNames:r}),W(`div`,{className:G(`cf-rating-text`,r?.ratingText),children:[U(`span`,{className:G(`cf-rating-text-lower`,r?.ratingTextLower),children:e.labels?.lower}),U(`span`,{className:G(`cf-rating-text-upper`,r?.ratingTextUpper),children:e.labels?.upper})]})]}),U(Z,{className:G(`cf-error`,r?.error),children:o})]})})},xn=({classNames:e,className:t,description:n,...r})=>U(Ct,{...r,className:G(t,e?.radio),children:p(r.children,t=>W(H,{children:[W(`div`,{className:G(`cf-choice-label`,e?.label),children:[U(`div`,{className:G(`cf-radio-indicator`,e?.indicator)}),t]}),n&&U(`span`,{className:G(`cf-choice-description`,e?.choiceDescription),children:n})]}))}),Sn=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s,defaultAnswer:c})=>{let l=!!n.editable,u=typeof c==`string`?c:null,d=u!==null&&n.options.some(e=>e.value===u),[f,p]=V(()=>u===null?null:d?u:l?oe:null),[m,h]=V(()=>u!==null&&!d&&l?u:``),g=B(null),_=B(null),v=z(()=>f===`__CONFETTI_RADIO_Others`?m||`__CONFETTI_RADIO_Others`:f??void 0,[m,f]);return R(()=>{i(v)},[i,v]),U(St,{isRequired:o,isInvalid:!!s,name:a,onChange:e=>{p(e),e===`__CONFETTI_RADIO_Others`&&requestAnimationFrame(()=>{_.current&&_.current.focus()})},value:f,className:G(`cf-question`,r?.question),children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(J,{className:G(`cf-title`,r?.title),children:[e,!o&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:t})]}),W(`div`,{className:G(`cf-response-choices`,r?.group),children:[n.options.map((e,t)=>U(xn,{classNames:{indicator:r?.indicator,radio:G(`cf-choice cf-radio`,r?.radio)},value:e.value,description:e.description,children:e.value},t)),l&&W(`div`,{className:G(`cf-choice cf-others-choice`,r?.othersChoice),children:[U(xn,{inputRef:g,value:`__CONFETTI_RADIO_Others`,classNames:{indicator:r?.indicator,radio:G(`cf-radio`,r?.radio)},description:n.editable?.description,children:n.editable?.label}),U(ht,{tabIndex:i.selectedValue===`__CONFETTI_RADIO_Others`?0:-1,ref:_,value:m,onChange:e=>h(e.target.value),onFocus:()=>{g.current?.checked===!1&&g.current.click()},className:G(`cf-input`,r?.othersInput)})]})]}),U(Z,{className:G(`cf-error`,r?.error),children:s})]})})},Cn=({properties:e,title:t,description:n,classNames:r})=>U(`div`,{className:G(`cf-question`,r?.question),children:W(`div`,{className:G(`cf-header`,r?.header),children:[t&&U(`div`,{className:G(`cf-title`,r?.title),children:t}),n&&U(`div`,{className:G(`cf-description`,r?.description),children:n})]})}),wn=({question:e,onChange:t,error:n,maskAllInputs:r,defaultAnswer:i})=>{switch(e.properties.type){case`rating`:return U(bn,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`open-ended`:return U(an,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`single-select`:return U(Sn,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`multi-select`:return U(cn,{...e,properties:e.properties,onChange:t,error:n,defaultAnswer:i},e.id);case`statement`:return U(Cn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`bug-report`:return U(rn,{...e,properties:e.properties,onChange:t,error:n,maskAllInputs:r,defaultAnswer:i},e.id)}return U(`div`,{children:`Unsupported question type`},e.id)},Tn=({title:e,description:t,classNames:n,onClose:r})=>{let{survey:i}=be();if(!i)return null;let a=t||i.confirmation.description;return W(H,{children:[U(`div`,{className:G(`cf-question`,n?.question),children:W(`div`,{className:G(`cf-header`,n?.header),children:[U(J,{className:G(`cf-title`,n?.title),children:e||i.confirmation.title||`Feedback submitted!`}),a&&U(Y,{slot:`description`,className:G(`cf-description`,n?.description),children:a})]})}),U(S,{className:`cf-submit-button`,onPress:()=>{r?.()},children:i.confirmation.buttonText||`Close`})]})},En=({onPress:e,children:t=`Back`})=>he()?null:U(S,{className:`cf-back-button`,onPress:e,children:t}),Dn=e=>e===void 0||e===``||Array.isArray(e)&&e.length===0,On=(e,t)=>e.type===`end`?!1:e.type!==`next`||!t,kn=({routingLogic:e,answer:t,required:n,isLastQuestion:r})=>{if(e.type!==`always`&&Dn(t)&&n)return!0;let i=e.type===`always`?e.target:Dn(t)?e.default:e.cases.find(e=>se({answer:t,condition:e}))?.target??e.default;return On(i,r)},An=({onPress:e,isDisabled:t,children:n=`Submit`})=>he()?null:U(S,{isDisabled:t,className:`cf-submit-button`,onPress:e,children:n}),jn=e=>{switch(e){case`multi-select`:return[];case`bug-report`:return{title:``};case`statement`:return;default:return``}},$=e=>!Dn(e),Mn=({onSubmit:e,children:t,question:n,isLastQuestion:r,defaultAnswer:i,backButton:a,saveAnswer:o})=>{let s=he(),[c,l]=V(i??jn(n.properties.type)),u=z(()=>jt(n.properties,{required:n.required}),[n.properties,n.required]),d=z(()=>{let e=u.safeParse(c);if(!e.success)return kt(e.error)},[c,u]),f=z(()=>kn({routingLogic:n.routingLogic,answer:c,required:n.required,isLastQuestion:r}),[c,r,n.required,n.routingLogic]),p=z(()=>n.properties.buttonLabel?n.properties.buttonLabel:f?!n.required&&!$(c)?`Skip`:`Next`:`Submit`,[c,f,n.properties.buttonLabel,n.required]),m=I(()=>{switch(n.properties.type){case`statement`:if(n.properties.buttonUrl&&typeof window<`u`){let e=ee.safeParse(n.properties.buttonUrl).data;e&&window.open(e,`_blank`)}return e(void 0);default:return e(c)}},[c,e,n.properties]),h=$(i),g=z(()=>{switch(n.properties.type){case`rating`:case`single-select`:return!!n.properties.shouldAutoProgress;default:return!1}},[n.properties])&&!h,_=I(t=>{l(t),g&&$(t)&&u.safeParse(t).success&&e(t)},[g,u,e]),v=z(()=>{if(!a||!we(a))return a;let e=a;return Ce(e,{onPress:()=>{$(c)&&o?.(c),e.props.onPress?.()}})},[a,c,o]);return W(H,{children:[t({onChange:_,question:n,error:d,defaultAnswer:i}),!s&&W(`div`,{className:`cf-button-row`,children:[v,(!g||!n.required)&&U(An,{isDisabled:!!d,onPress:m,children:p})]})]})},Nn=({onSubmit:e,children:t})=>W(H,{children:[t,U(An,{onPress:e})]});export{wn as a,bn as c,Ut as d,zt as f,Rt as h,Tn as i,cn as l,Ht as m,Mn as n,Cn as o,Vt as p,En as r,Sn as s,Nn as t,an as u};
@@ -1,5 +1,5 @@
1
- import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,L as l,M as u,N as d,O as f,P as p,R as m,S as h,T as g,U as _,V as v,W as y,c as ee,f as te,h as ne,j as re,k as ie,l as ae,m as oe,o as se,p as ce,t as le,v as ue,w as de,y as fe,z as pe}from"./Button-LiaNjkvk.js";import{n as me}from"./src-DAnW22YG.js";import{i as he,r as ge,t as _e}from"./internals-DMTYF5K8.js";import b,{createContext as x,forwardRef as S,useCallback as C,useContext as w,useEffect as T,useMemo as E,useReducer as ve,useRef as D,useState as O}from"react";import{useTimeout as ye}from"usehooks-ts";import{Fragment as be,jsx as k,jsxs as xe}from"react/jsx-runtime";import A from"clsx";import Se,{flushSync as Ce}from"react-dom";const we=x(null);x(null),x(null),x(null),x(null);const Te=x({});x(null);const Ee=x(null);var De=class{constructor(e,t,n,r){this._walkerStack=[],this._currentSetFor=new Set,this._acceptNode=e=>{if(e.nodeType===Node.ELEMENT_NODE){let t=e.shadowRoot;if(t){let e=this._doc.createTreeWalker(t,this.whatToShow,{acceptNode:this._acceptNode});return this._walkerStack.unshift(e),NodeFilter.FILTER_ACCEPT}else if(typeof this.filter==`function`)return this.filter(e);else if(this.filter?.acceptNode)return this.filter.acceptNode(e);else if(this.filter===null)return NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP},this._doc=e,this.root=t,this.filter=r??null,this.whatToShow=n??NodeFilter.SHOW_ALL,this._currentNode=t,this._walkerStack.unshift(e.createTreeWalker(t,n,this._acceptNode));let i=t.shadowRoot;if(i){let e=this._doc.createTreeWalker(i,this.whatToShow,{acceptNode:this._acceptNode});this._walkerStack.unshift(e)}}get currentNode(){return this._currentNode}set currentNode(t){if(!e(this.root,t))throw Error(`Cannot set currentNode to a node that is not contained by the root node.`);let n=[],r=t,i=t;for(this._currentNode=t;r&&r!==this.root;)if(r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let e=r,t=this._doc.createTreeWalker(e,this.whatToShow,{acceptNode:this._acceptNode});n.push(t),t.currentNode=i,this._currentSetFor.add(t),r=i=e.host}else r=r.parentNode;let a=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});n.push(a),a.currentNode=i,this._currentSetFor.add(a),this._walkerStack=n}get doc(){return this._doc}firstChild(){let t=this.currentNode,n=this.nextNode();return e(t,n)?(n&&(this.currentNode=n),n):(this.currentNode=t,null)}lastChild(){let e=this._walkerStack[0].lastChild();return e&&(this.currentNode=e),e}nextNode(){let e=this._walkerStack[0].nextNode();if(e){if(e.shadowRoot){let t;if(typeof this.filter==`function`?t=this.filter(e):this.filter?.acceptNode&&(t=this.filter.acceptNode(e)),t===NodeFilter.FILTER_ACCEPT)return this.currentNode=e,e;let n=this.nextNode();return n&&(this.currentNode=n),n}return e&&(this.currentNode=e),e}else if(this._walkerStack.length>1){this._walkerStack.shift();let e=this.nextNode();return e&&(this.currentNode=e),e}else return null}previousNode(){let e=this._walkerStack[0];if(e.currentNode===e.root){if(this._currentSetFor.has(e))if(this._currentSetFor.delete(e),this._walkerStack.length>1){this._walkerStack.shift();let e=this.previousNode();return e&&(this.currentNode=e),e}else return null;return null}let t=e.previousNode();if(t){if(t.shadowRoot){let e;if(typeof this.filter==`function`?e=this.filter(t):this.filter?.acceptNode&&(e=this.filter.acceptNode(t)),e===NodeFilter.FILTER_ACCEPT)return t&&(this.currentNode=t),t;let n=this.lastChild();return n&&(this.currentNode=n),n}return t&&(this.currentNode=t),t}else if(this._walkerStack.length>1){this._walkerStack.shift();let e=this.previousNode();return e&&(this.currentNode=e),e}else return null}nextSibling(){return null}previousSibling(){return null}parentNode(){return null}};function Oe(e,t,n,r){return p()?new De(e,t,n,r):e.createTreeWalker(t,n,r)}function ke(e,t){let{id:n,"aria-label":r,"aria-labelledby":i}=e;return n=pe(n),i&&r?i=[...new Set([n,...i.trim().split(/\s+/)])].join(` `):i&&=i.trim().split(/\s+/).join(` `),!r&&!i&&t&&(r=t),{id:n,"aria-label":r,"aria-labelledby":i}}function j(e,t){if(!e)return!1;let n=window.getComputedStyle(e),r=document.scrollingElement||document.documentElement,i=/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY);return e===r&&n.overflow!==`hidden`&&(i=!0),i&&t&&(i=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),i}function Ae(e,t){let n=e;for(j(n,t)&&(n=n.parentElement);n&&!j(n,t);)n=n.parentElement;return n||document.scrollingElement||document.documentElement}const je=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]);function M(e){return e instanceof HTMLInputElement&&!je.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}let N=typeof document<`u`&&window.visualViewport;function Me(){let e=t(),[n,r]=O(()=>e?{width:0,height:0}:P());return T(()=>{let e=e=>{r(t=>e.width===t.width&&e.height===t.height?t:e)},t=()=>{N&&N.scale>1||e(P())},n,i=t=>{N&&N.scale>1||M(d(t))&&(n=requestAnimationFrame(()=>{let t=u();(!t||!M(t))&&e({width:document.documentElement.clientWidth,height:document.documentElement.clientHeight})}))};return e(P()),y()&&window.addEventListener(`blur`,i,!0),N?N.addEventListener(`resize`,t):window.addEventListener(`resize`,t),()=>{cancelAnimationFrame(n),y()&&window.removeEventListener(`blur`,i,!0),N?N.removeEventListener(`resize`,t):window.removeEventListener(`resize`,t)}},[]),n}function P(){return{width:N?Math.min(N.width*N.scale,document.documentElement.clientWidth):document.documentElement.clientWidth,height:N?N.height*N.scale:document.documentElement.clientHeight}}function Ne(e,t=!0){let[n,r]=O(!0),i=n&&t;return v(()=>{if(i&&e.current&&`getAnimations`in e.current)for(let t of e.current.getAnimations())t instanceof CSSTransition&&t.cancel()},[e,i]),Fe(e,i,C(()=>r(!1),[])),i}function Pe(e,t){let[n,r]=O(t?`open`:`closed`);switch(n){case`open`:t||r(`exiting`);break;case`closed`:case`exiting`:t&&r(`open`);break}let i=n===`exiting`;return Fe(e,i,C(()=>{r(e=>e===`exiting`?`closed`:e)},[])),i}function Fe(e,t,n){v(()=>{if(t&&e.current){if(!(`getAnimations`in e.current)){n();return}let t=e.current.getAnimations();if(t.length===0){n();return}let r=!1;return Promise.allSettled(t.map(e=>e.finished)).then(()=>{r||Ce(()=>{n()})}),()=>{r=!0}}},[e,t,n])}const Ie=typeof HTMLElement<`u`&&`inert`in HTMLElement.prototype;function Le(e){return e.dataset.liveAnnouncer===`true`||e.dataset.reactAriaTopLayer!==void 0}let F=new WeakMap,I=[];function Re(t,n){let r=c(t?.[0]),i=n instanceof r.Element?{root:n}:n,o=i?.root??document.body,s=i?.shouldUseInert&&Ie,l=new Set(t),u=new Set,d=e=>s&&e instanceof r.HTMLElement?e.inert:e.getAttribute(`aria-hidden`)===`true`,f=(e,t)=>{s&&e instanceof r.HTMLElement?e.inert=t:t?e.setAttribute(`aria-hidden`,`true`):(e.removeAttribute(`aria-hidden`),e instanceof r.HTMLElement&&(e.inert=!1))},m=new Set;if(p())for(let e of t){let t=e;for(;t&&t!==o;){let e=t.getRootNode();`shadowRoot`in e&&m.add(e.shadowRoot),t=e.parentNode}}let h=t=>{for(let e of t.querySelectorAll(`[data-live-announcer], [data-react-aria-top-layer]`))l.add(e);let n=t=>{if(u.has(t)||l.has(t)||t.parentElement&&u.has(t.parentElement)&&t.parentElement.getAttribute(`role`)!==`row`)return NodeFilter.FILTER_REJECT;for(let n of l)if(e(t,n))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},r=Oe(a(t),t,NodeFilter.SHOW_ELEMENT,{acceptNode:n}),i=n(t);if(i===NodeFilter.FILTER_ACCEPT&&g(t),i!==NodeFilter.FILTER_REJECT){let e=r.nextNode();for(;e!=null;)g(e),e=r.nextNode()}},g=e=>{let t=F.get(e)??0;d(e)&&t===0||(t===0&&f(e,!0),u.add(e),F.set(e,t+1))};I.length&&I[I.length-1].disconnect(),h(o);let _=new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){if(n.target.isConnected&&![...l,...u].some(t=>e(t,n.target)))for(let e of n.addedNodes)(e instanceof HTMLElement||e instanceof SVGElement)&&Le(e)?l.add(e):e instanceof Element&&h(e);if(p()){for(let e of m)if(!e.isConnected){_.disconnect();break}}}});_.observe(o,{childList:!0,subtree:!0});let v=new Set;if(p())for(let t of m){let n=new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){if(n.target.isConnected&&![...l,...u].some(t=>e(t,n.target)))for(let e of n.addedNodes)(e instanceof HTMLElement||e instanceof SVGElement)&&Le(e)?l.add(e):e instanceof Element&&h(e);if(p()){for(let e of m)if(!e.isConnected){_.disconnect();break}}}});n.observe(t,{childList:!0,subtree:!0}),v.add(n)}let y={visibleNodes:l,hiddenNodes:u,observe(){_.observe(o,{childList:!0,subtree:!0})},disconnect(){_.disconnect()}};return I.push(y),()=>{if(_.disconnect(),p())for(let e of v)e.disconnect();for(let e of u){let t=F.get(e);t!=null&&(t===1?(f(e,!1),F.delete(e)):F.set(e,t-1))}y===I[I.length-1]?(I.pop(),I.length&&I[I.length-1].observe()):I.splice(I.indexOf(y),1)}}const ze=new Set([`Arab`,`Syrc`,`Samr`,`Mand`,`Thaa`,`Mend`,`Nkoo`,`Adlm`,`Rohg`,`Hebr`]),Be=new Set([`ae`,`ar`,`arc`,`bcc`,`bqi`,`ckb`,`dv`,`fa`,`glk`,`he`,`ku`,`mzn`,`nqo`,`pnb`,`ps`,`sd`,`ug`,`ur`,`yi`]);function Ve(e){if(Intl.Locale){let t=new Intl.Locale(e).maximize(),n=typeof t.getTextInfo==`function`?t.getTextInfo():t.textInfo;if(n)return n.direction===`rtl`;if(t.script)return ze.has(t.script)}let t=e.split(`-`)[0];return Be.has(t)}const He=Symbol.for(`react-aria.i18n.locale`);function Ue(){let e=typeof window<`u`&&window[He]||typeof navigator<`u`&&(navigator.language||navigator.userLanguage)||`en-US`;try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e=`en-US`}return{locale:e,direction:Ve(e)?`rtl`:`ltr`}}let We=Ue(),L=new Set;function Ge(){We=Ue();for(let e of L)e(We)}function Ke(){let e=t(),[n,r]=O(We);return T(()=>(L.size===0&&window.addEventListener(`languagechange`,Ge),L.add(r),()=>{L.delete(r),L.size===0&&window.removeEventListener(`languagechange`,Ge)}),[]),e?{locale:typeof window<`u`&&window[He]||`en-US`,direction:`ltr`}:n}const qe=b.createContext(null);function Je(){let e=Ke();return w(qe)||e}const Ye=Symbol.for(`react-aria.i18n.locale`),Xe=Symbol.for(`react-aria.i18n.strings`);let R;var Ze=class e{constructor(e,t=`en-US`){this.strings=Object.fromEntries(Object.entries(e).filter(([,e])=>e)),this.defaultLocale=t}getStringForLocale(e,t){let n=this.getStringsForLocale(t)[e];if(!n)throw Error(`Could not find intl message ${e} in ${t} locale`);return n}getStringsForLocale(e){let t=this.strings[e];return t||(t=Qe(e,this.strings,this.defaultLocale),this.strings[e]=t),t}static getGlobalDictionaryForPackage(t){if(typeof window>`u`)return null;let n=window[Ye];if(R===void 0){let t=window[Xe];if(!t)return null;R={};for(let r in t)R[r]=new e({[n]:t[r]},n)}let r=R?.[t];if(!r)throw Error(`Strings for package "${t}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);return r}};function Qe(e,t,n=`en-US`){if(t[e])return t[e];let r=$e(e);if(t[r])return t[r];for(let e in t)if(e.startsWith(r+`-`))return t[e];return t[n]}function $e(e){return Intl.Locale?new Intl.Locale(e).language:e.split(`-`)[0]}const et=new Map,tt=new Map;var nt=class{constructor(e,t){this.locale=e,this.strings=t}format(e,t){let n=this.strings.getStringForLocale(e,this.locale);return typeof n==`function`?n(t,this):n}plural(e,t,n=`cardinal`){let r=t[`=`+e];if(r)return typeof r==`function`?r():r;let i=this.locale+`:`+n,a=et.get(i);return a||(a=new Intl.PluralRules(this.locale,{type:n}),et.set(i,a)),r=t[a.select(e)]||t.other,typeof r==`function`?r():r}number(e){let t=tt.get(this.locale);return t||(t=new Intl.NumberFormat(this.locale),tt.set(this.locale,t)),t.format(e)}select(e,t){let n=e[t]||e.other;return typeof n==`function`?n():n}};const rt=new WeakMap;function it(e){let t=rt.get(e);return t||(t=new Ze(e),rt.set(e,t)),t}function at(e,t){return t&&Ze.getGlobalDictionaryForPackage(t)||it(e)}function ot(e,t){let{locale:n}=Je(),r=at(e,t);return E(()=>new nt(n,r),[n,r])}const st=b.createContext(null),ct=`react-aria-focus-scope-restore`;let z=null;function lt(e){let{children:t,contain:n,restoreFocus:r,autoFocus:i}=e,o=D(null),s=D(null),c=D([]),{parentNode:l}=w(st)||{},d=E(()=>new wt({scopeRef:c}),[c]);v(()=>{let e=l||q.root;if(q.getTreeNode(e.scopeRef)&&z&&!W(z,e.scopeRef)){let t=q.getTreeNode(z);t&&(e=t)}e.addChild(d),q.addNode(d)},[d,l]),v(()=>{let e=q.getTreeNode(c);e&&(e.contain=!!n)},[n]),v(()=>{let e=o.current?.nextSibling,t=[],n=e=>e.stopPropagation();for(;e&&e!==s.current;)t.push(e),e.addEventListener(ct,n),e=e.nextSibling;return c.current=t,()=>{for(let e of t)e.removeEventListener(ct,n)}},[t]),yt(c,r,n),pt(c,n),xt(c,r,n),vt(c,i),T(()=>{let e=u(a(c.current?c.current[0]:void 0)),t=null;if(H(e,c.current)){for(let n of q.traverse())n.scopeRef&&H(e,n.scopeRef.current)&&(t=n);t===q.getTreeNode(c)&&(z=t.scopeRef)}},[c]),v(()=>()=>{let e=q.getTreeNode(c)?.parent?.scopeRef??null;(c===z||W(c,z))&&(!e||q.getTreeNode(e))&&(z=e),q.removeTreeNode(c)},[c]);let f=E(()=>ut(c),[]),p=E(()=>({focusManager:f,parentNode:d}),[d,f]);return b.createElement(st.Provider,{value:p},b.createElement(`span`,{"data-focus-scope-start":!0,hidden:!0,ref:o}),t,b.createElement(`span`,{"data-focus-scope-end":!0,hidden:!0,ref:s}))}function ut(e){return{focusNext(t={}){let n=e.current,{from:r,tabbable:i,wrap:o,accept:s}=t,c=r||u(a(n[0]??void 0)),l=n[0].previousElementSibling,d=K(B(n),{tabbable:i,accept:s},n);d.currentNode=H(c,n)?c:l;let f=d.nextNode();return!f&&o&&(d.currentNode=l,f=d.nextNode()),f&&G(f,!0),f},focusPrevious(t={}){let n=e.current,{from:r,tabbable:i,wrap:o,accept:s}=t,c=r||u(a(n[0]??void 0)),l=n[n.length-1].nextElementSibling,d=K(B(n),{tabbable:i,accept:s},n);d.currentNode=H(c,n)?c:l;let f=d.previousNode();return!f&&o&&(d.currentNode=l,f=d.previousNode()),f&&G(f,!0),f},focusFirst(t={}){let n=e.current,{tabbable:r,accept:i}=t,a=K(B(n),{tabbable:r,accept:i},n);a.currentNode=n[0].previousElementSibling;let o=a.nextNode();return o&&G(o,!0),o},focusLast(t={}){let n=e.current,{tabbable:r,accept:i}=t,a=K(B(n),{tabbable:r,accept:i},n);a.currentNode=n[n.length-1].nextElementSibling;let o=a.previousNode();return o&&G(o,!0),o}}}function B(e){return e[0].parentElement}function V(e){let t=q.getTreeNode(z);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function dt(e){if(!e.form)return Array.from(a(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)).filter(e=>!e.form);let t=e.form.elements.namedItem(e.name),n=c(e);return t instanceof n.RadioNodeList?Array.from(t).filter(e=>e instanceof n.HTMLInputElement):t instanceof n.HTMLInputElement?[t]:[]}function ft(e){if(e.checked)return!0;let t=dt(e);return t.length>0&&!t.some(e=>e.checked)}function pt(e,t){let n=D(void 0),r=D(void 0);v(()=>{let i=e.current;if(!t){r.current&&=(cancelAnimationFrame(r.current),void 0);return}let o=a(i?i[0]:void 0),l=t=>{if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey||!V(e)||t.isComposing)return;let n=u(o),r=e.current;if(!r||!H(n,r))return;let i=K(B(r),{tabbable:!0},r);if(!n)return;i.currentNode=n;let a=t.shiftKey?i.previousNode():i.nextNode();a||=(i.currentNode=t.shiftKey?r[r.length-1].nextElementSibling:r[0].previousElementSibling,t.shiftKey?i.previousNode():i.nextNode()),t.preventDefault(),a&&(G(a,!0),a instanceof c(a).HTMLInputElement&&a.select())},f=t=>{(!z||W(z,e))&&H(d(t),e.current)?(z=e,n.current=d(t)):V(e)&&!U(d(t),e)?n.current?n.current.focus():z&&z.current&&_t(z.current):V(e)&&(n.current=d(t))},p=t=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{let r=ae(),i=(r===`virtual`||r===null)&&_()&&s(),a=u(o);if(!i&&a&&V(e)&&!U(a,e)){z=e;let r=d(t);r&&r.isConnected?(n.current=r,n.current?.focus()):z.current&&_t(z.current)}})};return o.addEventListener(`keydown`,l,!1),o.addEventListener(`focusin`,f,!1),i?.forEach(e=>e.addEventListener(`focusin`,f,!1)),i?.forEach(e=>e.addEventListener(`focusout`,p,!1)),()=>{o.removeEventListener(`keydown`,l,!1),o.removeEventListener(`focusin`,f,!1),i?.forEach(e=>e.removeEventListener(`focusin`,f,!1)),i?.forEach(e=>e.removeEventListener(`focusout`,p,!1))}},[e,t]),v(()=>()=>{r.current&&cancelAnimationFrame(r.current)},[r])}function mt(e){return U(e)}function H(t,n){return!t||!n?!1:n.some(n=>e(n,t))}function U(e,t=null){if(e instanceof Element&&e.closest(`[data-react-aria-top-layer]`))return!0;for(let{scopeRef:n}of q.traverse(q.getTreeNode(t)))if(n&&H(e,n.current))return!0;return!1}function ht(e){return U(e,z)}function W(e,t){let n=q.getTreeNode(t)?.parent;for(;n;){if(n.scopeRef===e)return!0;n=n.parent}return!1}function G(e,t=!1){if(e!=null&&!t)try{ee(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function gt(e,t=!0){let n=e[0].previousElementSibling,r=B(e),i=K(r,{tabbable:t},e);i.currentNode=n;let a=i.nextNode();return t&&!a&&(r=B(e),i=K(r,{tabbable:!1},e),i.currentNode=n,a=i.nextNode()),a}function _t(e,t=!0){G(gt(e,t))}function vt(e,t){let n=b.useRef(t);T(()=>{n.current&&(z=e,!H(u(a(e.current?e.current[0]:void 0)),z.current)&&e.current&&_t(e.current)),n.current=!1},[e])}function yt(e,t,n){v(()=>{if(t||n)return;let r=e.current,i=a(r?r[0]:void 0),o=t=>{let n=d(t);H(n,e.current)?z=e:mt(n)||(z=null)};return i.addEventListener(`focusin`,o,!1),r?.forEach(e=>e.addEventListener(`focusin`,o,!1)),()=>{i.removeEventListener(`focusin`,o,!1),r?.forEach(e=>e.removeEventListener(`focusin`,o,!1))}},[e,t,n])}function bt(e){let t=q.getTreeNode(z);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return t?.scopeRef===e}function xt(e,t,n){let r=D(typeof document<`u`?u(a(e.current?e.current[0]:void 0)):null);v(()=>{let r=e.current,i=a(r?r[0]:void 0);if(!t||n)return;let o=()=>{(!z||W(z,e))&&H(u(i),e.current)&&(z=e)};return i.addEventListener(`focusin`,o,!1),r?.forEach(e=>e.addEventListener(`focusin`,o,!1)),()=>{i.removeEventListener(`focusin`,o,!1),r?.forEach(e=>e.removeEventListener(`focusin`,o,!1))}},[e,n]),v(()=>{let r=a(e.current?e.current[0]:void 0);if(!t)return;let i=t=>{if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey||!V(e)||t.isComposing)return;let n=r.activeElement;if(!U(n,e)||!bt(e))return;let i=q.getTreeNode(e);if(!i)return;let a=i.nodeToRestore,o=K(r.body,{tabbable:!0});o.currentNode=n;let s=t.shiftKey?o.previousNode():o.nextNode();if((!a||!a.isConnected||a===r.body)&&(a=void 0,i.nodeToRestore=void 0),(!s||!U(s,e))&&a){o.currentNode=a;do s=t.shiftKey?o.previousNode():o.nextNode();while(U(s,e));t.preventDefault(),t.stopPropagation(),s?G(s,!0):mt(a)?G(a,!0):n.blur()}};return n||r.addEventListener(`keydown`,i,!0),()=>{n||r.removeEventListener(`keydown`,i,!0)}},[e,t,n]),v(()=>{let n=a(e.current?e.current[0]:void 0);if(!t)return;let i=q.getTreeNode(e);if(i)return i.nodeToRestore=r.current??void 0,()=>{let r=q.getTreeNode(e);if(!r)return;let i=r.nodeToRestore,a=u(n);if(t&&i&&(a&&U(a,e)||a===n.body&&bt(e))){let t=q.clone();requestAnimationFrame(()=>{if(n.activeElement===n.body){let n=t.getTreeNode(e);for(;n;){if(n.nodeToRestore&&n.nodeToRestore.isConnected){St(n.nodeToRestore);return}n=n.parent}for(n=t.getTreeNode(e);n;){if(n.scopeRef&&n.scopeRef.current&&q.getTreeNode(n.scopeRef)){St(gt(n.scopeRef.current,!0));return}n=n.parent}}})}}},[e,t])}function St(e){e.dispatchEvent(new CustomEvent(ct,{bubbles:!0,cancelable:!0}))&&G(e)}function K(t,r,i){let o=r?.tabbable?de:n,s=a(t?.nodeType===Node.ELEMENT_NODE?t:null),c=Oe(s,t||s,NodeFilter.SHOW_ELEMENT,{acceptNode(t){return e(r?.from,t)||r?.tabbable&&t.tagName===`INPUT`&&t.getAttribute(`type`)===`radio`&&(!ft(t)||c.currentNode.tagName===`INPUT`&&c.currentNode.type===`radio`&&c.currentNode.name===t.name)?NodeFilter.FILTER_REJECT:o(t)&&(!i||H(t,i))&&(!r?.accept||r.accept(t))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return r?.from&&(c.currentNode=r.from),c}var Ct=class e{constructor(){this.fastMap=new Map,this.root=new wt({scopeRef:null}),this.fastMap.set(null,this.root)}get size(){return this.fastMap.size}getTreeNode(e){return this.fastMap.get(e)}addTreeNode(e,t,n){let r=this.fastMap.get(t??null);if(!r)return;let i=new wt({scopeRef:e});r.addChild(i),i.parent=r,this.fastMap.set(e,i),n&&(i.nodeToRestore=n)}addNode(e){this.fastMap.set(e.scopeRef,e)}removeTreeNode(e){if(e===null)return;let t=this.fastMap.get(e);if(!t)return;let n=t.parent;for(let e of this.traverse())e!==t&&t.nodeToRestore&&e.nodeToRestore&&t.scopeRef&&t.scopeRef.current&&H(e.nodeToRestore,t.scopeRef.current)&&(e.nodeToRestore=t.nodeToRestore);let r=t.children;n&&(n.removeChild(t),r.size>0&&r.forEach(e=>n&&n.addChild(e))),this.fastMap.delete(t.scopeRef)}*traverse(e=this.root){if(e.scopeRef!=null&&(yield e),e.children.size>0)for(let t of e.children)yield*this.traverse(t)}clone(){let t=new e;for(let e of this.traverse())t.addTreeNode(e.scopeRef,e.parent?.scopeRef??null,e.nodeToRestore);return t}},wt=class{constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}};let q=new Ct;const Tt=typeof document<`u`?b.useInsertionEffect??b.useLayoutEffect:()=>{};function Et(e,t,n){let[r,i]=O(e||t),a=D(r),o=D(e!==void 0),s=e!==void 0;T(()=>{o.current,o.current=s},[s]);let c=s?e:r;Tt(()=>{a.current=c});let[,l]=ve(()=>({}),{});return[c,C((e,...t)=>{let r=typeof e==`function`?e(a.current):e;Object.is(a.current,r)||(a.current=r,i(r),l(),n?.(r,...t))},[n])]}function Dt({children:e}){let t=E(()=>({register:()=>{}}),[]);return b.createElement(te.Provider,{value:t},e)}function Ot(e){let{ref:t,onInteractOutside:n,isDisabled:r,onInteractOutsideStart:i}=e,o=D({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}),s=g(e=>{n&&kt(e,t)&&(i&&i(e),o.current.isPointerDown=!0)}),c=g(e=>{n&&n(e)});T(()=>{let e=o.current;if(r)return;let n=t.current,i=a(n);if(typeof PointerEvent<`u`){let n=n=>{e.isPointerDown&&kt(n,t)&&c(n),e.isPointerDown=!1};return i.addEventListener(`pointerdown`,s,!0),i.addEventListener(`click`,n,!0),()=>{i.removeEventListener(`pointerdown`,s,!0),i.removeEventListener(`click`,n,!0)}}},[t,r])}function kt(t,n){if(t.button>0)return!1;let r=d(t);if(r){let t=r.ownerDocument;if(!t||!e(t.documentElement,r)||r.closest(`[data-react-aria-top-layer]`))return!1}return n.current?!t.composedPath().includes(n.current):!1}const At={border:0,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`};function jt(e={}){let{style:t,isFocusable:n}=e,[r,i]=O(!1),{focusWithinProps:a}=se({isDisabled:!n,onFocusWithinChange:e=>i(e)}),o=E(()=>r?t:t?{...At,...t}:At,[r]);return{visuallyHiddenProps:{...a,style:o}}}function Mt(e){let{children:t,elementType:n=`div`,isFocusable:r,style:i,...a}=e,{visuallyHiddenProps:o}=jt(e);return b.createElement(n,f(a,o),t)}const Nt=x({});function Pt(){return w(Nt)??{}}const Ft=b.createContext(null);function It(e){let n=t(),{portalContainer:r=n?null:document.body,isExiting:i}=e,[a,o]=O(!1),s=E(()=>({contain:a,setContain:o}),[a,o]),{getContainer:c}=Pt();if(!e.portalContainer&&c&&(r=c()),!r)return null;let l=e.children;return e.disableFocusManagement||(l=b.createElement(lt,{restoreFocus:!0,contain:(e.shouldContainFocus||a)&&!i},l)),l=b.createElement(Ft.Provider,{value:s},b.createElement(Dt,null,l)),Se.createPortal(l,r)}function Lt(){let e=w(Ft)?.setContain;v(()=>{e?.(!0)},[e])}function Rt(e,t){let{role:n=`dialog`}=e,i=m();i=e[`aria-label`]?void 0:i;let a=D(!1);return T(()=>{if(t.current&&!re(t.current)){ee(t.current);let e=setTimeout(()=>{(u()===t.current||u()===document.body)&&(a.current=!0,t.current&&(t.current.blur(),ee(t.current)),a.current=!1)},500);return()=>{clearTimeout(e)}}},[t]),Lt(),D(!1),T(()=>{}),{dialogProps:{...r(e,{labelable:!0}),role:n,tabIndex:-1,"aria-labelledby":e[`aria-labelledby`]||i,onBlur:e=>{a.current&&e.stopPropagation()}},titleProps:{id:i}}}var zt={};zt={dismiss:`تجاهل`};var Bt={};Bt={dismiss:`Отхвърляне`};var Vt={};Vt={dismiss:`Odstranit`};var Ht={};Ht={dismiss:`Luk`};var Ut={};Ut={dismiss:`Schließen`};var Wt={};Wt={dismiss:`Απόρριψη`};var Gt={};Gt={dismiss:`Dismiss`};var Kt={};Kt={dismiss:`Descartar`};var qt={};qt={dismiss:`Lõpeta`};var Jt={};Jt={dismiss:`Hylkää`};var Yt={};Yt={dismiss:`Rejeter`};var Xt={};Xt={dismiss:`התעלם`};var Zt={};Zt={dismiss:`Odbaci`};var Qt={};Qt={dismiss:`Elutasítás`};var $t={};$t={dismiss:`Ignora`};var en={};en={dismiss:`閉じる`};var tn={};tn={dismiss:`무시`};var nn={};nn={dismiss:`Atmesti`};var rn={};rn={dismiss:`Nerādīt`};var an={};an={dismiss:`Lukk`};var on={};on={dismiss:`Negeren`};var sn={};sn={dismiss:`Zignoruj`};var cn={};cn={dismiss:`Descartar`};var ln={};ln={dismiss:`Dispensar`};var un={};un={dismiss:`Revocare`};var dn={};dn={dismiss:`Пропустить`};var fn={};fn={dismiss:`Zrušiť`};var pn={};pn={dismiss:`Opusti`};var mn={};mn={dismiss:`Odbaci`};var hn={};hn={dismiss:`Avvisa`};var gn={};gn={dismiss:`Kapat`};var _n={};_n={dismiss:`Скасувати`};var vn={};vn={dismiss:`取消`};var yn={};yn={dismiss:`關閉`};var bn={};bn={"ar-AE":zt,"bg-BG":Bt,"cs-CZ":Vt,"da-DK":Ht,"de-DE":Ut,"el-GR":Wt,"en-US":Gt,"es-ES":Kt,"et-EE":qt,"fi-FI":Jt,"fr-FR":Yt,"he-IL":Xt,"hr-HR":Zt,"hu-HU":Qt,"it-IT":$t,"ja-JP":en,"ko-KR":tn,"lt-LT":nn,"lv-LV":rn,"nb-NO":an,"nl-NL":on,"pl-PL":sn,"pt-BR":cn,"pt-PT":ln,"ro-RO":un,"ru-RU":dn,"sk-SK":fn,"sl-SI":pn,"sr-SP":mn,"sv-SE":hn,"tr-TR":gn,"uk-UA":_n,"zh-CN":vn,"zh-TW":yn};function xn(e){return e&&e.__esModule?e.default:e}function Sn(e){let{onDismiss:t,...n}=e,r=ke(n,ot(xn(bn),`@react-aria/overlays`).format(`dismiss`)),i=()=>{t&&t()};return b.createElement(Mt,null,b.createElement(`button`,{...r,tabIndex:-1,onClick:i,style:{width:1,height:1}}))}const J=[];function Cn(e,t){let{onClose:n,shouldCloseOnBlur:r,isOpen:i,isDismissable:a=!1,isKeyboardDismissDisabled:o=!1,shouldCloseOnInteractOutside:s}=e,c=D(void 0);T(()=>{if(i&&!J.includes(t))return J.push(t),()=>{let e=J.indexOf(t);e>=0&&J.splice(e,1)}},[i,t]);let l=()=>{J[J.length-1]===t&&n&&n()},u=e=>{let n=J[J.length-1];c.current=n,(!s||s(d(e)))&&n===t&&e.stopPropagation()},f=e=>{(!s||s(d(e)))&&(J[J.length-1]===t&&e.stopPropagation(),c.current===t&&l()),c.current=void 0},p=e=>{e.key===`Escape`&&!o&&!e.nativeEvent.isComposing&&(e.stopPropagation(),e.preventDefault(),l())};Ot({ref:t,onInteractOutside:a&&i?f:void 0,onInteractOutsideStart:u});let{focusWithinProps:m}=se({isDisabled:!r,onBlurWithin:e=>{!e.relatedTarget||ht(e.relatedTarget)||(!s||s(e.relatedTarget))&&n?.()}});return{overlayProps:{onKeyDown:p,...m},underlayProps:{}}}const Y=typeof document<`u`&&window.visualViewport;let X=0,wn;function Tn(e={}){let{isDisabled:t}=e;v(()=>{if(!t)return X++,X===1&&(wn=y()?Dn():En()),()=>{X--,X===0&&wn()}},[t])}function En(){let e=window.innerWidth-document.documentElement.clientWidth;return l(e>0&&(`scrollbarGutter`in document.documentElement.style?Z(document.documentElement,`scrollbarGutter`,`stable`):Z(document.documentElement,`paddingRight`,`${e}px`)),Z(document.documentElement,`overflow`,`hidden`))}function Dn(){let e=Z(document.documentElement,`overflow`,`hidden`),t,n=!1,r=e=>{let r=d(e);t=j(r)?r:Ae(r,!0),n=!1;let i=r.ownerDocument.defaultView.getSelection();i&&!i.isCollapsed&&i.containsNode(r,!0)&&(n=!0),e.composedPath().some(e=>e instanceof HTMLInputElement&&e.type===`range`)&&(n=!0),`selectionStart`in r&&`selectionEnd`in r&&r.selectionStart<r.selectionEnd&&r.ownerDocument.activeElement===r&&(n=!0)},i=document.createElement(`style`),a=h();a&&(i.nonce=a),i.textContent=`@layer {
1
+ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,L as l,M as u,N as d,O as f,P as p,R as m,S as h,T as g,U as _,V as v,W as y,c as ee,f as te,h as ne,j as re,k as ie,l as ae,m as oe,o as se,p as ce,t as le,v as ue,w as de,y as fe,z as pe}from"./Button-LiaNjkvk.js";import{n as me}from"./src-BewqzpwC.js";import{i as he,r as ge,t as _e}from"./internals-Dm8fD0Gh.js";import b,{createContext as x,forwardRef as S,useCallback as C,useContext as w,useEffect as T,useMemo as E,useReducer as ve,useRef as D,useState as O}from"react";import{useTimeout as ye}from"usehooks-ts";import{Fragment as be,jsx as k,jsxs as xe}from"react/jsx-runtime";import A from"clsx";import Se,{flushSync as Ce}from"react-dom";const we=x(null);x(null),x(null),x(null),x(null);const Te=x({});x(null);const Ee=x(null);var De=class{constructor(e,t,n,r){this._walkerStack=[],this._currentSetFor=new Set,this._acceptNode=e=>{if(e.nodeType===Node.ELEMENT_NODE){let t=e.shadowRoot;if(t){let e=this._doc.createTreeWalker(t,this.whatToShow,{acceptNode:this._acceptNode});return this._walkerStack.unshift(e),NodeFilter.FILTER_ACCEPT}else if(typeof this.filter==`function`)return this.filter(e);else if(this.filter?.acceptNode)return this.filter.acceptNode(e);else if(this.filter===null)return NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP},this._doc=e,this.root=t,this.filter=r??null,this.whatToShow=n??NodeFilter.SHOW_ALL,this._currentNode=t,this._walkerStack.unshift(e.createTreeWalker(t,n,this._acceptNode));let i=t.shadowRoot;if(i){let e=this._doc.createTreeWalker(i,this.whatToShow,{acceptNode:this._acceptNode});this._walkerStack.unshift(e)}}get currentNode(){return this._currentNode}set currentNode(t){if(!e(this.root,t))throw Error(`Cannot set currentNode to a node that is not contained by the root node.`);let n=[],r=t,i=t;for(this._currentNode=t;r&&r!==this.root;)if(r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let e=r,t=this._doc.createTreeWalker(e,this.whatToShow,{acceptNode:this._acceptNode});n.push(t),t.currentNode=i,this._currentSetFor.add(t),r=i=e.host}else r=r.parentNode;let a=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});n.push(a),a.currentNode=i,this._currentSetFor.add(a),this._walkerStack=n}get doc(){return this._doc}firstChild(){let t=this.currentNode,n=this.nextNode();return e(t,n)?(n&&(this.currentNode=n),n):(this.currentNode=t,null)}lastChild(){let e=this._walkerStack[0].lastChild();return e&&(this.currentNode=e),e}nextNode(){let e=this._walkerStack[0].nextNode();if(e){if(e.shadowRoot){let t;if(typeof this.filter==`function`?t=this.filter(e):this.filter?.acceptNode&&(t=this.filter.acceptNode(e)),t===NodeFilter.FILTER_ACCEPT)return this.currentNode=e,e;let n=this.nextNode();return n&&(this.currentNode=n),n}return e&&(this.currentNode=e),e}else if(this._walkerStack.length>1){this._walkerStack.shift();let e=this.nextNode();return e&&(this.currentNode=e),e}else return null}previousNode(){let e=this._walkerStack[0];if(e.currentNode===e.root){if(this._currentSetFor.has(e))if(this._currentSetFor.delete(e),this._walkerStack.length>1){this._walkerStack.shift();let e=this.previousNode();return e&&(this.currentNode=e),e}else return null;return null}let t=e.previousNode();if(t){if(t.shadowRoot){let e;if(typeof this.filter==`function`?e=this.filter(t):this.filter?.acceptNode&&(e=this.filter.acceptNode(t)),e===NodeFilter.FILTER_ACCEPT)return t&&(this.currentNode=t),t;let n=this.lastChild();return n&&(this.currentNode=n),n}return t&&(this.currentNode=t),t}else if(this._walkerStack.length>1){this._walkerStack.shift();let e=this.previousNode();return e&&(this.currentNode=e),e}else return null}nextSibling(){return null}previousSibling(){return null}parentNode(){return null}};function Oe(e,t,n,r){return p()?new De(e,t,n,r):e.createTreeWalker(t,n,r)}function ke(e,t){let{id:n,"aria-label":r,"aria-labelledby":i}=e;return n=pe(n),i&&r?i=[...new Set([n,...i.trim().split(/\s+/)])].join(` `):i&&=i.trim().split(/\s+/).join(` `),!r&&!i&&t&&(r=t),{id:n,"aria-label":r,"aria-labelledby":i}}function j(e,t){if(!e)return!1;let n=window.getComputedStyle(e),r=document.scrollingElement||document.documentElement,i=/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY);return e===r&&n.overflow!==`hidden`&&(i=!0),i&&t&&(i=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),i}function Ae(e,t){let n=e;for(j(n,t)&&(n=n.parentElement);n&&!j(n,t);)n=n.parentElement;return n||document.scrollingElement||document.documentElement}const je=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]);function M(e){return e instanceof HTMLInputElement&&!je.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}let N=typeof document<`u`&&window.visualViewport;function Me(){let e=t(),[n,r]=O(()=>e?{width:0,height:0}:P());return T(()=>{let e=e=>{r(t=>e.width===t.width&&e.height===t.height?t:e)},t=()=>{N&&N.scale>1||e(P())},n,i=t=>{N&&N.scale>1||M(d(t))&&(n=requestAnimationFrame(()=>{let t=u();(!t||!M(t))&&e({width:document.documentElement.clientWidth,height:document.documentElement.clientHeight})}))};return e(P()),y()&&window.addEventListener(`blur`,i,!0),N?N.addEventListener(`resize`,t):window.addEventListener(`resize`,t),()=>{cancelAnimationFrame(n),y()&&window.removeEventListener(`blur`,i,!0),N?N.removeEventListener(`resize`,t):window.removeEventListener(`resize`,t)}},[]),n}function P(){return{width:N?Math.min(N.width*N.scale,document.documentElement.clientWidth):document.documentElement.clientWidth,height:N?N.height*N.scale:document.documentElement.clientHeight}}function Ne(e,t=!0){let[n,r]=O(!0),i=n&&t;return v(()=>{if(i&&e.current&&`getAnimations`in e.current)for(let t of e.current.getAnimations())t instanceof CSSTransition&&t.cancel()},[e,i]),Fe(e,i,C(()=>r(!1),[])),i}function Pe(e,t){let[n,r]=O(t?`open`:`closed`);switch(n){case`open`:t||r(`exiting`);break;case`closed`:case`exiting`:t&&r(`open`);break}let i=n===`exiting`;return Fe(e,i,C(()=>{r(e=>e===`exiting`?`closed`:e)},[])),i}function Fe(e,t,n){v(()=>{if(t&&e.current){if(!(`getAnimations`in e.current)){n();return}let t=e.current.getAnimations();if(t.length===0){n();return}let r=!1;return Promise.allSettled(t.map(e=>e.finished)).then(()=>{r||Ce(()=>{n()})}),()=>{r=!0}}},[e,t,n])}const Ie=typeof HTMLElement<`u`&&`inert`in HTMLElement.prototype;function Le(e){return e.dataset.liveAnnouncer===`true`||e.dataset.reactAriaTopLayer!==void 0}let F=new WeakMap,I=[];function Re(t,n){let r=c(t?.[0]),i=n instanceof r.Element?{root:n}:n,o=i?.root??document.body,s=i?.shouldUseInert&&Ie,l=new Set(t),u=new Set,d=e=>s&&e instanceof r.HTMLElement?e.inert:e.getAttribute(`aria-hidden`)===`true`,f=(e,t)=>{s&&e instanceof r.HTMLElement?e.inert=t:t?e.setAttribute(`aria-hidden`,`true`):(e.removeAttribute(`aria-hidden`),e instanceof r.HTMLElement&&(e.inert=!1))},m=new Set;if(p())for(let e of t){let t=e;for(;t&&t!==o;){let e=t.getRootNode();`shadowRoot`in e&&m.add(e.shadowRoot),t=e.parentNode}}let h=t=>{for(let e of t.querySelectorAll(`[data-live-announcer], [data-react-aria-top-layer]`))l.add(e);let n=t=>{if(u.has(t)||l.has(t)||t.parentElement&&u.has(t.parentElement)&&t.parentElement.getAttribute(`role`)!==`row`)return NodeFilter.FILTER_REJECT;for(let n of l)if(e(t,n))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},r=Oe(a(t),t,NodeFilter.SHOW_ELEMENT,{acceptNode:n}),i=n(t);if(i===NodeFilter.FILTER_ACCEPT&&g(t),i!==NodeFilter.FILTER_REJECT){let e=r.nextNode();for(;e!=null;)g(e),e=r.nextNode()}},g=e=>{let t=F.get(e)??0;d(e)&&t===0||(t===0&&f(e,!0),u.add(e),F.set(e,t+1))};I.length&&I[I.length-1].disconnect(),h(o);let _=new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){if(n.target.isConnected&&![...l,...u].some(t=>e(t,n.target)))for(let e of n.addedNodes)(e instanceof HTMLElement||e instanceof SVGElement)&&Le(e)?l.add(e):e instanceof Element&&h(e);if(p()){for(let e of m)if(!e.isConnected){_.disconnect();break}}}});_.observe(o,{childList:!0,subtree:!0});let v=new Set;if(p())for(let t of m){let n=new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){if(n.target.isConnected&&![...l,...u].some(t=>e(t,n.target)))for(let e of n.addedNodes)(e instanceof HTMLElement||e instanceof SVGElement)&&Le(e)?l.add(e):e instanceof Element&&h(e);if(p()){for(let e of m)if(!e.isConnected){_.disconnect();break}}}});n.observe(t,{childList:!0,subtree:!0}),v.add(n)}let y={visibleNodes:l,hiddenNodes:u,observe(){_.observe(o,{childList:!0,subtree:!0})},disconnect(){_.disconnect()}};return I.push(y),()=>{if(_.disconnect(),p())for(let e of v)e.disconnect();for(let e of u){let t=F.get(e);t!=null&&(t===1?(f(e,!1),F.delete(e)):F.set(e,t-1))}y===I[I.length-1]?(I.pop(),I.length&&I[I.length-1].observe()):I.splice(I.indexOf(y),1)}}const ze=new Set([`Arab`,`Syrc`,`Samr`,`Mand`,`Thaa`,`Mend`,`Nkoo`,`Adlm`,`Rohg`,`Hebr`]),Be=new Set([`ae`,`ar`,`arc`,`bcc`,`bqi`,`ckb`,`dv`,`fa`,`glk`,`he`,`ku`,`mzn`,`nqo`,`pnb`,`ps`,`sd`,`ug`,`ur`,`yi`]);function Ve(e){if(Intl.Locale){let t=new Intl.Locale(e).maximize(),n=typeof t.getTextInfo==`function`?t.getTextInfo():t.textInfo;if(n)return n.direction===`rtl`;if(t.script)return ze.has(t.script)}let t=e.split(`-`)[0];return Be.has(t)}const He=Symbol.for(`react-aria.i18n.locale`);function Ue(){let e=typeof window<`u`&&window[He]||typeof navigator<`u`&&(navigator.language||navigator.userLanguage)||`en-US`;try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e=`en-US`}return{locale:e,direction:Ve(e)?`rtl`:`ltr`}}let We=Ue(),L=new Set;function Ge(){We=Ue();for(let e of L)e(We)}function Ke(){let e=t(),[n,r]=O(We);return T(()=>(L.size===0&&window.addEventListener(`languagechange`,Ge),L.add(r),()=>{L.delete(r),L.size===0&&window.removeEventListener(`languagechange`,Ge)}),[]),e?{locale:typeof window<`u`&&window[He]||`en-US`,direction:`ltr`}:n}const qe=b.createContext(null);function Je(){let e=Ke();return w(qe)||e}const Ye=Symbol.for(`react-aria.i18n.locale`),Xe=Symbol.for(`react-aria.i18n.strings`);let R;var Ze=class e{constructor(e,t=`en-US`){this.strings=Object.fromEntries(Object.entries(e).filter(([,e])=>e)),this.defaultLocale=t}getStringForLocale(e,t){let n=this.getStringsForLocale(t)[e];if(!n)throw Error(`Could not find intl message ${e} in ${t} locale`);return n}getStringsForLocale(e){let t=this.strings[e];return t||(t=Qe(e,this.strings,this.defaultLocale),this.strings[e]=t),t}static getGlobalDictionaryForPackage(t){if(typeof window>`u`)return null;let n=window[Ye];if(R===void 0){let t=window[Xe];if(!t)return null;R={};for(let r in t)R[r]=new e({[n]:t[r]},n)}let r=R?.[t];if(!r)throw Error(`Strings for package "${t}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);return r}};function Qe(e,t,n=`en-US`){if(t[e])return t[e];let r=$e(e);if(t[r])return t[r];for(let e in t)if(e.startsWith(r+`-`))return t[e];return t[n]}function $e(e){return Intl.Locale?new Intl.Locale(e).language:e.split(`-`)[0]}const et=new Map,tt=new Map;var nt=class{constructor(e,t){this.locale=e,this.strings=t}format(e,t){let n=this.strings.getStringForLocale(e,this.locale);return typeof n==`function`?n(t,this):n}plural(e,t,n=`cardinal`){let r=t[`=`+e];if(r)return typeof r==`function`?r():r;let i=this.locale+`:`+n,a=et.get(i);return a||(a=new Intl.PluralRules(this.locale,{type:n}),et.set(i,a)),r=t[a.select(e)]||t.other,typeof r==`function`?r():r}number(e){let t=tt.get(this.locale);return t||(t=new Intl.NumberFormat(this.locale),tt.set(this.locale,t)),t.format(e)}select(e,t){let n=e[t]||e.other;return typeof n==`function`?n():n}};const rt=new WeakMap;function it(e){let t=rt.get(e);return t||(t=new Ze(e),rt.set(e,t)),t}function at(e,t){return t&&Ze.getGlobalDictionaryForPackage(t)||it(e)}function ot(e,t){let{locale:n}=Je(),r=at(e,t);return E(()=>new nt(n,r),[n,r])}const st=b.createContext(null),ct=`react-aria-focus-scope-restore`;let z=null;function lt(e){let{children:t,contain:n,restoreFocus:r,autoFocus:i}=e,o=D(null),s=D(null),c=D([]),{parentNode:l}=w(st)||{},d=E(()=>new wt({scopeRef:c}),[c]);v(()=>{let e=l||q.root;if(q.getTreeNode(e.scopeRef)&&z&&!W(z,e.scopeRef)){let t=q.getTreeNode(z);t&&(e=t)}e.addChild(d),q.addNode(d)},[d,l]),v(()=>{let e=q.getTreeNode(c);e&&(e.contain=!!n)},[n]),v(()=>{let e=o.current?.nextSibling,t=[],n=e=>e.stopPropagation();for(;e&&e!==s.current;)t.push(e),e.addEventListener(ct,n),e=e.nextSibling;return c.current=t,()=>{for(let e of t)e.removeEventListener(ct,n)}},[t]),yt(c,r,n),pt(c,n),xt(c,r,n),vt(c,i),T(()=>{let e=u(a(c.current?c.current[0]:void 0)),t=null;if(H(e,c.current)){for(let n of q.traverse())n.scopeRef&&H(e,n.scopeRef.current)&&(t=n);t===q.getTreeNode(c)&&(z=t.scopeRef)}},[c]),v(()=>()=>{let e=q.getTreeNode(c)?.parent?.scopeRef??null;(c===z||W(c,z))&&(!e||q.getTreeNode(e))&&(z=e),q.removeTreeNode(c)},[c]);let f=E(()=>ut(c),[]),p=E(()=>({focusManager:f,parentNode:d}),[d,f]);return b.createElement(st.Provider,{value:p},b.createElement(`span`,{"data-focus-scope-start":!0,hidden:!0,ref:o}),t,b.createElement(`span`,{"data-focus-scope-end":!0,hidden:!0,ref:s}))}function ut(e){return{focusNext(t={}){let n=e.current,{from:r,tabbable:i,wrap:o,accept:s}=t,c=r||u(a(n[0]??void 0)),l=n[0].previousElementSibling,d=K(B(n),{tabbable:i,accept:s},n);d.currentNode=H(c,n)?c:l;let f=d.nextNode();return!f&&o&&(d.currentNode=l,f=d.nextNode()),f&&G(f,!0),f},focusPrevious(t={}){let n=e.current,{from:r,tabbable:i,wrap:o,accept:s}=t,c=r||u(a(n[0]??void 0)),l=n[n.length-1].nextElementSibling,d=K(B(n),{tabbable:i,accept:s},n);d.currentNode=H(c,n)?c:l;let f=d.previousNode();return!f&&o&&(d.currentNode=l,f=d.previousNode()),f&&G(f,!0),f},focusFirst(t={}){let n=e.current,{tabbable:r,accept:i}=t,a=K(B(n),{tabbable:r,accept:i},n);a.currentNode=n[0].previousElementSibling;let o=a.nextNode();return o&&G(o,!0),o},focusLast(t={}){let n=e.current,{tabbable:r,accept:i}=t,a=K(B(n),{tabbable:r,accept:i},n);a.currentNode=n[n.length-1].nextElementSibling;let o=a.previousNode();return o&&G(o,!0),o}}}function B(e){return e[0].parentElement}function V(e){let t=q.getTreeNode(z);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function dt(e){if(!e.form)return Array.from(a(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)).filter(e=>!e.form);let t=e.form.elements.namedItem(e.name),n=c(e);return t instanceof n.RadioNodeList?Array.from(t).filter(e=>e instanceof n.HTMLInputElement):t instanceof n.HTMLInputElement?[t]:[]}function ft(e){if(e.checked)return!0;let t=dt(e);return t.length>0&&!t.some(e=>e.checked)}function pt(e,t){let n=D(void 0),r=D(void 0);v(()=>{let i=e.current;if(!t){r.current&&=(cancelAnimationFrame(r.current),void 0);return}let o=a(i?i[0]:void 0),l=t=>{if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey||!V(e)||t.isComposing)return;let n=u(o),r=e.current;if(!r||!H(n,r))return;let i=K(B(r),{tabbable:!0},r);if(!n)return;i.currentNode=n;let a=t.shiftKey?i.previousNode():i.nextNode();a||=(i.currentNode=t.shiftKey?r[r.length-1].nextElementSibling:r[0].previousElementSibling,t.shiftKey?i.previousNode():i.nextNode()),t.preventDefault(),a&&(G(a,!0),a instanceof c(a).HTMLInputElement&&a.select())},f=t=>{(!z||W(z,e))&&H(d(t),e.current)?(z=e,n.current=d(t)):V(e)&&!U(d(t),e)?n.current?n.current.focus():z&&z.current&&_t(z.current):V(e)&&(n.current=d(t))},p=t=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{let r=ae(),i=(r===`virtual`||r===null)&&_()&&s(),a=u(o);if(!i&&a&&V(e)&&!U(a,e)){z=e;let r=d(t);r&&r.isConnected?(n.current=r,n.current?.focus()):z.current&&_t(z.current)}})};return o.addEventListener(`keydown`,l,!1),o.addEventListener(`focusin`,f,!1),i?.forEach(e=>e.addEventListener(`focusin`,f,!1)),i?.forEach(e=>e.addEventListener(`focusout`,p,!1)),()=>{o.removeEventListener(`keydown`,l,!1),o.removeEventListener(`focusin`,f,!1),i?.forEach(e=>e.removeEventListener(`focusin`,f,!1)),i?.forEach(e=>e.removeEventListener(`focusout`,p,!1))}},[e,t]),v(()=>()=>{r.current&&cancelAnimationFrame(r.current)},[r])}function mt(e){return U(e)}function H(t,n){return!t||!n?!1:n.some(n=>e(n,t))}function U(e,t=null){if(e instanceof Element&&e.closest(`[data-react-aria-top-layer]`))return!0;for(let{scopeRef:n}of q.traverse(q.getTreeNode(t)))if(n&&H(e,n.current))return!0;return!1}function ht(e){return U(e,z)}function W(e,t){let n=q.getTreeNode(t)?.parent;for(;n;){if(n.scopeRef===e)return!0;n=n.parent}return!1}function G(e,t=!1){if(e!=null&&!t)try{ee(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function gt(e,t=!0){let n=e[0].previousElementSibling,r=B(e),i=K(r,{tabbable:t},e);i.currentNode=n;let a=i.nextNode();return t&&!a&&(r=B(e),i=K(r,{tabbable:!1},e),i.currentNode=n,a=i.nextNode()),a}function _t(e,t=!0){G(gt(e,t))}function vt(e,t){let n=b.useRef(t);T(()=>{n.current&&(z=e,!H(u(a(e.current?e.current[0]:void 0)),z.current)&&e.current&&_t(e.current)),n.current=!1},[e])}function yt(e,t,n){v(()=>{if(t||n)return;let r=e.current,i=a(r?r[0]:void 0),o=t=>{let n=d(t);H(n,e.current)?z=e:mt(n)||(z=null)};return i.addEventListener(`focusin`,o,!1),r?.forEach(e=>e.addEventListener(`focusin`,o,!1)),()=>{i.removeEventListener(`focusin`,o,!1),r?.forEach(e=>e.removeEventListener(`focusin`,o,!1))}},[e,t,n])}function bt(e){let t=q.getTreeNode(z);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return t?.scopeRef===e}function xt(e,t,n){let r=D(typeof document<`u`?u(a(e.current?e.current[0]:void 0)):null);v(()=>{let r=e.current,i=a(r?r[0]:void 0);if(!t||n)return;let o=()=>{(!z||W(z,e))&&H(u(i),e.current)&&(z=e)};return i.addEventListener(`focusin`,o,!1),r?.forEach(e=>e.addEventListener(`focusin`,o,!1)),()=>{i.removeEventListener(`focusin`,o,!1),r?.forEach(e=>e.removeEventListener(`focusin`,o,!1))}},[e,n]),v(()=>{let r=a(e.current?e.current[0]:void 0);if(!t)return;let i=t=>{if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey||!V(e)||t.isComposing)return;let n=r.activeElement;if(!U(n,e)||!bt(e))return;let i=q.getTreeNode(e);if(!i)return;let a=i.nodeToRestore,o=K(r.body,{tabbable:!0});o.currentNode=n;let s=t.shiftKey?o.previousNode():o.nextNode();if((!a||!a.isConnected||a===r.body)&&(a=void 0,i.nodeToRestore=void 0),(!s||!U(s,e))&&a){o.currentNode=a;do s=t.shiftKey?o.previousNode():o.nextNode();while(U(s,e));t.preventDefault(),t.stopPropagation(),s?G(s,!0):mt(a)?G(a,!0):n.blur()}};return n||r.addEventListener(`keydown`,i,!0),()=>{n||r.removeEventListener(`keydown`,i,!0)}},[e,t,n]),v(()=>{let n=a(e.current?e.current[0]:void 0);if(!t)return;let i=q.getTreeNode(e);if(i)return i.nodeToRestore=r.current??void 0,()=>{let r=q.getTreeNode(e);if(!r)return;let i=r.nodeToRestore,a=u(n);if(t&&i&&(a&&U(a,e)||a===n.body&&bt(e))){let t=q.clone();requestAnimationFrame(()=>{if(n.activeElement===n.body){let n=t.getTreeNode(e);for(;n;){if(n.nodeToRestore&&n.nodeToRestore.isConnected){St(n.nodeToRestore);return}n=n.parent}for(n=t.getTreeNode(e);n;){if(n.scopeRef&&n.scopeRef.current&&q.getTreeNode(n.scopeRef)){St(gt(n.scopeRef.current,!0));return}n=n.parent}}})}}},[e,t])}function St(e){e.dispatchEvent(new CustomEvent(ct,{bubbles:!0,cancelable:!0}))&&G(e)}function K(t,r,i){let o=r?.tabbable?de:n,s=a(t?.nodeType===Node.ELEMENT_NODE?t:null),c=Oe(s,t||s,NodeFilter.SHOW_ELEMENT,{acceptNode(t){return e(r?.from,t)||r?.tabbable&&t.tagName===`INPUT`&&t.getAttribute(`type`)===`radio`&&(!ft(t)||c.currentNode.tagName===`INPUT`&&c.currentNode.type===`radio`&&c.currentNode.name===t.name)?NodeFilter.FILTER_REJECT:o(t)&&(!i||H(t,i))&&(!r?.accept||r.accept(t))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return r?.from&&(c.currentNode=r.from),c}var Ct=class e{constructor(){this.fastMap=new Map,this.root=new wt({scopeRef:null}),this.fastMap.set(null,this.root)}get size(){return this.fastMap.size}getTreeNode(e){return this.fastMap.get(e)}addTreeNode(e,t,n){let r=this.fastMap.get(t??null);if(!r)return;let i=new wt({scopeRef:e});r.addChild(i),i.parent=r,this.fastMap.set(e,i),n&&(i.nodeToRestore=n)}addNode(e){this.fastMap.set(e.scopeRef,e)}removeTreeNode(e){if(e===null)return;let t=this.fastMap.get(e);if(!t)return;let n=t.parent;for(let e of this.traverse())e!==t&&t.nodeToRestore&&e.nodeToRestore&&t.scopeRef&&t.scopeRef.current&&H(e.nodeToRestore,t.scopeRef.current)&&(e.nodeToRestore=t.nodeToRestore);let r=t.children;n&&(n.removeChild(t),r.size>0&&r.forEach(e=>n&&n.addChild(e))),this.fastMap.delete(t.scopeRef)}*traverse(e=this.root){if(e.scopeRef!=null&&(yield e),e.children.size>0)for(let t of e.children)yield*this.traverse(t)}clone(){let t=new e;for(let e of this.traverse())t.addTreeNode(e.scopeRef,e.parent?.scopeRef??null,e.nodeToRestore);return t}},wt=class{constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}};let q=new Ct;const Tt=typeof document<`u`?b.useInsertionEffect??b.useLayoutEffect:()=>{};function Et(e,t,n){let[r,i]=O(e||t),a=D(r),o=D(e!==void 0),s=e!==void 0;T(()=>{o.current,o.current=s},[s]);let c=s?e:r;Tt(()=>{a.current=c});let[,l]=ve(()=>({}),{});return[c,C((e,...t)=>{let r=typeof e==`function`?e(a.current):e;Object.is(a.current,r)||(a.current=r,i(r),l(),n?.(r,...t))},[n])]}function Dt({children:e}){let t=E(()=>({register:()=>{}}),[]);return b.createElement(te.Provider,{value:t},e)}function Ot(e){let{ref:t,onInteractOutside:n,isDisabled:r,onInteractOutsideStart:i}=e,o=D({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}),s=g(e=>{n&&kt(e,t)&&(i&&i(e),o.current.isPointerDown=!0)}),c=g(e=>{n&&n(e)});T(()=>{let e=o.current;if(r)return;let n=t.current,i=a(n);if(typeof PointerEvent<`u`){let n=n=>{e.isPointerDown&&kt(n,t)&&c(n),e.isPointerDown=!1};return i.addEventListener(`pointerdown`,s,!0),i.addEventListener(`click`,n,!0),()=>{i.removeEventListener(`pointerdown`,s,!0),i.removeEventListener(`click`,n,!0)}}},[t,r])}function kt(t,n){if(t.button>0)return!1;let r=d(t);if(r){let t=r.ownerDocument;if(!t||!e(t.documentElement,r)||r.closest(`[data-react-aria-top-layer]`))return!1}return n.current?!t.composedPath().includes(n.current):!1}const At={border:0,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`};function jt(e={}){let{style:t,isFocusable:n}=e,[r,i]=O(!1),{focusWithinProps:a}=se({isDisabled:!n,onFocusWithinChange:e=>i(e)}),o=E(()=>r?t:t?{...At,...t}:At,[r]);return{visuallyHiddenProps:{...a,style:o}}}function Mt(e){let{children:t,elementType:n=`div`,isFocusable:r,style:i,...a}=e,{visuallyHiddenProps:o}=jt(e);return b.createElement(n,f(a,o),t)}const Nt=x({});function Pt(){return w(Nt)??{}}const Ft=b.createContext(null);function It(e){let n=t(),{portalContainer:r=n?null:document.body,isExiting:i}=e,[a,o]=O(!1),s=E(()=>({contain:a,setContain:o}),[a,o]),{getContainer:c}=Pt();if(!e.portalContainer&&c&&(r=c()),!r)return null;let l=e.children;return e.disableFocusManagement||(l=b.createElement(lt,{restoreFocus:!0,contain:(e.shouldContainFocus||a)&&!i},l)),l=b.createElement(Ft.Provider,{value:s},b.createElement(Dt,null,l)),Se.createPortal(l,r)}function Lt(){let e=w(Ft)?.setContain;v(()=>{e?.(!0)},[e])}function Rt(e,t){let{role:n=`dialog`}=e,i=m();i=e[`aria-label`]?void 0:i;let a=D(!1);return T(()=>{if(t.current&&!re(t.current)){ee(t.current);let e=setTimeout(()=>{(u()===t.current||u()===document.body)&&(a.current=!0,t.current&&(t.current.blur(),ee(t.current)),a.current=!1)},500);return()=>{clearTimeout(e)}}},[t]),Lt(),D(!1),T(()=>{}),{dialogProps:{...r(e,{labelable:!0}),role:n,tabIndex:-1,"aria-labelledby":e[`aria-labelledby`]||i,onBlur:e=>{a.current&&e.stopPropagation()}},titleProps:{id:i}}}var zt={};zt={dismiss:`تجاهل`};var Bt={};Bt={dismiss:`Отхвърляне`};var Vt={};Vt={dismiss:`Odstranit`};var Ht={};Ht={dismiss:`Luk`};var Ut={};Ut={dismiss:`Schließen`};var Wt={};Wt={dismiss:`Απόρριψη`};var Gt={};Gt={dismiss:`Dismiss`};var Kt={};Kt={dismiss:`Descartar`};var qt={};qt={dismiss:`Lõpeta`};var Jt={};Jt={dismiss:`Hylkää`};var Yt={};Yt={dismiss:`Rejeter`};var Xt={};Xt={dismiss:`התעלם`};var Zt={};Zt={dismiss:`Odbaci`};var Qt={};Qt={dismiss:`Elutasítás`};var $t={};$t={dismiss:`Ignora`};var en={};en={dismiss:`閉じる`};var tn={};tn={dismiss:`무시`};var nn={};nn={dismiss:`Atmesti`};var rn={};rn={dismiss:`Nerādīt`};var an={};an={dismiss:`Lukk`};var on={};on={dismiss:`Negeren`};var sn={};sn={dismiss:`Zignoruj`};var cn={};cn={dismiss:`Descartar`};var ln={};ln={dismiss:`Dispensar`};var un={};un={dismiss:`Revocare`};var dn={};dn={dismiss:`Пропустить`};var fn={};fn={dismiss:`Zrušiť`};var pn={};pn={dismiss:`Opusti`};var mn={};mn={dismiss:`Odbaci`};var hn={};hn={dismiss:`Avvisa`};var gn={};gn={dismiss:`Kapat`};var _n={};_n={dismiss:`Скасувати`};var vn={};vn={dismiss:`取消`};var yn={};yn={dismiss:`關閉`};var bn={};bn={"ar-AE":zt,"bg-BG":Bt,"cs-CZ":Vt,"da-DK":Ht,"de-DE":Ut,"el-GR":Wt,"en-US":Gt,"es-ES":Kt,"et-EE":qt,"fi-FI":Jt,"fr-FR":Yt,"he-IL":Xt,"hr-HR":Zt,"hu-HU":Qt,"it-IT":$t,"ja-JP":en,"ko-KR":tn,"lt-LT":nn,"lv-LV":rn,"nb-NO":an,"nl-NL":on,"pl-PL":sn,"pt-BR":cn,"pt-PT":ln,"ro-RO":un,"ru-RU":dn,"sk-SK":fn,"sl-SI":pn,"sr-SP":mn,"sv-SE":hn,"tr-TR":gn,"uk-UA":_n,"zh-CN":vn,"zh-TW":yn};function xn(e){return e&&e.__esModule?e.default:e}function Sn(e){let{onDismiss:t,...n}=e,r=ke(n,ot(xn(bn),`@react-aria/overlays`).format(`dismiss`)),i=()=>{t&&t()};return b.createElement(Mt,null,b.createElement(`button`,{...r,tabIndex:-1,onClick:i,style:{width:1,height:1}}))}const J=[];function Cn(e,t){let{onClose:n,shouldCloseOnBlur:r,isOpen:i,isDismissable:a=!1,isKeyboardDismissDisabled:o=!1,shouldCloseOnInteractOutside:s}=e,c=D(void 0);T(()=>{if(i&&!J.includes(t))return J.push(t),()=>{let e=J.indexOf(t);e>=0&&J.splice(e,1)}},[i,t]);let l=()=>{J[J.length-1]===t&&n&&n()},u=e=>{let n=J[J.length-1];c.current=n,(!s||s(d(e)))&&n===t&&e.stopPropagation()},f=e=>{(!s||s(d(e)))&&(J[J.length-1]===t&&e.stopPropagation(),c.current===t&&l()),c.current=void 0},p=e=>{e.key===`Escape`&&!o&&!e.nativeEvent.isComposing&&(e.stopPropagation(),e.preventDefault(),l())};Ot({ref:t,onInteractOutside:a&&i?f:void 0,onInteractOutsideStart:u});let{focusWithinProps:m}=se({isDisabled:!r,onBlurWithin:e=>{!e.relatedTarget||ht(e.relatedTarget)||(!s||s(e.relatedTarget))&&n?.()}});return{overlayProps:{onKeyDown:p,...m},underlayProps:{}}}const Y=typeof document<`u`&&window.visualViewport;let X=0,wn;function Tn(e={}){let{isDisabled:t}=e;v(()=>{if(!t)return X++,X===1&&(wn=y()?Dn():En()),()=>{X--,X===0&&wn()}},[t])}function En(){let e=window.innerWidth-document.documentElement.clientWidth;return l(e>0&&(`scrollbarGutter`in document.documentElement.style?Z(document.documentElement,`scrollbarGutter`,`stable`):Z(document.documentElement,`paddingRight`,`${e}px`)),Z(document.documentElement,`overflow`,`hidden`))}function Dn(){let e=Z(document.documentElement,`overflow`,`hidden`),t,n=!1,r=e=>{let r=d(e);t=j(r)?r:Ae(r,!0),n=!1;let i=r.ownerDocument.defaultView.getSelection();i&&!i.isCollapsed&&i.containsNode(r,!0)&&(n=!0),e.composedPath().some(e=>e instanceof HTMLInputElement&&e.type===`range`)&&(n=!0),`selectionStart`in r&&`selectionEnd`in r&&r.selectionStart<r.selectionEnd&&r.ownerDocument.activeElement===r&&(n=!0)},i=document.createElement(`style`),a=h();a&&(i.nonce=a),i.textContent=`@layer {
2
2
  * {
3
3
  overscroll-behavior: contain;
4
4
  }
5
- }`,document.head.prepend(i);let o=e=>{if(!(e.touches.length===2||n)){if(!t||t===document.documentElement||t===document.body){e.preventDefault();return}t.scrollHeight===t.clientHeight&&t.scrollWidth===t.clientWidth&&e.preventDefault()}},s=e=>{let t=d(e),n=e.relatedTarget;n&&M(n)?(n.focus({preventScroll:!0}),kn(n,M(t))):n||(t.parentElement?.closest(`[tabindex]`))?.focus({preventScroll:!0})},c=HTMLElement.prototype.focus;HTMLElement.prototype.focus=function(e){let t=u(),n=t!=null&&M(t);c.call(this,{...e,preventScroll:!0}),(!e||!e.preventScroll)&&kn(this,n)};let f=l(On(document,`touchstart`,r,{passive:!1,capture:!0}),On(document,`touchmove`,o,{passive:!1,capture:!0}),On(document,`blur`,s,!0));return()=>{e(),f(),i.remove(),HTMLElement.prototype.focus=c}}function Z(e,t,n){let r=e.style[t];return e.style[t]=n,()=>{e.style[t]=r}}function On(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function kn(e,t){t||!Y?An(e):Y.addEventListener(`resize`,()=>An(e),{once:!0})}function An(e){let t=document.scrollingElement||document.documentElement,n=e;for(;n&&n!==t;){let e=Ae(n);if(e!==document.documentElement&&e!==document.body&&e!==n){let t=e.getBoundingClientRect(),r=n.getBoundingClientRect();if(r.top<t.top||r.bottom>t.top+n.clientHeight){let n=t.bottom;Y&&(n=Math.min(n,Y.offsetTop+Y.height));let i=r.top-t.top-((n-t.top)/2-r.height/2);e.scrollTo({top:Math.max(0,Math.min(e.scrollHeight-e.clientHeight,e.scrollTop+i)),behavior:`smooth`})}}n=e.parentElement}}function jn(e,t,n){let{overlayProps:r,underlayProps:i}=Cn({...e,isOpen:t.isOpen,onClose:t.close},n);return Tn({isDisabled:!t.isOpen}),Lt(),T(()=>{if(t.isOpen&&n.current)return Re([n.current],{shouldUseInert:!0})},[t.isOpen,n]),{modalProps:f(r),underlayProps:i}}function Mn(e){let[t,n]=Et(e.isOpen,e.defaultOpen||!1,e.onOpenChange);return{isOpen:t,setOpen:n,open:C(()=>{n(!0)},[n]),close:C(()=>{n(!1)},[n]),toggle:C(()=>{n(!t)},[n,t])}}const Nn=x(null),Q=x(null),Pn=S(function(e,t){let n=e[`aria-labelledby`];[e,t]=oe(e,t,Nn);let{dialogProps:i,titleProps:a}=Rt({...e,"aria-labelledby":n},t),o=w(Q);!i[`aria-label`]&&!i[`aria-labelledby`]&&e[`aria-labelledby`]&&(i[`aria-labelledby`]=e[`aria-labelledby`]);let s=ne({defaultClassName:`react-aria-Dialog`,className:e.className,style:e.style,children:e.children,values:{close:o?.close||(()=>{})}}),c=r(e,{global:!0});return b.createElement(fe.section,{...f(c,s,i),render:e.render,ref:t,slot:e.slot||void 0},b.createElement(ce,{values:[[Te,{slots:{[ue]:{},title:{...a,level:2}}}],[le,{slots:{[ue]:{},close:{onPress:()=>o?.close()}}}]]},s.children))}),Fn=x(null),In=x(null),Ln=S(function(e,t){if(w(In))return b.createElement(Vn,{...e,modalRef:t},e.children);let{isDismissable:n,isKeyboardDismissDisabled:r,isOpen:i,defaultOpen:a,onOpenChange:o,children:s,isEntering:c,isExiting:l,UNSTABLE_portalContainer:u,shouldCloseOnInteractOutside:d,...f}=e;return b.createElement(zn,{isDismissable:n,isKeyboardDismissDisabled:r,isOpen:i,defaultOpen:a,onOpenChange:o,isEntering:c,isExiting:l,UNSTABLE_portalContainer:u,shouldCloseOnInteractOutside:d},b.createElement(Vn,{...f,modalRef:t},s))});function Rn(e,n){[e,n]=oe(e,n,Fn);let r=w(Q),a=Mn(e),o=e.isOpen!=null||e.defaultOpen!=null||!r?a:r,s=i(n),c=D(null),l=Pe(s,o.isOpen),u=Pe(c,o.isOpen),d=l||u||e.isExiting||!1,f=t();return!o.isOpen&&!d||f?null:b.createElement(Bn,{...e,state:o,isExiting:d,overlayRef:s,modalRef:c})}const zn=S(Rn);function Bn({UNSTABLE_portalContainer:e,...t}){let n=t.modalRef,{state:i}=t,{modalProps:a,underlayProps:o}=jn(t,i,n),s=Ne(t.overlayRef)||t.isEntering||!1,c=ne({...t,defaultClassName:`react-aria-ModalOverlay`,values:{isEntering:s,isExiting:t.isExiting,state:i}}),l=Me(),u;if(typeof document<`u`){let e=j(document.body)?document.body:document.scrollingElement||document.documentElement,t=e.getBoundingClientRect().height%1;u=e.scrollHeight-t}let d={...c.style,"--visual-viewport-height":l.height+`px`,"--page-height":u===void 0?void 0:u+`px`};return b.createElement(It,{isExiting:t.isExiting,portalContainer:e},b.createElement(fe.div,{...f(r(t,{global:!0}),o),...c,style:d,ref:t.overlayRef,"data-entering":s||void 0,"data-exiting":t.isExiting||void 0},b.createElement(ce,{values:[[In,{modalProps:a,modalRef:n,isExiting:t.isExiting,isDismissable:t.isDismissable}],[Q,i]]},c.children)))}function Vn(e){let{modalProps:t,modalRef:n,isExiting:a,isDismissable:o}=w(In),s=w(Q),c=i(E(()=>ie(e.modalRef,n),[e.modalRef,n])),l=Ne(c),u=ne({...e,defaultClassName:`react-aria-Modal`,values:{isEntering:l,isExiting:a,state:s}});return b.createElement(fe.div,{...f(r(e,{global:!0}),t),...u,ref:c,"data-entering":l||void 0,"data-exiting":a||void 0},o&&b.createElement(Sn,{onDismiss:s.close}),u.children)}const Hn=x({}),Un=()=>w(Hn),Wn=x({}),Gn=({type:e,children:t})=>{let n=E(()=>({type:e}),[e]);return k(Wn.Provider,{value:n,children:t})},Kn=()=>w(Wn),$=x(null),qn=({children:e,surveyId:t,publishableKey:n,respondent:r,metadata:i={},apiBaseUrl:a})=>{let{type:s}=Kn(),c=Un(),l=c.version??`0.7.0`,u=c.build,d=D(!1),[f,p]=O(),m=o({publishableKey:n,apiBaseUrl:a});T(()=>{(async()=>{d.current=!1,p(void 0);try{let e=await m.get(`api/v1/cfti/${t}`).json(),n=me.safeParse(e);if(!n.success)return;p(n.data)}catch{}})()},[m,t]);let h=C(async({answers:e})=>{let n=crypto.randomUUID();await m.put(`api/v1/cfti/${t}/response/${n}`,{json:{respondent:r,data:e,metadata:i,telemetry:{...s!==void 0&&{type:s},version:l,...u&&{build:u}}}})},[u,m,i,r,t,l,s]),g=C(()=>{m.post(`api/v1/cfti/${t}/respondent/${r}/event`,{json:{type:`dismiss`}}).catch(()=>{})},[m,r,t]);return T(()=>{d.current||f&&r&&(d.current=!0,m.post(`api/v1/cfti/${t}/respondent/${r}/event`,{json:{type:`view`}}).catch(()=>{}))},[m,r,f,t]),f?k($.Provider,{value:{submit:h,dismiss:g,surveyId:t,survey:f,metadata:i},children:e}):null},Jn=e=>w($)?k(be,{children:e.children}):k(qn,{...e}),Yn=()=>{let e=w($);if(!e)throw Error(`useSurvey must be used within a SurveyProvider`);return e},Xn=()=>{let[e,t]=O(!1);return T(()=>{let e=e=>{let n=he.safeParse(e);n.error||t(n.data.detail.isRecording)};return document.addEventListener(ge,e),()=>{document.removeEventListener(ge,e)}},[]),e},Zn=({className:e,iconClassName:t,onClose:n})=>Xn()?null:k(`button`,{type:`button`,className:e,"aria-label":`Dismiss`,onClick:n,children:k(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`none`,className:t,children:k(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M3.53 3.529c.26-.26.682-.26.942 0l3.529 3.528 3.528-3.528a.667.667 0 0 1 .943.942L8.943 8l3.53 3.528a.667.667 0 0 1-.944.943L8.001 8.943 4.472 12.47a.667.667 0 1 1-.943-.943L7.058 8 3.529 4.47a.667.667 0 0 1 0-.942Z`,clipRule:`evenodd`})})}),Qn=({children:e,classNames:t,isDismissable:n,onDismiss:r,onClose:i,closeOnFinishMs:a,isSubmitted:o,onSubmitted:s})=>{let{survey:c,surveyId:l,dismiss:u}=Yn(),[d,f]=O(!1);return ye(()=>{c&&i?.()},d?a:null),xe(Pn,{"aria-label":`Survey`,id:`${l}-popover`,className:A(`confetti-modal-dialog ${_e}`,t?.dialog),children:[n&&k(Zn,{className:A(`confetti-modal-dialog-close`,t?.closeButton),iconClassName:t?.icon,onClose:async()=>{!o&&!d&&(await u(),r?.()),i?.()}}),typeof e==`function`?e({setIsSubmitted:()=>s?.(),setIsFinished:()=>f(!0)}):e]})},$n=({children:e,classNames:t,onDismiss:n,onClose:r,isDismissable:i=!0,closeOnFinishMs:a=3e3})=>{let{dismiss:o}=Yn(),[s,c]=O(!1);return k(zn,{isOpen:!0,isDismissable:i,isKeyboardDismissDisabled:!i,onOpenChange:async e=>{e||(s||(await o(),n?.()),r?.())},className:A(`confetti-modal-overlay ${_e}`,t?.overlay),children:k(Ln,{className:A(`confetti-modal ${_e}`,t?.modal),children:k(Qn,{classNames:t,isDismissable:i,onDismiss:n,onClose:r,closeOnFinishMs:a,isSubmitted:s,onSubmitted:()=>c(!0),children:e})})})};export{$ as a,Gn as c,K as d,Je as f,we as h,Xn as i,Mt as l,Ee as m,Qn as n,Jn as o,ke as p,Zn as r,Yn as s,$n as t,Et as u};
5
+ }`,document.head.prepend(i);let o=e=>{if(!(e.touches.length===2||n)){if(!t||t===document.documentElement||t===document.body){e.preventDefault();return}t.scrollHeight===t.clientHeight&&t.scrollWidth===t.clientWidth&&e.preventDefault()}},s=e=>{let t=d(e),n=e.relatedTarget;n&&M(n)?(n.focus({preventScroll:!0}),kn(n,M(t))):n||(t.parentElement?.closest(`[tabindex]`))?.focus({preventScroll:!0})},c=HTMLElement.prototype.focus;HTMLElement.prototype.focus=function(e){let t=u(),n=t!=null&&M(t);c.call(this,{...e,preventScroll:!0}),(!e||!e.preventScroll)&&kn(this,n)};let f=l(On(document,`touchstart`,r,{passive:!1,capture:!0}),On(document,`touchmove`,o,{passive:!1,capture:!0}),On(document,`blur`,s,!0));return()=>{e(),f(),i.remove(),HTMLElement.prototype.focus=c}}function Z(e,t,n){let r=e.style[t];return e.style[t]=n,()=>{e.style[t]=r}}function On(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function kn(e,t){t||!Y?An(e):Y.addEventListener(`resize`,()=>An(e),{once:!0})}function An(e){let t=document.scrollingElement||document.documentElement,n=e;for(;n&&n!==t;){let e=Ae(n);if(e!==document.documentElement&&e!==document.body&&e!==n){let t=e.getBoundingClientRect(),r=n.getBoundingClientRect();if(r.top<t.top||r.bottom>t.top+n.clientHeight){let n=t.bottom;Y&&(n=Math.min(n,Y.offsetTop+Y.height));let i=r.top-t.top-((n-t.top)/2-r.height/2);e.scrollTo({top:Math.max(0,Math.min(e.scrollHeight-e.clientHeight,e.scrollTop+i)),behavior:`smooth`})}}n=e.parentElement}}function jn(e,t,n){let{overlayProps:r,underlayProps:i}=Cn({...e,isOpen:t.isOpen,onClose:t.close},n);return Tn({isDisabled:!t.isOpen}),Lt(),T(()=>{if(t.isOpen&&n.current)return Re([n.current],{shouldUseInert:!0})},[t.isOpen,n]),{modalProps:f(r),underlayProps:i}}function Mn(e){let[t,n]=Et(e.isOpen,e.defaultOpen||!1,e.onOpenChange);return{isOpen:t,setOpen:n,open:C(()=>{n(!0)},[n]),close:C(()=>{n(!1)},[n]),toggle:C(()=>{n(!t)},[n,t])}}const Nn=x(null),Q=x(null),Pn=S(function(e,t){let n=e[`aria-labelledby`];[e,t]=oe(e,t,Nn);let{dialogProps:i,titleProps:a}=Rt({...e,"aria-labelledby":n},t),o=w(Q);!i[`aria-label`]&&!i[`aria-labelledby`]&&e[`aria-labelledby`]&&(i[`aria-labelledby`]=e[`aria-labelledby`]);let s=ne({defaultClassName:`react-aria-Dialog`,className:e.className,style:e.style,children:e.children,values:{close:o?.close||(()=>{})}}),c=r(e,{global:!0});return b.createElement(fe.section,{...f(c,s,i),render:e.render,ref:t,slot:e.slot||void 0},b.createElement(ce,{values:[[Te,{slots:{[ue]:{},title:{...a,level:2}}}],[le,{slots:{[ue]:{},close:{onPress:()=>o?.close()}}}]]},s.children))}),Fn=x(null),In=x(null),Ln=S(function(e,t){if(w(In))return b.createElement(Vn,{...e,modalRef:t},e.children);let{isDismissable:n,isKeyboardDismissDisabled:r,isOpen:i,defaultOpen:a,onOpenChange:o,children:s,isEntering:c,isExiting:l,UNSTABLE_portalContainer:u,shouldCloseOnInteractOutside:d,...f}=e;return b.createElement(zn,{isDismissable:n,isKeyboardDismissDisabled:r,isOpen:i,defaultOpen:a,onOpenChange:o,isEntering:c,isExiting:l,UNSTABLE_portalContainer:u,shouldCloseOnInteractOutside:d},b.createElement(Vn,{...f,modalRef:t},s))});function Rn(e,n){[e,n]=oe(e,n,Fn);let r=w(Q),a=Mn(e),o=e.isOpen!=null||e.defaultOpen!=null||!r?a:r,s=i(n),c=D(null),l=Pe(s,o.isOpen),u=Pe(c,o.isOpen),d=l||u||e.isExiting||!1,f=t();return!o.isOpen&&!d||f?null:b.createElement(Bn,{...e,state:o,isExiting:d,overlayRef:s,modalRef:c})}const zn=S(Rn);function Bn({UNSTABLE_portalContainer:e,...t}){let n=t.modalRef,{state:i}=t,{modalProps:a,underlayProps:o}=jn(t,i,n),s=Ne(t.overlayRef)||t.isEntering||!1,c=ne({...t,defaultClassName:`react-aria-ModalOverlay`,values:{isEntering:s,isExiting:t.isExiting,state:i}}),l=Me(),u;if(typeof document<`u`){let e=j(document.body)?document.body:document.scrollingElement||document.documentElement,t=e.getBoundingClientRect().height%1;u=e.scrollHeight-t}let d={...c.style,"--visual-viewport-height":l.height+`px`,"--page-height":u===void 0?void 0:u+`px`};return b.createElement(It,{isExiting:t.isExiting,portalContainer:e},b.createElement(fe.div,{...f(r(t,{global:!0}),o),...c,style:d,ref:t.overlayRef,"data-entering":s||void 0,"data-exiting":t.isExiting||void 0},b.createElement(ce,{values:[[In,{modalProps:a,modalRef:n,isExiting:t.isExiting,isDismissable:t.isDismissable}],[Q,i]]},c.children)))}function Vn(e){let{modalProps:t,modalRef:n,isExiting:a,isDismissable:o}=w(In),s=w(Q),c=i(E(()=>ie(e.modalRef,n),[e.modalRef,n])),l=Ne(c),u=ne({...e,defaultClassName:`react-aria-Modal`,values:{isEntering:l,isExiting:a,state:s}});return b.createElement(fe.div,{...f(r(e,{global:!0}),t),...u,ref:c,"data-entering":l||void 0,"data-exiting":a||void 0},o&&b.createElement(Sn,{onDismiss:s.close}),u.children)}const Hn=x({}),Un=()=>w(Hn),Wn=x({}),Gn=({type:e,children:t})=>{let n=E(()=>({type:e}),[e]);return k(Wn.Provider,{value:n,children:t})},Kn=()=>w(Wn),$=x(null),qn=({children:e,surveyId:t,publishableKey:n,respondent:r,metadata:i={},apiBaseUrl:a})=>{let{type:s}=Kn(),c=Un(),l=c.version??`0.7.2`,u=c.build,d=D(!1),[f,p]=O(),m=o({publishableKey:n,apiBaseUrl:a});T(()=>{(async()=>{d.current=!1,p(void 0);try{let e=await m.get(`api/v1/cfti/${t}`).json(),n=me.safeParse(e);if(!n.success)return;p(n.data)}catch{}})()},[m,t]);let h=C(async({answers:e})=>{let n=crypto.randomUUID();await m.put(`api/v1/cfti/${t}/response/${n}`,{json:{respondent:r,data:e,metadata:i,telemetry:{...s!==void 0&&{type:s},version:l,...u&&{build:u}}}})},[u,m,i,r,t,l,s]),g=C(()=>{m.post(`api/v1/cfti/${t}/respondent/${r}/event`,{json:{type:`dismiss`}}).catch(()=>{})},[m,r,t]);return T(()=>{d.current||f&&r&&(d.current=!0,m.post(`api/v1/cfti/${t}/respondent/${r}/event`,{json:{type:`view`}}).catch(()=>{}))},[m,r,f,t]),f?k($.Provider,{value:{submit:h,dismiss:g,surveyId:t,survey:f,metadata:i},children:e}):null},Jn=e=>w($)?k(be,{children:e.children}):k(qn,{...e}),Yn=()=>{let e=w($);if(!e)throw Error(`useSurvey must be used within a SurveyProvider`);return e},Xn=()=>{let[e,t]=O(!1);return T(()=>{let e=e=>{let n=he.safeParse(e);n.error||t(n.data.detail.isRecording)};return document.addEventListener(ge,e),()=>{document.removeEventListener(ge,e)}},[]),e},Zn=({className:e,iconClassName:t,onClose:n})=>Xn()?null:k(`button`,{type:`button`,className:e,"aria-label":`Dismiss`,onClick:n,children:k(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`none`,className:t,children:k(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M3.53 3.529c.26-.26.682-.26.942 0l3.529 3.528 3.528-3.528a.667.667 0 0 1 .943.942L8.943 8l3.53 3.528a.667.667 0 0 1-.944.943L8.001 8.943 4.472 12.47a.667.667 0 1 1-.943-.943L7.058 8 3.529 4.47a.667.667 0 0 1 0-.942Z`,clipRule:`evenodd`})})}),Qn=({children:e,classNames:t,isDismissable:n,onDismiss:r,onClose:i,closeOnFinishMs:a,isSubmitted:o,onSubmitted:s})=>{let{survey:c,surveyId:l,dismiss:u}=Yn(),[d,f]=O(!1);return ye(()=>{c&&i?.()},d?a:null),xe(Pn,{"aria-label":`Survey`,id:`${l}-popover`,className:A(`confetti-modal-dialog ${_e}`,t?.dialog),children:[n&&k(Zn,{className:A(`confetti-modal-dialog-close`,t?.closeButton),iconClassName:t?.icon,onClose:async()=>{!o&&!d&&(await u(),r?.()),i?.()}}),typeof e==`function`?e({setIsSubmitted:()=>s?.(),setIsFinished:()=>f(!0)}):e]})},$n=({children:e,classNames:t,onDismiss:n,onClose:r,isDismissable:i=!0,closeOnFinishMs:a=3e3})=>{let{dismiss:o}=Yn(),[s,c]=O(!1);return k(zn,{isOpen:!0,isDismissable:i,isKeyboardDismissDisabled:!i,onOpenChange:async e=>{e||(s||(await o(),n?.()),r?.())},className:A(`confetti-modal-overlay ${_e}`,t?.overlay),children:k(Ln,{className:A(`confetti-modal ${_e}`,t?.modal),children:k(Qn,{classNames:t,isDismissable:i,onDismiss:n,onClose:r,closeOnFinishMs:a,isSubmitted:s,onSubmitted:()=>c(!0),children:e})})})};export{$ as a,Gn as c,K as d,Je as f,we as h,Xn as i,Mt as l,Ee as m,Qn as n,Jn as o,ke as p,Zn as r,Yn as s,$n as t,Et as u};
@@ -1 +1 @@
1
- import{n as e}from"./ModalContainer-BiysurqW.js";export{e as UnstableModalContent};
1
+ import{n as e}from"./ModalContainer-Bae3o4wI.js";export{e as UnstableModalContent};
@@ -1,6 +1,6 @@
1
1
  import { n as ModalContainerProps, t as ModalContainer } from "./ModalContainer-CbbuRuFl.js";
2
- import { c as RatingQuestionProperties, d as TextQuestionProperties, l as SingleSelectQuestionProperties, s as MultiSelectQuestionProperties, u as StatementQuestionProperties } from "./index-rGiNABlG.js";
3
- import { C as ConfettiState, _ as useSurvey, a as BaseFieldProps, b as Answer, c as ConfettiProviderProps, d as RespondentVisibilityProviderProps, g as SurveyProviderProps, h as SurveyProvider, i as BugReportOptions, k as Question, l as RespondentVisibilityContext, m as SurveyContext, n as Confetti, o as Question$1, p as useRespondentVisibility, r as ConfettiProps, s as ConfettiProvider, t as BaseConfettiProps, u as RespondentVisibilityProvider, v as ConfettiController, y as ConfettiControllerProps } from "./Confetti-d1r1QIP2.js";
2
+ import { c as RatingQuestionProperties, d as TextQuestionProperties, l as SingleSelectQuestionProperties, s as MultiSelectQuestionProperties, u as StatementQuestionProperties } from "./index-CER9nZlw.js";
3
+ import { C as ConfettiState, _ as useSurvey, a as BaseFieldProps, b as Answer, c as ConfettiProviderProps, d as RespondentVisibilityProviderProps, g as SurveyProviderProps, h as SurveyProvider, i as BugReportOptions, k as Question, l as RespondentVisibilityContext, m as SurveyContext, n as Confetti, o as Question$1, p as useRespondentVisibility, r as ConfettiProps, s as ConfettiProvider, t as BaseConfettiProps, u as RespondentVisibilityProvider, v as ConfettiController, y as ConfettiControllerProps } from "./Confetti-De4vjrHr.js";
4
4
  import { HTMLAttributes, JSX, PropsWithChildren, SVGProps } from "react";
5
5
 
6
6
  //#region src/components/container/PopoverContainer.d.ts
@@ -1 +1 @@
1
- import{n as e,t}from"./DefaultConfettiTrigger-C-E0FHJD.js";import{a as n,o as r,r as i,s as a,t as o}from"./ModalContainer-BiysurqW.js";import{a as s,c,d as l,f as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x}from"./Embed-ByNzZH0P.js";import{ErrorBoundary as S}from"react-error-boundary";import{Fragment as C,jsx as w}from"react/jsx-runtime";const T=({children:e,respondent:t,isSurveyVisible:n,...i})=>{let{respondent:a}=m();return w(r,{...i,respondent:a,children:e})},E=({children:e,...t})=>w(_,{...t,children:w(T,{...t,children:e})}),D=({children:e,onFinished:t,shouldAutoSubmit:n,...r})=>w(S,{fallback:w(C,{}),children:w(E,{...r,children:w(d,{shouldAutoSubmit:n,onFinished:t,children:e})})});export{v as BackButton,i as CloseButton,D as Confetti,d as ConfettiController,E as ConfettiProvider,e as ConfettiTriggerIcon,t as DefaultConfettiTrigger,b as Embed,h as Flow,x as FreeText,o as ModalContainer,p as MultiChoice,l as PopoverContainer,c as Rating,u as RespondentVisibilityContext,_ as RespondentVisibilityProvider,y as SingleChoice,g as Statement,n as SurveyContext,r as SurveyProvider,s as SurveyQuestionFactory,f as ThankYouMessage,m as useRespondentVisibility,a as useSurvey};
1
+ import{n as e,t}from"./DefaultConfettiTrigger-DRQBj9sz.js";import{a as n,o as r,r as i,s as a,t as o}from"./ModalContainer-Bae3o4wI.js";import{a as s,c,d as l,f as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x}from"./Embed-BXjS2X_u.js";import{ErrorBoundary as S}from"react-error-boundary";import{Fragment as C,jsx as w}from"react/jsx-runtime";const T=({children:e,respondent:t,isSurveyVisible:n,...i})=>{let{respondent:a}=m();return w(r,{...i,respondent:a,children:e})},E=({children:e,...t})=>w(_,{...t,children:w(T,{...t,children:e})}),D=({children:e,onFinished:t,shouldAutoSubmit:n,...r})=>w(S,{fallback:w(C,{}),children:w(E,{...r,children:w(d,{shouldAutoSubmit:n,onFinished:t,children:e})})});export{v as BackButton,i as CloseButton,D as Confetti,d as ConfettiController,E as ConfettiProvider,e as ConfettiTriggerIcon,t as DefaultConfettiTrigger,b as Embed,h as Flow,x as FreeText,o as ModalContainer,p as MultiChoice,l as PopoverContainer,c as Rating,u as RespondentVisibilityContext,_ as RespondentVisibilityProvider,y as SingleChoice,g as Statement,n as SurveyContext,r as SurveyProvider,s as SurveyQuestionFactory,f as ThankYouMessage,m as useRespondentVisibility,a as useSurvey};
@@ -45,6 +45,7 @@ declare const singleSelectQuestionPropertiesSchema: z.ZodObject<{
45
45
  options: z.ZodArray<z.ZodObject<{
46
46
  value: z.ZodString;
47
47
  description: z.ZodOptional<z.ZodString>;
48
+ translationId: z.ZodOptional<z.ZodCUID2>;
48
49
  }, z.core.$strip>>;
49
50
  buttonLabel: z.ZodOptional<z.ZodString>;
50
51
  editable: z.ZodNullable<z.ZodObject<{
@@ -60,6 +61,7 @@ declare const multiSelectQuestionPropertiesSchema: z.ZodObject<{
60
61
  options: z.ZodArray<z.ZodObject<{
61
62
  value: z.ZodString;
62
63
  description: z.ZodOptional<z.ZodString>;
64
+ translationId: z.ZodOptional<z.ZodCUID2>;
63
65
  }, z.core.$strip>>;
64
66
  editable: z.ZodNullable<z.ZodObject<{
65
67
  label: z.ZodString;
@@ -163,6 +165,7 @@ declare const publicGetSurveyOutputSchema: z.ZodObject<{
163
165
  options: z.ZodArray<z.ZodObject<{
164
166
  value: z.ZodString;
165
167
  description: z.ZodOptional<z.ZodString>;
168
+ translationId: z.ZodOptional<z.ZodCUID2>;
166
169
  }, z.core.$strip>>;
167
170
  buttonLabel: z.ZodOptional<z.ZodString>;
168
171
  editable: z.ZodNullable<z.ZodObject<{
@@ -181,6 +184,7 @@ declare const publicGetSurveyOutputSchema: z.ZodObject<{
181
184
  options: z.ZodArray<z.ZodObject<{
182
185
  value: z.ZodString;
183
186
  description: z.ZodOptional<z.ZodString>;
187
+ translationId: z.ZodOptional<z.ZodCUID2>;
184
188
  }, z.core.$strip>>;
185
189
  editable: z.ZodNullable<z.ZodObject<{
186
190
  label: z.ZodString;
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { D as OptionallyDismissable, E as Finishable, O as Proxyable, S as ConfettiContainer, T as Dismissable, t as BaseConfettiProps, w as Containable, x as Closable } from "./Confetti-d1r1QIP2.js";
1
+ import { D as OptionallyDismissable, E as Finishable, O as Proxyable, S as ConfettiContainer, T as Dismissable, t as BaseConfettiProps, w as Containable, x as Closable } from "./Confetti-De4vjrHr.js";
2
2
 
3
3
  //#region src/contracts/api.d.ts
4
4
  type Template = 'TriggerPopover' | 'Popover' | 'Modal' | 'Embedded' | 'Stepper';
@@ -103,6 +103,49 @@ interface TriggerPopoverConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUr
103
103
  }
104
104
  declare function TriggerPopoverConfetti(props: TriggerPopoverConfettiProps): import("react").JSX.Element | null;
105
105
  //#endregion
106
+ //#region src/hooks/useRespondentState.d.ts
107
+ interface UseRespondentStateOptions {
108
+ /** Identifier of the published survey to load. */
109
+ surveyId: string;
110
+ /** Publishable API key that authorises read access to the survey. */
111
+ publishableKey: string;
112
+ /**
113
+ * Identifies who the survey is shown to and tracked against. Required —
114
+ * unlike drop-in templates, this hook does not generate an anonymous
115
+ * respondent id. Pass a stable non-empty user identifier to target a
116
+ * person, an event identifier on its own to target an event, or a
117
+ * composite such as `{User ID}-{Event ID}` to target a person for a
118
+ * specific event. An empty string returns `null`.
119
+ */
120
+ respondent: string;
121
+ /**
122
+ * Origin that serves the proxied Confetti API. Omit it to use the default
123
+ * Confetti origin.
124
+ */
125
+ proxyUrl?: string;
126
+ }
127
+ type UseRespondentStateResult = {
128
+ lastRespondedAt: Date | null;
129
+ lastDismissedAt: Date | null;
130
+ } | null | undefined;
131
+ /**
132
+ * Fetches the respondent's response and dismissal timestamps for a survey.
133
+ *
134
+ * Returns `undefined` until the availability probe and respondent-state fetch
135
+ * have both settled. Returns `null` when `respondent` is empty, or when the
136
+ * survey is not available. Otherwise returns `{ lastRespondedAt,
137
+ * lastDismissedAt }` as fresh `Date` values (or `null`).
138
+ *
139
+ * Fetch or parse failures on the respondent endpoint are treated as empty
140
+ * history (`null` timestamps), matching the drop-in templates.
141
+ */
142
+ declare function useRespondentState({
143
+ surveyId,
144
+ publishableKey,
145
+ respondent,
146
+ proxyUrl
147
+ }: UseRespondentStateOptions): UseRespondentStateResult;
148
+ //#endregion
106
149
  //#region src/hooks/useVisibleAfterDelay.d.ts
107
150
  interface UseVisibleAfterDelayOptions {
108
151
  delay: number;
@@ -143,4 +186,4 @@ declare const useVisibleAfterScroll: ({
143
186
  isVisible: boolean;
144
187
  };
145
188
  //#endregion
146
- export { type ConfettiContainer, EmbeddedConfetti, type EmbeddedConfettiProps, ModalConfetti, type ModalConfettiProps, PopoverConfetti, type PopoverConfettiProps, StepperConfetti, type StepperConfettiProps, TriggerPopoverConfetti, type TriggerPopoverConfettiProps, type TriggerRenderProps, useVisibleAfterDelay, useVisibleAfterPageVisits, useVisibleAfterScroll, useVisibleAfterSessionPageVisits };
189
+ export { type ConfettiContainer, EmbeddedConfetti, type EmbeddedConfettiProps, ModalConfetti, type ModalConfettiProps, PopoverConfetti, type PopoverConfettiProps, StepperConfetti, type StepperConfettiProps, TriggerPopoverConfetti, type TriggerPopoverConfettiProps, type TriggerRenderProps, type UseRespondentStateOptions, type UseRespondentStateResult, useRespondentState, useVisibleAfterDelay, useVisibleAfterPageVisits, useVisibleAfterScroll, useVisibleAfterSessionPageVisits };
package/build/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,i as t,o as n,r,t as i}from"./DefaultConfettiTrigger-C-E0FHJD.js";import{G as a}from"./Button-LiaNjkvk.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.7.0`},onFinished:x,onClose:()=>{y(!0),S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.options,x,S]);if(!b)return null;let w=h(j,{template:`Embedded`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:C});return h(d,{fallback:h(m,{}),children:i.container?i.container({survey:w}):w})}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.7.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.7.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.7.0`},onFinished:x,onClose:()=>{y(!0),S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.options,x,S]);if(!b)return null;let w=h(j,{template:`Stepper`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:C});return h(d,{fallback:h(m,{}),children:i.container?i.container({survey:w}):w})}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.7.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
+ import{a as e,i as t,o as n,r,t as i}from"./DefaultConfettiTrigger-DRQBj9sz.js";import{G as a}from"./Button-LiaNjkvk.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.7.2`},onFinished:x,onClose:()=>{y(!0),S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.options,x,S]);if(!b)return null;let w=h(j,{template:`Embedded`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:C});return h(d,{fallback:h(m,{}),children:i.container?i.container({survey:w}):w})}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.7.2`},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.7.2`},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.7.2`},onFinished:x,onClose:()=>{y(!0),S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.options,x,S]);if(!b)return null;let w=h(j,{template:`Stepper`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:C});return h(d,{fallback:h(m,{}),children:i.container?i.container({survey:w}):w})}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.7.2`},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}function L({surveyId:e,publishableKey:n,respondent:i,proxyUrl:o}){let s=a({publishableKey:n,apiBaseUrl:o}),{isAvailable:c,isSettled:l}=r({client:s,surveyId:e}),{state:u,isSettled:d}=t({client:s,surveyId:e,respondent:i});if(!i)return null;if(!(!l||!d))return c?{lastRespondedAt:u.lastRespondedAt?new Date(u.lastRespondedAt):null,lastDismissedAt:u.lastDismissedAt?new Date(u.lastDismissedAt):null}:null}const R=({delay:e})=>{let[t,n]=u(!1),r=c(()=>e,[]);return s(()=>{let e=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(e)},[]),{isVisible:t}},z=({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])}},B=({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])}},V=({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 useRespondentState,R as useVisibleAfterDelay,z as useVisibleAfterPageVisits,V as useVisibleAfterScroll,B as useVisibleAfterSessionPageVisits};
@@ -0,0 +1 @@
1
+ import"./src-BewqzpwC.js";import{z as e}from"zod";const t=e=>e.value,n=({answer:e,condition:n})=>{let r=t(n.value);switch(n.operator){case`equal`:return e===r;case`not-equal`:return e!==r;case`greater`:return typeof e==`number`&&typeof r==`number`&&e>r;case`greater-or-equal`:return typeof e==`number`&&typeof r==`number`&&e>=r;case`less`:return typeof e==`number`&&typeof r==`number`&&e<r;case`less-or-equal`:return typeof e==`number`&&typeof r==`number`&&e<=r;case`contains`:return Array.isArray(e)&&typeof r==`string`&&e.includes(r);case`not-contains`:return Array.isArray(e)&&typeof r==`string`&&!e.includes(r)}},r=({position:e,value:t})=>{switch(t.type){case`next`:return e+1;case`jump`:return t.target;case`end`:return null}},i=e=>e==null||Array.isArray(e)&&e.length===0,a=({position:e,question:t,answer:a})=>{let o=t.routingLogic;if(o.type===`always`)return r({position:e,value:o.target});if(i(a)&&t.required)return null;let s=i(a)?void 0:o.cases.find(e=>n({answer:a,condition:e}));return r(s?{position:e,value:s.target}:{position:e,value:o.default})},o=(e,t,{forceReachableIds:n}={})=>{let r=[...e].sort((e,t)=>e.position-t.position),i=new Set,o=new Set(n);for(let e=0;e<r.length;e++){let n=r[e];if(n){if(e===0||o.has(n.id)){i.add(n.id);continue}for(let o=0;o<e;o++){let s=r[o];if(!(!s||!i.has(s.id))&&a({position:o,question:s,answer:t[s.id]})===e){i.add(n.id);break}}}}return i},s=n,c=`cfti-mask`,l=`cfti-block`,u=`__confetti_bug_report_recording_event`,d=e.object({detail:e.object({isRecording:e.boolean()})});export{s as a,d as i,c as n,o,u as r,l as t};
@@ -1,4 +1,4 @@
1
- import { f as BinaryOperatorCondition, n as RoutableAnswer } from "./index-rGiNABlG.js";
1
+ import { f as BinaryOperatorCondition, n as RoutableAnswer } from "./index-CER9nZlw.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/core/logic/routing.d.ts
@@ -1 +1 @@
1
- import{a as e,i as t,n,r,t as i}from"./internals-DMTYF5K8.js";export{i as BUG_REPORT_BLOCK_CLASS,n as BUG_REPORT_MASK_CLASS,r as __INTERNAL_BUG_REPORT_RECORDING_EVENT,t as internalBugReportRecordingEventSchema,e as unstableInternalConfettiEvaluateCondition};
1
+ import{a as e,i as t,n,r,t as i}from"./internals-Dm8fD0Gh.js";export{i as BUG_REPORT_BLOCK_CLASS,n as BUG_REPORT_MASK_CLASS,r as __INTERNAL_BUG_REPORT_RECORDING_EVENT,t as internalBugReportRecordingEventSchema,e as unstableInternalConfettiEvaluateCondition};
@@ -0,0 +1 @@
1
+ import{z as e}from"zod";const t=e.object({type:e.literal(`next`)}),n=e.object({type:e.literal(`end`)}),r=e.object({type:e.literal(`jump`),target:e.number({error:`Target question is required`})}),i=e.discriminatedUnion(`type`,[t,r,n]),ee=e.object({type:e.literal(`value`),value:e.union([e.string().check(e.trim(),e.minLength(1,{error:`Value is required`})),e.number({error:`Value is required`})])}),a=e.object({type:e.literal(`binary-operator`),operator:e.union([e.literal(`equal`),e.literal(`not-equal`),e.literal(`greater`),e.literal(`greater-or-equal`),e.literal(`less`),e.literal(`less-or-equal`),e.literal(`contains`),e.literal(`not-contains`)]),value:ee,target:i}),o=e.object({type:e.literal(`switch`),cases:e.array(a),default:i}),s=e.object({type:e.literal(`always`),target:i}),c=e.discriminatedUnion(`type`,[s,o]),l=e.string().check(e.trim(),e.url({protocol:/^(https|mailto)/,error:`Link must start with https:// or mailto:`})),u=e.optional(e.string().check(e.trim(),e.maxLength(50))),d=e.object({value:e.string().check(e.trim(),e.minLength(1,{error:`Value is required`})),description:e.optional(e.string().check(e.trim())),translationId:e.optional(e.cuid2())}),f=e.array(d).check(e.superRefine((e,t)=>{let n=new Set;for(let r of e)if(r.translationId!==void 0){if(n.has(r.translationId)){t.addIssue({code:`custom`,message:`Option translation ids must be unique within a question`});return}n.add(r.translationId)}})),p=e.nullable(e.object({label:e.string().check(e.trim(),e.minLength(1,{error:`Value is required`})),max:e.number(),description:e.optional(e.string().check(e.trim()))})),m=e.optional(e.boolean()),h=e.object({type:e.literal(`rating`),buttonLabel:u,shouldAutoProgress:m,scale:e.number().check(e.gte(2),e.lte(10)),labels:e.optional(e.object({lower:e.optional(e.pipe(e.string().check(e.trim()),e.transform(e=>e===``?void 0:e))),upper:e.optional(e.pipe(e.string().check(e.trim()),e.transform(e=>e===``?void 0:e)))})),display:e.optional(e.literal([`star`,`emoji`,`number`]))}),g=e.object({type:e.literal(`open-ended`),placeholder:e.optional(e.string()),buttonLabel:u,max:e.number()}),te=e.object({type:e.literal(`single-select`),shouldAutoProgress:m,options:f,buttonLabel:u,editable:p}),ne=e.object({type:e.literal(`multi-select`),buttonLabel:u,options:f,editable:p,max:e.optional(e.number()),display:e.optional(e.literal([`checkbox`,`tag`]))}),re=e.object({type:e.literal(`statement`),buttonLabel:u,buttonUrl:e.optional(l)}),ie=e.object({type:e.literal(`bug-report`),placeholder:e.optional(e.string()),buttonLabel:u,enableScreenshot:e.boolean(),enableRecording:e.boolean(),detailsLabel:e.string().check(e.trim(),e.minLength(1,{error:`Label is required`}),e.maxLength(128)),detailsPlaceholder:e.optional(e.string()),redactClasses:e.optional(e.array(e.string()))}),ae=e.discriminatedUnion(`type`,[h,te,g,ne,re,ie]),_=e.object({label:e.optional(e.string()),description:e.optional(e.string())}),v=e.object({type:e.literal(`rating`),buttonLabel:u,labels:e.optional(e.object({lower:e.optional(e.string()),upper:e.optional(e.string())}))}),y=e.object({type:e.literal(`open-ended`),placeholder:e.optional(e.string()),buttonLabel:u}),b=e.object({type:e.literal(`single-select`),buttonLabel:u,options:e.optional(e.record(e.string(),_))}),x=e.object({type:e.literal(`multi-select`),buttonLabel:u,options:e.optional(e.record(e.string(),_))}),S=e.object({type:e.literal(`statement`),buttonLabel:u}),C=e.object({type:e.literal(`bug-report`),placeholder:e.optional(e.string()),buttonLabel:u,detailsLabel:e.optional(e.string()),detailsPlaceholder:e.optional(e.string())}),w=e.discriminatedUnion(`type`,[v,y,b,x,S,C]),T=`__CONFETTI_CHECKBOX_Others`,E=`__CONFETTI_RADIO_Others`,D=e.optional(e.looseObject({userAgent:e.string().check(e.trim(),e.maxLength(1e3)),screenResolution:e.string().check(e.trim(),e.maxLength(100)),viewportSize:e.string().check(e.trim(),e.maxLength(100)),pageUrl:e.string(),pageTitle:e.string().check(e.trim(),e.maxLength(1e3)),referrer:e.string(),datadogTraceId:e.optional(e.string()),datadogSessionId:e.optional(e.string()),datadogSessionReplayLink:e.optional(e.string())}).partial().catchall(e.optional(e.string())));e.cuid2();const O=e.looseObject({type:e.literal([0,1,2,3,4,5,6]),data:e.unknown(),timestamp:e.number(),delay:e.optional(e.number())});e.array(O);const k=e.array(O),A=e.string().check(e.refine(e=>{try{return k.safeParse(JSON.parse(e)).success}catch{return!1}},{error:`Invalid recording events`})),j=e.string().check(e.regex(/^data:image\/(png|jpeg|jpg|webp|gif);base64,[A-Za-z0-9+/]+=*$/,{error:`Invalid image data URL`})),M=t=>e.object({title:e.string().check(e.trim(),...t?[e.minLength(1,{error:`Title is required`})]:[],e.maxLength(256)),description:e.optional(e.string().check(e.trim(),e.maxLength(4096))),screenshotDataUrl:e.optional(j),recordingEventsJson:e.optional(A),metadata:D}),N=M(!0),P=(e,{required:t})=>M(t),F=t=>e.number({error:`Please select a rating`}).check(e.int(),e.gte(1),e.lte(t)),I=({scale:t},{required:n})=>{let r=F(t);return n?r:e.optional(r)},L=({maxLength:t},{required:n})=>e.string().check(e.trim(),...n?[e.minLength(1,{error:`This field is required`})]:[],e.maxLength(t??2048,{error:({maximum:e})=>`Please enter less than ${e} characters`})),oe=(t,n)=>e.string({error:`Please select an option`}).check(e.trim(),...n?[e.minLength(1,{error:`This field is required`})]:[],e.maxLength(t??1024,{error:({maximum:e})=>`Please enter less than ${e} characters`}),e.refine(e=>e!==E,{error:`Please fill out the free text field`})),R=({maxLength:t},{required:n})=>{let r=oe(t,n);return n?r:e.optional(r)},z=({maxSelected:t,maxLength:n},{required:r})=>e.array(e.string().check(e.trim(),...r?[e.minLength(1,{error:`This field is required`})]:[],e.maxLength(n??1024,{error:({maximum:e})=>`Please enter less than ${e} characters`}),e.refine(e=>e!==T,{error:`Please fill out the free text field`}))).check(...r?[e.minLength(1,{error:`Please select at least one option`})]:[],e.maxLength(t??1024,{error:({maximum:e})=>`Please select less than ${e} options`})),B=()=>e.optional(e.string()),V=e.enum([`en`,`zh`,`ms`,`ta`]),H=e.cuid2(),U=e.object({title:e.string().check(e.trim()),description:e.string().check(e.trim()),buttonText:e.string().check(e.trim())}),W=e.object({id:e.string(),title:e.string(),description:e.nullable(e.string()),position:e.number(),required:e.boolean(),properties:ae,routingLogic:c}),G=e.object({title:e.optional(e.string()),description:e.optional(e.string()),confirmation:e.optional(e.object({title:e.optional(e.string()),description:e.optional(e.string()),buttonText:e.optional(e.string())}))});e.partialRecord(V,G);const K=e.object({title:e.optional(e.string()),description:e.optional(e.string()),properties:e.optional(w)});e.partialRecord(V,K);const q=e.object({title:e.string(),description:e.nullable(e.string()),questions:e.array(W),confirmation:U,isBackNavigationAllowed:e.boolean(),backButtonLabel:e.nullable(e.string().check(e.trim(),e.maxLength(50)))});e.object({cursor:e.optional(e.string().check(e.minLength(1),e.maxLength(100))),limit:e.optional(e.number().check(e.int(),e.gte(1),e.lte(100)))});const J=e.object({id:e.string(),title:e.string(),description:e.nullable(e.string()),status:e.enum([`active`,`inactive`]),createdAt:e.date(),updatedAt:e.date()});e.object({data:e.array(J),nextCursor:e.nullable(e.string()),limit:e.number(),links:e.object({self:e.string(),next:e.nullable(e.string())})}),e.object({surveyId:H});const se=W;e.object({data:e.object({...J.shape,questions:e.array(se)})}),e.object({surveyId:H,responseId:e.union([e.cuid2(),e.uuid()])});const ce=e.catch(e.object({type:e.enum([`embedded`,`popover`,`modal`]),version:e.string().check(e.trim(),e.minLength(1),e.maxLength(50)),build:e.string().check(e.trim(),e.minLength(1),e.maxLength(50))}).partial(),{}),Y=e.record(e.string(),e.union([e.string().check(e.trim(),e.maxLength(2048)),e.number(),e.array(e.string().check(e.trim(),e.maxLength(2048))).check(e.maxLength(1024)),N])),X=e.string().check(e.trim(),e.maxLength(1e3)),Z=e.record(X,X).check(e.refine(e=>Object.keys(e).length<=20,`At most 20 metadata entries are allowed.`));e.object({respondent:e.string().check(e.trim(),e.minLength(1),e.maxLength(2048)),data:Y,metadata:Z,telemetry:e.optional(ce)}),e.object({id:e.string(),createdAt:e.date()}),e.object({surveyId:H,respondent:e.string().check(e.trim(),e.minLength(1),e.maxLength(2048))}),e.object({surveyId:H,respondent:e.string().check(e.trim(),e.minLength(1),e.maxLength(2048))}),e.object({surveyId:H});const le=e.object({lastRespondedAt:e.nullable(e.union([e.iso.datetime(),e.date()])),lastViewedAt:e.nullable(e.union([e.iso.datetime(),e.date()])),lastDismissedAt:e.nullable(e.union([e.iso.datetime(),e.date()]))});e.object({type:e.enum([`view`,`dismiss`])}),e.object({}),e.object({surveyId:H}),e.object({respondent:e.optional(e.string().check(e.trim(),e.minLength(1),e.maxLength(255))),after:e.optional(e.iso.datetime({offset:!0,local:!0})),before:e.optional(e.iso.datetime({offset:!0,local:!0})),cursor:e.optional(e.string().check(e.minLength(1),e.maxLength(100))),limit:e.optional(e.number().check(e.int(),e.gte(1),e.lte(100)))});const ue=e.object({id:e.string(),respondent:e.string(),data:Y,clientMetadata:e.record(e.string(),e.string()),createdAt:e.date()});e.object({data:e.array(ue),nextCursor:e.nullable(e.string()),limit:e.number(),links:e.object({self:e.string(),next:e.nullable(e.string())})});const Q=e.number().check(e.int(),e.gte(0));e.object({data:e.object({totalViews:Q,uniqueViewers:Q,totalDismissals:Q,uniqueDismissers:Q,totalResponses:Q,uniqueResponders:Q})}),e.object({questionIds:e.array(e.string()).check(e.minLength(1)),timeRange:e.union([e.enum([`last-7-days`,`last-30-days`]),e.string().check(e.regex(/^q[1-4]-\d{4}$/)),e.string().check(e.regex(/^custom_\d{4}-\d{2}-\d{2}_\d{4}-\d{2}-\d{2}$/))])});const $=e.record(e.string(),e.record(e.string(),e.number()));e.object({data:e.object({current:$,previousQuarter:e.nullable($)})});export{L as a,B as c,l as d,z as i,T as l,q as n,I as o,P as r,R as s,le as t,E as u};
package/build/static.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as WithProxyable, D as OptionallyDismissable, S as ConfettiContainer, T as Dismissable, d as RespondentVisibilityProviderProps, f as WithVisibilityControl, t as BaseConfettiProps, w as Containable, x as Closable } from "./Confetti-d1r1QIP2.js";
1
+ import { A as WithProxyable, D as OptionallyDismissable, S as ConfettiContainer, T as Dismissable, d as RespondentVisibilityProviderProps, f as WithVisibilityControl, t as BaseConfettiProps, w as Containable, x as Closable } from "./Confetti-De4vjrHr.js";
2
2
 
3
3
  //#region src/templates/EmbeddedConfettiContent.d.ts
4
4
  interface EmbeddedConfettiContentProps extends Omit<BaseConfettiProps, 'isSurveyVisible'>, Closable {
package/build/static.js CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./DefaultConfettiTrigger-C-E0FHJD.js";import{c as t,o as n,t as r}from"./ModalContainer-BiysurqW.js";import{a as i,d as a,h as o,i as s,m as c,n as l,p as u,r as d,t as f}from"./Embed-ByNzZH0P.js";import{useState as p}from"react";import{ErrorBoundary as m}from"react-error-boundary";import{Fragment as h,jsx as g,jsxs as _}from"react/jsx-runtime";const v=({onClose:e,...r})=>g(m,{fallback:g(h,{}),children:g(t,{type:`embedded`,children:g(n,{...r,children:g(o,{...r,shouldAutoSubmit:!1,children:({questions:t,update:n,submit:a,isSubmitted:o,errors:c})=>o?g(s,{onClose:e}):g(f,{onSubmit:a,children:t.filter(({visible:e})=>!!e).map(e=>g(i,{question:e,error:c[e.id]||``,maskAllInputs:r.options?.bugReport?.maskAllInputs,onChange:t=>n({question:e.position,answer:t})},e.position))})})})})}),y=e=>{let{respondent:t}=c();return g(v,{...e,respondent:t})};function b(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,container:o,...s}=e;if(t)return null;let c=g(y,{...s,apiBaseUrl:a,onClose:()=>{n(!0),s.onClose?.()}});return g(u,{surveyId:s.surveyId,publishableKey:s.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:o?o({survey:c}):c})}const x=({onDismiss:e,onClose:a,onFinished:c,closeOnFinishMs:l,isDismissable:u,...d})=>g(m,{fallback:g(h,{}),children:g(t,{type:`modal`,children:g(n,{...d,children:g(r,{onDismiss:e,onClose:a,closeOnFinishMs:l,isDismissable:u,children:({setIsSubmitted:e,setIsFinished:t})=>g(o,{...d,shouldAutoSubmit:!1,onSubmitted:()=>e(),onFinished:()=>{t(),c?.()},children:({questions:e,update:t,errors:n,submit:r,isSubmitted:o})=>o?g(s,{onClose:a}):g(f,{onSubmit:r,children:e.filter(({visible:e})=>!!e).map(e=>g(i,{question:e,error:n[e.id]||``,maskAllInputs:d.options?.bugReport?.maskAllInputs,onChange:n=>t({question:e.position,answer:n})},e.position))})})})})})}),S=e=>{let{respondent:t}=c();return g(x,{...e,respondent:t})};function C(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,...o}=e;return t?null:g(u,{surveyId:o.surveyId,publishableKey:o.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:g(S,{...o,apiBaseUrl:a,onClose:()=>{n(!0),o.onClose?.()}})})}const w=({onDismiss:e,onClose:r,onFinished:c,closeOnFinishMs:u,...f})=>g(m,{fallback:g(h,{}),children:g(t,{type:`popover`,children:g(n,{...f,children:g(a,{onDismiss:e,onClose:r,closeOnFinishMs:u,children:({setIsSubmitted:e,setIsFinished:t})=>g(o,{...f,shouldAutoSubmit:!0,onSubmitted:()=>e(),onFinished:()=>{t(),c?.()},children:({current:e,questions:t,answers:n,update:a,back:o,canGoBack:c,backButtonLabel:u,saveAnswer:p,isSubmitted:m})=>{let _=e===t.length-1;if(m)return g(s,{onClose:r});let v=t[e];return v?g(l,{isLastQuestion:_,question:v,defaultAnswer:n[v.id]??void 0,backButton:c?g(d,{onPress:o,children:u}):void 0,saveAnswer:e=>p(v.id,e),onSubmit:t=>a({question:e,answer:t}),children:e=>g(i,{maskAllInputs:f.options?.bugReport?.maskAllInputs,...e})},v.id):g(h,{})}})})})})}),T=e=>{let{respondent:t}=c();return g(w,{...e,respondent:t})};function E(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,...o}=e;return t?null:g(u,{surveyId:o.surveyId,publishableKey:o.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:g(T,{...o,apiBaseUrl:a,onClose:()=>{n(!0),o.onClose?.()}})})}const D=({onClose:e,...t})=>g(m,{fallback:g(h,{}),children:g(n,{...t,children:g(o,{...t,shouldAutoSubmit:!0,children:({current:n,questions:r,answers:a,update:o,back:c,canGoBack:u,backButtonLabel:f,saveAnswer:p,isSubmitted:m})=>{let _=n===r.length-1;if(m)return g(s,{onClose:e});let v=r[n];return v?g(l,{isLastQuestion:_,question:v,defaultAnswer:a[v.id]??void 0,backButton:u?g(d,{onPress:c,children:f}):void 0,saveAnswer:e=>p(v.id,e),onSubmit:e=>o({question:n,answer:e}),children:e=>g(i,{maskAllInputs:t.options?.bugReport?.maskAllInputs,...e})},v.id):g(h,{})}})})}),O=e=>{let{respondent:t}=c();return g(D,{...e,respondent:t})};function k(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,container:o,...s}=e;if(t)return null;let c=g(O,{...s,apiBaseUrl:a,onClose:()=>{n(!0),s.onClose?.()}});return g(u,{surveyId:s.surveyId,publishableKey:s.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:o?o({survey:c}):c})}const A=({trigger:e,children:t,onFinished:n,...r})=>{let[i,a]=p(!1),[o,s]=p(!1);return _(h,{children:[e({onClick:()=>a(!0),isWidgetOpen:i,hasSubmitted:o}),i&&t({...r,onDismiss:()=>a(!1),onFinished:()=>{s(!0),n?.()},onClose:()=>a(!1)})]})},j=({trigger:t=t=>g(e,{...t}),children:n,metadata:r,options:i,onFinished:a,proxyUrl:o,...s})=>g(m,{fallback:g(h,{}),children:g(u,{...s,apiBaseUrl:o,children:g(A,{trigger:t,surveyId:s.surveyId,publishableKey:s.publishableKey,proxyUrl:o,metadata:r,options:i,onFinished:a,children:n})})});export{j as ConfettiTrigger,b as EmbeddedConfetti,C as ModalConfetti,E as PopoverConfetti,k as StepperConfetti};
1
+ import{t as e}from"./DefaultConfettiTrigger-DRQBj9sz.js";import{c as t,o as n,t as r}from"./ModalContainer-Bae3o4wI.js";import{a as i,d as a,h as o,i as s,m as c,n as l,p as u,r as d,t as f}from"./Embed-BXjS2X_u.js";import{useState as p}from"react";import{ErrorBoundary as m}from"react-error-boundary";import{Fragment as h,jsx as g,jsxs as _}from"react/jsx-runtime";const v=({onClose:e,...r})=>g(m,{fallback:g(h,{}),children:g(t,{type:`embedded`,children:g(n,{...r,children:g(o,{...r,shouldAutoSubmit:!1,children:({questions:t,update:n,submit:a,isSubmitted:o,errors:c})=>o?g(s,{onClose:e}):g(f,{onSubmit:a,children:t.filter(({visible:e})=>!!e).map(e=>g(i,{question:e,error:c[e.id]||``,maskAllInputs:r.options?.bugReport?.maskAllInputs,onChange:t=>n({question:e.position,answer:t})},e.position))})})})})}),y=e=>{let{respondent:t}=c();return g(v,{...e,respondent:t})};function b(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,container:o,...s}=e;if(t)return null;let c=g(y,{...s,apiBaseUrl:a,onClose:()=>{n(!0),s.onClose?.()}});return g(u,{surveyId:s.surveyId,publishableKey:s.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:o?o({survey:c}):c})}const x=({onDismiss:e,onClose:a,onFinished:c,closeOnFinishMs:l,isDismissable:u,...d})=>g(m,{fallback:g(h,{}),children:g(t,{type:`modal`,children:g(n,{...d,children:g(r,{onDismiss:e,onClose:a,closeOnFinishMs:l,isDismissable:u,children:({setIsSubmitted:e,setIsFinished:t})=>g(o,{...d,shouldAutoSubmit:!1,onSubmitted:()=>e(),onFinished:()=>{t(),c?.()},children:({questions:e,update:t,errors:n,submit:r,isSubmitted:o})=>o?g(s,{onClose:a}):g(f,{onSubmit:r,children:e.filter(({visible:e})=>!!e).map(e=>g(i,{question:e,error:n[e.id]||``,maskAllInputs:d.options?.bugReport?.maskAllInputs,onChange:n=>t({question:e.position,answer:n})},e.position))})})})})})}),S=e=>{let{respondent:t}=c();return g(x,{...e,respondent:t})};function C(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,...o}=e;return t?null:g(u,{surveyId:o.surveyId,publishableKey:o.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:g(S,{...o,apiBaseUrl:a,onClose:()=>{n(!0),o.onClose?.()}})})}const w=({onDismiss:e,onClose:r,onFinished:c,closeOnFinishMs:u,...f})=>g(m,{fallback:g(h,{}),children:g(t,{type:`popover`,children:g(n,{...f,children:g(a,{onDismiss:e,onClose:r,closeOnFinishMs:u,children:({setIsSubmitted:e,setIsFinished:t})=>g(o,{...f,shouldAutoSubmit:!0,onSubmitted:()=>e(),onFinished:()=>{t(),c?.()},children:({current:e,questions:t,answers:n,update:a,back:o,canGoBack:c,backButtonLabel:u,saveAnswer:p,isSubmitted:m})=>{let _=e===t.length-1;if(m)return g(s,{onClose:r});let v=t[e];return v?g(l,{isLastQuestion:_,question:v,defaultAnswer:n[v.id]??void 0,backButton:c?g(d,{onPress:o,children:u}):void 0,saveAnswer:e=>p(v.id,e),onSubmit:t=>a({question:e,answer:t}),children:e=>g(i,{maskAllInputs:f.options?.bugReport?.maskAllInputs,...e})},v.id):g(h,{})}})})})})}),T=e=>{let{respondent:t}=c();return g(w,{...e,respondent:t})};function E(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,...o}=e;return t?null:g(u,{surveyId:o.surveyId,publishableKey:o.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:g(T,{...o,apiBaseUrl:a,onClose:()=>{n(!0),o.onClose?.()}})})}const D=({onClose:e,...t})=>g(m,{fallback:g(h,{}),children:g(n,{...t,children:g(o,{...t,shouldAutoSubmit:!0,children:({current:n,questions:r,answers:a,update:o,back:c,canGoBack:u,backButtonLabel:f,saveAnswer:p,isSubmitted:m})=>{let _=n===r.length-1;if(m)return g(s,{onClose:e});let v=r[n];return v?g(l,{isLastQuestion:_,question:v,defaultAnswer:a[v.id]??void 0,backButton:u?g(d,{onPress:c,children:f}):void 0,saveAnswer:e=>p(v.id,e),onSubmit:e=>o({question:n,answer:e}),children:e=>g(i,{maskAllInputs:t.options?.bugReport?.maskAllInputs,...e})},v.id):g(h,{})}})})}),O=e=>{let{respondent:t}=c();return g(D,{...e,respondent:t})};function k(e){let[t,n]=p(!1),{respondent:r,isSurveyVisible:i,proxyUrl:a,container:o,...s}=e;if(t)return null;let c=g(O,{...s,apiBaseUrl:a,onClose:()=>{n(!0),s.onClose?.()}});return g(u,{surveyId:s.surveyId,publishableKey:s.publishableKey,apiBaseUrl:a,respondent:r,isSurveyVisible:i,children:o?o({survey:c}):c})}const A=({trigger:e,children:t,onFinished:n,...r})=>{let[i,a]=p(!1),[o,s]=p(!1);return _(h,{children:[e({onClick:()=>a(!0),isWidgetOpen:i,hasSubmitted:o}),i&&t({...r,onDismiss:()=>a(!1),onFinished:()=>{s(!0),n?.()},onClose:()=>a(!1)})]})},j=({trigger:t=t=>g(e,{...t}),children:n,metadata:r,options:i,onFinished:a,proxyUrl:o,...s})=>g(m,{fallback:g(h,{}),children:g(u,{...s,apiBaseUrl:o,children:g(A,{trigger:t,surveyId:s.surveyId,publishableKey:s.publishableKey,proxyUrl:o,metadata:r,options:i,onFinished:a,children:n})})});export{j as ConfettiTrigger,b as EmbeddedConfetti,C as ModalConfetti,E as PopoverConfetti,k as StepperConfetti};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengovsg/confetti",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "sideEffects": false,
5
5
  "description": "Widgets for Confetti",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -94,8 +94,8 @@
94
94
  "react-aria-components": "1.16.0",
95
95
  "tsdown": "0.22.1",
96
96
  "typescript": "npm:@typescript/typescript6@^6.0.2",
97
- "@confetti/tsconfig": "0.0.0",
98
- "@confetti/validators": "0.0.0"
97
+ "@confetti/validators": "0.0.0",
98
+ "@confetti/tsconfig": "0.0.0"
99
99
  },
100
100
  "scripts": {
101
101
  "build:css": "postcss ./src/confetti.css -o ./build/confetti.css",
@@ -1 +0,0 @@
1
- import"./src-DAnW22YG.js";import{z as e}from"zod";const t=e=>e.value,n=({answer:e,condition:n})=>{let r=t(n.value);switch(n.operator){case`equal`:return e===r;case`not-equal`:return e!==r;case`greater`:return typeof e==`number`&&typeof r==`number`&&e>r;case`greater-or-equal`:return typeof e==`number`&&typeof r==`number`&&e>=r;case`less`:return typeof e==`number`&&typeof r==`number`&&e<r;case`less-or-equal`:return typeof e==`number`&&typeof r==`number`&&e<=r;case`contains`:return Array.isArray(e)&&typeof r==`string`&&e.includes(r);case`not-contains`:return Array.isArray(e)&&typeof r==`string`&&!e.includes(r)}},r=({position:e,value:t})=>{switch(t.type){case`next`:return e+1;case`jump`:return t.target;case`end`:return null}},i=({position:e,question:t,answer:i})=>{let a=t.routingLogic;if(a.type===`always`)return r({position:e,value:a.target});if(i==null&&t.required)return null;let o=i==null?void 0:a.cases.find(e=>n({answer:i,condition:e}));return r(o?{position:e,value:o.target}:{position:e,value:a.default})},a=(e,t,{forceReachableIds:n}={})=>{let r=[...e].sort((e,t)=>e.position-t.position),a=new Set,o=new Set(n);for(let e=0;e<r.length;e++){let n=r[e];if(n){if(e===0||o.has(n.id)){a.add(n.id);continue}for(let o=0;o<e;o++){let s=r[o];if(!(!s||!a.has(s.id))&&i({position:o,question:s,answer:t[s.id]})===e){a.add(n.id);break}}}}return a},o=n,s=`cfti-mask`,c=`cfti-block`,l=`__confetti_bug_report_recording_event`,u=e.object({detail:e.object({isRecording:e.boolean()})});export{o as a,u as i,s as n,a as o,l as r,c as t};
@@ -1 +0,0 @@
1
- import{z as e}from"zod";const t=e.object({type:e.literal(`next`)}),n=e.object({type:e.literal(`end`)}),r=e.object({type:e.literal(`jump`),target:e.number({error:`Target question is required`})}),i=e.discriminatedUnion(`type`,[t,r,n]),a=e.object({type:e.literal(`value`),value:e.union([e.string().check(e.trim(),e.minLength(1,{error:`Value is required`})),e.number({error:`Value is required`})])}),o=e.object({type:e.literal(`binary-operator`),operator:e.union([e.literal(`equal`),e.literal(`not-equal`),e.literal(`greater`),e.literal(`greater-or-equal`),e.literal(`less`),e.literal(`less-or-equal`),e.literal(`contains`),e.literal(`not-contains`)]),value:a,target:i}),s=e.object({type:e.literal(`switch`),cases:e.array(o),default:i}),c=e.object({type:e.literal(`always`),target:i}),l=e.discriminatedUnion(`type`,[c,s]),u=e.string().check(e.trim(),e.url({protocol:/^(https|mailto)/,error:`Link must start with https:// or mailto:`})),d=e.optional(e.string().check(e.trim(),e.maxLength(50))),f=e.object({value:e.string().check(e.trim(),e.minLength(1,{error:`Value is required`})),description:e.optional(e.string().check(e.trim()))}),p=e.nullable(e.object({label:e.string().check(e.trim(),e.minLength(1,{error:`Value is required`})),max:e.number(),description:e.optional(e.string().check(e.trim()))})),m=e.optional(e.boolean()),h=e.object({type:e.literal(`rating`),buttonLabel:d,shouldAutoProgress:m,scale:e.number().check(e.gte(2),e.lte(10)),labels:e.optional(e.object({lower:e.optional(e.pipe(e.string().check(e.trim()),e.transform(e=>e===``?void 0:e))),upper:e.optional(e.pipe(e.string().check(e.trim()),e.transform(e=>e===``?void 0:e)))})),display:e.optional(e.literal([`star`,`emoji`,`number`]))}),g=e.object({type:e.literal(`open-ended`),placeholder:e.optional(e.string()),buttonLabel:d,max:e.number()}),_=e.object({type:e.literal(`single-select`),shouldAutoProgress:m,options:e.array(f),buttonLabel:d,editable:p}),v=e.object({type:e.literal(`multi-select`),buttonLabel:d,options:e.array(f),editable:p,max:e.optional(e.number()),display:e.optional(e.literal([`checkbox`,`tag`]))}),y=e.object({type:e.literal(`statement`),buttonLabel:d,buttonUrl:e.optional(u)}),b=e.object({type:e.literal(`bug-report`),placeholder:e.optional(e.string()),buttonLabel:d,enableScreenshot:e.boolean(),enableRecording:e.boolean(),detailsLabel:e.string().check(e.trim(),e.minLength(1,{error:`Label is required`}),e.maxLength(128)),detailsPlaceholder:e.optional(e.string()),redactClasses:e.optional(e.array(e.string()))}),x=e.discriminatedUnion(`type`,[h,_,g,v,y,b]),S=`__CONFETTI_CHECKBOX_Others`,C=`__CONFETTI_RADIO_Others`,w=e.optional(e.looseObject({userAgent:e.string().check(e.trim(),e.maxLength(1e3)),screenResolution:e.string().check(e.trim(),e.maxLength(100)),viewportSize:e.string().check(e.trim(),e.maxLength(100)),pageUrl:e.string(),pageTitle:e.string().check(e.trim(),e.maxLength(1e3)),referrer:e.string(),datadogTraceId:e.optional(e.string()),datadogSessionId:e.optional(e.string()),datadogSessionReplayLink:e.optional(e.string())}).partial().catchall(e.optional(e.string())));e.cuid2();const T=e.looseObject({type:e.literal([0,1,2,3,4,5,6]),data:e.unknown(),timestamp:e.number(),delay:e.optional(e.number())});e.array(T);const E=e.array(T),D=e.string().check(e.refine(e=>{try{return E.safeParse(JSON.parse(e)).success}catch{return!1}},{error:`Invalid recording events`})),O=e.string().check(e.regex(/^data:image\/(png|jpeg|jpg|webp|gif);base64,[A-Za-z0-9+/]+=*$/,{error:`Invalid image data URL`})),k=t=>e.object({title:e.string().check(e.trim(),...t?[e.minLength(1,{error:`Title is required`})]:[],e.maxLength(256)),description:e.optional(e.string().check(e.trim(),e.maxLength(4096))),screenshotDataUrl:e.optional(O),recordingEventsJson:e.optional(D),metadata:w}),A=k(!0),j=(e,{required:t})=>k(t),M=t=>e.number({error:`Please select a rating`}).check(e.int(),e.gte(1),e.lte(t)),N=({scale:t},{required:n})=>{let r=M(t);return n?r:e.optional(r)},P=({maxLength:t},{required:n})=>e.string().check(e.trim(),...n?[e.minLength(1,{error:`This field is required`})]:[],e.maxLength(t??2048,{error:({maximum:e})=>`Please enter less than ${e} characters`})),F=(t,n)=>e.string({error:`Please select an option`}).check(e.trim(),...n?[e.minLength(1,{error:`This field is required`})]:[],e.maxLength(t??1024,{error:({maximum:e})=>`Please enter less than ${e} characters`}),e.refine(e=>e!==C,{error:`Please fill out the free text field`})),I=({maxLength:t},{required:n})=>{let r=F(t,n);return n?r:e.optional(r)},L=({maxSelected:t,maxLength:n},{required:r})=>e.array(e.string().check(e.trim(),...r?[e.minLength(1,{error:`This field is required`})]:[],e.maxLength(n??1024,{error:({maximum:e})=>`Please enter less than ${e} characters`}),e.refine(e=>e!==S,{error:`Please fill out the free text field`}))).check(...r?[e.minLength(1,{error:`Please select at least one option`})]:[],e.maxLength(t??1024,{error:({maximum:e})=>`Please select less than ${e} options`})),R=()=>e.optional(e.string()),z=e.cuid2(),B=e.object({title:e.string().check(e.trim()),description:e.string().check(e.trim()),buttonText:e.string().check(e.trim())}),V=e.object({id:e.string(),title:e.string(),description:e.nullable(e.string()),position:e.number(),required:e.boolean(),properties:x,routingLogic:l}),H=e.object({title:e.string(),description:e.nullable(e.string()),questions:e.array(V),confirmation:B,isBackNavigationAllowed:e.boolean(),backButtonLabel:e.nullable(e.string().check(e.trim(),e.maxLength(50)))});e.object({cursor:e.optional(e.string().check(e.minLength(1),e.maxLength(100))),limit:e.optional(e.number().check(e.int(),e.gte(1),e.lte(100)))});const U=e.object({id:e.string(),title:e.string(),description:e.nullable(e.string()),status:e.enum([`active`,`inactive`]),createdAt:e.date(),updatedAt:e.date()});e.object({data:e.array(U),nextCursor:e.nullable(e.string()),limit:e.number(),links:e.object({self:e.string(),next:e.nullable(e.string())})}),e.object({surveyId:z});const W=V;e.object({data:e.object({...U.shape,questions:e.array(W)})}),e.object({surveyId:z,responseId:e.union([e.cuid2(),e.uuid()])});const G=e.catch(e.object({type:e.enum([`embedded`,`popover`,`modal`]),version:e.string().check(e.trim(),e.minLength(1),e.maxLength(50)),build:e.string().check(e.trim(),e.minLength(1),e.maxLength(50))}).partial(),{}),K=e.record(e.string(),e.union([e.string().check(e.trim(),e.maxLength(2048)),e.number(),e.array(e.string().check(e.trim(),e.maxLength(2048))).check(e.maxLength(1024)),A])),q=e.string().check(e.trim(),e.maxLength(1e3)),J=e.record(q,q).check(e.refine(e=>Object.keys(e).length<=20,`At most 20 metadata entries are allowed.`));e.object({respondent:e.string().check(e.trim(),e.minLength(1),e.maxLength(2048)),data:K,metadata:J,telemetry:e.optional(G)}),e.object({id:e.string(),createdAt:e.date()}),e.object({surveyId:z,respondent:e.string().check(e.trim(),e.minLength(1),e.maxLength(2048))}),e.object({surveyId:z,respondent:e.string().check(e.trim(),e.minLength(1),e.maxLength(2048))}),e.object({surveyId:z});const Y=e.object({lastRespondedAt:e.nullable(e.union([e.iso.datetime(),e.date()])),lastViewedAt:e.nullable(e.union([e.iso.datetime(),e.date()])),lastDismissedAt:e.nullable(e.union([e.iso.datetime(),e.date()]))});e.object({type:e.enum([`view`,`dismiss`])}),e.object({}),e.object({surveyId:z}),e.object({respondent:e.optional(e.string().check(e.trim(),e.minLength(1),e.maxLength(255))),after:e.optional(e.iso.datetime({offset:!0,local:!0})),before:e.optional(e.iso.datetime({offset:!0,local:!0})),cursor:e.optional(e.string().check(e.minLength(1),e.maxLength(100))),limit:e.optional(e.number().check(e.int(),e.gte(1),e.lte(100)))});const X=e.object({id:e.string(),respondent:e.string(),data:K,clientMetadata:e.record(e.string(),e.string()),createdAt:e.date()});e.object({data:e.array(X),nextCursor:e.nullable(e.string()),limit:e.number(),links:e.object({self:e.string(),next:e.nullable(e.string())})});const Z=e.number().check(e.int(),e.gte(0));e.object({data:e.object({totalViews:Z,uniqueViewers:Z,totalDismissals:Z,uniqueDismissers:Z,totalResponses:Z,uniqueResponders:Z})}),e.object({questionIds:e.array(e.string()).check(e.minLength(1)),timeRange:e.union([e.enum([`last-7-days`,`last-30-days`]),e.string().check(e.regex(/^q[1-4]-\d{4}$/)),e.string().check(e.regex(/^custom_\d{4}-\d{2}-\d{2}_\d{4}-\d{2}-\d{2}$/))])});const Q=e.record(e.string(),e.record(e.string(),e.number()));e.object({data:e.object({current:Q,previousQuarter:e.nullable(Q)})});export{P as a,R as c,u as d,L as i,S as l,H as n,N as o,j as r,I as s,Y as t,C as u};