@opengovsg/confetti 0.4.0 → 0.5.1

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.
@@ -0,0 +1,5 @@
1
+ import{A as e,B as t,D as n,E as r,F as i,G as a,H as o,I as s,J as c,K as l,L as u,M as d,N as f,O as p,P as m,R as h,T as g,U as _,V as ee,W as v,_ as te,b as ne,c as re,d as ie,g as ae,h as oe,it as se,j as ce,k as y,m as le,t as ue,u as de,w as fe,x as pe,z as me}from"./Button-giwEer5K.js";import{i as he,r as ge,t as _e}from"./internals-B5GhpjgM.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(e){if(!d(this.root,e))throw Error(`Cannot set currentNode to a node that is not contained by the root node.`);let t=[],n=e,r=e;for(this._currentNode=e;n&&n!==this.root;)if(n.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let e=n,i=this._doc.createTreeWalker(e,this.whatToShow,{acceptNode:this._acceptNode});t.push(i),i.currentNode=r,this._currentSetFor.add(i),n=r=e.host}else n=n.parentNode;let i=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});t.push(i),i.currentNode=r,this._currentSetFor.add(i),this._walkerStack=t}get doc(){return this._doc}firstChild(){let e=this.currentNode,t=this.nextNode();return d(e,t)?(t&&(this.currentNode=t),t):(this.currentNode=e,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 s()?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=ee(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=o(),[t,n]=O(()=>e?{width:0,height:0}:P());return T(()=>{let e=e=>{n(t=>e.width===t.width&&e.height===t.height?t:e)},t=()=>{N&&N.scale>1||e(P())},r,a=t=>{N&&N.scale>1||M(i(t))&&(r=requestAnimationFrame(()=>{let t=m();(!t||!M(t))&&e({width:document.documentElement.clientWidth,height:document.documentElement.clientHeight})}))};return e(P()),l()&&window.addEventListener(`blur`,a,!0),N?N.addEventListener(`resize`,t):window.addEventListener(`resize`,t),()=>{cancelAnimationFrame(r),l()&&window.removeEventListener(`blur`,a,!0),N?N.removeEventListener(`resize`,t):window.removeEventListener(`resize`,t)}},[]),t}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 _(()=>{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){_(()=>{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(e,t){let n=h(e?.[0]),r=t instanceof n.Element?{root:t}:t,i=r?.root??document.body,a=r?.shouldUseInert&&Ie,o=new Set(e),c=new Set,l=e=>a&&e instanceof n.HTMLElement?e.inert:e.getAttribute(`aria-hidden`)===`true`,f=(e,t)=>{a&&e instanceof n.HTMLElement?e.inert=t:t?e.setAttribute(`aria-hidden`,`true`):(e.removeAttribute(`aria-hidden`),e instanceof n.HTMLElement&&(e.inert=!1))},p=new Set;if(s())for(let t of e){let e=t;for(;e&&e!==i;){let t=e.getRootNode();`shadowRoot`in t&&p.add(t.shadowRoot),e=t.parentNode}}let m=e=>{for(let t of e.querySelectorAll(`[data-live-announcer], [data-react-aria-top-layer]`))o.add(t);let t=e=>{if(c.has(e)||o.has(e)||e.parentElement&&c.has(e.parentElement)&&e.parentElement.getAttribute(`role`)!==`row`)return NodeFilter.FILTER_REJECT;for(let t of o)if(d(e,t))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},n=Oe(u(e),e,NodeFilter.SHOW_ELEMENT,{acceptNode:t}),r=t(e);if(r===NodeFilter.FILTER_ACCEPT&&g(e),r!==NodeFilter.FILTER_REJECT){let e=n.nextNode();for(;e!=null;)g(e),e=n.nextNode()}},g=e=>{let t=F.get(e)??0;l(e)&&t===0||(t===0&&f(e,!0),c.add(e),F.set(e,t+1))};I.length&&I[I.length-1].disconnect(),m(i);let _=new MutationObserver(e=>{for(let t of e)if(t.type===`childList`){if(t.target.isConnected&&![...o,...c].some(e=>d(e,t.target)))for(let e of t.addedNodes)(e instanceof HTMLElement||e instanceof SVGElement)&&Le(e)?o.add(e):e instanceof Element&&m(e);if(s()){for(let e of p)if(!e.isConnected){_.disconnect();break}}}});_.observe(i,{childList:!0,subtree:!0});let ee=new Set;if(s())for(let e of p){let t=new MutationObserver(e=>{for(let t of e)if(t.type===`childList`){if(t.target.isConnected&&![...o,...c].some(e=>d(e,t.target)))for(let e of t.addedNodes)(e instanceof HTMLElement||e instanceof SVGElement)&&Le(e)?o.add(e):e instanceof Element&&m(e);if(s()){for(let e of p)if(!e.isConnected){_.disconnect();break}}}});t.observe(e,{childList:!0,subtree:!0}),ee.add(t)}let v={visibleNodes:o,hiddenNodes:c,observe(){_.observe(i,{childList:!0,subtree:!0})},disconnect(){_.disconnect()}};return I.push(v),()=>{if(_.disconnect(),s())for(let e of ee)e.disconnect();for(let e of c){let t=F.get(e);t!=null&&(t===1?(f(e,!1),F.delete(e)):F.set(e,t-1))}v===I[I.length-1]?(I.pop(),I.length&&I[I.length-1].observe()):I.splice(I.indexOf(v),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=o(),[t,n]=O(We);return T(()=>(L.size===0&&window.addEventListener(`languagechange`,Ge),L.add(n),()=>{L.delete(n),L.size===0&&window.removeEventListener(`languagechange`,Ge)}),[]),e?{locale:typeof window<`u`&&window[He]||`en-US`,direction:`ltr`}:t}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,a=D(null),o=D(null),s=D([]),{parentNode:c}=w(st)||{},l=E(()=>new wt({scopeRef:s}),[s]);_(()=>{let e=c||q.root;if(q.getTreeNode(e.scopeRef)&&z&&!W(z,e.scopeRef)){let t=q.getTreeNode(z);t&&(e=t)}e.addChild(l),q.addNode(l)},[l,c]),_(()=>{let e=q.getTreeNode(s);e&&(e.contain=!!n)},[n]),_(()=>{let e=a.current?.nextSibling,t=[],n=e=>e.stopPropagation();for(;e&&e!==o.current;)t.push(e),e.addEventListener(ct,n),e=e.nextSibling;return s.current=t,()=>{for(let e of t)e.removeEventListener(ct,n)}},[t]),yt(s,r,n),pt(s,n),xt(s,r,n),vt(s,i),T(()=>{let e=m(u(s.current?s.current[0]:void 0)),t=null;if(H(e,s.current)){for(let n of q.traverse())n.scopeRef&&H(e,n.scopeRef.current)&&(t=n);t===q.getTreeNode(s)&&(z=t.scopeRef)}},[s]),_(()=>()=>{let e=q.getTreeNode(s)?.parent?.scopeRef??null;(s===z||W(s,z))&&(!e||q.getTreeNode(e))&&(z=e),q.removeTreeNode(s)},[s]);let d=E(()=>ut(s),[]),f=E(()=>({focusManager:d,parentNode:l}),[l,d]);return b.createElement(st.Provider,{value:f},b.createElement(`span`,{"data-focus-scope-start":!0,hidden:!0,ref:a}),t,b.createElement(`span`,{"data-focus-scope-end":!0,hidden:!0,ref:o}))}function ut(e){return{focusNext(t={}){let n=e.current,{from:r,tabbable:i,wrap:a,accept:o}=t,s=r||m(u(n[0]??void 0)),c=n[0].previousElementSibling,l=K(B(n),{tabbable:i,accept:o},n);l.currentNode=H(s,n)?s:c;let d=l.nextNode();return!d&&a&&(l.currentNode=c,d=l.nextNode()),d&&G(d,!0),d},focusPrevious(t={}){let n=e.current,{from:r,tabbable:i,wrap:a,accept:o}=t,s=r||m(u(n[0]??void 0)),c=n[n.length-1].nextElementSibling,l=K(B(n),{tabbable:i,accept:o},n);l.currentNode=H(s,n)?s:c;let d=l.previousNode();return!d&&a&&(l.currentNode=c,d=l.previousNode()),d&&G(d,!0),d},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(u(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)).filter(e=>!e.form);let t=e.form.elements.namedItem(e.name),n=h(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);_(()=>{let o=e.current;if(!t){r.current&&=(cancelAnimationFrame(r.current),void 0);return}let s=u(o?o[0]:void 0),c=t=>{if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey||!V(e)||t.isComposing)return;let n=m(s),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 h(a).HTMLInputElement&&a.select())},l=t=>{(!z||W(z,e))&&H(i(t),e.current)?(z=e,n.current=i(t)):V(e)&&!U(i(t),e)?n.current?n.current.focus():z&&z.current&&_t(z.current):V(e)&&(n.current=i(t))},d=t=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{let r=ie(),o=(r===`virtual`||r===null)&&a()&&v(),c=m(s);if(!o&&c&&V(e)&&!U(c,e)){z=e;let r=i(t);r&&r.isConnected?(n.current=r,n.current?.focus()):z.current&&_t(z.current)}})};return s.addEventListener(`keydown`,c,!1),s.addEventListener(`focusin`,l,!1),o?.forEach(e=>e.addEventListener(`focusin`,l,!1)),o?.forEach(e=>e.addEventListener(`focusout`,d,!1)),()=>{s.removeEventListener(`keydown`,c,!1),s.removeEventListener(`focusin`,l,!1),o?.forEach(e=>e.removeEventListener(`focusin`,l,!1)),o?.forEach(e=>e.removeEventListener(`focusout`,d,!1))}},[e,t]),_(()=>()=>{r.current&&cancelAnimationFrame(r.current)},[r])}function mt(e){return U(e)}function H(e,t){return!e||!t?!1:t.some(t=>d(t,e))}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{de(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(m(u(e.current?e.current[0]:void 0)),z.current)&&e.current&&_t(e.current)),n.current=!1},[e])}function yt(e,t,n){_(()=>{if(t||n)return;let r=e.current,a=u(r?r[0]:void 0),o=t=>{let n=i(t);H(n,e.current)?z=e:mt(n)||(z=null)};return a.addEventListener(`focusin`,o,!1),r?.forEach(e=>e.addEventListener(`focusin`,o,!1)),()=>{a.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`?m(u(e.current?e.current[0]:void 0)):null);_(()=>{let r=e.current,i=u(r?r[0]:void 0);if(!t||n)return;let a=()=>{(!z||W(z,e))&&H(m(i),e.current)&&(z=e)};return i.addEventListener(`focusin`,a,!1),r?.forEach(e=>e.addEventListener(`focusin`,a,!1)),()=>{i.removeEventListener(`focusin`,a,!1),r?.forEach(e=>e.removeEventListener(`focusin`,a,!1))}},[e,n]),_(()=>{let r=u(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]),_(()=>{let n=u(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=m(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(e,t,n){let i=t?.tabbable?r:g,a=u(e?.nodeType===Node.ELEMENT_NODE?e:null),o=Oe(a,e||a,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return d(t?.from,e)||t?.tabbable&&e.tagName===`INPUT`&&e.getAttribute(`type`)===`radio`&&(!ft(e)||o.currentNode.tagName===`INPUT`&&o.currentNode.type===`radio`&&o.currentNode.name===e.name)?NodeFilter.FILTER_REJECT:i(e)&&(!n||H(e,n))&&(!t?.accept||t.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t?.from&&(o.currentNode=t.from),o}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(le.Provider,{value:t},e)}function Ot(e){let{ref:t,onInteractOutside:r,isDisabled:i,onInteractOutsideStart:a}=e,o=D({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}),s=n(e=>{r&&kt(e,t)&&(a&&a(e),o.current.isPointerDown=!0)}),c=n(e=>{r&&r(e)});T(()=>{let e=o.current;if(i)return;let n=t.current,r=u(n);if(typeof PointerEvent<`u`){let n=n=>{e.isPointerDown&&kt(n,t)&&c(n),e.isPointerDown=!1};return r.addEventListener(`pointerdown`,s,!0),r.addEventListener(`click`,n,!0),()=>{r.removeEventListener(`pointerdown`,s,!0),r.removeEventListener(`click`,n,!0)}}},[t,i])}function kt(e,t){if(e.button>0)return!1;let n=i(e);if(n){let e=n.ownerDocument;if(!e||!d(e.documentElement,n)||n.closest(`[data-react-aria-top-layer]`))return!1}return t.current?!e.composedPath().includes(t.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}=re({isDisabled:!n,onFocusWithinChange:e=>i(e)}),o=E(()=>r?t:t?{...At,...t}:At,[r]);return{visuallyHiddenProps:{...a,style:o}}}function Mt(t){let{children:n,elementType:r=`div`,isFocusable:i,style:a,...o}=t,{visuallyHiddenProps:s}=jt(t);return b.createElement(r,e(o,s),n)}const Nt=x({});function Pt(){return w(Nt)??{}}const Ft=b.createContext(null);function It(e){let t=o(),{portalContainer:n=t?null:document.body,isExiting:r}=e,[i,a]=O(!1),s=E(()=>({contain:i,setContain:a}),[i,a]),{getContainer:c}=Pt();if(!e.portalContainer&&c&&(n=c()),!n)return null;let l=e.children;return e.disableFocusManagement||(l=b.createElement(lt,{restoreFocus:!0,contain:(e.shouldContainFocus||i)&&!r},l)),l=b.createElement(Ft.Provider,{value:s},b.createElement(Dt,null,l)),Se.createPortal(l,n)}function Lt(){let e=w(Ft)?.setContain;_(()=>{e?.(!0)},[e])}function Rt(e,n){let{role:r=`dialog`}=e,i=t();i=e[`aria-label`]?void 0:i;let a=D(!1);return T(()=>{if(n.current&&!f(n.current)){de(n.current);let e=setTimeout(()=>{(m()===n.current||m()===document.body)&&(a.current=!0,n.current&&(n.current.blur(),de(n.current)),a.current=!1)},500);return()=>{clearTimeout(e)}}},[n]),Lt(),D(!1),T(()=>{}),{dialogProps:{...y(e,{labelable:!0}),role:r,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:a,isDismissable:o=!1,isKeyboardDismissDisabled:s=!1,shouldCloseOnInteractOutside:c}=e,l=D(void 0);T(()=>{if(a&&!J.includes(t))return J.push(t),()=>{let e=J.indexOf(t);e>=0&&J.splice(e,1)}},[a,t]);let u=()=>{J[J.length-1]===t&&n&&n()},d=e=>{let n=J[J.length-1];l.current=n,(!c||c(i(e)))&&n===t&&e.stopPropagation()},f=e=>{(!c||c(i(e)))&&(J[J.length-1]===t&&e.stopPropagation(),l.current===t&&u()),l.current=void 0},p=e=>{e.key===`Escape`&&!s&&!e.nativeEvent.isComposing&&(e.stopPropagation(),e.preventDefault(),u())};Ot({ref:t,onInteractOutside:o&&a?f:void 0,onInteractOutsideStart:d});let{focusWithinProps:m}=re({isDisabled:!r,onBlurWithin:e=>{!e.relatedTarget||ht(e.relatedTarget)||(!c||c(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;_(()=>{if(!t)return X++,X===1&&(wn=l()?Dn():En()),()=>{X--,X===0&&wn()}},[t])}function En(){let e=window.innerWidth-document.documentElement.clientWidth;return me(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=i(e);t=j(r)?r:Ae(r,!0),n=!1;let a=r.ownerDocument.defaultView.getSelection();a&&!a.isCollapsed&&a.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)},a=document.createElement(`style`),o=fe();o&&(a.nonce=o),a.textContent=`@layer {
2
+ * {
3
+ overscroll-behavior: contain;
4
+ }
5
+ }`,document.head.prepend(a);let s=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()}},c=e=>{let t=i(e),n=e.relatedTarget;n&&M(n)?(n.focus({preventScroll:!0}),kn(n,M(t))):n||(t.parentElement?.closest(`[tabindex]`))?.focus({preventScroll:!0})},l=HTMLElement.prototype.focus;HTMLElement.prototype.focus=function(e){let t=m(),n=t!=null&&M(t);l.call(this,{...e,preventScroll:!0}),(!e||!e.preventScroll)&&kn(this,n)};let u=me(On(document,`touchstart`,r,{passive:!1,capture:!0}),On(document,`touchmove`,s,{passive:!1,capture:!0}),On(document,`blur`,c,!0));return()=>{e(),u(),a.remove(),HTMLElement.prototype.focus=l}}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(t,n,r){let{overlayProps:i,underlayProps:a}=Cn({...t,isOpen:n.isOpen,onClose:n.close},r);return Tn({isDisabled:!n.isOpen}),Lt(),T(()=>{if(n.isOpen&&r.current)return Re([r.current],{shouldUseInert:!0})},[n.isOpen,r]),{modalProps:e(i),underlayProps:a}}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(t,n){let r=t[`aria-labelledby`];[t,n]=ae(t,n,Nn);let{dialogProps:i,titleProps:a}=Rt({...t,"aria-labelledby":r},n),o=w(Q);!i[`aria-label`]&&!i[`aria-labelledby`]&&t[`aria-labelledby`]&&(i[`aria-labelledby`]=t[`aria-labelledby`]);let s=te({defaultClassName:`react-aria-Dialog`,className:t.className,style:t.style,children:t.children,values:{close:o?.close||(()=>{})}}),c=y(t,{global:!0});return b.createElement(pe.section,{...e(c,s,i),render:t.render,ref:n,slot:t.slot||void 0},b.createElement(oe,{values:[[Te,{slots:{[ne]:{},title:{...a,level:2}}}],[ue,{slots:{[ne]:{},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,t){[e,t]=ae(e,t,Fn);let n=w(Q),r=Mn(e),i=e.isOpen!=null||e.defaultOpen!=null||!n?r:n,a=p(t),s=D(null),c=Pe(a,i.isOpen),l=Pe(s,i.isOpen),u=c||l||e.isExiting||!1,d=o();return!i.isOpen&&!u||d?null:b.createElement(Bn,{...e,state:i,isExiting:u,overlayRef:a,modalRef:s})}const zn=S(Rn);function Bn({UNSTABLE_portalContainer:t,...n}){let r=n.modalRef,{state:i}=n,{modalProps:a,underlayProps:o}=jn(n,i,r),s=Ne(n.overlayRef)||n.isEntering||!1,c=te({...n,defaultClassName:`react-aria-ModalOverlay`,values:{isEntering:s,isExiting:n.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:n.isExiting,portalContainer:t},b.createElement(pe.div,{...e(y(n,{global:!0}),o),...c,style:d,ref:n.overlayRef,"data-entering":s||void 0,"data-exiting":n.isExiting||void 0},b.createElement(oe,{values:[[In,{modalProps:a,modalRef:r,isExiting:n.isExiting,isDismissable:n.isDismissable}],[Q,i]]},c.children)))}function Vn(t){let{modalProps:n,modalRef:r,isExiting:i,isDismissable:a}=w(In),o=w(Q),s=p(E(()=>ce(t.modalRef,r),[t.modalRef,r])),c=Ne(s),l=te({...t,defaultClassName:`react-aria-Modal`,values:{isEntering:c,isExiting:i,state:o}});return b.createElement(pe.div,{...e(y(t,{global:!0}),n),...l,ref:s,"data-entering":c||void 0,"data-exiting":i||void 0},a&&b.createElement(Sn,{onDismiss:o.close}),l.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:o}=Kn(),s=Un(),l=s.version??`0.5.1`,u=s.build,d=D(!1),[f,p]=O(),m=se({publishableKey:n,apiBaseUrl:a});T(()=>{(async()=>{d.current=!1,p(void 0);try{let e=await m.get(`api/v1/cfti/${t}`).json(),n=c.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:{...o!==void 0&&{type:o},version:l,...u&&{build:u}}}})},[u,m,i,r,t,l,o]),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};
@@ -0,0 +1,65 @@
1
+ //#region src/components/container/ModalContainer.d.ts
2
+ interface ModalContainerProps {
3
+ closeOnFinishMs?: number | null;
4
+ isDismissable?: boolean;
5
+ classNames?: {
6
+ overlay?: string;
7
+ modal?: string;
8
+ dialog?: string;
9
+ closeButton?: string;
10
+ icon?: string;
11
+ };
12
+ /**
13
+ * Invoked when the user dismisses the survey via the close button or the
14
+ * overlay before submitting. Not invoked on auto-close after finish, on the
15
+ * Thank-You button, or on any close after submission, all of which close a
16
+ * completed survey rather than dismiss it.
17
+ */
18
+ onDismiss?: () => void;
19
+ /**
20
+ * Invoked on every close path: the close button, the overlay, the
21
+ * close-on-finish timer, and the Thank-You button. Lets the owning wrapper
22
+ * tear the widget down.
23
+ */
24
+ onClose?: () => void;
25
+ children: React.ReactNode | ((props: {
26
+ setIsSubmitted: () => void;
27
+ setIsFinished: () => void;
28
+ }) => React.ReactNode);
29
+ }
30
+ type ModalContentProps = ModalContainerProps & Required<Pick<ModalContainerProps, 'closeOnFinishMs' | 'isDismissable'>> & {
31
+ /**
32
+ * Submitted flag owned by ModalContainer so its overlay handler can tell a
33
+ * post-submission close apart from a dismissal. Standalone consumers may
34
+ * omit it, in which case closes count as dismissals until the render
35
+ * prop's `setIsFinished` reports the submission has settled.
36
+ */
37
+ isSubmitted?: boolean;
38
+ /**
39
+ * Invoked when the survey content reports submission through the render
40
+ * prop's `setIsSubmitted`. Fires when the Thank-You view is shown, before
41
+ * the submission network call settles. When omitted, the render prop's
42
+ * `setIsSubmitted` is a silent no-op, so `isSubmitted` never flips.
43
+ */
44
+ onSubmitted?: () => void;
45
+ };
46
+ declare const ModalContent: ({
47
+ children,
48
+ classNames,
49
+ isDismissable,
50
+ onDismiss,
51
+ onClose,
52
+ closeOnFinishMs,
53
+ isSubmitted,
54
+ onSubmitted
55
+ }: ModalContentProps) => import("react").JSX.Element;
56
+ declare const ModalContainer: ({
57
+ children,
58
+ classNames,
59
+ onDismiss,
60
+ onClose,
61
+ isDismissable,
62
+ closeOnFinishMs
63
+ }: ModalContainerProps) => import("react").JSX.Element;
64
+ //#endregion
65
+ export { ModalContainerProps as n, ModalContent as r, ModalContainer as t };
@@ -1,2 +1,2 @@
1
- import { r as ModalContent } from "./ModalContainer-CPX4GCql.js";
1
+ import { r as ModalContent } from "./ModalContainer-CbbuRuFl.js";
2
2
  export { ModalContent as UnstableModalContent };
@@ -1 +1 @@
1
- import{n as e}from"./ModalContainer-B3QLAjgy.js";export{e as UnstableModalContent};
1
+ import{n as e}from"./ModalContainer-B-WGlRn4.js";export{e as UnstableModalContent};
@@ -1,6 +1,6 @@
1
- import { n as ModalContainerProps, t as ModalContainer } from "./ModalContainer-CPX4GCql.js";
2
- import { a as MultiSelectQuestionProperties, c as StatementQuestionProperties, l as TextQuestionProperties, n as ConfettiState, o as RatingQuestionProperties, r as Question, s as SingleSelectQuestionProperties, t as Answer } from "./types-CJY8TUUa.js";
3
- import { a as Question$1, c as ConfettiProviderProps, d as ConfettiControllerProps, i as BaseFieldProps, l as useConfetti, n as ConfettiProps, o as ConfettiContext, r as BugReportOptions, s as ConfettiProvider, t as Confetti, u as ConfettiController } from "./Confetti-X1LYIVnH.js";
1
+ import { n as ModalContainerProps, t as ModalContainer } from "./ModalContainer-CbbuRuFl.js";
2
+ import { _ as TextQuestionProperties, g as StatementQuestionProperties, h as SingleSelectQuestionProperties, i as ConfettiState, m as RatingQuestionProperties, p as MultiSelectQuestionProperties, t as Answer, u as Question } from "./types-C-q5VrLk.js";
3
+ import { _ as useSurvey, a as BaseFieldProps, c as ConfettiProviderProps, d as RespondentVisibilityProviderProps, g as SurveyProviderProps, h as SurveyProvider, i as BugReportOptions, 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-ClwOwSrM.js";
4
4
  import { HTMLAttributes, JSX, PropsWithChildren, SVGProps } from "react";
5
5
 
6
6
  //#region src/components/container/PopoverContainer.d.ts
@@ -11,9 +11,21 @@ interface PopoverContainerProps {
11
11
  closeButton?: string;
12
12
  icon?: string;
13
13
  };
14
+ /**
15
+ * Invoked when the user dismisses the survey via the close button before
16
+ * submitting. Not invoked on auto-close after finish, on the Thank-You
17
+ * button, or on any close after submission, all of which close a completed
18
+ * survey rather than dismiss it.
19
+ */
14
20
  onDismiss?: () => void;
21
+ /**
22
+ * Invoked on every close path: the close button, the close-on-finish timer,
23
+ * and the Thank-You button. Lets the owning wrapper tear the widget down.
24
+ */
25
+ onClose?: () => void;
15
26
  containerProps?: Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
16
27
  children: React.ReactNode | ((props: {
28
+ setIsSubmitted: () => void;
17
29
  setIsFinished: () => void;
18
30
  }) => React.ReactNode);
19
31
  }
@@ -22,6 +34,7 @@ declare const PopoverContainer: ({
22
34
  classNames,
23
35
  containerProps,
24
36
  onDismiss,
37
+ onClose,
25
38
  closeOnFinishMs
26
39
  }: PopoverContainerProps) => import("react").JSX.Element;
27
40
  //#endregion
@@ -199,11 +212,13 @@ interface ThankYouMessageProps {
199
212
  title?: string;
200
213
  description?: string;
201
214
  };
215
+ onClose?: () => void;
202
216
  }
203
217
  declare const ThankYouMessage: ({
204
218
  title,
205
219
  description,
206
- classNames
220
+ classNames,
221
+ onClose
207
222
  }: ThankYouMessageProps) => import("react").JSX.Element | null;
208
223
  //#endregion
209
224
  //#region src/components/presentation/Flow.d.ts
@@ -258,4 +273,4 @@ declare const DefaultConfettiTrigger: ({
258
273
  label
259
274
  }: DefaultConfettiTriggerProps) => import("react").JSX.Element | null;
260
275
  //#endregion
261
- export { type Answer, CloseButton, Confetti, ConfettiContext, ConfettiController, type ConfettiControllerProps, type ConfettiProps, ConfettiProvider, type ConfettiProviderProps, type ConfettiState, ConfettiTriggerIcon, DefaultConfettiTrigger, type DefaultConfettiTriggerProps, Embed, type EmbedProps, Flow, type FlowProps, FreeText, type FreeTextProps, ModalContainer, type ModalContainerProps, MultiChoice, type MultiChoiceProps, PopoverContainer, type PopoverContainerProps, type Question, Rating, type RatingProps, SingleChoice, type SingleChoiceProps, Statement, type StatementProps, SurveyQuestionFactory, type SurveyQuestionFactoryProps, ThankYouMessage, useConfetti };
276
+ export { type Answer, type BaseConfettiProps, CloseButton, Confetti, ConfettiController, type ConfettiControllerProps, type ConfettiProps, ConfettiProvider, type ConfettiProviderProps, type ConfettiState, ConfettiTriggerIcon, DefaultConfettiTrigger, type DefaultConfettiTriggerProps, Embed, type EmbedProps, Flow, type FlowProps, FreeText, type FreeTextProps, ModalContainer, type ModalContainerProps, MultiChoice, type MultiChoiceProps, PopoverContainer, type PopoverContainerProps, type Question, Rating, type RatingProps, RespondentVisibilityContext, RespondentVisibilityProvider, type RespondentVisibilityProviderProps, SingleChoice, type SingleChoiceProps, Statement, type StatementProps, SurveyContext, SurveyProvider, type SurveyProviderProps, SurveyQuestionFactory, type SurveyQuestionFactoryProps, ThankYouMessage, useRespondentVisibility, useSurvey };
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,f as r,i,l as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./DefaultConfettiTrigger-JDSIZWbW.js";import{B as m,H as h,V as g,r as _,t as v}from"./ModalContainer-B3QLAjgy.js";export{_ as CloseButton,l as Confetti,m as ConfettiContext,o as ConfettiController,g as ConfettiProvider,s as ConfettiTriggerIcon,f as DefaultConfettiTrigger,n as Embed,r as Flow,p as FreeText,v as ModalContainer,a as MultiChoice,u as PopoverContainer,t as Rating,d as SingleChoice,c as Statement,e as SurveyQuestionFactory,i as ThankYouMessage,h as useConfetti};
1
+ import{n as e,t}from"./DefaultConfettiTrigger-DFJBQ35H.js";import{a as n,o as r,r as i,s as a,t as o}from"./ModalContainer-B-WGlRn4.js";import{a as s,c,d as l,f as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./Embed-J5cfWjpk.js";import{ErrorBoundary as x}from"react-error-boundary";import{Fragment as S,jsx as C}from"react/jsx-runtime";const w=({children:e,respondent:t,isSurveyVisible:n,...i})=>{let{respondent:a}=g();return C(r,{...i,respondent:a,children:e})},T=({children:e,...t})=>C(u,{...t,children:C(w,{...t,children:e})}),E=({children:e,onFinished:t,shouldAutoSubmit:n,...r})=>C(x,{fallback:C(S,{}),children:C(T,{...r,children:C(p,{shouldAutoSubmit:n,onFinished:t,children:e})})});export{i as CloseButton,E as Confetti,p as ConfettiController,T as ConfettiProvider,e as ConfettiTriggerIcon,t as DefaultConfettiTrigger,y as Embed,m as Flow,f as FreeText,o as ModalContainer,c as MultiChoice,b as PopoverContainer,v as Rating,l as RespondentVisibilityContext,u as RespondentVisibilityProvider,h as SingleChoice,s as Statement,n as SurveyContext,r as SurveyProvider,d as SurveyQuestionFactory,_ as ThankYouMessage,g as useRespondentVisibility,a as useSurvey};
package/build/index.d.ts CHANGED
@@ -1,43 +1,108 @@
1
- import { c as ConfettiProviderProps, n as ConfettiProps } from "./Confetti-X1LYIVnH.js";
1
+ import { a as Containable, c as OptionallyDismissable, l as Proxyable, n as Closable, o as Dismissable, r as ConfettiContainer, s as Finishable } from "./types-C-q5VrLk.js";
2
+ import { t as BaseConfettiProps } from "./Confetti-ClwOwSrM.js";
2
3
 
3
- //#region src/templates/EmbeddedConfettiContent.d.ts
4
- declare const EmbeddedConfetti: (props: ConfettiProps) => import("react").JSX.Element;
5
- //#endregion
6
- //#region src/templates/ModalConfettiContent.d.ts
7
- interface ModalConfettiProps extends ConfettiProps {
8
- closeOnFinishMs?: number | null;
9
- onDismiss?: () => void;
10
- isDismissable?: boolean;
4
+ //#region src/contracts/api.d.ts
5
+ type Template = 'TriggerPopover' | 'Popover' | 'Modal' | 'Embedded' | 'Stepper';
6
+ interface MountHandle {
7
+ readonly id: number;
8
+ }
9
+ interface MountPropsBase extends Finishable {
10
+ surveyId: string;
11
+ publishableKey: string;
12
+ respondent: string;
13
+ metadata?: Record<string, string>;
14
+ apiBaseUrl?: string;
15
+ telemetry?: Partial<{
16
+ version?: string;
17
+ }>;
18
+ options?: unknown;
19
+ }
20
+ interface PopoverMountProps extends MountPropsBase, Dismissable {}
21
+ interface ModalMountProps extends MountPropsBase, OptionallyDismissable {}
22
+ interface EmbeddedMountProps extends MountPropsBase, Closable {}
23
+ interface StepperMountProps extends MountPropsBase, Closable {}
24
+ interface TriggerPopoverMountProps extends PopoverMountProps {
25
+ isOpen?: boolean;
26
+ }
27
+ interface MountPropsByTemplate {
28
+ Popover: PopoverMountProps;
29
+ Modal: ModalMountProps;
30
+ Embedded: EmbeddedMountProps;
31
+ Stepper: StepperMountProps;
32
+ TriggerPopover: TriggerPopoverMountProps;
33
+ }
34
+ interface ConfettiApi {
35
+ readonly version: string;
36
+ readonly protocolVersion: typeof EXPECTED_WIRE_PROTOCOL_VERSION;
37
+ readonly channel: 'stable';
38
+ mount<T extends Template>(options: {
39
+ template: T;
40
+ element: HTMLElement;
41
+ props: MountPropsByTemplate[T];
42
+ }): MountHandle;
43
+ update<T extends Template>(handle: MountHandle, props: MountPropsByTemplate[T]): void;
44
+ unmount(handle: MountHandle): void;
45
+ }
46
+ declare const EXPECTED_WIRE_PROTOCOL_VERSION = 1;
47
+ declare global {
48
+ interface Window {
49
+ __confetti?: ConfettiApi;
50
+ }
11
51
  }
12
- declare const ModalConfetti: ({
13
- onDismiss,
14
- closeOnFinishMs,
15
- isDismissable,
16
- ...props
17
- }: ModalConfettiProps) => import("react").JSX.Element;
18
52
  //#endregion
19
- //#region src/templates/PopoverConfettiContent.d.ts
20
- interface PopoverConfettiProps extends ConfettiProps {
53
+ //#region src/loader.d.ts
54
+ type SupportedChannel = 'stable';
55
+ //#endregion
56
+ //#region src/hosted/types.d.ts
57
+ /**
58
+ * Host-side options for loading and gating the hosted CDN bundle, layered on top
59
+ * of the shared survey config (`BaseConfettiProps`) by every hosted shell.
60
+ * `isSurveyVisible` is not declared here: it already arrives through
61
+ * `BaseConfettiProps`, which the shells extend.
62
+ */
63
+ interface HostedLoaderProps extends Proxyable {
21
64
  /**
22
- * The popover will automatically close this many milliseconds
23
- * after the survey is finished.
24
- * Set to `null` to disable automatic closing.
25
- * @default 3000
65
+ * Release channel of the hosted bundle and stylesheet to load.
66
+ * @default 'stable'
26
67
  */
27
- closeOnFinishMs?: number | null;
68
+ channel?: SupportedChannel;
69
+ /** Invoked on script-load failure. Default behaviour is silent no-op. */
70
+ onError?: (error: Error) => void;
71
+ }
72
+ //#endregion
73
+ //#region src/hosted/EmbeddedConfetti.d.ts
74
+ interface EmbeddedConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, Closable, Containable {}
75
+ declare function EmbeddedConfetti(props: EmbeddedConfettiProps): import("react").JSX.Element | null;
76
+ //#endregion
77
+ //#region src/hosted/ModalConfetti.d.ts
78
+ interface ModalConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, OptionallyDismissable {}
79
+ declare function ModalConfetti(props: ModalConfettiProps): import("react").JSX.Element | null;
80
+ //#endregion
81
+ //#region src/hosted/PopoverConfetti.d.ts
82
+ interface PopoverConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, Dismissable {}
83
+ declare function PopoverConfetti(props: PopoverConfettiProps): import("react").JSX.Element | null;
84
+ //#endregion
85
+ //#region src/hosted/StepperConfetti.d.ts
86
+ interface StepperConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps, Closable, Containable {}
87
+ declare function StepperConfetti(props: StepperConfettiProps): import("react").JSX.Element | null;
88
+ //#endregion
89
+ //#region src/hosted/TriggerPopoverConfetti.d.ts
90
+ interface TriggerRenderProps {
91
+ /** Opens the popover survey. */
92
+ onClick: () => void;
93
+ /** Whether the popover is currently open. */
94
+ isOpen: boolean;
95
+ /** Whether the respondent has already submitted the survey. */
96
+ isSubmitted: boolean;
97
+ }
98
+ interface TriggerPopoverConfettiProps extends Omit<BaseConfettiProps, 'apiBaseUrl'>, HostedLoaderProps {
28
99
  /**
29
- * Callback is invoked when the popover is explicitly dismissed.
100
+ * Renders the element that opens the popover. Receives the click handler and
101
+ * the open and submitted state. Defaults to the built-in trigger button.
30
102
  */
31
- onDismiss?: () => void;
103
+ trigger?: (renderProps: TriggerRenderProps) => React.ReactNode;
32
104
  }
33
- declare const PopoverConfetti: ({
34
- onDismiss,
35
- closeOnFinishMs,
36
- ...props
37
- }: PopoverConfettiProps) => import("react").JSX.Element;
38
- //#endregion
39
- //#region src/templates/StepperConfettiContent.d.ts
40
- declare const StepperConfetti: (props: ConfettiProps) => import("react").JSX.Element;
105
+ declare function TriggerPopoverConfetti(props: TriggerPopoverConfettiProps): import("react").JSX.Element | null;
41
106
  //#endregion
42
107
  //#region src/hooks/useVisibleAfterDelay.d.ts
43
108
  interface UseVisibleAfterDelayOptions {
@@ -79,25 +144,4 @@ declare const useVisibleAfterScroll: ({
79
144
  isVisible: boolean;
80
145
  };
81
146
  //#endregion
82
- //#region src/static/ConfettiTrigger.d.ts
83
- interface TriggerRenderProps {
84
- onClick: () => void;
85
- isWidgetOpen: boolean;
86
- hasSubmitted: boolean;
87
- }
88
- interface TriggerChildProps extends Pick<ConfettiProviderProps, 'publishableKey' | 'surveyId'> {
89
- onDismiss: () => void;
90
- }
91
- interface ConfettiTriggerProps extends Omit<ConfettiProviderProps, 'children' | 'alwaysRenderChildren'> {
92
- surveyId: string;
93
- publishableKey: string;
94
- trigger?: (renderProps: TriggerRenderProps) => React.ReactNode;
95
- children: (triggerProps: TriggerChildProps) => React.ReactNode;
96
- }
97
- declare const ConfettiTrigger: ({
98
- trigger,
99
- children,
100
- ...providerProps
101
- }: ConfettiTriggerProps) => import("react").JSX.Element;
102
- //#endregion
103
- export { ConfettiTrigger, type ConfettiTriggerProps, EmbeddedConfetti, ModalConfetti, PopoverConfetti, StepperConfetti, type TriggerChildProps, type TriggerRenderProps, useVisibleAfterDelay, useVisibleAfterPageVisits, useVisibleAfterScroll, useVisibleAfterSessionPageVisits };
147
+ export { type ConfettiContainer, EmbeddedConfetti, type EmbeddedConfettiProps, ModalConfetti, type ModalConfettiProps, PopoverConfetti, type PopoverConfettiProps, StepperConfetti, type StepperConfettiProps, TriggerPopoverConfetti, type TriggerPopoverConfettiProps, type TriggerRenderProps, useVisibleAfterDelay, useVisibleAfterPageVisits, useVisibleAfterScroll, useVisibleAfterSessionPageVisits };
package/build/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,d as t,f as n,i as r,m as i,p as a,r as o,t as s}from"./DefaultConfettiTrigger-JDSIZWbW.js";import{B as c,H as l,U as u,V as d,t as f}from"./ModalContainer-B3QLAjgy.js";import{ErrorBoundary as p}from"react-error-boundary";import{useCallback as m,useEffect as h,useMemo as g,useState as _}from"react";import{useLocalStorage as v,useSessionStorage as y}from"usehooks-ts";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";const C=n=>x(p,{fallback:x(b,{}),children:x(u,{type:`embedded`,children:x(a,{...n,shouldAutoSubmit:!1,children:({questions:i,update:a,isCompleted:o,submit:s,isSubmitted:c,errors:l})=>c?x(r,{}):x(t,{onSubmit:s,isCompleted:o,children:i.filter(({visible:e})=>!!e).map(t=>x(e,{question:t,error:l[t.id]||``,maskAllInputs:n.options?.bugReport?.maskAllInputs,onChange:e=>a({question:t.position,answer:e})},t.position))})})})}),w=({onDismiss:n,closeOnFinishMs:a,isDismissable:o,...s})=>x(p,{fallback:x(b,{}),children:x(u,{type:`modal`,children:x(d,{...s,children:x(f,{onDismiss:n,closeOnFinishMs:a,isDismissable:o,children:({setIsFinished:n})=>x(i,{...s,shouldAutoSubmit:!1,onFinished:()=>{n(),s.onFinished?.()},children:({questions:n,update:i,isCompleted:a,errors:o,submit:c,isSubmitted:l})=>l?x(r,{}):x(t,{onSubmit:c,isCompleted:a,children:n.filter(({visible:e})=>!!e).map(t=>x(e,{question:t,error:o[t.id]||``,maskAllInputs:s.options?.bugReport?.maskAllInputs,onChange:e=>i({question:t.position,answer:e})},t.position))})})})})})}),T=({onDismiss:t,closeOnFinishMs:a,...s})=>x(p,{fallback:x(b,{}),children:x(u,{type:`popover`,children:x(d,{...s,children:x(o,{onDismiss:t,closeOnFinishMs:a,children:({setIsFinished:t})=>x(i,{shouldAutoSubmit:!0,...s,onFinished:()=>{t(),s.onFinished?.()},children:({current:t,questions:i,update:a,isSubmitted:o})=>{let c=t===i.length-1;if(o)return x(r,{});let l=i[t];return l?x(n,{isLastQuestion:c,question:l,onSubmit:e=>a({question:t,answer:e}),children:t=>x(e,{maskAllInputs:s.options?.bugReport?.maskAllInputs,...t})},l.id):x(b,{})}})})})})}),E=t=>x(a,{...t,shouldAutoSubmit:!0,children:({current:i,questions:a,update:o,isSubmitted:s})=>{let c=i===a.length-1;if(s)return x(r,{});let l=a[i];return l?x(n,{isLastQuestion:c,question:l,onSubmit:e=>o({question:i,answer:e}),children:n=>x(e,{maskAllInputs:t.options?.bugReport?.maskAllInputs,...n})},l.id):x(b,{})}}),D=({delay:e})=>{let[t,n]=_(!1),r=g(()=>e,[]);return h(()=>{let e=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(e)},[]),{isVisible:t}},O=({visits:e,respondent:t})=>{let[n,r]=v(`cfti:${g(()=>window.location.pathname,[])}:visits:${t??``}`,0);return h(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:m(()=>r(0),[r])}},k=({visits:e,respondent:t})=>{let[n,r]=y(`cfti:${g(()=>window.location.pathname,[])}:visits:${t??``}`,0);return h(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:m(()=>r(0),[r])}},A=({threshold:e})=>{let[t,n]=_(()=>typeof window>`u`?!1:window.scrollY>=e);return h(()=>{let t=()=>{window.scrollY>=e&&n(!0)};return window.addEventListener(`scroll`,t,{passive:!0}),()=>window.removeEventListener(`scroll`,t)},[e]),{isVisible:t}},j=({trigger:e,children:t,publishableKey:n,surveyId:r})=>{let i=l(),[a,o]=_(!1),[s,u]=_(!1);if(!i.isVisible)return null;let d=()=>{o(!1)};return S(b,{children:[e({onClick:()=>o(!0),isWidgetOpen:a,hasSubmitted:s}),a&&x(c.Provider,{value:{...i,dismiss:()=>{i.dismiss(),d()},submit:async e=>{let t=await i.submit(e);return u(!0),t}},children:t({onDismiss:d,surveyId:r,publishableKey:n})})]})},M=({trigger:e=e=>x(s,{...e}),children:t,...n})=>x(p,{fallback:x(b,{}),children:x(d,{...n,alwaysRenderChildren:!0,children:x(j,{trigger:e,surveyId:n.surveyId,publishableKey:n.publishableKey,children:t})})});export{M as ConfettiTrigger,C as EmbeddedConfetti,w as ModalConfetti,T as PopoverConfetti,E as StepperConfetti,D as useVisibleAfterDelay,O as useVisibleAfterPageVisits,A as useVisibleAfterScroll,k as useVisibleAfterSessionPageVisits};
1
+ import{a as e,i as t,o as n,r,t as i}from"./DefaultConfettiTrigger-DFJBQ35H.js";import{it as a}from"./Button-giwEer5K.js";import{useCallback as o,useEffect as s,useMemo as c,useRef as l,useState as u}from"react";import{ErrorBoundary as d}from"react-error-boundary";import{useLocalStorage as f,useSessionStorage as p}from"usehooks-ts";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";const _=`confetti:ready`,v=`https://confetti.gov.sg`,y={promise:null,channel:null,url:null};function b(){y.promise=null,y.channel=null,y.url=null}function x(){y.promise=null}function S(e){return new URL(``,e).href}function C(e,t,n){let r=new URL(e);return r.pathname.endsWith(`/`)||(r.pathname+=`/`),new URL(`widget/v1/${t}.${n}`,r).href}function w(e=`stable`,t=v){if(typeof window>`u`)return Promise.reject(Error(`[confetti] No window found, SSR environments are not supported`));let n;try{n=S(t)}catch{return Promise.reject(Error(`[confetti] Invalid URL: ${t}`))}if(y.promise)return y.channel===e?y.url===n?y.promise:Promise.reject(Error(`[confetti] Cannot switch baseUrl from ${String(y.url)} to ${n} on the same page`)):Promise.reject(Error(`[confetti] Cannot switch channel from ${String(y.channel)} to ${e} on the same page`));let r=window.__confetti;if(r){let t=String(r.channel);return t===e?y.url!==null&&y.url!==n?Promise.reject(Error(`[confetti] Cannot switch URL from ${y.url} to ${n} on the same page`)):k(r):Promise.reject(Error(`[confetti] Cannot switch channel from ${t} to ${e} on the same page`))}let i=E(n,e);return y.channel=e,y.url=n,y.promise=i,i}function T(e=`stable`,t=v){if(typeof window>`u`)return Promise.resolve();let n;try{n=S(t)}catch{return Promise.reject(Error(`[confetti] Invalid URL: ${t}`))}return D(n,e)}async function E(e,t){let n=!!document.querySelector(`link[data-confetti-loader]`),r,i=new Promise((e,t)=>{r=setTimeout(()=>t(Error(`[confetti] Script load timeout`)),1e4)});try{let[,n]=await Promise.race([i,Promise.all([D(e,t),O(e,t)])]);return clearTimeout(r),x(),n}catch(e){throw clearTimeout(r),n||document.querySelector(`link[data-confetti-loader]`)?.remove(),document.querySelector(`script[data-confetti-loader]`)?.remove(),b(),e}}function D(e,t){return new Promise((n,r)=>{if(document.querySelector(`link[data-confetti-loader]`)){n();return}let i=document.createElement(`link`);i.rel=`stylesheet`,i.href=C(e,t,`css`),i.crossOrigin=`anonymous`,i.dataset.confettiLoader=``,i.onload=()=>n(),i.onerror=e=>{i.remove(),console.error(`[confetti] Stylesheet load failed. If your site uses a Content-Security-Policy, ensure style-src includes https://confetti.gov.sg (and script-src for the bundle).`),r(Error(`[confetti] Stylesheet load failed (check CSP allowlist for confetti.gov.sg)`,{cause:e}))},document.head.appendChild(i)})}function O(e,t){return new Promise((n,r)=>{let i=()=>{let e=window.__confetti;if(!e){r(Error(`[confetti] Ready event fired but global state is missing`));return}k(e).then(n,r)};if(window.addEventListener(_,i,{once:!0}),document.querySelector(`script[data-confetti-loader]`))return;let a=document.createElement(`script`);a.src=C(e,t,`js`),a.async=!0,a.crossOrigin=`anonymous`,a.dataset.confettiLoader=``,a.onerror=e=>{window.removeEventListener(_,i),console.error(`[confetti] Script load failed. If your site uses a Content-Security-Policy, ensure script-src includes https://confetti.gov.sg (and style-src for the CSS).`),r(Error(`[confetti] Script load failed (check CSP allowlist for confetti.gov.sg)`,{cause:e}))},document.head.appendChild(a)})}function k(e){let t=Number(e.protocolVersion);return Number.isFinite(t)?t===1?Promise.resolve(e):Promise.reject(Error(`[confetti] Wire protocol v${t} does not match expected v1`)):Promise.reject(Error(`[confetti] Wire protocol value is not a number (got ${typeof e.protocolVersion})`))}function A(e){let t=l(null),n=l(null),r=l(e.props),i=e.channel??`stable`,a=e.scriptBaseUrl??`https://confetti.gov.sg`;r.current=e.props,s(()=>{if(!e.element)return;let o=!1;return w(i,a).then(i=>{o||!e.element||(n.current=i,t.current=i.mount({template:e.template,element:e.element,props:r.current}))}).catch(t=>e.onError?.(t instanceof Error?t:Error(String(t)))),()=>{o=!0,t.current&&n.current&&n.current.unmount(t.current),t.current=null,n.current=null}},[i,a,e.element,e.template]),s(()=>{t.current&&n.current&&n.current.update(t.current,e.props)},[e.props])}function j(e){let[t,n]=u(null);return A({...e,element:t}),h(d,{fallback:h(m,{}),children:h(`div`,{ref:n,"data-confetti-mount":!0})})}function M(i){let o=e({surveyId:i.surveyId,override:i.respondent}),s=a({publishableKey:i.publishableKey,apiBaseUrl:i.proxyUrl}),{isAvailable:l,isSettled:f}=r({client:s,surveyId:i.surveyId}),{state:p,isSettled:g}=t({client:s,surveyId:i.surveyId,respondent:o}),_=n(p,i.isSurveyVisible),[v,y]=u(!1),b=f&&l&&g&&_&&!v,x=i.onFinished,S=i.onClose,C=c(()=>({surveyId:i.surveyId,publishableKey:i.publishableKey,respondent:o,metadata:i.metadata,apiBaseUrl:i.proxyUrl,telemetry:{version:`0.5.1`},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.5.1`},closeOnFinishMs:i.closeOnFinishMs,isDismissable:i.isDismissable,onFinished:x,onClose:()=>{y(!0),C?.()},onDismiss:()=>{S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.closeOnFinishMs,i.isDismissable,i.options,x,S,C]);return b?h(d,{fallback:h(m,{}),children:h(j,{template:`Modal`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:w})}):null}function P(i){let o=e({surveyId:i.surveyId,override:i.respondent}),s=a({publishableKey:i.publishableKey,apiBaseUrl:i.proxyUrl}),{isAvailable:l,isSettled:f}=r({client:s,surveyId:i.surveyId}),{state:p,isSettled:g}=t({client:s,surveyId:i.surveyId,respondent:o}),_=n(p,i.isSurveyVisible),[v,y]=u(!1),b=f&&l&&g&&_&&!v,x=i.onFinished,S=i.onDismiss,C=i.onClose,w=c(()=>({surveyId:i.surveyId,publishableKey:i.publishableKey,respondent:o,metadata:i.metadata,apiBaseUrl:i.proxyUrl,telemetry:{version:`0.5.1`},closeOnFinishMs:i.closeOnFinishMs,onFinished:x,onClose:()=>{y(!0),C?.()},onDismiss:()=>{S?.()},options:i.options}),[i.surveyId,i.publishableKey,o,i.metadata,i.proxyUrl,i.closeOnFinishMs,i.options,x,S,C]);return b?h(d,{fallback:h(m,{}),children:h(j,{template:`Popover`,channel:i.channel,scriptBaseUrl:i.proxyUrl,onError:i.onError,props:w})}):null}function F(i){let o=e({surveyId:i.surveyId,override:i.respondent}),s=a({publishableKey:i.publishableKey,apiBaseUrl:i.proxyUrl}),{isAvailable:l,isSettled:f}=r({client:s,surveyId:i.surveyId}),{state:p,isSettled:g}=t({client:s,surveyId:i.surveyId,respondent:o}),_=n(p,i.isSurveyVisible),[v,y]=u(!1),b=f&&l&&g&&_&&!v,x=i.onFinished,S=i.onClose,C=c(()=>({surveyId:i.surveyId,publishableKey:i.publishableKey,respondent:o,metadata:i.metadata,apiBaseUrl:i.proxyUrl,telemetry:{version:`0.5.1`},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.5.1`},isOpen:E,onFinished:()=>{k(!0),L?.()},onClose:()=>{D(!1)},onDismiss:()=>{D(!1)},options:f.options}),[f.surveyId,f.publishableKey,p,f.metadata,f.proxyUrl,f.options,E,L]);return w?g(d,{fallback:h(m,{}),children:[f.trigger?f.trigger({onClick:I,isOpen:E,isSubmitted:O}):h(i,{onClick:I,isWidgetOpen:E}),F?h(j,{template:`TriggerPopover`,channel:f.channel,scriptBaseUrl:f.proxyUrl,onError:f.onError,props:R}):null]}):null}const L=({delay:e})=>{let[t,n]=u(!1),r=c(()=>e,[]);return s(()=>{let e=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(e)},[]),{isVisible:t}},R=({visits:e,respondent:t})=>{let[n,r]=f(`cfti:${c(()=>window.location.pathname,[])}:visits:${t??``}`,0);return s(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:o(()=>r(0),[r])}},z=({visits:e,respondent:t})=>{let[n,r]=p(`cfti:${c(()=>window.location.pathname,[])}:visits:${t??``}`,0);return s(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:o(()=>r(0),[r])}},B=({threshold:e})=>{let[t,n]=u(()=>typeof window>`u`?!1:window.scrollY>=e);return s(()=>{let t=()=>{window.scrollY>=e&&n(!0)};return window.addEventListener(`scroll`,t,{passive:!0}),()=>window.removeEventListener(`scroll`,t)},[e]),{isVisible:t}};export{M as EmbeddedConfetti,N as ModalConfetti,P as PopoverConfetti,F as StepperConfetti,I as TriggerPopoverConfetti,L as useVisibleAfterDelay,R as useVisibleAfterPageVisits,B as useVisibleAfterScroll,z as useVisibleAfterSessionPageVisits};
@@ -1,4 +1,4 @@
1
- import { t as Answer, u as BinaryOperatorCondition } from "./types-CJY8TUUa.js";
1
+ import { t as Answer, v as BinaryOperatorCondition } from "./types-C-q5VrLk.js";
2
2
  import { z } from "zod/mini";
3
3
 
4
4
  //#region src/core/logic/routing.d.ts
@@ -0,0 +1,91 @@
1
+ import { a as Containable, c as OptionallyDismissable, d as WithProxyable, n as Closable, o as Dismissable, r as ConfettiContainer } from "./types-C-q5VrLk.js";
2
+ import { d as RespondentVisibilityProviderProps, f as WithVisibilityControl, t as BaseConfettiProps } from "./Confetti-ClwOwSrM.js";
3
+
4
+ //#region src/templates/EmbeddedConfettiContent.d.ts
5
+ interface EmbeddedConfettiContentProps extends Omit<BaseConfettiProps, 'isSurveyVisible'>, Closable {
6
+ respondent: string;
7
+ }
8
+ //#endregion
9
+ //#region src/static/EmbeddedConfetti.d.ts
10
+ type EmbeddedConfettiProps = WithProxyable<WithVisibilityControl<EmbeddedConfettiContentProps>> & Containable;
11
+ declare function EmbeddedConfetti(props: EmbeddedConfettiProps): import("react").JSX.Element | null;
12
+ //#endregion
13
+ //#region src/templates/ModalConfettiContent.d.ts
14
+ interface ModalConfettiContentProps extends Omit<BaseConfettiProps, 'isSurveyVisible'>, OptionallyDismissable {
15
+ respondent: string;
16
+ }
17
+ //#endregion
18
+ //#region src/static/ModalConfetti.d.ts
19
+ type ModalConfettiProps = WithProxyable<WithVisibilityControl<ModalConfettiContentProps>>;
20
+ declare function ModalConfetti(props: ModalConfettiProps): import("react").JSX.Element | null;
21
+ //#endregion
22
+ //#region src/templates/PopoverConfettiContent.d.ts
23
+ interface PopoverConfettiContentProps extends Omit<BaseConfettiProps, 'isSurveyVisible'>, Dismissable {
24
+ respondent: string;
25
+ }
26
+ //#endregion
27
+ //#region src/static/PopoverConfetti.d.ts
28
+ type PopoverConfettiProps = WithProxyable<WithVisibilityControl<PopoverConfettiContentProps>>;
29
+ declare function PopoverConfetti(props: PopoverConfettiProps): import("react").JSX.Element | null;
30
+ //#endregion
31
+ //#region src/templates/StepperConfettiContent.d.ts
32
+ interface StepperConfettiContentProps extends Omit<BaseConfettiProps, 'isSurveyVisible'>, Closable {
33
+ respondent: string;
34
+ }
35
+ //#endregion
36
+ //#region src/static/StepperConfetti.d.ts
37
+ type StepperConfettiProps = WithProxyable<WithVisibilityControl<StepperConfettiContentProps>> & Containable;
38
+ declare function StepperConfetti(props: StepperConfettiProps): import("react").JSX.Element | null;
39
+ //#endregion
40
+ //#region src/static/ConfettiTrigger.d.ts
41
+ interface TriggerRenderProps {
42
+ /** Opens the survey. */
43
+ onClick: () => void;
44
+ /** Whether the survey is currently open. */
45
+ isWidgetOpen: boolean;
46
+ /** Whether the respondent has already submitted the survey. */
47
+ hasSubmitted: boolean;
48
+ }
49
+ interface TriggerChildProps extends Pick<ConfettiTriggerProps, 'surveyId' | 'publishableKey' | 'proxyUrl' | 'metadata' | 'options'> {
50
+ /**
51
+ * Invoked when the user dismisses the survey via the close button before
52
+ * submitting. Collapses the popover back to the trigger button.
53
+ */
54
+ onDismiss: () => void;
55
+ /**
56
+ * Invoked when the user completes the survey. Marks the trigger button as
57
+ * submitted, then calls the trigger-level `onFinished`.
58
+ */
59
+ onFinished: () => void;
60
+ /**
61
+ * Invoked on every close path: the close button, the close-on-finish timer,
62
+ * and the Thank-You button. Collapses the popover back to the trigger
63
+ * button. The next click reopens a fresh survey.
64
+ */
65
+ onClose: () => void;
66
+ }
67
+ interface ConfettiTriggerProps extends WithProxyable<Omit<RespondentVisibilityProviderProps, 'children'> & BaseConfettiProps> {
68
+ surveyId: string;
69
+ publishableKey: string;
70
+ /**
71
+ * Renders the element that opens the survey. Receives the click handler and
72
+ * the open and submitted state. Defaults to the built-in trigger button.
73
+ */
74
+ trigger?: (renderProps: TriggerRenderProps) => React.ReactNode;
75
+ /**
76
+ * Renders the survey surface once the trigger is activated. Receives the
77
+ * survey props plus the close, dismiss, and finish handlers.
78
+ */
79
+ children: (triggerProps: TriggerChildProps) => React.ReactNode;
80
+ }
81
+ declare const ConfettiTrigger: ({
82
+ trigger,
83
+ children,
84
+ metadata,
85
+ options,
86
+ onFinished,
87
+ proxyUrl,
88
+ ...providerProps
89
+ }: ConfettiTriggerProps) => import("react").JSX.Element;
90
+ //#endregion
91
+ export { type ConfettiContainer, ConfettiTrigger, type ConfettiTriggerProps, EmbeddedConfetti, type EmbeddedConfettiProps, ModalConfetti, type ModalConfettiProps, PopoverConfetti, type PopoverConfettiProps, StepperConfetti, type StepperConfettiProps, type TriggerChildProps, type TriggerRenderProps };
@@ -0,0 +1 @@
1
+ import{t as e}from"./DefaultConfettiTrigger-DFJBQ35H.js";import{c as t,o as n,t as r}from"./ModalContainer-B-WGlRn4.js";import{f as i,i as a,m as o,n as s,p as c,r as l,t as u,u as d}from"./Embed-J5cfWjpk.js";import{useState as f}from"react";import{ErrorBoundary as p}from"react-error-boundary";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";const _=({onClose:e,...r})=>h(p,{fallback:h(m,{}),children:h(t,{type:`embedded`,children:h(n,{...r,children:h(o,{...r,shouldAutoSubmit:!1,children:({questions:t,update:n,isCompleted:i,submit:o,isSubmitted:s,errors:c})=>s?h(l,{onClose:e}):h(u,{onSubmit:o,isCompleted:i,children:t.filter(({visible:e})=>!!e).map(e=>h(a,{question:e,error:c[e.id]||``,maskAllInputs:r.options?.bugReport?.maskAllInputs,onChange:t=>n({question:e.position,answer:t})},e.position))})})})})}),v=e=>{let{respondent:t}=c();return h(_,{...e,respondent:t})};function y(e){let[t,n]=f(!1),{respondent:r,isSurveyVisible:a,proxyUrl:o,container:s,...c}=e;if(t)return null;let l=h(v,{...c,apiBaseUrl:o,onClose:()=>{n(!0),c.onClose?.()}});return h(i,{surveyId:c.surveyId,publishableKey:c.publishableKey,apiBaseUrl:o,respondent:r,isSurveyVisible:a,children:s?s({survey:l}):l})}const b=({onDismiss:e,onClose:i,onFinished:s,closeOnFinishMs:c,isDismissable:d,...f})=>h(p,{fallback:h(m,{}),children:h(t,{type:`modal`,children:h(n,{...f,children:h(r,{onDismiss:e,onClose:i,closeOnFinishMs:c,isDismissable:d,children:({setIsSubmitted:e,setIsFinished:t})=>h(o,{...f,shouldAutoSubmit:!1,onSubmitted:()=>e(),onFinished:()=>{t(),s?.()},children:({questions:e,update:t,isCompleted:n,errors:r,submit:o,isSubmitted:s})=>s?h(l,{onClose:i}):h(u,{onSubmit:o,isCompleted:n,children:e.filter(({visible:e})=>!!e).map(e=>h(a,{question:e,error:r[e.id]||``,maskAllInputs:f.options?.bugReport?.maskAllInputs,onChange:n=>t({question:e.position,answer:n})},e.position))})})})})})}),x=e=>{let{respondent:t}=c();return h(b,{...e,respondent:t})};function S(e){let[t,n]=f(!1),{respondent:r,isSurveyVisible:a,proxyUrl:o,...s}=e;return t?null:h(i,{surveyId:s.surveyId,publishableKey:s.publishableKey,apiBaseUrl:o,respondent:r,isSurveyVisible:a,children:h(x,{...s,apiBaseUrl:o,onClose:()=>{n(!0),s.onClose?.()}})})}const C=({onDismiss:e,onClose:r,onFinished:i,closeOnFinishMs:c,...u})=>h(p,{fallback:h(m,{}),children:h(t,{type:`popover`,children:h(n,{...u,children:h(d,{onDismiss:e,onClose:r,closeOnFinishMs:c,children:({setIsSubmitted:e,setIsFinished:t})=>h(o,{...u,shouldAutoSubmit:!0,onSubmitted:()=>e(),onFinished:()=>{t(),i?.()},children:({current:e,questions:t,update:n,isSubmitted:i})=>{let o=e===t.length-1;if(i)return h(l,{onClose:r});let c=t[e];return c?h(s,{isLastQuestion:o,question:c,onSubmit:t=>n({question:e,answer:t}),children:e=>h(a,{maskAllInputs:u.options?.bugReport?.maskAllInputs,...e})},c.id):h(m,{})}})})})})}),w=e=>{let{respondent:t}=c();return h(C,{...e,respondent:t})};function T(e){let[t,n]=f(!1),{respondent:r,isSurveyVisible:a,proxyUrl:o,...s}=e;return t?null:h(i,{surveyId:s.surveyId,publishableKey:s.publishableKey,apiBaseUrl:o,respondent:r,isSurveyVisible:a,children:h(w,{...s,apiBaseUrl:o,onClose:()=>{n(!0),s.onClose?.()}})})}const E=({onClose:e,...t})=>h(p,{fallback:h(m,{}),children:h(n,{...t,children:h(o,{...t,shouldAutoSubmit:!0,children:({current:n,questions:r,update:i,isSubmitted:o})=>{let c=n===r.length-1;if(o)return h(l,{onClose:e});let u=r[n];return u?h(s,{isLastQuestion:c,question:u,onSubmit:e=>i({question:n,answer:e}),children:e=>h(a,{maskAllInputs:t.options?.bugReport?.maskAllInputs,...e})},u.id):h(m,{})}})})}),D=e=>{let{respondent:t}=c();return h(E,{...e,respondent:t})};function O(e){let[t,n]=f(!1),{respondent:r,isSurveyVisible:a,proxyUrl:o,container:s,...c}=e;if(t)return null;let l=h(D,{...c,apiBaseUrl:o,onClose:()=>{n(!0),c.onClose?.()}});return h(i,{surveyId:c.surveyId,publishableKey:c.publishableKey,apiBaseUrl:o,respondent:r,isSurveyVisible:a,children:s?s({survey:l}):l})}const k=({trigger:e,children:t,onFinished:n,...r})=>{let[i,a]=f(!1),[o,s]=f(!1);return g(m,{children:[e({onClick:()=>a(!0),isWidgetOpen:i,hasSubmitted:o}),i&&t({...r,onDismiss:()=>a(!1),onFinished:()=>{s(!0),n?.()},onClose:()=>a(!1)})]})},A=({trigger:t=t=>h(e,{...t}),children:n,metadata:r,options:a,onFinished:o,proxyUrl:s,...c})=>h(p,{fallback:h(m,{}),children:h(i,{...c,apiBaseUrl:s,children:h(k,{trigger:t,surveyId:c.surveyId,publishableKey:c.publishableKey,proxyUrl:s,metadata:r,options:a,onFinished:o,children:n})})});export{A as ConfettiTrigger,y as EmbeddedConfetti,S as ModalConfetti,T as PopoverConfetti,O as StepperConfetti};