-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.js
9 lines (8 loc) · 174 KB
/
forms.js
1
2
3
4
5
6
7
8
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).formbricks=t()}(this,(function(){"use strict";class e{constructor(){this.logLevel="error"}static getInstance(){return e.instance||(e.instance=new e),e.instance}configure(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)}logger(e,t){if("debug"===t&&"debug"!==this.logLevel)return;const n=`🧱 Formbricks - ${(new Date).toISOString()} [${t.toUpperCase()}] - ${e}`;"error"===t?console.error(n):console.log(n)}debug(e){this.logger(e,"debug")}error(e){this.logger(e,"error")}}const t=e=>({ok:!0,value:e}),n=e=>({ok:!1,error:e});const r=e=>(...t)=>{try{return{ok:!0,value:e(...t)}}catch(n){return{ok:!1,error:n}}},i=e.getInstance(),s=class t{constructor(t){this.customized=!1,t?(this.handleError=t,this.customized=!0):this.handleError=t=>e.getInstance().error(JSON.stringify(t))}static getInstance(){return t.instance||(t.instance=new t),t.instance}static init(e){this.initialized=!0,t.instance=new t(e)}printStatus(){i.debug("Custom error handler: "+(this.customized?"yes":"no"))}handle(e){this.handleError(e)}};s.initialized=!1;let o=s;const a="formbricks-js";class l{constructor(){this.config=null;const e=this.loadFromLocalStorage();e.ok&&(this.config=e.value)}static getInstance(){return l.instance||(l.instance=new l),l.instance}update(e){if(e){const t=new Date((new Date).getTime()+9e5);this.config={...this.config,...e,expiresAt:t},this.saveToLocalStorage()}}get(){if(!this.config)throw new Error("config is null, maybe the init function was not called?");return this.config}loadFromLocalStorage(){if("undefined"!=typeof window){const e=localStorage.getItem(a);if(e){const r=JSON.parse(e);return r.expiresAt&&new Date(r.expiresAt)<=new Date?n(new Error("Config in local storage has expired")):t(JSON.parse(e))}}return n(new Error("No or invalid config in local storage"))}saveToLocalStorage(){return r((()=>localStorage.setItem(a,JSON.stringify(this.config))))()}resetConfig(){return this.config=null,r((()=>localStorage.removeItem(a)))()}}const d=e=>({ok:!1,error:e});async function c(e,t,n,r){const i=new URL(t,e),s=JSON.stringify(r),o=(a=fetch,(...e)=>{try{return{ok:!0,data:a(...e)}}catch(t){return{ok:!1,error:t}}})(i.toString(),{method:n,headers:{"Content-Type":"application/json"},body:s});var a;if(!1===o.ok)return d(o.error);const l=await o.data,{data:c}=await l.json();return l.ok?(e=>({ok:!0,data:e}))(c):d({code:"network_error",message:l.statusText,status:l.status,url:i})}class u{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return c(this.apiHost,`/api/v1/client/${this.environmentId}/responses`,"POST",e)}async update({responseId:e,finished:t,data:n,ttc:r}){return c(this.apiHost,`/api/v1/client/${this.environmentId}/responses/${e}`,"PUT",{finished:t,data:n,ttc:r})}}class p{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return c(this.apiHost,`/api/v1/client/${this.environmentId}/displays`,"POST",e)}async update(e,t){return c(this.apiHost,`/api/v1/client/${this.environmentId}/displays/${e}`,"PUT",t)}}class h{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return c(this.apiHost,`/api/v1/client/${this.environmentId}/actions`,"POST",e)}}class f{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return c(this.apiHost,`/api/v1/client/${this.environmentId}/people`,"POST",{environmentId:this.environmentId,userId:e})}async update(e,t){return c(this.apiHost,`/api/v1/client/${this.environmentId}/people/${e}`,"POST",t)}}class m{constructor(e,t){this.apiHost=e,this.environmentId=t}async uploadFile(e,{allowedFileExtensions:t,surveyId:n}={}){if(!(e instanceof Blob&&e instanceof File))throw new Error("Invalid file type. Expected Blob or File, but received "+typeof e);const r={fileName:e.name,fileType:e.type,allowedFileExtensions:t,surveyId:n},i=await fetch(`${this.apiHost}/api/v1/client/${this.environmentId}/storage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`Upload failed with status: ${i.status}`);const s=await i.json(),{data:o}=s,{signedUrl:a,fileUrl:l,signingData:d,presignedFields:c}=o;let u={};if(d){const{signature:t,timestamp:r,uuid:i}=d;u={"X-File-Type":e.type,"X-File-Name":encodeURIComponent(e.name),"X-Survey-ID":n??"","X-Signature":t,"X-Timestamp":String(r),"X-UUID":i}}const p=new FormData;c&&Object.keys(c).forEach((e=>{p.append(e,c[e])})),p.append("file",e);const h=await fetch(a,{method:"POST",...d?{headers:u}:{},body:p});if(!h.ok){const e=await h.json();throw new Error(`${e.message}`)}return l}}class b{constructor(e){const{apiHost:t,environmentId:n}=e;this.response=new u(t,n),this.display=new p(t,n),this.action=new h(t,n),this.people=new f(t,n),this.storage=new m(t,n)}}class g{constructor(e){this.client=new b(e)}}class v{constructor(e,t){this.queue=[],this.isRequestInProgress=!1,this.config=e,this.surveyState=t,this.api=new g({apiHost:e.apiHost,environmentId:e.environmentId})}add(e){this.surveyState.accumulateResponse(e),this.config.setSurveyState&&this.config.setSurveyState(this.surveyState),this.queue.push(e),this.processQueue()}async processQueue(){if(this.isRequestInProgress)return;if(0===this.queue.length)return;this.isRequestInProgress=!0;const e=this.queue[0];let t=0;for(;t<this.config.retryAttempts;){if(await this.sendResponse(e)){this.queue.shift();break}console.error("Formbricks: Failed to send response. Retrying...",t),t++}t>=this.config.retryAttempts&&(console.error("Failed to send response after 2 attempts."),this.surveyState.responseAcc.finished&&this.config.onResponseSendingFailed&&this.config.onResponseSendingFailed(this.surveyState.responseAcc),this.queue.shift()),this.isRequestInProgress=!1,this.processQueue()}async sendResponse(e){try{if(null!==this.surveyState.responseId)await this.api.client.response.update({...e,responseId:this.surveyState.responseId});else{const t=await this.api.client.response.create({...e,surveyId:this.surveyState.surveyId,userId:this.surveyState.userId||null,singleUseId:this.surveyState.singleUseId||null});if(!t.ok)throw new Error("Could not create response");this.surveyState.displayId&&await this.api.client.display.update(this.surveyState.displayId,{responseId:t.data.id}),this.surveyState.updateResponseId(t.data.id),this.config.setSurveyState&&this.config.setSurveyState(this.surveyState)}return!0}catch(t){return console.error(t),!1}}updateSurveyState(e){this.surveyState=e}}class _{constructor(e,t,n,r){this.responseId=null,this.displayId=null,this.userId=null,this.responseAcc={finished:!1,data:{},ttc:{}},this.surveyId=e,this.userId=r??null,this.singleUseId=t??null,this.responseId=n??null}setSurveyId(e){this.surveyId=e,this.clear()}copy(){const e=new _(this.surveyId,this.singleUseId??void 0,this.responseId??void 0,this.userId??void 0);return e.responseId=this.responseId,e.responseAcc=this.responseAcc,e}updateResponseId(e){this.responseId=e}updateDisplayId(e){this.displayId=e}updateUserId(e){this.userId=e}accumulateResponse(e){this.responseAcc={finished:e.finished,ttc:e.ttc,data:{...this.responseAcc.data,...e.data}}}isResponseFinished(){return this.responseAcc.finished}clear(){this.responseId=null,this.responseAcc={finished:!1,data:{},ttc:{}}}}const y=_;var w,k,x,j,I,C,N,S={},L=[],T=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,E=Array.isArray;function O(e,t){for(var n in t)e[n]=t[n];return e}function A(e){var t=e.parentNode;t&&t.removeChild(e)}function M(e,t,n){var r,i,s,o={};for(s in t)"key"==s?r=t[s]:"ref"==s?i=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?w.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===o[s]&&(o[s]=e.defaultProps[s]);return q(e,o,r,i,null)}function q(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==i?++x:i,__i:-1,__u:0};return null==i&&null!=k.vnode&&k.vnode(s),s}function Z(e){return e.children}function U(e,t){this.props=e,this.context=t}function P(e,t){if(null==t)return e.__?P(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?P(e):null}function F(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return F(e)}}function R(e){(!e.__d&&(e.__d=!0)&&j.push(e)&&!$.__r++||I!==k.debounceRendering)&&((I=k.debounceRendering)||C)($)}function $(){var e,t,n,r,i,s,o,a,l;for(j.sort(N);e=j.shift();)e.__d&&(t=j.length,r=void 0,s=(i=(n=e).__v).__e,a=[],l=[],(o=n.__P)&&((r=O({},i)).__v=i.__v+1,k.vnode&&k.vnode(r),Y(o,r,i,n.__n,void 0!==o.ownerSVGElement,32&i.__u?[s]:null,a,null==s?P(i):s,!!(32&i.__u),l),r.__.__k[r.__i]=r,J(a,r,l),r.__e!=s&&F(r)),j.length>t&&j.sort(N));$.__r=0}function z(e,t,n,r,i,s,o,a,l,d,c){var u,p,h,f,m,b=r&&r.__k||L,g=t.length;for(n.__d=l,function(e,t,n){var r,i,s,o,a,l=t.length,d=n.length,c=d,u=0;for(e.__k=[],r=0;r<l;r++)null!=(i=e.__k[r]=null==(i=t[r])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?q(null,i,null,null,i):E(i)?q(Z,{children:i},null,null,null):i.__b>0?q(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=e,i.__b=e.__b+1,a=H(i,n,o=r+u,c),i.__i=a,s=null,-1!==a&&(c--,(s=n[a])&&(s.__u|=131072)),null==s||null===s.__v?(-1==a&&u--,"function"!=typeof i.type&&(i.__u|=65536)):a!==o&&(a===o+1?u++:a>o?c>l-o?u+=a-o:u--:u=a<o&&a==o-1?a-o:0,a!==r+u&&(i.__u|=65536))):(s=n[r])&&null==s.key&&s.__e&&(s.__e==e.__d&&(e.__d=P(s)),G(s,s,!1),n[r]=null,c--);if(c)for(r=0;r<d;r++)null!=(s=n[r])&&0==(131072&s.__u)&&(s.__e==e.__d&&(e.__d=P(s)),G(s,s))}(n,t,b),l=n.__d,u=0;u<g;u++)null!=(h=n.__k[u])&&"boolean"!=typeof h&&"function"!=typeof h&&(p=-1===h.__i?S:b[h.__i]||S,h.__i=u,Y(e,h,p,i,s,o,a,l,d,c),f=h.__e,h.ref&&p.ref!=h.ref&&(p.ref&&X(p.ref,null,h),c.push(h.ref,h.__c||f,h)),null==m&&null!=f&&(m=f),65536&h.__u||p.__k===h.__k?l=D(h,l,e):"function"==typeof h.type&&void 0!==h.__d?l=h.__d:f&&(l=f.nextSibling),h.__d=void 0,h.__u&=-196609);n.__d=l,n.__e=m}function D(e,t,n){var r,i;if("function"==typeof e.type){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=D(r[i],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function B(e,t){return t=t||[],null==e||"boolean"==typeof e||(E(e)?e.some((function(e){B(e,t)})):t.push(e)),t}function H(e,t,n,r){var i=e.key,s=e.type,o=n-1,a=n+1,l=t[n];if(null===l||l&&i==l.key&&s===l.type)return n;if(r>(null!=l&&0==(131072&l.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((l=t[o])&&0==(131072&l.__u)&&i==l.key&&s===l.type)return o;o--}if(a<t.length){if((l=t[a])&&0==(131072&l.__u)&&i==l.key&&s===l.type)return a;a++}}return-1}function W(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||T.test(t)?n:n+"px"}function Q(e,t,n,r,i){var s;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||W(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||W(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Date.now(),e.addEventListener(t,s?K:V,s)):e.removeEventListener(t,s?K:V,s);else{if(i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(o){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function V(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(k.event?k.event(e):e)}function K(e){return this.l[e.type+!0](k.event?k.event(e):e)}function Y(e,t,n,r,i,s,o,a,l,d){var c,u,p,h,f,m,b,g,v,_,y,x,j,I,C,N=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),s=[a=t.__e=n.__e]),(c=k.__b)&&c(t);e:if("function"==typeof N)try{if(g=t.props,v=(c=N.contextType)&&r[c.__c],_=c?v?v.props.value:c.__:r,n.__c?b=(u=t.__c=n.__c).__=u.__E:("prototype"in N&&N.prototype.render?t.__c=u=new N(g,_):(t.__c=u=new U(g,_),u.constructor=N,u.render=ee),v&&v.sub(u),u.props=g,u.state||(u.state={}),u.context=_,u.__n=r,p=u.__d=!0,u.__h=[],u._sb=[]),null==u.__s&&(u.__s=u.state),null!=N.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=O({},u.__s)),O(u.__s,N.getDerivedStateFromProps(g,u.__s))),h=u.props,f=u.state,u.__v=t,p)null==N.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(null==N.getDerivedStateFromProps&&g!==h&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(g,_),!u.__e&&(null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(g,u.__s,_)||t.__v===n.__v)){for(t.__v!==n.__v&&(u.props=g,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach((function(e){e&&(e.__=t)})),y=0;y<u._sb.length;y++)u.__h.push(u._sb[y]);u._sb=[],u.__h.length&&o.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(g,u.__s,_),null!=u.componentDidUpdate&&u.__h.push((function(){u.componentDidUpdate(h,f,m)}))}if(u.context=_,u.props=g,u.__P=e,u.__e=!1,x=k.__r,j=0,"prototype"in N&&N.prototype.render){for(u.state=u.__s,u.__d=!1,x&&x(t),c=u.render(u.props,u.state,u.context),I=0;I<u._sb.length;I++)u.__h.push(u._sb[I]);u._sb=[]}else do{u.__d=!1,x&&x(t),c=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++j<25);u.state=u.__s,null!=u.getChildContext&&(r=O(O({},r),u.getChildContext())),p||null==u.getSnapshotBeforeUpdate||(m=u.getSnapshotBeforeUpdate(h,f)),z(e,E(C=null!=c&&c.type===Z&&null==c.key?c.props.children:c)?C:[C],t,n,r,i,s,o,a,l,d),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),b&&(u.__E=u.__=null)}catch(L){t.__v=null,l||null!=s?(t.__e=a,t.__u|=l?160:32,s[s.indexOf(a)]=null):(t.__e=n.__e,t.__k=n.__k),k.__e(L,t,n)}else null==s&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,r,i,s,o,a,l){var d,c,u,p,h,f,m,b=n.props,g=t.props,v=t.type;if("svg"===v&&(i=!0),null!=s)for(d=0;d<s.length;d++)if((h=s[d])&&"setAttribute"in h==!!v&&(v?h.localName===v:3===h.nodeType)){e=h,s[d]=null;break}if(null==e){if(null===v)return document.createTextNode(g);e=i?document.createElementNS("http://www.w3.org/2000/svg",v):document.createElement(v,g.is&&g),s=null,a=!1}if(null===v)b===g||a&&e.data===g||(e.data=g);else{if(s=s&&w.call(e.childNodes),b=n.props||S,!a&&null!=s)for(b={},d=0;d<e.attributes.length;d++)b[(h=e.attributes[d]).name]=h.value;for(d in b)h=b[d],"children"==d||("dangerouslySetInnerHTML"==d?u=h:"key"===d||d in g||Q(e,d,null,h,i));for(d in g)h=g[d],"children"==d?p=h:"dangerouslySetInnerHTML"==d?c=h:"value"==d?f=h:"checked"==d?m=h:"key"===d||a&&"function"!=typeof h||b[d]===h||Q(e,d,h,b[d],i);if(c)a||u&&(c.__html===u.__html||c.__html===e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(u&&(e.innerHTML=""),z(e,E(p)?p:[p],t,n,r,i&&"foreignObject"!==v,s,o,s?s[0]:n.__k&&P(n,0),a,l),null!=s)for(d=s.length;d--;)null!=s[d]&&A(s[d]);a||(d="value",void 0!==f&&(f!==e[d]||"progress"===v&&!f||"option"===v&&f!==b[d])&&Q(e,d,f,b[d],!1),d="checked",void 0!==m&&m!==e[d]&&Q(e,d,m,b[d],!1))}return e}(n.__e,t,n,r,i,s,o,l,d);(c=k.diffed)&&c(t)}function J(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)X(n[r],n[++r],n[++r]);k.__c&&k.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(n){k.__e(n,t.__v)}}))}function X(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(r){k.__e(r,n)}}function G(e,t,n){var r,i;if(k.unmount&&k.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||X(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){k.__e(s,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&G(r[i],t,n||"function"!=typeof e.type);n||null==e.__e||A(e.__e),e.__=e.__e=e.__d=void 0}function ee(e,t,n){return this.constructor(e,n)}w=L.slice,k={__e:function(e,t,n,r){for(var i,s,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&null!=s.getDerivedStateFromError&&(i.setState(s.getDerivedStateFromError(e)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(a){e=a}throw e}},x=0,U.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=O({},this.state),"function"==typeof e&&(e=e(O({},n),this.props)),e&&O(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),R(this))},U.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),R(this))},U.prototype.render=Z,j=[],C="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,N=function(e,t){return e.__v.__b-t.__v.__b},$.__r=0;var te=0;function ne(e,t,n,r,i,s){var o,a,l={};for(a in t)"ref"==a?o=t[a]:l[a]=t[a];var d={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--te,__i:-1,__u:0,__source:i,__self:s};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return k.vnode&&k.vnode(d),d}function re(){return ne("a",{href:"https://formbricks.com?utm_source=survey_branding",target:"_blank",tabIndex:-1,className:"mb-5 mt-2 flex justify-center",children:ne("p",{className:"text-signature text-xs",children:["Powered by"," ",ne("b",{children:ne("span",{className:"text-info-text hover:text-heading",children:"Formbricks"})})]})})}function ie({progress:e}){return ne("div",{className:"bg-accent-bg h-2 w-full rounded-full",children:ne("div",{className:"transition-width bg-brand z-20 h-2 rounded-full duration-500",style:{width:`${Math.floor(100*e)}%`}})})}const se=(...e)=>e.filter(Boolean).join(" ");const oe=e=>{for(let t=0;t<e.length;t++){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}},ae=(e,t)=>{const n=[...e],r=n.findIndex((e=>"other"===e.id)),i=-1!==r?n.splice(r,1)[0]:null;if("all"===t)oe(n);else if("exceptLast"===t){const e=n.pop();oe(n),n.push(e)}return i&&n.push(i),n},le=(e,t)=>{var n;const r=e.questions[t],i=e.questions.length,s=Math.floor(i/2),o=(null==(n=null==r?void 0:r.logic)?void 0:n.map((e=>e.destination)))||[];let a=t||.5;const l=(()=>{const t=e.questions.filter((e=>o.includes(e.id))).sort(((t,n)=>e.questions.indexOf(t)-e.questions.indexOf(n))).pop();return e.questions.findIndex((e=>e.id===(null==t?void 0:t.id)))})();return l>0&&(a=Math.min(s,l-1)),o.includes("end")&&(a=s),a};var de,ce,ue,pe,he=0,fe=[],me=[],be=k.__b,ge=k.__r,ve=k.diffed,_e=k.__c,ye=k.unmount;function we(e,t){k.__h&&k.__h(ce,e,he||t),he=0;var n=ce.__H||(ce.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:me}),n.__[e]}function ke(e){return he=1,function(e,t,n){var r=we(de++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ae(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=ce,!ce.u)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter((function(e){return e.__c}));if(i.every((function(e){return!e.__N})))return!s||s.call(this,e,t,n);var o=!1;return i.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}})),!(!o&&r.__c.props===e)&&(!s||s.call(this,e,t,n))};ce.u=!0;var s=ce.shouldComponentUpdate,o=ce.componentWillUpdate;ce.componentWillUpdate=function(e,t,n){if(this.__e){var r=s;s=void 0,i(e,t,n),s=r}o&&o.call(this,e,t,n)},ce.shouldComponentUpdate=i}return r.__N||r.__}(Ae,e)}function xe(e,t){var n=we(de++,3);!k.__s&&Oe(n.__H,t)&&(n.__=e,n.i=t,ce.__H.__h.push(n))}function je(e){return he=5,Ie((function(){return{current:e}}),[])}function Ie(e,t){var n=we(de++,7);return Oe(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function Ce(e,t){return he=8,Ie((function(){return e}),t)}function Ne(){for(var e;e=fe.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Te),e.__H.__h.forEach(Ee),e.__H.__h=[]}catch(t){e.__H.__h=[],k.__e(t,e.__v)}}k.__b=function(e){ce=null,be&&be(e)},k.__r=function(e){ge&&ge(e),de=0;var t=(ce=e.__c).__H;t&&(ue===ce?(t.__h=[],ce.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=me,e.__N=e.i=void 0}))):(t.__h.forEach(Te),t.__h.forEach(Ee),t.__h=[],de=0)),ue=ce},k.diffed=function(e){ve&&ve(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==fe.push(t)&&pe===k.requestAnimationFrame||((pe=k.requestAnimationFrame)||Le)(Ne)),t.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==me&&(e.__=e.__V),e.i=void 0,e.__V=me}))),ue=ce=null},k.__c=function(e,t){t.some((function(e){try{e.__h.forEach(Te),e.__h=e.__h.filter((function(e){return!e.__||Ee(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],k.__e(n,e.__v)}})),_e&&_e(e,t)},k.unmount=function(e){ye&&ye(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{Te(e)}catch(n){t=n}})),n.__H=void 0,t&&k.__e(t,n.__v))};var Se="function"==typeof requestAnimationFrame;function Le(e){var t,n=function(){clearTimeout(r),Se&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);Se&&(t=requestAnimationFrame(n))}function Te(e){var t=ce,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),ce=t}function Ee(e){var t=ce;e.__c=e.__(),ce=t}function Oe(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function Ae(e,t){return"function"==typeof t?t(e):t}function Me({survey:e,questionId:t}){const n=Ie((()=>e.questions.findIndex((e=>e.id===t))),[e,t]),r=Ce(((e,t,n)=>{if(0===t.questions.length)return 0;let r=t.questions.findIndex((t=>t.id===e));-1===r&&(r=0);const i=le(t,r)/t.questions.length;let s=n;return i>n?s=i:i<=n&&n+.1<=1&&(s=n+.1),s}),[]),i=Ie((()=>{let t=0,n=[];return e.questions.forEach((i=>{t=r(i.id,e,t),n.push(t)})),n}),[r,e]);return ne(ie,{progress:"end"===t?1:i[n]})}function qe({survey:e,onClose:t,children:n}){const[r,i]=ke(100),[s,o]=ke(!1),a=je(performance.now()),l=je(null),d=()=>{null!==l.current&&(o(!0),cancelAnimationFrame(l.current),l.current=null)};return xe((()=>{if(!e.autoClose)return;const n=()=>{const r=1e3*e.autoClose,s=performance.now()-a.current,o=Math.max(0,r-s);i(o/r),o>0?l.current=requestAnimationFrame(n):(d(),t())};return i(1),l.current=requestAnimationFrame(n),()=>d()}),[e.autoClose,t]),ne(Z,{children:[!s&&e.autoClose&&ne(ie,{progress:r}),ne("div",{onClick:d,onMouseOver:d,className:"h-full w-full",children:n})]})}function Ze(e,t){switch(e.condition){case"equals":return Array.isArray(t)&&1===t.length&&t.includes(e.value)||(null==t?void 0:t.toString())===e.value;case"notEquals":return t!==e.value;case"lessThan":return void 0!==e.value&&t<e.value;case"lessEqual":return void 0!==e.value&&t<=e.value;case"greaterThan":return void 0!==e.value&&t>e.value;case"greaterEqual":return void 0!==e.value&&t>=e.value;case"includesAll":return Array.isArray(t)&&Array.isArray(e.value)&&e.value.every((e=>t.includes(e)));case"includesOne":return Array.isArray(t)&&Array.isArray(e.value)&&e.value.some((e=>t.includes(e)));case"accepted":return"accepted"===t;case"clicked":return"clicked"===t;case"submitted":return"string"==typeof t?"dismissed"!==t&&""!==t&&null!==t:Array.isArray(t)?t.length>0:"number"==typeof t&&null!==t;case"skipped":return Array.isArray(t)&&0===t.length||""===t||null==t||"dismissed"===t;case"uploaded":return Array.isArray(t)?t.length>0:"skipped"!==t&&""!==t&&null!==t;case"notUploaded":return Array.isArray(t)&&0===t.length||""===t||null===t||"skipped"===t;default:return!1}}function Ue({onClick:e,backButtonLabel:t,tabIndex:n=2}){return ne("button",{tabIndex:n,type:"button",className:se("border-back-button-border text-heading focus:ring-focus flex items-center rounded-md border px-3 py-3 text-base font-medium leading-4 shadow-sm hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2"),onClick:e,children:t||"Back"})}function Pe({buttonLabel:e,isLastQuestion:t,onClick:n,tabIndex:r=1,focus:i=!1,type:s="submit"}){return ne("button",{ref:Ce((e=>{e&&i&&setTimeout((()=>{e.focus()}),200)}),[i]),type:s,tabIndex:r,autoFocus:i,className:"bg-brand border-submit-button-border text-on-brand focus:ring-focus flex items-center rounded-md border px-3 py-3 text-base font-medium leading-4 shadow-sm hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2",onClick:n,children:e||(t?"Finish":"Next")})}function Fe({imgUrl:e,altText:t="Image"}){return ne("div",{className:"mb-4 rounded-md",children:ne("img",{src:e,alt:t,className:"mb-4 rounded-md"})})}function Re({headline:e,questionId:t,required:n=!0,alignTextCenter:r=!1}){return ne("label",{htmlFor:t,className:"text-heading mb-1.5 block text-base font-semibold leading-6",children:ne("div",{className:"flex items-center "+(r?"justify-center":"justify-between"),children:[e,!n&&ne("span",{className:"text-info-text ml-2 self-start text-sm font-normal leading-7",tabIndex:-1,children:"Optional"})]})})}
/*!
* Sanitize an HTML string
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
* @param {String} str The HTML string to sanitize
* @return {String} The sanitized string
*/function $e(e){function t(e,t){let n=t.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!n.includes("javascript:")&&!n.includes("data:"))||!!e.startsWith("on")}function n(e){let n=e.attributes;for(let{name:r,value:i}of n)t(r,i)&&e.removeAttribute(r)}let r=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body");return function(e){let t=e.querySelectorAll("script");for(let n of t)n.remove()}(r),function e(t){let r=t.children;for(let i of r)n(i),e(i)}(r),r.innerHTML}function ze({htmlString:e,questionId:t}){return e?ne("label",{htmlFor:t,className:"fb-htmlbody",dangerouslySetInnerHTML:{__html:$e(e)}}):null}function De(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function Be(e){this.props=e}(Be.prototype=new U).isPureReactComponent=!0,Be.prototype.shouldComponentUpdate=function(e,t){return De(this.props,e)||De(this.state,t)};var He=k.__b;k.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),He&&He(e)};var We=k.__e;k.__e=function(e,t,n,r){if(e.then)for(var i,s=t;s=s.__;)if((i=s.__c)&&i.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t);We(e,t,n,r)};var Qe=k.unmount;function Ve(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),e.__c.__H=null),null!=(e=function(e,t){for(var n in t)e[n]=t[n];return e}({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return Ve(e,t,n)}))),e}function Ke(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return Ke(e,t,n)})),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Ye(){this.__u=0,this.t=null,this.__b=null}function Je(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Xe(){this.u=null,this.o=null}k.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Qe&&Qe(e)},(Ye.prototype=new U).__c=function(e,t){var n=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(n);var i=Je(r.__v),s=!1,o=function(){s||(s=!0,n.__R=null,i?i(a):a())};n.__R=o;var a=function(){if(! --r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ke(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.t.pop();)t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Ye.prototype.componentWillUnmount=function(){this.t=[]},Ye.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=Ve(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&M(Z,null,e.fallback);return i&&(i.__u&=-33),[M(Z,null,t.__a?null:e.children),i]};var Ge=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.u=n=n[2]}};(Xe.prototype=new U).__a=function(e){var t=this,n=Je(t.__v),r=t.o.get(e);return r[0]++,function(i){var s=function(){t.props.revealOrder?(r.push(i),Ge(t,e,r)):i()};n?n(s):s()}},Xe.prototype.render=function(e){this.u=null,this.o=new Map;var t=B(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.o.set(t[n],this.u=[1,0,this.u]);return e.children},Xe.prototype.componentDidUpdate=Xe.prototype.componentDidMount=function(){var e=this;this.o.forEach((function(t,n){Ge(e,n,t)}))};var et="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,tt=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,nt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,rt=/[A-Z0-9]/g,it="undefined"!=typeof document,st=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};U.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(e){Object.defineProperty(U.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}));var ot=k.event;function at(){}function lt(){return this.cancelBubble}function dt(){return this.defaultPrevented}k.event=function(e){return ot&&(e=ot(e)),e.persist=at,e.isPropagationStopped=lt,e.isDefaultPrevented=dt,e.nativeEvent=e};var ct={enumerable:!1,configurable:!0,get:function(){return this.class}},ut=k.vnode;k.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,r={};for(var i in t){var s=t[i];if(!("value"===i&&"defaultValue"in t&&null==s||it&&"children"===i&&"noscript"===n||"class"===i||"className"===i)){var o=i.toLowerCase();"defaultValue"===i&&"value"in t&&null==t.value?i="value":"download"===i&&!0===s?s="":"ondoubleclick"===o?i="ondblclick":"onchange"!==o||"input"!==n&&"textarea"!==n||st(t.type)?"onfocus"===o?i="onfocusin":"onblur"===o?i="onfocusout":nt.test(i)?i=o:-1===n.indexOf("-")&&tt.test(i)?i=i.replace(rt,"-$&").toLowerCase():null===s&&(s=void 0):o=i="oninput","oninput"===o&&r[i=o]&&(i="oninputCapture"),r[i]=s}}"select"==n&&r.multiple&&Array.isArray(r.value)&&(r.value=B(t.children).forEach((function(e){e.props.selected=-1!=r.value.indexOf(e.props.value)}))),"select"==n&&null!=r.defaultValue&&(r.value=B(t.children).forEach((function(e){e.props.selected=r.multiple?-1!=r.defaultValue.indexOf(e.props.value):r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",ct)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=et,ut&&ut(e)};var pt=k.__r;k.__r=function(e){pt&&pt(e),e.__c};var ht=k.diffed;k.diffed=function(e){ht&&ht(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};const ft=(e,t,n)=>e.hasOwnProperty(t)?{...e,[t]:e[t]+n}:{...e,[t]:n},mt=(e,t,n,r,i)=>{xe((()=>{i(performance.now())}),[e]),xe((()=>{const s=()=>{if("visible"===document.visibilityState)i(performance.now());else{const i=ft(t,e,performance.now()-r);n(i)}};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}}),[])};function bt({question:e,onSubmit:t,onBack:n,isFirstQuestion:r,isLastQuestion:i,ttc:s,setTtc:o}){const[a,l]=ke(performance.now());return mt(e.id,s,o,a,l),ne("div",{children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(ze,{htmlString:e.html,questionId:e.id}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!r&&ne(Ue,{backButtonLabel:e.backButtonLabel,onClick:()=>{const r=ft(s,e.id,performance.now()-a);o(r),t({[e.id]:""},r),n()}}),ne("div",{className:"flex w-full justify-end",children:[!e.required&&ne("button",{tabIndex:0,type:"button",onClick:()=>{const n=ft(s,e.id,performance.now()-a);o(n),t({[e.id]:"dismissed"},n)},className:"text-heading focus:ring-focus mr-4 flex items-center rounded-md px-3 py-3 text-base font-medium leading-4 hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2",children:e.dismissButtonLabel||"Skip"}),ne(Pe,{buttonLabel:e.buttonLabel,isLastQuestion:i,focus:!0,onClick:()=>{var n;e.buttonExternal&&e.buttonUrl&&(null==(n=null==window?void 0:window.open(e.buttonUrl,"_blank"))||n.focus());const r=ft(s,e.id,performance.now()-a);o(r),t({[e.id]:"clicked"},r)},type:"button"})]})]})]})}function gt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=ke(performance.now());return mt(e.id,a,l,d,c),ne("div",{children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(ze,{htmlString:e.html||"",questionId:e.id}),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},children:[ne("label",{tabIndex:1,onKeyDown:t=>{"Enter"==t.key&&n({[e.id]:"accepted"})},className:"border-border bg-survey-bg text-heading hover:bg-accent-bg focus:bg-accent-bg focus:ring-border-highlight relative z-10 mt-4 flex w-full cursor-pointer items-center rounded-md border p-4 text-sm focus:outline-none focus:ring-2 focus:ring-offset-2",children:[ne("input",{type:"checkbox",id:e.id,name:e.id,value:e.label,onChange:t=>{t.target instanceof HTMLInputElement&&t.target.checked?n({[e.id]:"accepted"}):n({[e.id]:"dismissed"})},checked:"accepted"===t,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${e.id}-label`,required:e.required}),ne("span",{id:`${e.id}-label`,className:"ml-3 font-medium",children:e.label})]}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{tabIndex:3,backButtonLabel:e.backButtonLabel,onClick:()=>{const n=ft(a,e.id,performance.now()-d);l(n),r({[e.id]:t},n),i()}}),ne("div",{}),ne(Pe,{tabIndex:2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})]})}function vt({allowedFileExtensions:e,surveyId:t,onUploadCallback:n,onFileUpload:r,fileUrls:i,maxSizeInMB:s,allowMultipleFiles:o}){const[a,l]=ke([]),[d,c]=ke(!1),u=Ie((()=>!d&&(!!o||!(i&&i.length>0))),[o,i,d]);return ne("div",{className:"items-left relative mt-3 flex w-full cursor-pointer flex-col justify-center rounded-lg border-2 border-dashed border-slate-300 bg-slate-50 hover:bg-slate-100 dark:border-slate-600 dark:bg-slate-700 dark:hover:border-slate-500 dark:hover:bg-slate-800",children:[ne("div",{children:i&&(null==i?void 0:i.map(((e,t)=>ne("div",{className:"relative m-2 rounded-md bg-slate-200",children:[ne("div",{className:"absolute right-0 top-0 m-2",children:ne("div",{className:"flex h-5 w-5 items-center justify-center rounded-md bg-slate-100 hover:bg-slate-50",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 26 26",strokeWidth:1,stroke:"currentColor",className:"h-5 text-slate-700 hover:text-slate-900",onClick:e=>((e,t)=>{if(t.stopPropagation(),i){const t=[...a];t.splice(e,1),l(t);const r=[...i];r.splice(e,1),n(r)}})(t,e),children:ne("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9l10 10m0-10L9 19"})})})}),ne("div",{className:"flex flex-col items-center justify-center p-2",children:[ne("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-file",className:"h-6 text-slate-500",children:[ne("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),ne("polyline",{points:"14 2 14 8 20 8"})]}),ne("p",{className:"mt-1 text-sm text-slate-600 dark:text-slate-400",children:decodeURIComponent(e).split("/").pop()})]})]},t))))}),ne("div",{children:[d&&ne("div",{className:"inset-0 flex animate-pulse items-center justify-center rounded-lg bg-slate-100 py-4",children:ne("label",{htmlFor:"selectedFile",className:"text-sm font-medium text-slate-500",children:"Uploading..."})}),ne("label",{htmlFor:"selectedFile",onDragOver:e=>(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy"})(e),onDrop:d=>(async d=>{d.preventDefault(),d.stopPropagation();const u=Array.from(d.dataTransfer.files);if(!o&&u.length>1)alert("Only one file can be uploaded at a time.");else if(u.length>0){const o=u.filter((t=>!(e&&e.length>0)||e.includes(t.type.substring(t.type.lastIndexOf("/")+1))));if(o.length>0){const d=[];for(const n of o)if(s)if((await n.arrayBuffer()).byteLength/1024>1024*s)alert(`File should be less than ${s} MB`);else{c(!0);try{const i=await r(n,{allowedFileExtensions:e,surveyId:t});l([...a,n]),d.push(i)}catch(p){c(!1),"File size exceeds the 10 MB limit"===p.message?alert(p.message):alert("Upload failed! Please try again.")}}else{c(!0);try{const i=await r(n,{allowedFileExtensions:e,surveyId:t});l([...a,n]),d.push(i)}catch(p){c(!1),"File size exceeds the 10 MB limit"===p.message?alert(p.message):alert("Upload failed! Please try again.")}}c(!1),n(i?[...i,...d]:d)}else alert("no selected files are valid")}})(d),children:u&&ne("div",{className:"flex flex-col items-center justify-center py-6",children:[ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-6 text-slate-500",children:ne("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),ne("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:ne("span",{className:"font-medium",children:"Click or drag to upload files."})}),ne("input",{type:"file",id:"selectedFile",name:"selectedFile",accept:null==e?void 0:e.map((e=>`.${e}`)).join(","),className:"hidden",onChange:o=>{const d=o.target;d.files&&(async o=>{if(o)if(s)if((await o.arrayBuffer()).byteLength/1024>1024*s)alert(`File should be less than ${s} MB`);else{c(!0);try{const s=await r(o,{allowedFileExtensions:e,surveyId:t});l([...a,o]),c(!1),n(i?[...i,s]:[s])}catch(d){c(!1),"File size exceeds the 10 MB limit"===d.message?alert(d.message):alert("Upload failed! Please try again.")}}else{c(!0);try{const s=await r(o,{allowedFileExtensions:e,surveyId:t});l([...a,o]),c(!1),n(i?[...i,s]:[s])}catch(d){c(!1),"File size exceeds the 10 MB limit"===d.message?alert(d.message):alert("Upload failed! Please try again.")}}else alert("Please select a file")})(d.files[0])}})]})})]})]})}function _t({subheader:e,questionId:t}){return ne("label",{htmlFor:t,className:"text-subheading block text-sm font-normal leading-6",children:e})}function yt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,surveyId:a,onFileUpload:l,ttc:d,setTtc:c}){const[u,p]=ke(performance.now());return mt(e.id,d,c,u,p),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(d,e.id,performance.now()-u);c(i),e.required?t&&("string"==typeof t||Array.isArray(t))&&t.length>0?r({[e.id]:"string"==typeof t?[t]:t},i):alert("Please upload a file"):r(t?{[e.id]:"string"==typeof t?[t]:t}:{[e.id]:"skipped"},i)},className:"w-full",children:[ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(_t,{subheader:e.subheader,questionId:e.id}),ne(vt,{surveyId:a,onFileUpload:l,onUploadCallback:t=>{n(t?{[e.id]:t}:{[e.id]:"skipped"})},fileUrls:t,allowMultipleFiles:e.allowMultipleFiles,...e.allowedFileExtensions?{allowedFileExtensions:e.allowedFileExtensions}:{},...e.maxSizeInMB?{maxSizeInMB:e.maxSizeInMB}:{}}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{backButtonLabel:e.backButtonLabel,onClick:()=>{i()}}),ne("div",{}),ne(Pe,{buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function wt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=ke(performance.now());mt(e.id,a,l,d,c);const u=Ce((()=>e.choices.filter((e=>"other"!==e.id)).map((e=>e.label))),[e]),[p,h]=ke(!!t&&(Array.isArray(t)?t:[t]).some((e=>!1===u().includes(e)))),[f,m]=ke(Array.isArray(t)&&t.filter((t=>!e.choices.find((e=>e.label===t))))[0]||""),b=Ie((()=>{if(!e.choices)return[];const t=e.choices.filter((e=>"other"!==e.id));return e.shuffleOption?ae(t,e.shuffleOption):t}),[e.choices,e.shuffleOption]),g=Ie((()=>e.choices.find((e=>"other"===e.id))),[e.choices]),v=je(null);xe((()=>{var e;p&&(null==(e=v.current)||e.focus())}),[p]);const _=r=>Array.isArray(t)?n({[e.id]:[...t,r]}):n({[e.id]:[r]}),y=r=>Array.isArray(t)?n({[e.id]:t.filter((e=>e!==r))}):n({[e.id]:[]});return ne("form",{onSubmit:i=>{i.preventDefault();const s=null==t?void 0:t.filter((e=>u().includes(e)||e===f));n({[e.id]:s});const o=ft(a,e.id,performance.now()-d);l(o),r({[e.id]:t},o)},className:"w-full",children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(_t,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"bg-survey-bg relative max-h-[42vh] space-y-2 overflow-y-auto rounded-md py-0.5 pr-2",children:[b.map(((n,r)=>ne("label",{tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&(Array.isArray(t)&&t.includes(n.label)?y(n.label):_(n.label))},className:se(t===n.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight hover:bg-accent-bg focus:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),children:ne("span",{className:"flex items-center text-sm",children:[ne("input",{type:"checkbox",id:n.id,name:e.id,tabIndex:-1,value:n.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${n.id}-label`,onChange:e=>{var t;(null==(t=e.target)?void 0:t.checked)?_(n.label):y(n.label)},checked:Array.isArray(t)&&t.includes(n.label),required:!(e.required&&Array.isArray(t)&&t.length)&&e.required}),ne("span",{id:`${n.id}-label`,className:"ml-3 font-medium",children:n.label})]})},n.id))),g&&ne("label",{tabIndex:b.length+1,className:se(t===g.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight focus-within:bg-accent-bg hover:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),onKeyDown:e=>{"Enter"==e.key&&h(!p)},children:[ne("span",{className:"flex items-center text-sm",children:[ne("input",{type:"checkbox",tabIndex:-1,id:g.id,name:e.id,value:g.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${g.id}-label`,onChange:e=>{var t;if(h(!p),null==(t=e.target)?void 0:t.checked){if(!f)return;_(f)}else y(f)},checked:p}),ne("span",{id:`${g.id}-label`,className:"ml-3 font-medium",children:g.label})]}),p&&ne("input",{ref:v,id:`${g.id}-label`,name:e.id,tabIndex:b.length+1,value:f,onChange:e=>{m(e.currentTarget.value),_(e.currentTarget.value)},onKeyDown:n=>{if("Enter"==n.key){const n=ft(a,e.id,performance.now()-d);l(n),setTimeout((()=>{r({[e.id]:t},n)}),100)}},placeholder:"Please specify",className:"placeholder:text-placeholder border-border bg-survey-bg text-heading focus:ring-focus mt-3 flex h-10 w-full rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",required:e.required,"aria-labelledby":`${g.id}-label`})]})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{tabIndex:b.length+3,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),ne(Pe,{tabIndex:b.length+2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function kt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=ke(performance.now());mt(e.id,a,l,d,c);const[u,p]=ke(!!t&&!e.choices.find((e=>e.label===t))),h=Ie((()=>{if(!e.choices)return[];const t=e.choices.filter((e=>"other"!==e.id));return e.shuffleOption?ae(t,e.shuffleOption):t}),[e.choices,e.shuffleOption]),f=Ie((()=>e.choices.find((e=>"other"===e.id))),[e.choices]),m=je(null);return xe((()=>{var e;u&&(null==(e=m.current)||e.focus())}),[u]),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},className:"w-full",children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(_t,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"bg-survey-bg relative max-h-[42vh] space-y-2 overflow-y-auto rounded-md py-0.5 pr-2",role:"radiogroup",children:[h.map(((i,s)=>ne("label",{tabIndex:s+1,onKeyDown:t=>{if("Enter"==t.key){n({[e.id]:i.label});const t=ft(a,e.id,performance.now()-d);l(t),setTimeout((()=>{r({[e.id]:i.label},t)}),350)}},className:se(t===i.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight focus-within:bg-accent-bg hover:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),children:ne("span",{className:"flex items-center text-sm",children:[ne("input",{tabIndex:-1,type:"radio",id:i.id,name:e.id,value:i.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${i.id}-label`,onChange:()=>{p(!1),n({[e.id]:i.label})},checked:t===i.label,required:e.required&&0===s}),ne("span",{id:`${i.id}-label`,className:"ml-3 font-medium",children:i.label})]})},i.id))),f&&ne("label",{tabIndex:h.length+1,className:se(t===f.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight focus-within:bg-accent-bg hover:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),onKeyDown:t=>{"Enter"==t.key&&(p(!u),u||n({[e.id]:""}))},children:[ne("span",{className:"flex items-center text-sm",children:[ne("input",{type:"radio",id:f.id,tabIndex:-1,name:e.id,value:f.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${f.id}-label`,onChange:()=>{p(!u),n({[e.id]:""})},checked:u}),ne("span",{id:`${f.id}-label`,className:"ml-3 font-medium",children:f.label})]}),u&&ne("input",{ref:m,tabIndex:h.length+1,id:`${f.id}-label`,name:e.id,value:t,onChange:t=>{n({[e.id]:t.currentTarget.value})},onKeyDown:n=>{if("Enter"==n.key){const n=ft(a,e.id,performance.now()-d);l(n),setTimeout((()=>{r({[e.id]:t},n)}),100)}},placeholder:"Please specify",className:"placeholder:text-placeholder border-border bg-survey-bg text-heading focus:ring-focus mt-3 flex h-10 w-full rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",required:e.required,"aria-labelledby":`${f.id}-label`})]})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{backButtonLabel:e.backButtonLabel,tabIndex:h.length+3,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),ne(Pe,{tabIndex:h.length+2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function xt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=ke(performance.now());return mt(e.id,a,l,d,c),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(_t,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"my-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"flex",children:Array.from({length:11},((e,t)=>t)).map(((i,s)=>ne("label",{tabIndex:s+1,onKeyDown:t=>{if("Enter"==t.key){const t=ft(a,e.id,performance.now()-d);l(t),r({[e.id]:i},t)}},className:se(t===i?"border-border-highlight bg-accent-selected-bg z-10":"border-border","bg-survey-bg text-heading hover:bg-accent-bg relative h-10 flex-1 cursor-pointer border text-center text-sm leading-10 first:rounded-l-md last:rounded-r-md focus:outline-none"),children:[ne("input",{type:"radio",name:"nps",value:i,checked:t===i,className:"absolute h-full w-full cursor-pointer opacity-0",onClick:()=>{if(e.required){const t=ft(a,e.id,performance.now()-d);l(t),r({[e.id]:i},t)}n({[e.id]:i})},required:e.required}),i]},i)))}),ne("div",{className:"text-info-text flex justify-between px-1.5 text-xs leading-6",children:[ne("p",{children:e.lowerLabel}),ne("p",{children:e.upperLabel})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{tabIndex:o?12:13,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),!e.required&&ne(Pe,{tabIndex:12,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function jt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,autoFocus:a=!0,ttc:l,setTtc:d}){const[c,u]=ke(performance.now());mt(e.id,l,d,c,u);const p=t=>{n({[e.id]:t})},h=Ce((e=>{e&&a&&e.focus()}),[e.id]);return ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(l,e.id,performance.now()-c);d(i),r({[e.id]:t,inputType:e.inputType},i)},className:"w-full",children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(_t,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:!1===e.longAnswer?ne("input",{ref:h,tabIndex:1,name:e.id,id:e.id,placeholder:e.placeholder,required:e.required,value:t||"",type:e.inputType,onInput:e=>p(e.currentTarget.value),autoFocus:a,className:"border-border bg-survey-bg focus:border-border-highlight block w-full rounded-md border p-2 shadow-sm focus:outline-none focus:ring-0 sm:text-sm",onKeyDown:n=>{if("Enter"===n.key&&(i=t,e.required&&!(null==i?void 0:i.trim())))n.preventDefault();else if("Enter"===n.key){const n=ft(l,e.id,performance.now()-c);d(n),r({[e.id]:t,inputType:e.inputType},n)}var i},pattern:"phone"===e.inputType?"[+][0-9 ]+":".*",title:"phone"===e.inputType?"Enter a valid phone number":void 0}):ne("textarea",{ref:h,rows:3,name:e.id,tabIndex:1,id:e.id,placeholder:e.placeholder,required:e.required,value:t,type:e.inputType,onInput:e=>p(e.currentTarget.value),autoFocus:a,className:"border-border bg-survey-bg text-subheading focus:border-border-highlight block w-full rounded-md border p-2 shadow-sm focus:ring-0 sm:text-sm",pattern:"phone"===e.inputType?"[+][0-9 ]+":".*",title:"phone"===e.inputType?"Please enter a valid phone number":void 0})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(l,e.id,performance.now()-c);d(t),i()}}),ne("div",{}),ne(Pe,{buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function It({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=ke(performance.now());mt(e.id,a,l,d,c);const u=r=>{Array.isArray(t)&&t.includes(r)?(r=>{let i=[];i=e.allowMulti&&Array.isArray(t)?t.filter((e=>e!==r)):[],n({[e.id]:i})})(r):(r=>{let i=[];i=e.allowMulti&&Array.isArray(t)?[...t,r]:[r],n({[e.id]:i})})(r)};xe((()=>{!e.allowMulti&&Array.isArray(t)&&t.length>1&&n({[e.id]:[]})}),[e.allowMulti]);const p=e.choices;return ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},className:"w-full",children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(_t,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"rounded-m bg-survey-bg relative grid max-h-[42vh] grid-cols-2 gap-x-5 gap-y-4 overflow-y-auto pr-2.5",children:p.map(((n,r)=>ne("label",{tabIndex:r+1,htmlFor:n.id,onKeyDown:e=>{"Enter"==e.key&&u(n.id)},onClick:()=>u(n.id),className:se(Array.isArray(t)&&t.includes(n.id)?"border-brand text-brand z-10 border-4 shadow-xl focus:border-4":"","border-border focus:border-border-highlight focus:bg-accent-selected-bg relative box-border inline-block h-28 w-full overflow-hidden rounded-xl border focus:outline-none"),children:[ne("img",{src:n.imageUrl,id:n.id,alt:n.imageUrl.split("/").pop(),className:"h-full w-full object-cover"}),e.allowMulti?ne("input",{id:`${n.id}-checked`,name:`${n.id}-checkbox`,type:"checkbox",tabindex:-1,checked:Array.isArray(t)&&t.includes(n.id),className:se("border-border pointer-events-none absolute right-2 top-2 z-20 h-5 w-5 rounded border",Array.isArray(t)&&t.includes(n.id)?"border-brand text-brand":""),required:!(e.required&&Array.isArray(t)&&t.length)&&e.required}):ne("input",{id:`${n.id}-radio`,name:`${n.id}-radio`,type:"radio",tabindex:-1,checked:Array.isArray(t)&&t.includes(n.id),className:se("border-border pointer-events-none absolute right-2 top-2 z-20 h-5 w-5 rounded-full border",Array.isArray(t)&&t.includes(n.id)?"border-brand text-brand":""),required:!(e.required&&Array.isArray(t)&&t.length)&&e.required})]},n.id)))})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{tabIndex:p.length+3,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),ne(Pe,{tabIndex:p.length+2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}const Ct=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m21.88 23.92c5.102-0.06134 7.273-1.882 8.383-3.346"}),ne("path",{stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",d:"m46.24 47.56c0-2.592-2.867-7.121-10.25-6.93-6.974 0.1812-10.22 4.518-10.22 7.111s4.271-1.611 10.05-1.492c6.317 0.13 10.43 3.903 10.43 1.311z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m23.16 28.47c5.215 1.438 5.603 0.9096 8.204 1.207 1.068 0.1221-2.03 2.67-7.282 4.397"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m50.12 23.92c-5.102-0.06134-7.273-1.882-8.383-3.346"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m48.84 28.47c-5.215 1.438-5.603 0.9096-8.204 1.207-1.068 0.1221 2.03 2.67 7.282 4.397"})]})}),Nt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m22.88 23.92c5.102-0.06134 7.273-1.882 8.383-3.346"}),ne("path",{stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",d:"m46.24 47.56c0-2.592-2.867-7.121-10.25-6.93-6.974 0.1812-10.22 4.518-10.22 7.111s4.271-1.611 10.05-1.492c6.317 0.13 10.43 3.903 10.43 1.311z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m49.12 23.92c-5.102-0.06134-7.273-1.882-8.383-3.346"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m48.24 30.51c-6.199 1.47-7.079 1.059-8.868-1.961"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m23.76 30.51c6.199 1.47 7.079 1.059 8.868-1.961"})]})}),St=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("line",{x1:"44.5361",x2:"50.9214",y1:"21.4389",y2:"24.7158",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2"}),ne("line",{x1:"26.9214",x2:"20.5361",y1:"21.4389",y2:"24.7158",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M24,28c2.3334,1.3333,4.6666,2.6667,7,4c-2.3334,1.3333-4.6666,2.6667-7,4"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M48,28c-2.3334,1.3333-4.6666,2.6667-7,4c2.3334,1.3333,4.6666,2.6667,7,4"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M28,51c0.2704-0.3562,1-8,8.4211-8.0038C43,42.9929,43.6499,50.5372,44,51C38.6667,51,33.3333,51,28,51z"})]})}),Lt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M26.5,48c1.8768-3.8326,5.8239-6.1965,10-6c3.8343,0.1804,7.2926,2.4926,9,6"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),Tt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m44.7 43.92c-6.328-1.736-11.41-0.906-17.4 1.902"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),Et=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("line",{x1:"27",x2:"45",y1:"43",y2:"43",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),Ot=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M45.8149,44.9293 c-2.8995,1.6362-6.2482,2.5699-9.8149,2.5699s-6.9153-0.9336-9.8149-2.5699"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),At=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M45.8147,45.2268a15.4294,15.4294,0,0,1-19.6294,0"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M31.6941,33.4036a4.7262,4.7262,0,0,0-8.6382,0"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M48.9441,33.4036a4.7262,4.7262,0,0,0-8.6382,0"})]})}),Mt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M50.595,41.64a11.5554,11.5554,0,0,1-.87,4.49c-12.49,3.03-25.43.34-27.49-.13a11.4347,11.4347,0,0,1-.83-4.36h.11s14.8,3.59,28.89.07Z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M49.7251,46.13c-1.79,4.27-6.35,7.23-13.69,7.23-7.41,0-12.03-3.03-13.8-7.36C24.2951,46.47,37.235,49.16,49.7251,46.13Z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M31.6941,32.4036a4.7262,4.7262,0,0,0-8.6382,0"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M48.9441,32.4036a4.7262,4.7262,0,0,0-8.6382,0"})]})}),qt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("polyline",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",points:"25.168 27.413 31.755 31.427 25.168 35.165"}),ne("polyline",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",points:"46.832 27.413 40.245 31.427 46.832 35.165"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M50.595,41.64a11.5554,11.5554,0,0,1-.87,4.49c-12.49,3.03-25.43.34-27.49-.13a11.4347,11.4347,0,0,1-.83-4.36h.11s14.8,3.59,28.89.07Z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M49.7251,46.13c-1.79,4.27-6.35,7.23-13.69,7.23-7.41,0-12.03-3.03-13.8-7.36C24.2951,46.47,37.235,49.16,49.7251,46.13Z"})]})});function Zt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=ke(0),[u,p]=ke(performance.now());mt(e.id,a,l,u,p);const h=t=>{if(n({[e.id]:t}),e.required){const n=ft(a,e.id,performance.now()-u);l(n),r({[e.id]:t},n)}},f=({number:n})=>ne("input",{type:"radio",name:"rating",value:n,className:"absolute left-0 h-full w-full cursor-pointer opacity-0",onChange:()=>h(n),required:e.required,checked:t===n});return ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-u);l(i),r({[e.id]:t},i)},className:"w-full",children:[e.imageUrl&&ne(Fe,{imgUrl:e.imageUrl}),ne(Re,{headline:e.headline,questionId:e.id,required:e.required}),ne(_t,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mb-4 mt-8",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Choices"}),ne("div",{className:"flex",children:Array.from({length:e.range},((e,t)=>t+1)).map(((n,r,i)=>ne("span",{onMouseOver:()=>c(n),onMouseLeave:()=>c(0),className:"max-w-10 bg-survey-bg relative max-h-10 flex-1 cursor-pointer text-center text-sm leading-10",children:"number"===e.scale?ne("label",{tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&h(n)},className:se(t===n?"bg-accent-selected-bg border-border-highlight z-10":"",i.length===n?"rounded-r-md":"",1===n?"rounded-l-md":"","text-heading hover:bg-accent-bg focus:bg-accent-bg block h-full w-full border focus:outline-none"),children:[ne(f,{number:n}),n]}):"star"===e.scale?ne("label",{tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&h(n)},className:se(n<=d?"text-rating-focus":"text-heading","focus:text-rating-focus flex h-full w-full justify-center focus:outline-none"),onFocus:()=>c(n),onBlur:()=>c(0),children:[ne(f,{number:n}),"number"==typeof t&&t>=n?ne("span",{className:"text-rating-fill",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"h-8 max-h-full w-8 ",children:ne("path",{fillRule:"evenodd",d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z",clipRule:"evenodd"})})}):ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",className:"h-8 max-h-full w-8",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})]}):ne("label",{className:se("flex h-full w-full justify-center",t===n||d===n?"stroke-rating-selected text-rating-selected":"stroke-heading text-heading"),tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&h(n)},onFocus:()=>c(n),onBlur:()=>c(0),children:[ne(f,{number:n}),ne(Ut,{active:t===n||d===n,idx:r,range:e.range})]})},n)))}),ne("div",{className:"text-subheading flex justify-between px-1.5 text-xs leading-6",children:[ne("p",{className:"w-1/2 text-left",children:e.lowerLabel}),ne("p",{className:"w-1/2 text-right",children:e.upperLabel})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(Ue,{tabIndex:!e.required||t?e.range+2:e.range+1,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-u);l(t),i()}}),ne("div",{}),(!e.required||t)&&ne(Pe,{tabIndex:e.range+1,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function Ut({active:e,idx:t,range:n}){const r="fill-rating-fill",i="fill-none";let s=[ne(Ct,{className:e?r:i}),ne(Nt,{className:e?r:i}),ne(St,{className:e?r:i}),ne(Lt,{className:e?r:i}),ne(Tt,{className:e?r:i}),ne(Et,{className:e?r:i}),ne(Ot,{className:e?r:i}),ne(At,{className:e?r:i}),ne(Mt,{className:e?r:i}),ne(qt,{className:e?r:i})];return 7==n?s=[s[1],s[3],s[4],s[5],s[6],s[8],s[9]]:5==n?s=[s[3],s[4],s[5],s[6],s[7]]:4==n?s=[s[4],s[5],s[6],s[7]]:3==n&&(s=[s[4],s[5],s[7]]),s[t]}var Pt,Ft,Rt;ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36}),(Ft=Pt||(Pt={})).assertEqual=e=>e,Ft.assertIs=function(e){},Ft.assertNever=function(e){throw new Error},Ft.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},Ft.getValidEnumValues=e=>{const t=Ft.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),n={};for(const r of t)n[r]=e[r];return Ft.objectValues(n)},Ft.objectValues=e=>Ft.objectKeys(e).map((function(t){return e[t]})),Ft.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},Ft.find=(e,t)=>{for(const n of e)if(t(n))return n},Ft.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,Ft.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},Ft.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(Rt||(Rt={})).mergeShapes=(e,t)=>({...e,...t});const $t=Pt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zt=e=>{switch(typeof e){case"undefined":return $t.undefined;case"string":return $t.string;case"number":return isNaN(e)?$t.nan:$t.number;case"boolean":return $t.boolean;case"function":return $t.function;case"bigint":return $t.bigint;case"symbol":return $t.symbol;case"object":return Array.isArray(e)?$t.array:null===e?$t.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?$t.promise:"undefined"!=typeof Map&&e instanceof Map?$t.map:"undefined"!=typeof Set&&e instanceof Set?$t.set:"undefined"!=typeof Date&&e instanceof Date?$t.date:$t.object;default:return $t.unknown}},Dt=Pt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Bt extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(const i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(r);else if("invalid_return_type"===i.code)r(i.returnTypeError);else if("invalid_arguments"===i.code)r(i.argumentsError);else if(0===i.path.length)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){const n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pt.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Bt.create=e=>new Bt(e);const Ht=(e,t)=>{let n;switch(e.code){case Dt.invalid_type:n=e.received===$t.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case Dt.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Pt.jsonStringifyReplacer)}`;break;case Dt.unrecognized_keys:n=`Unrecognized key(s) in object: ${Pt.joinValues(e.keys,", ")}`;break;case Dt.invalid_union:n="Invalid input";break;case Dt.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Pt.joinValues(e.options)}`;break;case Dt.invalid_enum_value:n=`Invalid enum value. Expected ${Pt.joinValues(e.options)}, received '${e.received}'`;break;case Dt.invalid_arguments:n="Invalid function arguments";break;case Dt.invalid_return_type:n="Invalid function return type";break;case Dt.invalid_date:n="Invalid date";break;case Dt.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Pt.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case Dt.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case Dt.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case Dt.custom:n="Invalid input";break;case Dt.invalid_intersection_types:n="Intersection results could not be merged";break;case Dt.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Dt.not_finite:n="Number must be finite";break;default:n=t.defaultError,Pt.assertNever(e)}return{message:n}};let Wt=Ht;function Qt(){return Wt}const Vt=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};let a="";const l=r.filter((e=>!!e)).slice().reverse();for(const d of l)a=d(o,{data:t,defaultError:a}).message;return{...i,path:s,message:i.message||a}};function Kt(e,t){const n=Vt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Qt(),Ht].filter((e=>!!e))});e.common.issues.push(n)}class Yt{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if("aborted"===r.status)return Jt;"dirty"===r.status&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return Yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:i}=r;if("aborted"===t.status)return Jt;if("aborted"===i.status)return Jt;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===t.value||void 0===i.value&&!r.alwaysSet||(n[t.value]=i.value)}return{status:e.value,value:n}}}const Jt=Object.freeze({status:"aborted"}),Xt=e=>({status:"dirty",value:e}),Gt=e=>({status:"valid",value:e}),en=e=>"aborted"===e.status,tn=e=>"dirty"===e.status,nn=e=>"valid"===e.status,rn=e=>"undefined"!=typeof Promise&&e instanceof Promise;var sn,on;(on=sn||(sn={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},on.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;class an{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ln=(e,t)=>{if(nn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Bt(e.common.issues);return this._error=t,this._error}}};function dn(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:i};return{errorMap:(e,t)=>"invalid_type"!==e.code?{message:t.defaultError}:void 0===t.data?{message:null!=r?r:t.defaultError}:{message:null!=n?n:t.defaultError},description:i}}class cn{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return zt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Yt,ctx:{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(rn(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:null!==(n=null==t?void 0:t.async)&&void 0!==n&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zt(e)},i=this._parseSync({data:e,path:r.path,parent:r});return ln(r,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zt(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(rn(r)?r:Promise.resolve(r));return ln(n,i)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,r)=>{const i=e(t),s=()=>r.addIssue({code:Dt.custom,...n(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then((e=>!!e||(s(),!1))):!!i||(s(),!1)}))}refinement(e,t){return this._refinement(((n,r)=>!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1)))}_refinement(e){return new Jn({schema:this,typeName:dr.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Xn.create(this,this._def)}nullable(){return Gn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return On.create(this,this._def)}promise(){return Yn.create(this,this._def)}or(e){return qn.create([this,e],this._def)}and(e){return Fn.create(this,e,this._def)}transform(e){return new Jn({...dn(this._def),schema:this,typeName:dr.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new er({...dn(this._def),innerType:this,defaultValue:t,typeName:dr.ZodDefault})}brand(){return new ir({typeName:dr.ZodBranded,type:this,...dn(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new tr({...dn(this._def),innerType:this,catchValue:t,typeName:dr.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return sr.create(this,e)}readonly(){return or.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const un=/^c[^\s-]{8,}$/i,pn=/^[a-z][a-z0-9]*$/,hn=/^[0-9A-HJKMNP-TV-Z]{26}$/,fn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,mn=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let bn;const gn=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,vn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;class _n extends cn{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==$t.string){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.string,received:t.parsedType}),Jt}const t=new Yt;let n;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("max"===a.kind)e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("length"===a.kind){const r=e.data.length>a.value,i=e.data.length<a.value;(r||i)&&(n=this._getOrReturnCtx(e,n),r?Kt(n,{code:Dt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&Kt(n,{code:Dt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if("email"===a.kind)mn.test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"email",code:Dt.invalid_string,message:a.message}),t.dirty());else if("emoji"===a.kind)bn||(bn=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),bn.test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"emoji",code:Dt.invalid_string,message:a.message}),t.dirty());else if("uuid"===a.kind)fn.test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"uuid",code:Dt.invalid_string,message:a.message}),t.dirty());else if("cuid"===a.kind)un.test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"cuid",code:Dt.invalid_string,message:a.message}),t.dirty());else if("cuid2"===a.kind)pn.test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"cuid2",code:Dt.invalid_string,message:a.message}),t.dirty());else if("ulid"===a.kind)hn.test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"ulid",code:Dt.invalid_string,message:a.message}),t.dirty());else if("url"===a.kind)try{new URL(e.data)}catch(o){n=this._getOrReturnCtx(e,n),Kt(n,{validation:"url",code:Dt.invalid_string,message:a.message}),t.dirty()}else if("regex"===a.kind){a.regex.lastIndex=0;a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"regex",code:Dt.invalid_string,message:a.message}),t.dirty())}else if("trim"===a.kind)e.data=e.data.trim();else if("includes"===a.kind)e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.dirty());else if("toLowerCase"===a.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===a.kind)e.data=e.data.toUpperCase();else if("startsWith"===a.kind)e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty());else if("endsWith"===a.kind)e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty());else if("datetime"===a.kind){((s=a).precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):0===s.precision?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$")).test(e.data)||(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.invalid_string,validation:"datetime",message:a.message}),t.dirty())}else"ip"===a.kind?(r=e.data,("v4"!==(i=a.version)&&i||!gn.test(r))&&("v6"!==i&&i||!vn.test(r))&&(n=this._getOrReturnCtx(e,n),Kt(n,{validation:"ip",code:Dt.invalid_string,message:a.message}),t.dirty())):Pt.assertNever(a);var r,i,s;return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement((t=>e.test(t)),{validation:t,code:Dt.invalid_string,...sn.errToObj(n)})}_addCheck(e){return new _n({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...sn.errToObj(e)})}url(e){return this._addCheck({kind:"url",...sn.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...sn.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...sn.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...sn.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...sn.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...sn.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...sn.errToObj(e)})}datetime(e){var t;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,...sn.errToObj(null==e?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...sn.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...sn.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...sn.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...sn.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...sn.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...sn.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...sn.errToObj(t)})}nonempty(e){return this.min(1,sn.errToObj(e))}trim(){return new _n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new _n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new _n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function yn(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(".",""))%parseInt(t.toFixed(i).replace(".",""))/Math.pow(10,i)}_n.create=e=>{var t;return new _n({checks:[],typeName:dr.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...dn(e)})};class wn extends cn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==$t.number){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.number,received:t.parsedType}),Jt}let t;const n=new Yt;for(const r of this._def.checks)if("int"===r.kind)Pt.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else"multipleOf"===r.kind?0!==yn(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.not_finite,message:r.message}),n.dirty()):Pt.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,sn.toString(t))}gt(e,t){return this.setLimit("min",e,!1,sn.toString(t))}lte(e,t){return this.setLimit("max",e,!0,sn.toString(t))}lt(e,t){return this.setLimit("max",e,!1,sn.toString(t))}setLimit(e,t,n,r){return new wn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:sn.toString(r)}]})}_addCheck(e){return new wn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:sn.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:sn.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:sn.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:sn.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:sn.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:sn.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:sn.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:sn.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:sn.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&Pt.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}wn.create=e=>new wn({checks:[],typeName:dr.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...dn(e)});class kn extends cn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==$t.bigint){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.bigint,received:t.parsedType}),Jt}let t;const n=new Yt;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),Kt(t,{code:Dt.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Pt.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,sn.toString(t))}gt(e,t){return this.setLimit("min",e,!1,sn.toString(t))}lte(e,t){return this.setLimit("max",e,!0,sn.toString(t))}lt(e,t){return this.setLimit("max",e,!1,sn.toString(t))}setLimit(e,t,n,r){return new kn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:sn.toString(r)}]})}_addCheck(e){return new kn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:sn.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:sn.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:sn.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:sn.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:sn.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}kn.create=e=>{var t;return new kn({checks:[],typeName:dr.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...dn(e)})};class xn extends cn{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==$t.boolean){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.boolean,received:t.parsedType}),Jt}return Gt(e.data)}}xn.create=e=>new xn({typeName:dr.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...dn(e)});class jn extends cn{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==$t.date){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.date,received:t.parsedType}),Jt}if(isNaN(e.data.getTime())){return Kt(this._getOrReturnCtx(e),{code:Dt.invalid_date}),Jt}const t=new Yt;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),Kt(n,{code:Dt.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):Pt.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new jn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:sn.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:sn.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}jn.create=e=>new jn({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:dr.ZodDate,...dn(e)});class In extends cn{_parse(e){if(this._getType(e)!==$t.symbol){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.symbol,received:t.parsedType}),Jt}return Gt(e.data)}}In.create=e=>new In({typeName:dr.ZodSymbol,...dn(e)});class Cn extends cn{_parse(e){if(this._getType(e)!==$t.undefined){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.undefined,received:t.parsedType}),Jt}return Gt(e.data)}}Cn.create=e=>new Cn({typeName:dr.ZodUndefined,...dn(e)});class Nn extends cn{_parse(e){if(this._getType(e)!==$t.null){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.null,received:t.parsedType}),Jt}return Gt(e.data)}}Nn.create=e=>new Nn({typeName:dr.ZodNull,...dn(e)});class Sn extends cn{constructor(){super(...arguments),this._any=!0}_parse(e){return Gt(e.data)}}Sn.create=e=>new Sn({typeName:dr.ZodAny,...dn(e)});class Ln extends cn{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Gt(e.data)}}Ln.create=e=>new Ln({typeName:dr.ZodUnknown,...dn(e)});class Tn extends cn{_parse(e){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.never,received:t.parsedType}),Jt}}Tn.create=e=>new Tn({typeName:dr.ZodNever,...dn(e)});class En extends cn{_parse(e){if(this._getType(e)!==$t.undefined){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.void,received:t.parsedType}),Jt}return Gt(e.data)}}En.create=e=>new En({typeName:dr.ZodVoid,...dn(e)});class On extends cn{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==$t.array)return Kt(t,{code:Dt.invalid_type,expected:$t.array,received:t.parsedType}),Jt;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(Kt(t,{code:e?Dt.too_big:Dt.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(Kt(t,{code:Dt.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(Kt(t,{code:Dt.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map(((e,n)=>r.type._parseAsync(new an(t,e,t.path,n))))).then((e=>Yt.mergeArray(n,e)));const i=[...t.data].map(((e,n)=>r.type._parseSync(new an(t,e,t.path,n))));return Yt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new On({...this._def,minLength:{value:e,message:sn.toString(t)}})}max(e,t){return new On({...this._def,maxLength:{value:e,message:sn.toString(t)}})}length(e,t){return new On({...this._def,exactLength:{value:e,message:sn.toString(t)}})}nonempty(e){return this.min(1,e)}}function An(e){if(e instanceof Mn){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Xn.create(An(r))}return new Mn({...e._def,shape:()=>t})}return e instanceof On?new On({...e._def,type:An(e.element)}):e instanceof Xn?Xn.create(An(e.unwrap())):e instanceof Gn?Gn.create(An(e.unwrap())):e instanceof Rn?Rn.create(e.items.map((e=>An(e)))):e}On.create=(e,t)=>new On({type:e,minLength:null,maxLength:null,exactLength:null,typeName:dr.ZodArray,...dn(t)});class Mn extends cn{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=Pt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==$t.object){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.object,received:t.parsedType}),Jt}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Tn&&"strip"===this._def.unknownKeys))for(const a in n.data)i.includes(a)||s.push(a);const o=[];for(const a of i){const e=r[a],t=n.data[a];o.push({key:{status:"valid",value:a},value:e._parse(new an(n,t,n.path,a)),alwaysSet:a in n.data})}if(this._def.catchall instanceof Tn){const e=this._def.unknownKeys;if("passthrough"===e)for(const t of s)o.push({key:{status:"valid",value:t},value:{status:"valid",value:n.data[t]}});else if("strict"===e)s.length>0&&(Kt(n,{code:Dt.unrecognized_keys,keys:s}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of s){const r=n.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new an(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of o){const n=await t.key;e.push({key:n,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>Yt.mergeObjectSync(t,e))):Yt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return sn.errToObj,new Mn({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{var r,i,s,o;const a=null!==(s=null===(i=(r=this._def).errorMap)||void 0===i?void 0:i.call(r,t,n).message)&&void 0!==s?s:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(o=sn.errToObj(e).message)&&void 0!==o?o:a}:{message:a}}}:{}})}strip(){return new Mn({...this._def,unknownKeys:"strip"})}passthrough(){return new Mn({...this._def,unknownKeys:"passthrough"})}extend(e){return new Mn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Mn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:dr.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Mn({...this._def,catchall:e})}pick(e){const t={};return Pt.objectKeys(e).forEach((n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])})),new Mn({...this._def,shape:()=>t})}omit(e){const t={};return Pt.objectKeys(this.shape).forEach((n=>{e[n]||(t[n]=this.shape[n])})),new Mn({...this._def,shape:()=>t})}deepPartial(){return An(this)}partial(e){const t={};return Pt.objectKeys(this.shape).forEach((n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()})),new Mn({...this._def,shape:()=>t})}required(e){const t={};return Pt.objectKeys(this.shape).forEach((n=>{if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof Xn;)e=e._def.innerType;t[n]=e}})),new Mn({...this._def,shape:()=>t})}keyof(){return Qn(Pt.objectKeys(this.shape))}}Mn.create=(e,t)=>new Mn({shape:()=>e,unknownKeys:"strip",catchall:Tn.create(),typeName:dr.ZodObject,...dn(t)}),Mn.strictCreate=(e,t)=>new Mn({shape:()=>e,unknownKeys:"strict",catchall:Tn.create(),typeName:dr.ZodObject,...dn(t)}),Mn.lazycreate=(e,t)=>new Mn({shape:e,unknownKeys:"strip",catchall:Tn.create(),typeName:dr.ZodObject,...dn(t)});class qn extends cn{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map((async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const n=e.map((e=>new Bt(e.ctx.common.issues)));return Kt(t,{code:Dt.invalid_union,unionErrors:n}),Jt}));{let e;const r=[];for(const s of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=s._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=r.map((e=>new Bt(e)));return Kt(t,{code:Dt.invalid_union,unionErrors:i}),Jt}}get options(){return this._def.options}}qn.create=(e,t)=>new qn({options:e,typeName:dr.ZodUnion,...dn(t)});const Zn=e=>e instanceof Hn?Zn(e.schema):e instanceof Jn?Zn(e.innerType()):e instanceof Wn?[e.value]:e instanceof Vn?e.options:e instanceof Kn?Object.keys(e.enum):e instanceof er?Zn(e._def.innerType):e instanceof Cn?[void 0]:e instanceof Nn?[null]:null;class Un extends cn{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==$t.object)return Kt(t,{code:Dt.invalid_type,expected:$t.object,received:t.parsedType}),Jt;const n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(Kt(t,{code:Dt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Jt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const i of t){const t=Zn(i.shape[e]);if(!t)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(r.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);r.set(n,i)}}return new Un({typeName:dr.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...dn(n)})}}function Pn(e,t){const n=zt(e),r=zt(t);if(e===t)return{valid:!0,data:e};if(n===$t.object&&r===$t.object){const n=Pt.objectKeys(t),r=Pt.objectKeys(e).filter((e=>-1!==n.indexOf(e))),i={...e,...t};for(const s of r){const n=Pn(e[s],t[s]);if(!n.valid)return{valid:!1};i[s]=n.data}return{valid:!0,data:i}}if(n===$t.array&&r===$t.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let r=0;r<e.length;r++){const i=Pn(e[r],t[r]);if(!i.valid)return{valid:!1};n.push(i.data)}return{valid:!0,data:n}}return n===$t.date&&r===$t.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Fn extends cn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(en(e)||en(r))return Jt;const i=Pn(e.value,r.value);return i.valid?((tn(e)||tn(r))&&t.dirty(),{status:t.value,value:i.data}):(Kt(n,{code:Dt.invalid_intersection_types}),Jt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((([e,t])=>r(e,t))):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Fn.create=(e,t,n)=>new Fn({left:e,right:t,typeName:dr.ZodIntersection,...dn(n)});class Rn extends cn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==$t.array)return Kt(n,{code:Dt.invalid_type,expected:$t.array,received:n.parsedType}),Jt;if(n.data.length<this._def.items.length)return Kt(n,{code:Dt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Jt;!this._def.rest&&n.data.length>this._def.items.length&&(Kt(n,{code:Dt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new an(n,e,n.path,t)):null})).filter((e=>!!e));return n.common.async?Promise.all(r).then((e=>Yt.mergeArray(t,e))):Yt.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Rn({...this._def,rest:e})}}Rn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Rn({items:e,typeName:dr.ZodTuple,rest:null,...dn(t)})};class $n extends cn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==$t.object)return Kt(n,{code:Dt.invalid_type,expected:$t.object,received:n.parsedType}),Jt;const r=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)r.push({key:i._parse(new an(n,o,n.path,o)),value:s._parse(new an(n,n.data[o],n.path,o))});return n.common.async?Yt.mergeObjectAsync(t,r):Yt.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new $n(t instanceof cn?{keyType:e,valueType:t,typeName:dr.ZodRecord,...dn(n)}:{keyType:_n.create(),valueType:e,typeName:dr.ZodRecord,...dn(t)})}}class zn extends cn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==$t.map)return Kt(n,{code:Dt.invalid_type,expected:$t.map,received:n.parsedType}),Jt;const r=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map((([e,t],s)=>({key:r._parse(new an(n,e,n.path,[s,"key"])),value:i._parse(new an(n,t,n.path,[s,"value"]))})));if(n.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const n of s){const r=await n.key,i=await n.value;if("aborted"===r.status||"aborted"===i.status)return Jt;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const n of s){const r=n.key,i=n.value;if("aborted"===r.status||"aborted"===i.status)return Jt;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}}zn.create=(e,t,n)=>new zn({valueType:t,keyType:e,typeName:dr.ZodMap,...dn(n)});class Dn extends cn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==$t.set)return Kt(n,{code:Dt.invalid_type,expected:$t.set,received:n.parsedType}),Jt;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&(Kt(n,{code:Dt.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&(Kt(n,{code:Dt.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function s(e){const n=new Set;for(const r of e){if("aborted"===r.status)return Jt;"dirty"===r.status&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}const o=[...n.data.values()].map(((e,t)=>i._parse(new an(n,e,n.path,t))));return n.common.async?Promise.all(o).then((e=>s(e))):s(o)}min(e,t){return new Dn({...this._def,minSize:{value:e,message:sn.toString(t)}})}max(e,t){return new Dn({...this._def,maxSize:{value:e,message:sn.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Dn.create=(e,t)=>new Dn({valueType:e,minSize:null,maxSize:null,typeName:dr.ZodSet,...dn(t)});class Bn extends cn{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==$t.function)return Kt(t,{code:Dt.invalid_type,expected:$t.function,received:t.parsedType}),Jt;function n(e,n){return Vt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qt(),Ht].filter((e=>!!e)),issueData:{code:Dt.invalid_arguments,argumentsError:n}})}function r(e,n){return Vt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qt(),Ht].filter((e=>!!e)),issueData:{code:Dt.invalid_return_type,returnTypeError:n}})}const i={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof Yn){const e=this;return Gt((async function(...t){const o=new Bt([]),a=await e._def.args.parseAsync(t,i).catch((e=>{throw o.addIssue(n(t,e)),o})),l=await Reflect.apply(s,this,a);return await e._def.returns._def.type.parseAsync(l,i).catch((e=>{throw o.addIssue(r(l,e)),o}))}))}{const e=this;return Gt((function(...t){const o=e._def.args.safeParse(t,i);if(!o.success)throw new Bt([n(t,o.error)]);const a=Reflect.apply(s,this,o.data),l=e._def.returns.safeParse(a,i);if(!l.success)throw new Bt([r(a,l.error)]);return l.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Bn({...this._def,args:Rn.create(e).rest(Ln.create())})}returns(e){return new Bn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Bn({args:e||Rn.create([]).rest(Ln.create()),returns:t||Ln.create(),typeName:dr.ZodFunction,...dn(n)})}}class Hn extends cn{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Hn.create=(e,t)=>new Hn({getter:e,typeName:dr.ZodLazy,...dn(t)});class Wn extends cn{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Kt(t,{received:t.data,code:Dt.invalid_literal,expected:this._def.value}),Jt}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Qn(e,t){return new Vn({values:e,typeName:dr.ZodEnum,...dn(t)})}Wn.create=(e,t)=>new Wn({value:e,typeName:dr.ZodLiteral,...dn(t)});class Vn extends cn{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return Kt(t,{expected:Pt.joinValues(n),received:t.parsedType,code:Dt.invalid_type}),Jt}if(-1===this._def.values.indexOf(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return Kt(t,{received:t.data,code:Dt.invalid_enum_value,options:n}),Jt}return Gt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Vn.create(e)}exclude(e){return Vn.create(this.options.filter((t=>!e.includes(t))))}}Vn.create=Qn;class Kn extends cn{_parse(e){const t=Pt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==$t.string&&n.parsedType!==$t.number){const e=Pt.objectValues(t);return Kt(n,{expected:Pt.joinValues(e),received:n.parsedType,code:Dt.invalid_type}),Jt}if(-1===t.indexOf(e.data)){const e=Pt.objectValues(t);return Kt(n,{received:n.data,code:Dt.invalid_enum_value,options:e}),Jt}return Gt(e.data)}get enum(){return this._def.values}}Kn.create=(e,t)=>new Kn({values:e,typeName:dr.ZodNativeEnum,...dn(t)});class Yn extends cn{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==$t.promise&&!1===t.common.async)return Kt(t,{code:Dt.invalid_type,expected:$t.promise,received:t.parsedType}),Jt;const n=t.parsedType===$t.promise?t.data:Promise.resolve(t.data);return Gt(n.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}Yn.create=(e,t)=>new Yn({type:e,typeName:dr.ZodPromise,...dn(t)});class Jn extends cn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===dr.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{Kt(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===r.type){const e=r.transform(n.data,i);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:n.path,parent:n}))):this._def.schema._parseSync({data:e,path:n.path,parent:n})}if("refinement"===r.type){const e=e=>{const t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===r.status?Jt:("dirty"===r.status&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((n=>"aborted"===n.status?Jt:("dirty"===n.status&&t.dirty(),e(n.value).then((()=>({status:t.value,value:n.value}))))))}if("transform"===r.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!nn(e))return e;const s=r.transform(e.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((e=>nn(e)?Promise.resolve(r.transform(e.value,i)).then((e=>({status:t.value,value:e}))):e))}Pt.assertNever(r)}}Jn.create=(e,t,n)=>new Jn({schema:e,typeName:dr.ZodEffects,effect:t,...dn(n)}),Jn.createWithPreprocess=(e,t,n)=>new Jn({schema:t,effect:{type:"preprocess",transform:e},typeName:dr.ZodEffects,...dn(n)});class Xn extends cn{_parse(e){return this._getType(e)===$t.undefined?Gt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Xn.create=(e,t)=>new Xn({innerType:e,typeName:dr.ZodOptional,...dn(t)});class Gn extends cn{_parse(e){return this._getType(e)===$t.null?Gt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Gn.create=(e,t)=>new Gn({innerType:e,typeName:dr.ZodNullable,...dn(t)});class er extends cn{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===$t.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}er.create=(e,t)=>new er({innerType:e,typeName:dr.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...dn(t)});class tr extends cn{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return rn(r)?r.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new Bt(n.common.issues)},input:n.data})}))):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new Bt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}tr.create=(e,t)=>new tr({innerType:e,typeName:dr.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...dn(t)});class nr extends cn{_parse(e){if(this._getType(e)!==$t.nan){const t=this._getOrReturnCtx(e);return Kt(t,{code:Dt.invalid_type,expected:$t.nan,received:t.parsedType}),Jt}return{status:"valid",value:e.data}}}nr.create=e=>new nr({typeName:dr.ZodNaN,...dn(e)});const rr=Symbol("zod_brand");class ir extends cn{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class sr extends cn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?Jt:"dirty"===e.status?(t.dirty(),Xt(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?Jt:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new sr({in:e,out:t,typeName:dr.ZodPipeline})}}class or extends cn{_parse(e){const t=this._def.innerType._parse(e);return nn(t)&&(t.value=Object.freeze(t.value)),t}}or.create=(e,t)=>new or({innerType:e,typeName:dr.ZodReadonly,...dn(t)});const ar=(e,t={},n)=>e?Sn.create().superRefine(((r,i)=>{var s,o;if(!e(r)){const e="function"==typeof t?t(r):"string"==typeof t?{message:t}:t,a=null===(o=null!==(s=e.fatal)&&void 0!==s?s:n)||void 0===o||o,l="string"==typeof e?{message:e}:e;i.addIssue({code:"custom",...l,fatal:a})}})):Sn.create(),lr={object:Mn.lazycreate};var dr,cr;(cr=dr||(dr={})).ZodString="ZodString",cr.ZodNumber="ZodNumber",cr.ZodNaN="ZodNaN",cr.ZodBigInt="ZodBigInt",cr.ZodBoolean="ZodBoolean",cr.ZodDate="ZodDate",cr.ZodSymbol="ZodSymbol",cr.ZodUndefined="ZodUndefined",cr.ZodNull="ZodNull",cr.ZodAny="ZodAny",cr.ZodUnknown="ZodUnknown",cr.ZodNever="ZodNever",cr.ZodVoid="ZodVoid",cr.ZodArray="ZodArray",cr.ZodObject="ZodObject",cr.ZodUnion="ZodUnion",cr.ZodDiscriminatedUnion="ZodDiscriminatedUnion",cr.ZodIntersection="ZodIntersection",cr.ZodTuple="ZodTuple",cr.ZodRecord="ZodRecord",cr.ZodMap="ZodMap",cr.ZodSet="ZodSet",cr.ZodFunction="ZodFunction",cr.ZodLazy="ZodLazy",cr.ZodLiteral="ZodLiteral",cr.ZodEnum="ZodEnum",cr.ZodEffects="ZodEffects",cr.ZodNativeEnum="ZodNativeEnum",cr.ZodOptional="ZodOptional",cr.ZodNullable="ZodNullable",cr.ZodDefault="ZodDefault",cr.ZodCatch="ZodCatch",cr.ZodPromise="ZodPromise",cr.ZodBranded="ZodBranded",cr.ZodPipeline="ZodPipeline",cr.ZodReadonly="ZodReadonly";const ur=_n.create,pr=wn.create,hr=nr.create,fr=kn.create,mr=xn.create,br=jn.create,gr=In.create,vr=Cn.create,_r=Nn.create,yr=Sn.create,wr=Ln.create,kr=Tn.create,xr=En.create,jr=On.create,Ir=Mn.create,Cr=Mn.strictCreate,Nr=qn.create,Sr=Un.create,Lr=Fn.create,Tr=Rn.create,Er=$n.create,Or=zn.create,Ar=Dn.create,Mr=Bn.create,qr=Hn.create,Zr=Wn.create,Ur=Vn.create,Pr=Kn.create,Fr=Yn.create,Rr=Jn.create,$r=Xn.create,zr=Gn.create,Dr=Jn.createWithPreprocess,Br=sr.create,Hr={string:e=>_n.create({...e,coerce:!0}),number:e=>wn.create({...e,coerce:!0}),boolean:e=>xn.create({...e,coerce:!0}),bigint:e=>kn.create({...e,coerce:!0}),date:e=>jn.create({...e,coerce:!0})},Wr=Jt;var Qr=Object.freeze({__proto__:null,defaultErrorMap:Ht,setErrorMap:function(e){Wt=e},getErrorMap:Qt,makeIssue:Vt,EMPTY_PATH:[],addIssueToContext:Kt,ParseStatus:Yt,INVALID:Jt,DIRTY:Xt,OK:Gt,isAborted:en,isDirty:tn,isValid:nn,isAsync:rn,get util(){return Pt},get objectUtil(){return Rt},ZodParsedType:$t,getParsedType:zt,ZodType:cn,ZodString:_n,ZodNumber:wn,ZodBigInt:kn,ZodBoolean:xn,ZodDate:jn,ZodSymbol:In,ZodUndefined:Cn,ZodNull:Nn,ZodAny:Sn,ZodUnknown:Ln,ZodNever:Tn,ZodVoid:En,ZodArray:On,ZodObject:Mn,ZodUnion:qn,ZodDiscriminatedUnion:Un,ZodIntersection:Fn,ZodTuple:Rn,ZodRecord:$n,ZodMap:zn,ZodSet:Dn,ZodFunction:Bn,ZodLazy:Hn,ZodLiteral:Wn,ZodEnum:Vn,ZodNativeEnum:Kn,ZodPromise:Yn,ZodEffects:Jn,ZodTransformer:Jn,ZodOptional:Xn,ZodNullable:Gn,ZodDefault:er,ZodCatch:tr,ZodNaN:nr,BRAND:rr,ZodBranded:ir,ZodPipeline:sr,ZodReadonly:or,custom:ar,Schema:cn,ZodSchema:cn,late:lr,get ZodFirstPartyTypeKind(){return dr},coerce:Hr,any:yr,array:jr,bigint:fr,boolean:mr,date:br,discriminatedUnion:Sr,effect:Rr,enum:Ur,function:Mr,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>ar((t=>t instanceof e),t),intersection:Lr,lazy:qr,literal:Zr,map:Or,nan:hr,nativeEnum:Pr,never:kr,null:_r,nullable:zr,number:pr,object:Ir,oboolean:()=>mr().optional(),onumber:()=>pr().optional(),optional:$r,ostring:()=>ur().optional(),pipeline:Br,preprocess:Dr,promise:Fr,record:Er,set:Ar,strictObject:Cr,string:ur,symbol:gr,transformer:Rr,tuple:Tr,undefined:vr,union:Nr,unknown:wr,void:xr,NEVER:Wr,ZodIssueCode:Dt,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:Bt});Qr.string(),Qr.number(),Qr.number().optional();const Vr=Qr.string().regex(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/),Kr=Qr.enum(["bottomLeft","bottomRight","topLeft","topRight","center"]),Yr=Qr.enum(["png","jpeg","jpg","pdf","doc","docx","xls","xlsx","ppt","pptx","plain","csv","mp4","mov","avi","mkv","webm","zip","rar","7z","tar"]),Jr=Qr.object({enabled:Qr.boolean(),headline:Qr.optional(Qr.string()),subheader:Qr.optional(Qr.string())});var Xr=(e=>(e.FileUpload="fileUpload",e.OpenText="openText",e.MultipleChoiceSingle="multipleChoiceSingle",e.MultipleChoiceMulti="multipleChoiceMulti",e.NPS="nps",e.CTA="cta",e.Rating="rating",e.Consent="consent",e.PictureSelection="pictureSelection",e))(Xr||{});const Gr=Qr.object({enabled:Qr.boolean(),headline:Qr.optional(Qr.string()),html:Qr.string().optional(),fileUrl:Qr.string().optional(),buttonLabel:Qr.string().optional(),timeToFinish:Qr.boolean().default(!0),showResponseCount:Qr.boolean().default(!1)}),ei=Qr.object({enabled:Qr.boolean(),fieldIds:Qr.optional(Qr.array(Qr.string()))}),ti=Qr.object({brandColor:Vr.nullish(),highlightBorderColor:Vr.nullish(),placement:Kr.nullish(),clickOutsideClose:Qr.boolean().nullish(),darkOverlay:Qr.boolean().nullish()});Qr.enum(["animation","color","image"]);const ni=Qr.object({bg:Qr.string().nullish(),bgType:Qr.enum(["animation","color","image"]).nullish(),brightness:Qr.number().nullish()}),ri=Qr.object({background:ni.nullish()}),ii=Qr.object({enabled:Qr.boolean().optional(),heading:Qr.string().optional(),subheading:Qr.string().optional()}).nullable().optional(),si=Qr.object({enabled:Qr.boolean(),heading:Qr.optional(Qr.string()),subheading:Qr.optional(Qr.string()),isEncrypted:Qr.boolean()}).nullable(),oi=Qr.object({name:Qr.optional(Qr.string()),subheading:Qr.optional(Qr.string())}).optional(),ai=Qr.object({id:Qr.string(),label:Qr.string()}),li=Qr.object({id:Qr.string(),imageUrl:Qr.string()}),di=Qr.enum(["accepted","clicked","submitted","skipped","equals","notEquals","lessThan","lessEqual","greaterThan","greaterEqual","includesAll","includesOne","uploaded","notUploaded"]),ci=Qr.object({condition:di.optional(),value:Qr.union([Qr.string(),Qr.array(Qr.string())]).optional(),destination:Qr.union([Qr.string(),Qr.literal("end")]).optional()}),ui=ci.extend({condition:Qr.enum(["uploaded","notUploaded"]).optional(),value:Qr.undefined()}),pi=ci.extend({condition:Qr.enum(["submitted","skipped"]).optional(),value:Qr.undefined()}),hi=ci.extend({condition:Qr.enum(["skipped","accepted"]).optional(),value:Qr.undefined()}),fi=ci.extend({condition:Qr.enum(["submitted","skipped","equals","notEquals"]).optional(),value:Qr.string().optional()}),mi=ci.extend({condition:Qr.enum(["submitted","skipped","includesAll","includesOne","equals"]).optional(),value:Qr.union([Qr.array(Qr.string()),Qr.string()]).optional()}),bi=ci.extend({condition:Qr.enum(["equals","notEquals","lessThan","lessEqual","greaterThan","greaterEqual","submitted","skipped"]).optional(),value:Qr.union([Qr.string(),Qr.number()]).optional()}),gi=ci.extend({condition:Qr.enum(["clicked","submitted","skipped"]).optional(),value:Qr.undefined()}),vi=ci.extend({condition:Qr.enum(["equals","notEquals","lessThan","lessEqual","greaterThan","greaterEqual","submitted","skipped"]).optional(),value:Qr.union([Qr.string(),Qr.number()]).optional()}),_i=ci.extend({condition:Qr.enum(["submitted","skipped"]).optional(),value:Qr.undefined()}),yi=Qr.union([pi,hi,fi,mi,bi,gi,vi,_i,ui]),wi=Qr.object({id:Qr.string(),type:Qr.string(),headline:Qr.string(),subheader:Qr.string().optional(),imageUrl:Qr.string().optional(),required:Qr.boolean(),buttonLabel:Qr.string().optional(),backButtonLabel:Qr.string().optional(),scale:Qr.enum(["number","smiley","star"]).optional(),range:Qr.union([Qr.literal(5),Qr.literal(3),Qr.literal(4),Qr.literal(7),Qr.literal(10)]).optional(),logic:Qr.array(yi).optional(),isDraft:Qr.boolean().optional()}),ki=wi.extend({type:Qr.literal("fileUpload"),allowMultipleFiles:Qr.boolean(),maxSizeInMB:Qr.number().optional(),allowedFileExtensions:Qr.array(Yr).optional(),logic:Qr.array(ui).optional()}),xi=Qr.enum(["text","email","url","number","phone"]),ji=wi.extend({type:Qr.literal("openText"),placeholder:Qr.string().optional(),longAnswer:Qr.boolean().optional(),logic:Qr.array(pi).optional(),inputType:xi.optional().default("text")}),Ii=wi.extend({type:Qr.literal("consent"),html:Qr.string().optional(),label:Qr.string(),dismissButtonLabel:Qr.string().optional(),placeholder:Qr.string().optional(),logic:Qr.array(hi).optional()}),Ci=wi.extend({type:Qr.literal("multipleChoiceSingle"),choices:Qr.array(ai),logic:Qr.array(fi).optional(),shuffleOption:Qr.enum(["none","all","exceptLast"]).optional()}),Ni=wi.extend({type:Qr.literal("multipleChoiceMulti"),choices:Qr.array(ai),logic:Qr.array(mi).optional(),shuffleOption:Qr.enum(["none","all","exceptLast"]).optional()}),Si=wi.extend({type:Qr.literal("nps"),lowerLabel:Qr.string(),upperLabel:Qr.string(),logic:Qr.array(bi).optional()}),Li=wi.extend({type:Qr.literal("cta"),html:Qr.string().optional(),buttonUrl:Qr.string().optional(),buttonExternal:Qr.boolean(),dismissButtonLabel:Qr.string().optional(),logic:Qr.array(gi).optional()}),Ti=wi.extend({type:Qr.literal("rating"),scale:Qr.enum(["number","smiley","star"]),range:Qr.union([Qr.literal(5),Qr.literal(3),Qr.literal(4),Qr.literal(7),Qr.literal(10)]),lowerLabel:Qr.string(),upperLabel:Qr.string(),logic:Qr.array(vi).optional()}),Ei=wi.extend({type:Qr.literal("pictureSelection"),allowMulti:Qr.boolean().optional().default(!1),choices:Qr.array(li),logic:Qr.array(_i).optional()}),Oi=Qr.union([ji,Ii,Ci,Ni,Si,Li,Ti,Ei,ki]),Ai=Qr.array(Oi),Mi=Qr.object({attributeClassId:Qr.string().cuid2(),condition:Qr.enum(["equals","notEquals"]),value:Qr.string()}),qi=Qr.enum(["displayOnce","displayMultiple","respondMultiple"]),Zi=Qr.enum(["web","email","link","mobile"]),Ui=Qr.enum(["draft","inProgress","paused","completed"]);function Pi({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,autoFocus:a=!0,ttc:l,setTtc:d,surveyId:c,onFileUpload:u}){return e.type===Xr.OpenText?ne(jt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,autoFocus:a,ttc:l,setTtc:d}):e.type===Xr.MultipleChoiceSingle?ne(kt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===Xr.MultipleChoiceMulti?ne(wt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===Xr.NPS?ne(xt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===Xr.CTA?ne(bt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===Xr.Rating?ne(Zt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===Xr.Consent?ne(gt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===Xr.PictureSelection?ne(It,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===Xr.FileUpload?ne(yt,{surveyId:c,question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,onFileUpload:u,ttc:l,setTtc:d}):null}Qr.object({id:Qr.string().cuid2(),createdAt:Qr.date(),updatedAt:Qr.date(),name:Qr.string(),type:Zi,environmentId:Qr.string(),status:Ui,attributeFilters:Qr.array(Mi),displayOption:qi,autoClose:Qr.number().nullable(),triggers:Qr.array(Qr.string()),redirectUrl:Qr.string().url().nullable(),recontactDays:Qr.number().nullable(),welcomeCard:Gr,questions:Ai,thankYouCard:Jr,hiddenFields:ei,delay:Qr.number(),autoComplete:Qr.number().nullable(),closeOnDate:Qr.date().nullable(),productOverwrites:ti.nullable(),styling:ri.nullable(),surveyClosedMessage:ii.nullable(),singleUse:si.nullable(),verifyEmail:oi.nullable(),pin:Qr.string().nullable().optional()}),Qr.object({name:Qr.string(),type:Zi.optional(),status:Ui.optional(),displayOption:qi.optional(),autoClose:Qr.number().optional(),redirectUrl:Qr.string().url().optional(),recontactDays:Qr.number().optional(),welcomeCard:Gr.optional(),questions:Ai.optional(),thankYouCard:Jr.optional(),hiddenFields:ei,delay:Qr.number().optional(),autoComplete:Qr.number().optional(),closeOnDate:Qr.date().optional(),surveyClosedMessage:ii.optional(),verifyEmail:oi.optional(),attributeFilters:Qr.array(Mi).optional(),triggers:Qr.array(Qr.string()).optional()}),Qr.union([Qr.literal("fileUpload"),Qr.literal("openText"),Qr.literal("multipleChoiceSingle"),Qr.literal("multipleChoiceMulti"),Qr.literal("nps"),Qr.literal("cta"),Qr.literal("rating"),Qr.literal("consent"),Qr.literal("pictureSelection")]);const Fi=5;function Ri({redirectUrl:e,isRedirectDisabled:t}){const[n,r]=ke(Fi);return xe((()=>{if(e){const n=setInterval((()=>{r((r=>r<=0?(clearInterval(n),t||(window.location.href=e),0):r-1))}),1e3)}return()=>clearInterval(undefined)}),[e,t]),e?ne("div",{children:ne("div",{className:"bg-accent-bg text-subheading mt-10 rounded-md p-2 text-sm",children:[ne("span",{children:"You're redirected in "}),ne("span",{children:n})]})}):null}function $i({headline:e,subheader:t,redirectUrl:n,isRedirectDisabled:r}){return ne("div",{className:"text-center",children:[ne("div",{className:"text-brand flex items-center justify-center",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"h-24 w-24",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),ne("span",{className:"bg-shadow mb-[10px] inline-block h-1 w-16 rounded-[100%]"}),ne("div",{children:[ne(Re,{alignTextCenter:!0,headline:e,questionId:"thankYouCard"}),ne(_t,{subheader:t,questionId:"thankYouCard"}),ne(Ri,{redirectUrl:n,isRedirectDisabled:r})]})]})}const zi=()=>ne("div",{className:"mr-1",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",class:"bi bi-stopwatch",viewBox:"0 0 16 16",children:[ne("path",{d:"M8.5 5.6a.5.5 0 1 0-1 0v2.9h-3a.5.5 0 0 0 0 1H8a.5.5 0 0 0 .5-.5V5.6z"}),ne("path",{d:"M6.5 1A.5.5 0 0 1 7 .5h2a.5.5 0 0 1 0 1v.57c1.36.196 2.594.78 3.584 1.64a.715.715 0 0 1 .012-.013l.354-.354-.354-.353a.5.5 0 0 1 .707-.708l1.414 1.415a.5.5 0 1 1-.707.707l-.353-.354-.354.354a.512.512 0 0 1-.013.012A7 7 0 1 1 7 2.071V1.5a.5.5 0 0 1-.5-.5zM8 3a6 6 0 1 0 .001 12A6 6 0 0 0 8 3z"})]})}),Di=()=>ne("div",{className:"mr-1",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"h-4 w-4",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})})});function Bi({headline:e,html:t,fileUrl:n,buttonLabel:r,onSubmit:i,survey:s,responseCount:o}){const a=()=>{let e=le(s,0);.5===e&&(e=1);const t=s.questions.length/e*15;if(t>360)return"6+ minutes";const n=Math.floor(t/60);return t%60>0?0===n?"less than 1 minute":`less than ${n+1} minutes`:`${n} minutes`},l=s.welcomeCard.timeToFinish,d=s.welcomeCard.showResponseCount;return ne("div",{children:[n&&ne("img",{src:n,className:"mb-8 max-h-96 w-1/3 rounded-lg object-contain",alt:"Company Logo"}),ne(Re,{headline:e,questionId:"welcomeCard"}),ne(ze,{htmlString:t,questionId:"welcomeCard"}),ne("div",{className:"mt-10 flex w-full justify-between",children:ne("div",{className:"flex w-full justify-start gap-4",children:[ne(Pe,{buttonLabel:r,isLastQuestion:!1,focus:!0,onClick:()=>{i({welcomeCard:"clicked"},{})},type:"button"}),ne("div",{className:"text-subheading flex items-center text-xs",children:"Press Enter ↵"})]})}),l&&!d?ne("div",{className:"item-center mt-4 flex text-slate-500",children:[ne(zi,{}),ne("p",{className:"pt-1 text-xs",children:ne("span",{children:[" Takes ",a()," "]})})]}):d&&!l&&o&&o>3?ne("div",{className:"item-center mt-4 flex text-slate-500",children:[ne(Di,{}),ne("p",{className:"pt-1 text-xs",children:ne("span",{children:`${o} people responded`})})]}):l&&d?ne("div",{className:"item-center mt-4 flex text-slate-500",children:[ne(zi,{}),ne("p",{className:"pt-1 text-xs",children:[ne("span",{children:[" Takes ",a()," "]}),ne("span",{children:o&&o>3?`⋅ ${o} people responded`:""})]})]}):null]})}function Hi({survey:e,isBrandingEnabled:t,activeQuestionId:n,onDisplay:r=(()=>{}),onActiveQuestionChange:i=(()=>{}),onResponse:s=(()=>{}),onClose:o=(()=>{}),onFinished:a=(()=>{}),isRedirectDisabled:l=!1,prefillResponseData:d,onFileUpload:c,responseCount:u}){var p;const[h,f]=ke(n||(e.welcomeCard.enabled?"start":null==(p=null==e?void 0:e.questions[0])?void 0:p.id)),[m,b]=ke(!1),[g,v]=ke([]),[_,y]=ke({}),w=e.questions.findIndex((e=>e.id===h)),k=e.questions[w],x=je(null),[j,I]=ke({});xe((()=>{var t,r;"hidden"!==n&&("start"!==n||e.welcomeCard.enabled?f(n||(e.welcomeCard.enabled?"start":null==(r=null==e?void 0:e.questions[0])?void 0:r.id)):f(null==(t=null==e?void 0:e.questions[0])?void 0:t.id))}),[n,e.questions,e.welcomeCard.enabled]),xe((()=>{x.current&&(x.current.scrollTop=0)}),[h]),xe((()=>{r(),d&&L(d,{},!0)}),[]);let C=w,N=k;const S=e=>{const t={..._,...e};y(t)},L=(t,n,r=!1)=>{const o=Object.keys(t)[0];b(!0);const l=function(t,n=!1){var r,i;const s=e.questions,o=t[h];if("start"===h){if(!n)return(null==(r=s[0])?void 0:r.id)||"end";C=0,N=s[0]}if(-1===C)throw new Error("Question not found");if((null==N?void 0:N.logic)&&(null==N?void 0:N.logic.length)>0)for(let e of N.logic)if(e.destination&&Ze(e,o))return e.destination;return(null==(i=s[C+1])?void 0:i.id)||"end"}(t,r),d="end"===l;s({data:t,ttc:n,finished:d}),d&&a(),f(l),v([...g,o]),b(!1),i(l)},T=()=>{var t;let n;if((null==g?void 0:g.length)>0){const t=[...g];if(n=t.pop(),d&&n===e.questions[0].id)return;v(t)}else n=null==(t=e.questions[C-1])?void 0:t.id;if(!n)throw new Error("Question not found");f(n),i(n)};return ne(Z,{children:ne(qe,{survey:e,onClose:o,children:ne("div",{className:"flex h-full w-full flex-col justify-between rounded-lg bg-[--fb-survey-background-color] px-6 pb-3 pt-6",children:[ne("div",{ref:x,className:se(m?"animate-pulse opacity-60":"","my-auto"),children:0!==e.questions.length||e.welcomeCard.enabled||e.thankYouCard.enabled?function(){var t;if("start"===h&&e.welcomeCard.enabled)return ne(Bi,{headline:e.welcomeCard.headline,html:e.welcomeCard.html,fileUrl:e.welcomeCard.fileUrl,buttonLabel:e.welcomeCard.buttonLabel,onSubmit:L,survey:e,responseCount:u});if("end"===h&&e.thankYouCard.enabled)return ne($i,{headline:e.thankYouCard.headline,subheader:e.thankYouCard.subheader,redirectUrl:e.redirectUrl,isRedirectDisabled:l});{const n=e.questions.find((e=>e.id===h));return n&&ne(Pi,{surveyId:e.id,question:n,value:_[n.id],onChange:S,onSubmit:L,onBack:T,ttc:j,setTtc:I,onFileUpload:c,isFirstQuestion:g&&d?g[g.length-1]===e.questions[0].id:n.id===(null==(t=null==e?void 0:e.questions[0])?void 0:t.id),isLastQuestion:n.id===e.questions[e.questions.length-1].id})}}():ne("div",{children:"No questions available."})}),ne("div",{className:"mt-8",children:[t&&ne(re,{}),ne(Me,{survey:e,questionId:h})]})]})})})}function Wi({children:e,isOpen:t,placement:n,clickOutside:r,darkOverlay:i,highlightBorderColor:s,onClose:o}){const[a,l]=ke(!1),d="center"===n,c=je(null);xe((()=>{l(t)}),[t]),xe((()=>{if(d)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)};function e(e){r&&a&&c.current&&!c.current.contains(e.target)&&o()}}),[a,r,o,d]);const u=Ie((()=>s?{borderRadius:"8px",border:"2px solid",overflow:"hidden",borderColor:s}:{}),[s]);return a?ne("div",{"aria-live":"assertive",className:se(d?"pointer-events-auto":"pointer-events-none","z-999999 fixed inset-0 flex items-end"),children:ne("div",{className:se("relative h-full w-full",d?i?"bg-gray-700/80":"bg-white/50":"bg-none transition-all duration-500 ease-in-out"),children:ne("div",{ref:c,className:se((e=>{switch(e){case"bottomRight":default:return"sm:bottom-3 sm:right-3";case"topRight":return"sm:top-3 sm:right-3 sm:bottom-3";case"topLeft":return"sm:top-3 sm:left-3 sm:bottom-3";case"bottomLeft":return"sm:bottom-3 sm:left-3";case"center":return"sm:top-1/2 sm:left-1/2 sm:transform sm:-translate-x-1/2 sm:-translate-y-1/2"}})(n),a?"opacity-100":"opacity-0","border-border pointer-events-auto absolute bottom-0 h-fit w-full overflow-hidden rounded-lg border bg-white shadow-lg transition-all duration-500 ease-in-out sm:m-4 sm:max-w-sm"),children:[!d&&ne("div",{class:"absolute right-0 top-0 block pr-2 pt-2",children:ne("button",{type:"button",onClick:o,class:"text-close-button hover:text-close-button-focus focus:ring-close-button-focus relative h-5 w-5 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2",children:[ne("span",{class:"sr-only",children:"Close survey"}),ne("svg",{class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor","aria-hidden":"true",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4 4L20 20M4 20L20 4"})})]})}),ne("div",{style:u,children:e})]})})}):null}function Qi({survey:e,isBrandingEnabled:t,activeQuestionId:n,placement:r,clickOutside:i,darkOverlay:s,highlightBorderColor:o,onDisplay:a=(()=>{}),onActiveQuestionChange:l=(()=>{}),onResponse:d=(()=>{}),onClose:c=(()=>{}),onFinished:u=(()=>{}),onFileUpload:p,isRedirectDisabled:h=!1,responseCount:f}){const[m,b]=ke(!0),g=()=>{b(!1),setTimeout((()=>{c()}),1e3)};return ne("div",{id:"fbjs",className:"formbricks-form",children:ne(Wi,{placement:r,clickOutside:i,darkOverlay:s,highlightBorderColor:o,isOpen:m,onClose:g,children:ne(Hi,{survey:e,isBrandingEnabled:t,activeQuestionId:n,onDisplay:a,onActiveQuestionChange:l,onResponse:d,onClose:c,onFinished:()=>{u(),setTimeout((()=>{e.redirectUrl||g()}),4e3)},onFileUpload:p,isRedirectDisabled:h,responseCount:f})})})}const Vi=({brandColor:e})=>{if(null===document.getElementById("formbricks__css"))return;const t=document.createElement("style");t.id="formbricks__css__custom",t.innerHTML=`\n :root {\n --fb-brand-color: ${e};\n ${function(e){let t,n,r;if(4===e.length?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):7===e.length&&(t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16)),void 0===t||void 0===n||void 0===r)throw new Error("Invalid color");return.299*t+.587*n+.114*r>128}(e)?"--fb-brand-text-color: black;":"--fb-brand-text-color: white;"}\n }\n `,document.head.appendChild(t)},Ki=e=>{(()=>{if(null===document.getElementById("formbricks__css")){const e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :before,#fbjs :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}#fbjs :before,#fbjs :after{--tw-content: ""}#fbjs html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}#fbjs body{margin:0;line-height:inherit}#fbjs hr{height:0;color:inherit;border-top-width:1px}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs samp,#fbjs pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{text-indent:0;border-color:inherit;border-collapse:collapse}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs button,#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dl,#fbjs dd,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs figure,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs ol,#fbjs ul,#fbjs menu{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{opacity:1;color:#9ca3af}#fbjs input::placeholder,#fbjs textarea::placeholder{opacity:1;color:#9ca3af}#fbjs button,#fbjs [role=button]{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs img,#fbjs svg,#fbjs video,#fbjs canvas,#fbjs audio,#fbjs iframe,#fbjs embed,#fbjs object{display:block;vertical-align:middle}#fbjs img,#fbjs video{max-width:100%;height:auto}#fbjs [hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}#fbjs :is(.sr-only){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}#fbjs :is(.pointer-events-none){pointer-events:none}#fbjs :is(.pointer-events-auto){pointer-events:auto}#fbjs :is(.visible){visibility:visible}#fbjs :is(.fixed){position:fixed}#fbjs :is(.absolute){position:absolute}#fbjs :is(.relative){position:relative}#fbjs :is(.inset-0){top:0;right:0;bottom:0;left:0}#fbjs :is(.bottom-0){bottom:0}#fbjs :is(.left-0){left:0}#fbjs :is(.right-0){right:0}#fbjs :is(.right-2){right:.5em}#fbjs :is(.top-0){top:0}#fbjs :is(.top-2){top:.5em}#fbjs :is(.z-10){z-index:10}#fbjs :is(.z-20){z-index:20}#fbjs :is(.z-999999){z-index:999999}#fbjs :is(.m-2){margin:.5em}#fbjs :is(.my-4){margin-top:1em;margin-bottom:1em}#fbjs :is(.my-auto){margin-top:auto;margin-bottom:auto}#fbjs :is(.mb-1){margin-bottom:.25em}#fbjs :is(.mb-1\\.5){margin-bottom:.375em}#fbjs :is(.mb-4){margin-bottom:1em}#fbjs :is(.mb-5){margin-bottom:1.25em}#fbjs :is(.mb-8){margin-bottom:2em}#fbjs :is(.mb-\\[10px\\]){margin-bottom:10px}#fbjs :is(.ml-2){margin-left:.5em}#fbjs :is(.ml-3){margin-left:.75em}#fbjs :is(.mr-1){margin-right:.25em}#fbjs :is(.mr-4){margin-right:1em}#fbjs :is(.mt-1){margin-top:.25em}#fbjs :is(.mt-10){margin-top:2.5em}#fbjs :is(.mt-2){margin-top:.5em}#fbjs :is(.mt-3){margin-top:.75em}#fbjs :is(.mt-4){margin-top:1em}#fbjs :is(.mt-8){margin-top:2em}#fbjs :is(.box-border){box-sizing:border-box}#fbjs :is(.block){display:block}#fbjs :is(.inline-block){display:inline-block}#fbjs :is(.flex){display:flex}#fbjs :is(.grid){display:grid}#fbjs :is(.hidden){display:none}#fbjs :is(.h-1){height:.25em}#fbjs :is(.h-10){height:2.5em}#fbjs :is(.h-2){height:.5em}#fbjs :is(.h-24){height:6em}#fbjs :is(.h-28){height:7em}#fbjs :is(.h-4){height:1em}#fbjs :is(.h-5){height:1.25em}#fbjs :is(.h-6){height:1.5em}#fbjs :is(.h-8){height:2em}#fbjs :is(.h-fit){height:-moz-fit-content;height:fit-content}#fbjs :is(.h-full){height:100%}#fbjs :is(.max-h-10){max-height:2.5em}#fbjs :is(.max-h-96){max-height:24em}#fbjs :is(.max-h-\\[42vh\\]){max-height:42vh}#fbjs :is(.max-h-full){max-height:100%}#fbjs :is(.w-1\\/2){width:50%}#fbjs :is(.w-1\\/3){width:33.333333%}#fbjs :is(.w-16){width:4em}#fbjs :is(.w-24){width:6em}#fbjs :is(.w-4){width:1em}#fbjs :is(.w-5){width:1.25em}#fbjs :is(.w-8){width:2em}#fbjs :is(.w-full){width:100%}#fbjs :is(.flex-1){flex:1 1 0%}@keyframes pulse{50%{opacity:.5}}#fbjs :is(.animate-pulse){animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs :is(.cursor-pointer){cursor:pointer}#fbjs :is(.grid-cols-2){grid-template-columns:repeat(2,minmax(0,1fr))}#fbjs :is(.flex-col){flex-direction:column}#fbjs :is(.items-end){align-items:flex-end}#fbjs :is(.items-center){align-items:center}#fbjs :is(.justify-start){justify-content:flex-start}#fbjs :is(.justify-end){justify-content:flex-end}#fbjs :is(.justify-center){justify-content:center}#fbjs :is(.justify-between){justify-content:space-between}#fbjs :is(.gap-4){gap:1em}#fbjs :is(.gap-x-5){-moz-column-gap:1.25em;column-gap:1.25em}#fbjs :is(.gap-y-4){row-gap:1em}#fbjs :is(.space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.5em * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5em * var(--tw-space-y-reverse))}#fbjs :is(.self-start){align-self:flex-start}#fbjs :is(.overflow-hidden){overflow:hidden}#fbjs :is(.overflow-y-auto){overflow-y:auto}#fbjs :is(.rounded){border-radius:.25em}#fbjs :is(.rounded-\\[100\\%\\]){border-radius:100%}#fbjs :is(.rounded-full){border-radius:9999px}#fbjs :is(.rounded-lg){border-radius:.5em}#fbjs :is(.rounded-md){border-radius:.375em}#fbjs :is(.rounded-xl){border-radius:.75em}#fbjs :is(.rounded-l-md){border-top-left-radius:.375em;border-bottom-left-radius:.375em}#fbjs :is(.rounded-r-md){border-top-right-radius:.375em;border-bottom-right-radius:.375em}#fbjs :is(.border){border-width:1px}#fbjs :is(.border-2){border-width:2px}#fbjs :is(.border-4){border-width:4px}#fbjs :is(.border-dashed){border-style:dashed}#fbjs :is(.border-back-button-border){border-color:var(--fb-back-btn-border)}#fbjs :is(.border-border){border-color:var(--fb-border-color)}#fbjs :is(.border-border-highlight){border-color:var(--fb-border-color-highlight)}#fbjs :is(.border-brand){border-color:var(--fb-brand-color)}#fbjs :is(.border-slate-300){--tw-border-opacity: 1;border-color:rgb(203 213 225 / var(--tw-border-opacity))}#fbjs :is(.border-submit-button-border){border-color:var(--fb-submit-btn-border)}#fbjs :is(.bg-\\[--fb-survey-background-color\\]){background-color:var(--fb-survey-background-color)}#fbjs :is(.bg-accent-bg){background-color:var(--fb-accent-background-color)}#fbjs :is(.bg-accent-selected-bg){background-color:var(--fb-accent-background-color-selected)}#fbjs :is(.bg-brand){background-color:var(--fb-brand-color)}#fbjs :is(.bg-gray-700\\/80){background-color:#374151cc}#fbjs :is(.bg-shadow){background-color:var(--fb-shadow-color)}#fbjs :is(.bg-slate-100){--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}#fbjs :is(.bg-slate-200){--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity))}#fbjs :is(.bg-slate-50){--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity))}#fbjs :is(.bg-survey-bg){background-color:var(--fb-survey-background-color)}#fbjs :is(.bg-white){--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}#fbjs :is(.bg-white\\/50){background-color:#ffffff80}#fbjs :is(.bg-none){background-image:none}#fbjs :is(.fill-none){fill:none}#fbjs :is(.fill-rating-fill){fill:var(--fb-rating-fill)}#fbjs :is(.stroke-heading){stroke:var(--fb-heading-color)}#fbjs :is(.stroke-rating-selected){stroke:var(--fb-rating-selected)}#fbjs :is(.object-contain){-o-object-fit:contain;object-fit:contain}#fbjs :is(.object-cover){-o-object-fit:cover;object-fit:cover}#fbjs :is(.p-2){padding:.5em}#fbjs :is(.p-4){padding:1em}#fbjs :is(.px-1){padding-left:.25em;padding-right:.25em}#fbjs :is(.px-1\\.5){padding-left:.375em;padding-right:.375em}#fbjs :is(.px-3){padding-left:.75em;padding-right:.75em}#fbjs :is(.px-6){padding-left:1.5em;padding-right:1.5em}#fbjs :is(.py-0){padding-top:0;padding-bottom:0}#fbjs :is(.py-0\\.5){padding-top:.125em;padding-bottom:.125em}#fbjs :is(.py-2){padding-top:.5em;padding-bottom:.5em}#fbjs :is(.py-3){padding-top:.75em;padding-bottom:.75em}#fbjs :is(.py-4){padding-top:1em;padding-bottom:1em}#fbjs :is(.py-6){padding-top:1.5em;padding-bottom:1.5em}#fbjs :is(.pb-3){padding-bottom:.75em}#fbjs :is(.pr-2){padding-right:.5em}#fbjs :is(.pr-2\\.5){padding-right:.625em}#fbjs :is(.pt-1){padding-top:.25em}#fbjs :is(.pt-2){padding-top:.5em}#fbjs :is(.pt-6){padding-top:1.5em}#fbjs :is(.text-left){text-align:left}#fbjs :is(.text-center){text-align:center}#fbjs :is(.text-right){text-align:right}#fbjs :is(.text-base){font-size:1em;line-height:1.5em}#fbjs :is(.text-sm){font-size:.875em;line-height:1.25em}#fbjs :is(.text-xs){font-size:.75em;line-height:1em}#fbjs :is(.font-medium){font-weight:500}#fbjs :is(.font-normal){font-weight:400}#fbjs :is(.font-semibold){font-weight:600}#fbjs :is(.leading-10){line-height:2.5em}#fbjs :is(.leading-4){line-height:1em}#fbjs :is(.leading-6){line-height:1.5em}#fbjs :is(.leading-7){line-height:1.75em}#fbjs :is(.text-brand){color:var(--fb-brand-color)}#fbjs :is(.text-close-button){color:var(--fb-close-btn-color)}#fbjs :is(.text-heading){color:var(--fb-heading-color)}#fbjs :is(.text-info-text){color:var(--fb-info-text-color)}#fbjs :is(.text-on-brand){color:var(--fb-brand-text-color)}#fbjs :is(.text-rating-fill){color:var(--fb-rating-fill)}#fbjs :is(.text-rating-focus){color:var(--fb-rating-hover)}#fbjs :is(.text-rating-selected){color:var(--fb-rating-selected)}#fbjs :is(.text-signature){color:var(--fb-signature-text-color)}#fbjs :is(.text-slate-500){--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity))}#fbjs :is(.text-slate-600){--tw-text-opacity: 1;color:rgb(71 85 105 / var(--tw-text-opacity))}#fbjs :is(.text-slate-700){--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity))}#fbjs :is(.text-subheading){color:var(--fb-subheading-color)}#fbjs :is(.opacity-0){opacity:0}#fbjs :is(.opacity-100){opacity:1}#fbjs :is(.opacity-60){opacity:.6}#fbjs :is(.shadow-lg){--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}#fbjs :is(.shadow-sm){--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}#fbjs :is(.shadow-xl){--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}#fbjs :is(.filter){filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}#fbjs :is(.transition-all){transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}#fbjs :is(.duration-500){transition-duration:.5s}#fbjs :is(.ease-in-out){transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs{font-size:16px}#fbjs *{scrollbar-width:thin;scrollbar-color:#e2e8f0}#fbjs *::-webkit-scrollbar{width:8px;border-radius:99px}#fbjs *::-webkit-scrollbar-track{background:#e2e8f0;border-radius:99px}#fbjs *::-webkit-scrollbar-thumb{background-color:#cbd5e1;border:3px solid #cbd5e1;border-radius:99px}.fb-htmlbody{display:block;font-size:.875em;font-weight:400;line-height:1.5em;color:var(--fb-subheading-color)!important}p.fb-editor-paragraph{color:var(--fb-subheading-color)!important}:root{--slate-50: rgb(248 250 252);--slate-100: rgb(241 245 249);--slate-200: rgb(226 232 240);--slate-300: rgb(203 213 225);--slate-400: rgb(148 163 184);--slate-500: rgb(100 116 139);--slate-600: rgb(71 85 105);--slate-700: rgb(51 65 85);--slate-800: rgb(30 41 59);--slate-900: rgb(15 23 42);--gray-100: rgb(243 244 246);--gray-200: rgb(229 231 235);--yellow-300: rgb(253 224 71);--yellow-500: rgb(234 179 8);--fb-brand-color: rgb(255, 255, 255);--fb-brand-text-color: black;--fb-border-color: var(--slate-300);--fb-border-color-highlight: var(--slate-500);--fb-focus-color: var(--slate-500);--fb-heading-color: var(--slate-900);--fb-subheading-color: var(--slate-700);--fb-info-text-color: var(--slate-500);--fb-signature-text-color: var(--slate-400);--fb-survey-background-color: white;--fb-accent-background-color: var(--slate-200);--fb-accent-background-color-selected: var(--slate-100);--fb-placeholder-color: var(--slate-400);--fb-shadow-color: var(--slate-300);--fb-rating-fill: var(--yellow-300);--fb-rating-hover: var(--yellow-500);--fb-back-btn-border: transparent;--fb-submit-btn-border: transparent;--fb-rating-selected: black;--fb-close-btn-color: var(--slate-500);--fb-close-btn-color-hover: var(--slate-700)}#fbjs :is(.placeholder\\:text-placeholder)::-moz-placeholder{color:var(--fb-placeholder-color)}#fbjs :is(.placeholder\\:text-placeholder)::placeholder{color:var(--fb-placeholder-color)}#fbjs :is(.first\\:rounded-l-md:first-child){border-top-left-radius:.375em;border-bottom-left-radius:.375em}#fbjs :is(.last\\:rounded-r-md:last-child){border-top-right-radius:.375em;border-bottom-right-radius:.375em}#fbjs :is(.focus-within\\:border-border-highlight:focus-within){border-color:var(--fb-border-color-highlight)}#fbjs :is(.focus-within\\:bg-accent-bg:focus-within){background-color:var(--fb-accent-background-color)}#fbjs :is(.hover\\:bg-accent-bg:hover){background-color:var(--fb-accent-background-color)}#fbjs :is(.hover\\:bg-slate-100:hover){--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}#fbjs :is(.hover\\:bg-slate-50:hover){--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity))}#fbjs :is(.hover\\:text-close-button-focus:hover){color:var(--fb-close-btn-hover-color)}#fbjs :is(.hover\\:text-heading:hover){color:var(--fb-heading-color)}#fbjs :is(.hover\\:text-slate-900:hover){--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity))}#fbjs :is(.hover\\:opacity-90:hover){opacity:.9}#fbjs :is(.focus\\:border-4:focus){border-width:4px}#fbjs :is(.focus\\:border-border-highlight:focus){border-color:var(--fb-border-color-highlight)}#fbjs :is(.focus\\:bg-accent-bg:focus){background-color:var(--fb-accent-background-color)}#fbjs :is(.focus\\:bg-accent-selected-bg:focus){background-color:var(--fb-accent-background-color-selected)}#fbjs :is(.focus\\:text-rating-focus:focus){color:var(--fb-rating-hover)}#fbjs :is(.focus\\:outline-none:focus){outline:2px solid transparent;outline-offset:2px}#fbjs :is(.focus\\:ring-0:focus){--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}#fbjs :is(.focus\\:ring-2:focus){--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}#fbjs :is(.focus\\:ring-border-highlight:focus){--tw-ring-color: var(--fb-border-color-highlight)}#fbjs :is(.focus\\:ring-close-button-focus:focus){--tw-ring-color: var(--fb-close-btn-hover-color)}#fbjs :is(.focus\\:ring-focus:focus){--tw-ring-color: var(--fb-focus-color)}#fbjs :is(.focus\\:ring-offset-0:focus){--tw-ring-offset-width: 0px}#fbjs :is(.focus\\:ring-offset-2:focus){--tw-ring-offset-width: 2px}#fbjs :is(.disabled\\:cursor-not-allowed:disabled){cursor:not-allowed}#fbjs :is(.disabled\\:opacity-50:disabled){opacity:.5}#fbjs :is(.dark .dark\\:border-slate-600){--tw-border-opacity: 1;border-color:rgb(71 85 105 / var(--tw-border-opacity))}#fbjs :is(.dark .dark\\:bg-slate-700){--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity))}#fbjs :is(.dark .dark\\:text-slate-400){--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity))}#fbjs :is(.dark .dark\\:hover\\:border-slate-500:hover){--tw-border-opacity: 1;border-color:rgb(100 116 139 / var(--tw-border-opacity))}#fbjs :is(.dark .dark\\:hover\\:bg-slate-800:hover){--tw-bg-opacity: 1;background-color:rgb(30 41 59 / var(--tw-bg-opacity))}@media (min-width: 640px){#fbjs :is(.sm\\:bottom-3){bottom:.75em}#fbjs :is(.sm\\:left-1\\/2){left:50%}#fbjs :is(.sm\\:left-3){left:.75em}#fbjs :is(.sm\\:right-3){right:.75em}#fbjs :is(.sm\\:top-1\\/2){top:50%}#fbjs :is(.sm\\:top-3){top:.75em}#fbjs :is(.sm\\:m-4){margin:1em}#fbjs :is(.sm\\:max-w-sm){max-width:24em}#fbjs :is(.sm\\:-translate-x-1\\/2){--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.sm\\:-translate-y-1\\/2){--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.sm\\:transform){transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.sm\\:text-sm){font-size:.875em;line-height:1.25em}}.fb-editor-text-bold{font-weight:700!important}.fb-editor-text-italic{font-style:italic!important}.fb-editor-link{color:#334155!important;text-decoration:underline!important}.editor-tokenFunction{color:#dd4a68!important}.fb-editor-paragraph{margin:0!important;position:relative!important;color:#334155!important}.fb-editor-paragraph:last-child{margin-bottom:0!important}.fb-editor-heading-h1{font-size:25px!important;font-weight:400!important;margin-bottom:20px!important;font-weight:700!important}.fb-editor-heading-h2{font-size:20px!important;font-weight:700!important;margin-bottom:20px!important}.fb-editor-list-ul,.fb-editor-list-ol{margin-bottom:12px!important}.fb-editor-listitem{margin:0 32px!important}.fb-editor-nested-listitem{list-style-type:none!important}',document.head.appendChild(e)}})(),Vi({brandColor:e.brandColor});const t=document.createElement("div");var n,r,i,s,o,a,l;t.id="formbricks-modal-container",document.body.appendChild(t),n=M(Qi,e),r=t,k.__&&k.__(n,r),o=(s="function"==typeof i)?null:i&&i.__k||r.__k,a=[],l=[],Y(r,n=(!s&&i||r).__k=M(Z,null,[n]),o||S,S,void 0!==r.ownerSVGElement,!s&&i?[i]:o?null:r.firstChild?w.call(r.childNodes):null,a,!s&&i?i:o?o.__e:r.firstChild,s,l),J(a,n,l)},Yi=l.getInstance(),Ji=e.getInstance();let Xi=null;const Gi=(e,t)=>{const n=Math.abs(t.getTime()-e.getTime());return Math.floor(n/864e5)},es=async e=>{try{const i=await(async({apiHost:e,environmentId:r,userId:i})=>{const s=`${e}/api/v1/client/${r}/in-app/sync/${i}`,o=`${e}/api/v1/client/${r}/in-app/sync`;if(!i){const e=await fetch(o);if(!e.ok){const t=await e.json();return n({code:"network_error",status:e.status,message:"Error syncing with backend",url:s,responseMessage:t.message})}return t((await e.json()).data)}const a=await fetch(s);if(!a.ok){const e=await a.json();return n({code:"network_error",status:a.status,message:"Error syncing with backend",url:s,responseMessage:e.message})}const l=await a.json(),{data:d}=l;return t(d)})(e);if(!0!==(null==i?void 0:i.ok))throw Ji.error(`Sync failed: ${JSON.stringify(i.error)}`),i.error;let s;try{s=Yi.get().state}catch(r){}let o={surveys:i.value.surveys,noCodeActionClasses:i.value.noCodeActionClasses,product:i.value.product,attributes:(null==s?void 0:s.attributes)||{}};if(e.userId){const e=o.surveys.map((e=>e.name));Ji.debug("Fetched "+e.length+" surveys during sync: "+e.join(", "))}else{o={...o,displays:(null==s?void 0:s.displays)||[]},o=ts(o);const e=o.surveys.map((e=>e.name));Ji.debug("Fetched "+e.length+" surveys during sync: "+e.join(", "))}Yi.update({apiHost:e.apiHost,environmentId:e.environmentId,userId:e.userId,state:o})}catch(i){throw Ji.error(`Error during sync: ${i}`),i}},ts=e=>{const{displays:t,product:n}=e;let{surveys:r}=e;if(!t)return e;let i=r.filter((e=>{if("respondMultiple"===e.displayOption)return!0;if("displayOnce"===e.displayOption)return 0===t.filter((t=>t.surveyId===e.id)).length;if("displayMultiple"===e.displayOption)return 0===t.filter((t=>t.surveyId===e.id&&t.responded)).length;throw Error("Invalid displayOption")}));const s=t.length>0?t[t.length-1]:void 0;return i=i.filter((e=>{if(s){if(null!==e.recontactDays){const n=t.filter((t=>t.surveyId===e.id))[0];return!n||Gi(new Date,new Date(n.createdAt))>=e.recontactDays}return null===n.recontactDays||Gi(new Date,new Date(s.createdAt))>=n.recontactDays}return!0})),{...e,surveys:i}},ns=()=>{"undefined"!=typeof window&&null!==Xi&&(window.clearInterval(Xi),Xi=null)},rs="formbricks-web-container",is=l.getInstance(),ss=e.getInstance(),os=o.getInstance();let as=!1;const ls=e=>{if(as)return void ss.debug("A survey is already running. Skipping.");as=!0,e.delay&&ss.debug(`Delaying survey by ${e.delay} seconds.`);const t=is.get().state.product,n=new y(e.id,null,null,is.get().userId),r=new v({apiHost:is.get().apiHost,environmentId:is.get().environmentId,retryAttempts:2,onResponseSendingFailed:e=>{alert(`Failed to send response: ${JSON.stringify(e,null,2)}`)}},n),i=e.productOverwrites??{},s=i.brandColor??t.brandColor,o=i.highlightBorderColor??t.highlightBorderColor,a=i.clickOutsideClose??t.clickOutsideClose,l=i.darkOverlay??t.darkOverlay,d=i.placement??t.placement,c=t.inAppSurveyBranding;setTimeout((()=>{Ki({survey:e,brandColor:s,isBrandingEnabled:c,clickOutside:a,darkOverlay:l,highlightBorderColor:o,placement:d,onDisplay:async()=>{const{userId:t}=is.get();if(!t){const t={createdAt:new Date,surveyId:e.id,responded:!1},n=is.get().state.displays,r=n?[...n,t]:[t],i=is.get();let s=ts({...i.state,displays:r});is.update({...i,state:s})}const i=new g({apiHost:is.get().apiHost,environmentId:is.get().environmentId}),s=await i.client.display.create({surveyId:e.id,userId:t});if(!s.ok)throw new Error("Could not create display");const{id:o}=s.data;n.updateDisplayId(o),r.updateSurveyState(n)},onResponse:e=>{const{userId:t}=is.get();if(!t){const e=is.get().state.displays,t=e&&e[e.length-1];if(!t)throw new Error("No lastDisplay found");if(!t.responded){t.responded=!0;const n=is.get();let r=ts({...n.state,displays:e});is.update({...n,state:r})}}t&&n.updateUserId(t),r.updateSurveyState(n),r.add({data:e.data,ttc:e.ttc,finished:e.finished})},onClose:ds,onFileUpload:async(e,t)=>{const n=new g({apiHost:is.get().apiHost,environmentId:is.get().environmentId});return await n.client.storage.uploadFile(e,t)}})}),1e3*e.delay)},ds=async()=>{var e;if(null==(e=document.getElementById(rs))||e.remove(),cs(),!is.get().userId){const e=is.get().state,t=ts(e);return is.update({...is.get(),state:t}),void(as=!1)}try{await es({apiHost:is.get().apiHost,environmentId:is.get().environmentId,userId:is.get().userId}),as=!1}catch(t){os.handle(t)}},cs=()=>{const e=document.createElement("div");e.id=rs,document.body.appendChild(e)},us=e.getInstance(),ps=l.getInstance(),hs=["Exit Intent (Desktop)","50% Scroll"],fs=async(e,t={})=>{var r;const{userId:i}=ps.get(),s={environmentId:ps.get().environmentId,userId:i,name:e,properties:t||{}};if(i&&!hs.includes(e)){us.debug(`Sending action "${e}" to backend`);const t=new g({apiHost:ps.get().apiHost,environmentId:ps.get().environmentId}),r=await t.client.action.create({...s,userId:i});if(!r.ok)return n({code:"network_error",message:`Error tracking action ${e}`,status:500,url:`${ps.get().apiHost}/api/v1/client/${ps.get().environmentId}/actions`,responseMessage:r.error.message})}us.debug(`Formbricks: Action "${e}" tracked`);const o=null==(r=ps.get().state)?void 0:r.surveys;return o&&o.length>0?ms(e,o):us.debug("No active surveys to display"),{ok:!0,value:void 0}},ms=(e,t)=>{for(const n of t)for(const t of n.triggers)if(t===e)return us.debug(`Formbricks: survey ${n.id} triggered by action "${e}"`),void ls(n)};let bs=!1,gs=async function(e){if(e.clientY<=0){const e=await fs("Exit Intent (Desktop)");if(!0!==e.ok)return n(e.error)}};const vs=()=>{bs&&(document.removeEventListener("mouseleave",gs),bs=!1)};let _s=!1,ys=!1,ws=async()=>{const e=window.scrollY,t=window.innerHeight,r=document.documentElement.scrollHeight;if(0===e&&(ys=!1),!ys&&e/(r-t)>=.5){ys=!0;const e=await fs("50% Scroll");if(!0!==e.ok)return n(e.error)}};const ks=()=>{_s&&(window.removeEventListener("scroll",ws),_s=!1)},xs=l.getInstance(),js=e.getInstance(),Is=o.getInstance(),Cs=async()=>{var e;js.debug(`Checking page url: ${window.location.href}`);const{state:t}=xs.get();if(void 0===(null==t?void 0:t.noCodeActionClasses))return{ok:!0,value:void 0};const r=((null==t?void 0:t.noCodeActionClasses)||[]).filter((e=>{const{innerHtml:t,cssSelector:n,pageUrl:r}=e.noCodeConfig||{};return r&&!t&&!n}));if(0===r.length)return{ok:!0,value:void 0};for(const i of r){if(!(null==(e=i.noCodeConfig)?void 0:e.pageUrl))continue;const{noCodeConfig:{pageUrl:t}}=i,r=Ts(window.location.href,t.value,t.rule);if(!0!==r.ok)return n(r.error);if(!1===r.value)continue;const s=await fs(i.name);if(!0!==s.ok)return n(s.error)}return{ok:!0,value:void 0}};let Ns=!1;const Ss=()=>Cs(),Ls=()=>{"undefined"!=typeof window&&Ns&&(window.removeEventListener("hashchange",Ss),window.removeEventListener("popstate",Ss),window.removeEventListener("pushstate",Ss),window.removeEventListener("replacestate",Ss),window.removeEventListener("load",Ss),Ns=!1)};function Ts(e,r,i){switch(i){case"exactMatch":return t(e===r);case"contains":return t(e.includes(r));case"startsWith":return t(e.startsWith(r));case"endsWith":return t(e.endsWith(r));case"notMatch":return t(e!==r);case"notContains":return t(!e.includes(r));default:return n({code:"invalid_match_type",message:"Invalid match type"})}}let Es=!1;const Os=e=>(e=>{const{state:t}=xs.get();if(!t)return;const n=e.target;((null==t?void 0:t.noCodeActionClasses)||[]).forEach((e=>{var t,r,i,s,o,a,l,d;const c=null==(r=null==(t=e.noCodeConfig)?void 0:t.innerHtml)?void 0:r.value,u=null==(s=null==(i=e.noCodeConfig)?void 0:i.cssSelector)?void 0:s.value,p=null==(a=null==(o=e.noCodeConfig)?void 0:o.pageUrl)?void 0:a.value,h=null==(d=null==(l=e.noCodeConfig)?void 0:l.pageUrl)?void 0:d.rule;if((c||u||p)&&(!c||n.innerHTML===c)){if(u){const e=u.split(/\s*(?=[.#])/);for(let t of e)if(!n.matches(t))return}if(p&&h){const e=Ts(window.location.href,p,h);if(!e.ok||!e.value)return}fs(e.name).then((e=>{var t,n,r;n=e=>{},r=e=>{Is.handle(e)},!0===(t=e).ok?n(t.value):r(t.error)}))}}))})(e),As=()=>{Es&&(document.removeEventListener("click",Os),Es=!1)};let Ms=!1;const qs=()=>{"undefined"!=typeof window&&null===Xi&&(Xi=window.setInterval((async()=>{Yi.get().expiresAt&&new Date(Yi.get().expiresAt)>=new Date||(Ji.debug("Config has expired. Starting sync."),await es({apiHost:Yi.get().apiHost,environmentId:Yi.get().environmentId,userId:Yi.get().userId}))}),6e4)),"undefined"==typeof window||Ns||(window.addEventListener("hashchange",Ss),window.addEventListener("popstate",Ss),window.addEventListener("pushstate",Ss),window.addEventListener("replacestate",Ss),window.addEventListener("load",Ss),Ns=!0),"undefined"==typeof window||Es||(document.addEventListener("click",Os),Es=!0),"undefined"==typeof document||bs||(document.querySelector("body").addEventListener("mouseleave",gs),bs=!0),"undefined"==typeof window||_s||(window.addEventListener("load",(()=>{window.addEventListener("scroll",ws)})),_s=!0)},Zs=()=>{ns(),Ls(),As(),vs(),ks(),Ms&&(window.removeEventListener("beforeunload",(()=>{ns(),Ls(),As(),vs(),ks()})),Ms=!1)},Us=l.getInstance(),Ps=e.getInstance(),Fs=async()=>(Ps.error("'setUserId' is no longer supported. Please set the userId in the init call instead."),{ok:!0,value:void 0}),Rs=async(e,t)=>{if(Ps.debug("Setting attribute: "+e+" to value: "+t),((e,t)=>Us.get().state.attributes[e]===t)(e,t.toString()))return Ps.debug("Attribute already set to this value. Skipping update."),{ok:!0,value:void 0};const r=await(async(e,t)=>{const{apiHost:r,environmentId:i,userId:s}=Us.get();if(!s)return n({code:"missing_person",message:"Unable to update attribute. User identification deactivated. No userId set."});const o={attributes:{[e]:t}},a=new g({apiHost:Us.get().apiHost,environmentId:Us.get().environmentId}),l=await a.client.people.update(s,o);return l.ok?(Ps.debug("Attribute updated. Syncing..."),await es({environmentId:i,apiHost:r,userId:s}),{ok:!0,value:void 0}):n({code:"network_error",status:500,message:`Error updating person with userId ${s}`,url:`${Us.get().apiHost}/api/v1/client/${i}/people/${s}`,responseMessage:l.error.message})})(e,t.toString());return r.ok?(Us.update({environmentId:Us.get().environmentId,apiHost:Us.get().apiHost,userId:Us.get().userId,state:{...Us.get().state,attributes:{...Us.get().state.attributes,[e]:t.toString()}}}),{ok:!0,value:void 0}):n(r.error)},$s=async()=>{Qs()},zs=async()=>{Ps.debug("Resetting state & getting new state from backend"),ds();const e={environmentId:Us.get().environmentId,apiHost:Us.get().apiHost,userId:Us.get().userId};await $s();try{return await Ws(e),{ok:!0,value:void 0}}catch(t){return n(t)}},Ds=l.getInstance(),Bs=e.getInstance();let Hs=!1;const Ws=async e=>{if(Hs)return Bs.debug("Already initialized, skipping initialization."),{ok:!0,value:void 0};if((e=>{e.debug&&(Bs.debug("Setting log level to debug"),Bs.configure({logLevel:"debug"}))})(e),o.getInstance().printStatus(),Bs.debug("Start initialize"),!e.environmentId)return Bs.debug("No environmentId provided"),n({code:"missing_field",field:"environmentId"});if(!e.apiHost)return Bs.debug("No apiHost provided"),n({code:"missing_field",field:"apiHost"});if(Bs.debug("Adding widget container to DOM"),cs(),!e.userId&&e.attributes)return Bs.error("No userId provided but attributes. Cannot update attributes without userId."),n({code:"missing_field",field:"userId"});let r,i=null;if(e.userId&&e.attributes){const r=await(async(e,r,i,s)=>{var o,a;if(!i)return n({code:"missing_person",message:"Unable to update attribute. User identification deactivated. No userId set."});const l={...s};try{const e=null==(a=null==(o=Us.get())?void 0:o.state)?void 0:a.attributes;if(e)for(const[t,n]of Object.entries(e))l[t]===n&&delete l[t]}catch(p){Ps.debug("config not set; sending all attributes to backend")}if(0===Object.keys(l).length)return Ps.debug("No attributes to update. Skipping update."),t(l);Ps.debug("Updating attributes: "+JSON.stringify(l));const d={attributes:l},c=new g({apiHost:e,environmentId:r}),u=await c.client.people.update(i,d);return u.ok?t(l):n({code:"network_error",status:500,message:`Error updating person with userId ${i}`,url:`${e}/api/v1/client/${r}/people/${i}`,responseMessage:u.error.message})})(e.apiHost,e.environmentId,e.userId,e.attributes);if(!0!==r.ok)return n(r.error);i=r.value}try{r=Ds.get()}catch(s){Bs.debug("No existing configuration found.")}return r&&r.state&&r.environmentId===e.environmentId&&r.apiHost===e.apiHost&&r.userId===e.userId&&r.expiresAt?(Bs.debug("Found existing configuration."),r.expiresAt<new Date?(Bs.debug("Configuration expired."),await es({apiHost:e.apiHost,environmentId:e.environmentId,userId:e.userId})):(Bs.debug("Configuration not expired. Extending expiration."),Ds.update(r))):(Bs.debug("No valid configuration found or it has been expired. Creating new config."),Bs.debug("Syncing."),await es({apiHost:e.apiHost,environmentId:e.environmentId,userId:e.userId}),await fs("New Session")),i&&Object.keys(i).length>0&&Ds.update({environmentId:Ds.get().environmentId,apiHost:Ds.get().apiHost,userId:Ds.get().userId,state:{...Ds.get().state,attributes:{...Ds.get().state.attributes,...e.attributes}}}),Bs.debug("Adding event listeners"),qs(),Ms||(window.addEventListener("beforeunload",(()=>{ns(),Ls(),As(),vs(),ks()})),Ms=!0),Hs=!0,Bs.debug("Initialized"),Cs(),{ok:!0,value:void 0}},Qs=()=>{Bs.debug("Deinitializing"),ds(),Zs(),Ds.resetConfig(),Hs=!1};e.getInstance().debug("Create command queue");const Vs=new class{constructor(){this.queue=[],this.running=!1,this.resolvePromise=null,this.commandPromise=null}add(e=!0,t,...n){this.queue.push({command:t,checkInitialized:e,commandArgs:n}),this.running||(this.commandPromise=new Promise((e=>{this.resolvePromise=e,this.run()})))}async wait(){this.running&&await this.commandPromise}async run(){for(this.running=!0;this.queue.length>0;){const e=o.getInstance(),t=this.queue.shift();if(!t)continue;if(t.checkInitialized){const t=(Bs.debug("Check if initialized"),Hs&&o.initialized?{ok:!0,value:void 0}:n({code:"not_initialized",message:"Formbricks not initialized. Call initialize() first."}));t&&!0!==t.ok&&e.handle(t.error)}const r=await(null==t?void 0:t.command.apply(null,null==t?void 0:t.commandArgs));r&&(!0!==r.ok&&e.handle(r.error))}this.running=!1,this.resolvePromise&&(this.resolvePromise(),this.resolvePromise=null,this.commandPromise=null)}},Ks=async(e,t)=>{Vs.add(!0,Rs,e,t),await Vs.wait()};return{init:async e=>{o.init(e.errorHandler),Vs.add(!1,Ws,e),await Vs.wait()},setUserId:async()=>{Vs.add(!0,Fs),await Vs.wait()},setEmail:async e=>{Ks("email",e),await Vs.wait()},setAttribute:Ks,track:async(e,t={})=>{Vs.add(!0,fs,e,t),await Vs.wait()},logout:async()=>{Vs.add(!0,$s),await Vs.wait()},reset:async()=>{Vs.add(!0,zs),await Vs.wait()},registerRouteChange:async()=>{Vs.add(!0,Cs),await Vs.wait()},getApi:()=>{const e=l.getInstance(),{environmentId:t,apiHost:n}=e.get();if(!t||!n)throw new Error("formbricks.init() must be called before getApi()");return new g({apiHost:n,environmentId:t})}}}));
//# sourceMappingURL=index.umd.js.map