@insure-os/client 0.0.81 → 0.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- const e=()=>{globalThis.insureOSDebug};var t,n,r,i,o,s,a,l,c,d,u,h,m,f,p,g,y={},v=[],w=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,b=Array.isArray;function x(e,t){for(var n in t)e[n]=t[n];return e}function k(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function N(e,n,r){var i,o,s,a={};for(s in n)"key"==s?i=n[s]:"ref"==s?o=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?t.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===a[s]&&(a[s]=e.defaultProps[s]);return S(e,a,i,o,null)}function S(e,t,i,o,s){var a={type:e,props:t,key:i,ref:o,i:null,m:null,p:0,v:null,k:null,constructor:void 0,N:null==s?++r:s,C:-1,_:0};return null==s&&null!=n.vnode&&n.vnode(a),a}function C(e){return e.children}function _(e,t){this.props=e,this.context=t}function $(e,t){if(null==t)return e.m?$(e.m,e.C+1):null;for(var n;t<e.i.length;t++)if(null!=(n=e.i[t])&&null!=n.v)return n.v;return"function"==typeof e.type?$(e):null}function I(e){if(e.I&&e.P){var t=e.N,r=t.v,i=[],o=[],s=x({},t);s.N=t.N+1,n.vnode&&n.vnode(s),A(e.I,s,t,e.R,e.I.namespaceURI,32&t._?[r]:null,i,null==r?$(t):r,!!(32&t._),o),s.N=t.N,s.m.i[s.C]=s,B(i,s,o),t.v=t.m=null,s.v!=r&&T(s)}}function T(e){if(null!=(e=e.m)&&null!=e.k)return e.v=e.k.base=null,e.i.some(function(t){if(null!=t&&null!=t.v)return e.v=e.k.base=t.v}),T(e)}function E(e){(!e.P&&(e.P=!0)&&i.push(e)&&!P.O++||o!=n.debounceRendering)&&((o=n.debounceRendering)||s)(P)}function P(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(a),e=i.shift(),t=i.length,I(e)}finally{i.length=P.O=0}}function z(e,t,n,r,i,o,s,a,l,c,d){var u,h,m,f,p,g,w,b=r&&r.i||v,x=t.length;for(l=D(n,t,b,l,x),u=0;u<x;u++)null!=(m=n.i[u])&&(h=-1!=m.C&&b[m.C]||y,m.C=u,g=A(e,m,h,i,o,s,a,l,c,d),f=m.v,m.ref&&h.ref!=m.ref&&(h.ref&&H(h.ref,null,m),d.push(m.ref,m.k||f,m)),null==p&&null!=f&&(p=f),(w=!!(4&m._))||h.i===m.i?(l=R(m,l,e,w),w&&h.v&&(h.v=null)):"function"==typeof m.type&&void 0!==g?l=g:f&&(l=f.nextSibling),m._&=-7);return n.v=p,l}function D(e,t,n,r,i){var o,s,a,l,c,d=n.length,u=d,h=0;for(e.i=new Array(i),o=0;o<i;o++)null!=(s=t[o])&&"boolean"!=typeof s&&"function"!=typeof s?("string"==typeof s||"number"==typeof s||"bigint"==typeof s||s.constructor==String?s=e.i[o]=S(null,s,null,null,null):b(s)?s=e.i[o]=S(C,{children:s},null,null,null):void 0===s.constructor&&s.p>0?s=e.i[o]=S(s.type,s.props,s.key,s.ref?s.ref:null,s.N):e.i[o]=s,l=o+h,s.m=e,s.p=e.p+1,a=null,-1!=(c=s.C=M(s,n,l,u))&&(u--,(a=n[c])&&(a._|=2)),null==a||null==a.N?(-1==c&&(i>d?h--:i<d&&h++),"function"!=typeof s.type&&(s._|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,s._|=4))):e.i[o]=null;if(u)for(o=0;o<d;o++)null!=(a=n[o])&&!(2&a._)&&(a.v==r&&(r=$(a)),U(a,a));return r}function R(e,t,n,r){var i,o;if("function"==typeof e.type){for(i=e.i,o=0;i&&o<i.length;o++)i[o]&&(i[o].m=e,t=R(i[o],t,n,r));return t}e.v!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=$(e)),n.insertBefore(e.v,t||null)),t=e.v);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function M(e,t,n,r){var i,o,s,a=e.key,l=e.type,c=t[n],d=null!=c&&!(2&c._);if(null===c&&null==a||d&&a==c.key&&l==c.type)return n;if(r>(d?1:0))for(i=n-1,o=n+1;i>=0||o<t.length;)if(null!=(c=t[s=i>=0?i--:o++])&&!(2&c._)&&a==c.key&&l==c.type)return s;return-1}function O(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||w.test(t)?n:n+"px"}function j(e,t,n,r,i){var o,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||O(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||O(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(u,"$1")),s=t.toLowerCase(),t=s in e||"onFocusOut"==t||"onFocusIn"==t?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[d]=r[d]:(n[d]=h,e.addEventListener(t,o?f:m,o)):e.removeEventListener(t,o?f:m,o);else{if("http://www.w3.org/2000/svg"==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&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function W(e){return function(t){if(this.l){var r=this.l[t.type+e];if(null==t[c])t[c]=h++;else if(t[c]<r[d])return;return r(n.event?n.event(t):t)}}}function A(e,t,r,i,o,s,a,l,c,d){var u,h,m,f,p,g,y,w,N,S,$,I,T,E,P,D=t.type;if(void 0!==t.constructor)return null;128&r._&&(c=!!(32&r._),s=[l=t.v=r.v]),(u=n.p)&&u(t);e:if("function"==typeof D)try{if(w=t.props,N=D.prototype&&D.prototype.render,S=(u=D.contextType)&&i[u.k],$=u?S?S.props.value:u.m:i,r.k?y=(h=t.k=r.k).m=h.j:(N?t.k=h=new D(w,$):(t.k=h=new _(w,$),h.constructor=D,h.render=Y),S&&S.sub(h),h.state||(h.state={}),h.R=i,m=h.P=!0,h.W=[],h.A=[]),N&&null==h.L&&(h.L=h.state),N&&null!=D.getDerivedStateFromProps&&(h.L==h.state&&(h.L=x({},h.L)),x(h.L,D.getDerivedStateFromProps(w,h.L))),f=h.props,p=h.state,h.N=t,m)N&&null==D.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),N&&null!=h.componentDidMount&&h.W.push(h.componentDidMount);else{if(N&&null==D.getDerivedStateFromProps&&w!==f&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(w,$),t.N==r.N||!h.v&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(w,h.L,$)){t.N!=r.N&&(h.props=w,h.state=h.L,h.P=!1),t.v=r.v,t.i=r.i,t.i.some(function(e){e&&(e.m=t)}),v.push.apply(h.W,h.A),h.A=[],h.W.length&&a.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(w,h.L,$),N&&null!=h.componentDidUpdate&&h.W.push(function(){h.componentDidUpdate(f,p,g)})}if(h.context=$,h.props=w,h.I=e,h.v=!1,I=n.O,T=0,N)h.state=h.L,h.P=!1,I&&I(t),u=h.render(h.props,h.state,h.context),v.push.apply(h.W,h.A),h.A=[];else do{h.P=!1,I&&I(t),u=h.render(h.props,h.state,h.context),h.state=h.L}while(h.P&&++T<25);h.state=h.L,null!=h.getChildContext&&(i=x(x({},i),h.getChildContext())),N&&!m&&null!=h.getSnapshotBeforeUpdate&&(g=h.getSnapshotBeforeUpdate(f,p)),E=null!=u&&u.type===C&&null==u.key?q(u.props.children):u,l=z(e,b(E)?E:[E],t,r,i,o,s,a,l,c,d),h.base=t.v,t._&=-161,h.W.length&&a.push(h),y&&(h.j=h.m=null)}catch(e){if(t.N=null,c||null!=s)if(e.then){for(t._|=c?160:128;l&&8==l.nodeType&&l.nextSibling;)l=l.nextSibling;s[s.indexOf(l)]=null,t.v=l}else{for(P=s.length;P--;)k(s[P]);L(t)}else t.v=r.v,t.i=r.i,e.then||L(t);n.v(e,t,r)}else null==s&&t.N==r.N?(t.i=r.i,t.v=r.v):l=t.v=F(r.v,t,r,i,o,s,a,c,d);return(u=n.diffed)&&u(t),128&t._?void 0:l}function L(e){e&&(e.k&&(e.k.v=!0),e.i&&e.i.some(L))}function B(e,t,r){for(var i=0;i<r.length;i++)H(r[i],r[++i],r[++i]);n.k&&n.k(t,e),e.some(function(t){try{e=t.W,t.W=[],e.some(function(e){e.call(t)})}catch(e){n.v(e,t.N)}})}function q(e){return"object"!=typeof e||null==e||e.p>0?e:b(e)?e.map(q):x({},e)}function F(e,r,i,o,s,a,l,c,d){var u,h,m,f,p,g,v,w=i.props||y,x=r.props,N=r.type;if("svg"==N?s="http://www.w3.org/2000/svg":"math"==N?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),null!=a)for(u=0;u<a.length;u++)if((p=a[u])&&"setAttribute"in p==!!N&&(N?p.localName==N:3==p.nodeType)){e=p,a[u]=null;break}if(null==e){if(null==N)return document.createTextNode(x);e=document.createElementNS(s,N,x.is&&x),c&&(n.B&&n.B(r,a),c=!1),a=null}if(null==N)w===x||c&&e.data==x||(e.data=x);else{if(a=a&&t.call(e.childNodes),!c&&null!=a)for(w={},u=0;u<e.attributes.length;u++)w[(p=e.attributes[u]).name]=p.value;for(u in w)p=w[u],"dangerouslySetInnerHTML"==u?m=p:"children"==u||u in x||"value"==u&&"defaultValue"in x||"checked"==u&&"defaultChecked"in x||j(e,u,null,p,s);for(u in x)p=x[u],"children"==u?f=p:"dangerouslySetInnerHTML"==u?h=p:"value"==u?g=p:"checked"==u?v=p:c&&"function"!=typeof p||w[u]===p||j(e,u,p,w[u],s);if(h)c||m&&(h.H==m.H||h.H==e.innerHTML)||(e.innerHTML=h.H),r.i=[];else if(m&&(e.innerHTML=""),z("template"==r.type?e.content:e,b(f)?f:[f],r,i,o,"foreignObject"==N?"http://www.w3.org/1999/xhtml":s,a,l,a?a[0]:i.i&&$(i,0),c,d),null!=a)for(u=a.length;u--;)k(a[u]);c||(u="value","progress"==N&&null==g?e.removeAttribute("value"):null!=g&&(g!==e[u]||"progress"==N&&!g||"option"==N&&g!=w[u])&&j(e,u,g,w[u],s),u="checked",null!=v&&v!=e[u]&&j(e,u,v,w[u],s))}return e}function H(e,t,r){try{if("function"==typeof e){var i="function"==typeof e._;i&&e._(),i&&null==t||(e._=e(t))}else e.current=t}catch(e){n.v(e,r)}}function U(e,t,r){var i,o;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.v||H(i,null,t)),null!=(i=e.k)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.v(e,t)}i.base=i.I=null}if(i=e.i)for(o=0;o<i.length;o++)i[o]&&U(i[o],t,r||"function"!=typeof e.type);r||k(e.v),e.k=e.m=e.v=void 0}function Y(e,t,n){return this.constructor(e,n)}t=v.slice,n={v:function(e,t,n,r){for(var i,o,s;t=t.m;)if((i=t.k)&&!i.m)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(e)),s=i.P),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=i.P),s)return i.j=i}catch(t){e=t}throw e}},r=0,_.prototype.setState=function(e,t){var n;n=null!=this.L&&this.L!=this.state?this.L:this.L=x({},this.state),"function"==typeof e&&(e=e(x({},n),this.props)),e&&x(n,e),null!=e&&this.N&&(t&&this.A.push(t),E(this))},_.prototype.forceUpdate=function(e){this.N&&(this.v=!0,e&&this.W.push(e),E(this))},_.prototype.render=C,i=[],s="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,a=function(e,t){return e.N.p-t.N.p},P.O=0,l=Math.random().toString(8),c="__d"+l,d="__a"+l,u=/(PointerCapture)$|Capture$/i,h=0,m=W(!1),f=W(!0),p=0,function(e){e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.VALIDATION_ERROR="VALIDATION_ERROR",e.STORAGE_ERROR="STORAGE_ERROR",e.TIMEOUT_ERROR="TIMEOUT_ERROR",e.MAINTENANCE_ERROR="MAINTENANCE_ERROR"}(g||(g={}));class Z extends Error{constructor(e,t,n=!1,r,i,o,s){super(t),this.type=e,this.retryable=n,this.statusCode=r,this.retryAfter=i,this.validationErrors=o,this.organisation=s,this.name="InsureOSError"}}class G{handleNetworkError(e){return new Z(g.NETWORK_ERROR,"Network connection failed. Please check your internet connection.",!0)}handleApiError(e){if(503===e.status)return new Z(g.MAINTENANCE_ERROR,"We're performing scheduled maintenance. Please check back in a few minutes.",!1,e.status);const t=e.status>=500||429===e.status;return 429===e.status?new Z(g.API_ERROR,"Too many requests. Please wait a moment and try again.",!0,e.status):e.status>=400&&e.status<500?new Z(g.API_ERROR,"Invalid request. Please refresh the page and try again.",!1,e.status):e.status>=500?new Z(g.API_ERROR,"Service temporarily unavailable. Please try again in a moment.",!0,e.status):new Z(g.API_ERROR,`Request failed: ${e.statusText}`,t,e.status)}handleStorageError(e){return new Z(g.STORAGE_ERROR,"Unable to save progress. The quote will still work, but progress won't be saved.",!1)}shouldRetry(e){return e.retryable}getUserFriendlyMessage(e){switch(e.type){case g.NETWORK_ERROR:return"Connection failed. Please check your internet connection and try again.";case g.MAINTENANCE_ERROR:return"We're performing scheduled maintenance. Please check back in a few minutes.";case g.API_ERROR:return 429===e.statusCode?"Too many requests. Please wait a moment and try again.":e.statusCode&&e.statusCode>=400&&e.statusCode<500?"Invalid request. Please refresh the page and try again.":e.statusCode&&e.statusCode>=500?"Service temporarily unavailable. Please try again in a moment.":"Request failed. Please try again.";case g.STORAGE_ERROR:return"Unable to save progress. The quote will still work, but progress won't be saved.";case g.TIMEOUT_ERROR:return"Request timed out. Please try again.";case g.VALIDATION_ERROR:return e.validationErrors&&Object.keys(e.validationErrors).length>0?"There were validation errors in your form. Please check your inputs and try again.":"Invalid data provided. Please check your input and try again.";default:return"An unexpected error occurred. Please try again."}}}class V{constructor(e){this.config=e}shouldRetry(e,t){return!(t>=this.config.maxRetries)&&this.isRetryableError(e)}getDelay(e,t){if(t){const e=parseInt(t,10);if(!isNaN(e))return 1e3*e}const n=this.config.baseDelay*Math.pow(2,e);return Math.min(n,this.config.maxDelay)}isRetryableError(e){return e instanceof Z?e.retryable:!("TypeError"!==e.name||!e.message.includes("fetch"))||"AbortError"===e.name}}class Q{constructor(e){this.config=e,this.retryStrategy=new V(e.retryConfig)}getBaseUrl(){return this.config.apiBaseUrl||"https://api.os.insure"}async makeRequest({url:e,method:t,body:n,skipOrgHeader:r=!1}){return this.executeWithRetry(async()=>{const i=new AbortController,o=setTimeout(()=>i.abort(),this.config.timeout);try{const s={"Content-Type":"application/json"},a=e.includes("signed=");r||a||(s["X-Organisation-ID"]=this.config.orgId);const l={method:t,headers:s,signal:i.signal};n&&(l.body=JSON.stringify(n));const c=await fetch(e,l);if(clearTimeout(o),!c.ok)throw await this.handleApiError(c);const d=await c.json();return d.data||d}catch(e){if(clearTimeout(o),e instanceof Z)throw e;if(e instanceof Error&&"AbortError"===e.name)throw new Z(g.TIMEOUT_ERROR,"Request timed out",!0);if(e instanceof TypeError&&e.message.includes("fetch"))throw new Z(g.NETWORK_ERROR,"Network connection failed. Please check your internet connection.",!0);throw e}})}getQuoteIntent(e){return this.makeRequest({url:e,method:"GET"})}async fetchAvailableProducts(t){var n;const r=null==t?void 0:t.includes("*"),i=!t||0===t.length,o=`${this.config.apiBaseUrl}/products`,s=await this.makeRequest({url:o,method:"GET"}),a=s.products||[],l=null===(n=s.organisation)||void 0===n?void 0:n.client_settings;let c=a;if(r)e(),c=a;else if(t&&t.length>0)c=a.filter(e=>t.includes(e.code));else if(i&&(null==l?void 0:l.products)&&l.products.length>0){const t=l.products.map(e=>e.code);c=t.map(e=>a.find(t=>t.code===e)).filter(e=>void 0!==e),e((a.length,c.length))}else i&&(e(),c=a);return{products:c,organisation:s.organisation}}createQuoteIntent(e){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents`,method:"POST",body:e})}updateQuoteIntent(e,t){return this.makeRequest({url:e,method:"PUT",body:t})}deleteQuoteIntent(e){return this.makeRequest({url:e,method:"DELETE"})}calculateQuoteIntent(e){return this.makeRequest({url:e,method:"POST"})}calculateQuoteIntentV2(e){return this.makeRequest({url:e,method:"POST"})}repriceQuoteIntentV2(e,t){return this.makeRequest({url:e,method:"POST",body:t})}bindQuoteIntentV2(e,t){return this.makeRequest({url:e,method:"POST",body:t})}deleteCalculations(e){return this.makeRequest({url:e,method:"DELETE"})}initiatePayment(e,t){const n="string"==typeof t?t:t.code;return this.makeRequest({url:`${this.config.apiBaseUrl}/payments/initiate`,method:"POST",body:{...e,gateway_code:n}})}getPaymentStatus(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/payments/status/${e}`,method:"GET"})}createQuotePaymentLink(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/payment-link`,method:"POST",body:t})}continueLater(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/continue-later`,method:"POST",body:{email:t}})}resumeQuoteIntent(e){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/resume`,method:"GET"})}getPaymentLinkDetails(e){return this.makeRequest({url:e,method:"GET",skipOrgHeader:!0})}getPaymentLinkById(e){return this.makeRequest({url:`${this.config.apiBaseUrl}/payment-links/${e}`,method:"GET"})}initiateFixedPayment(e,t,n,r){return this.makeRequest({url:`${this.config.apiBaseUrl}/payment-links/${e}/pay`,method:"POST",body:{gateway_code:t,client_name:n,...r?{gateway_method:r}:{}}})}validateCoverStartDate(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/payment-links/${e}/validate-cover-date`,method:"POST",body:{cover_start_date:t}})}validateQuoteCoverStartDate(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/validate-cover-date`,method:"POST",body:{cover_start_date:t}})}resolvePaymentTransaction(e){return this.makeRequest({url:`${this.config.apiBaseUrl}/payments/${e}/resolve`,method:"POST",body:{}})}validatePromoCode(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/validate-promo-code`,method:"POST",body:{code:t}})}async executeWithRetry(t){let n;for(let r=0;r<=this.config.retryConfig.maxRetries;r++)try{return e(this.config.retryConfig.maxRetries),await t()}catch(t){n=t;const i=this.retryStrategy.shouldRetry(n,r);if(e(t instanceof Z&&(t.type,t.message)),e(this.config.retryConfig.maxRetries),r===this.config.retryConfig.maxRetries||!i)throw e(),n;const o=t instanceof Z?t.retryAfter:void 0,s=this.retryStrategy.getDelay(r,o);e(),await new Promise(e=>setTimeout(e,s))}throw n}async handleApiError(t){var n,r;const i=t.headers.get("retry-after"),o=await t.json().catch(()=>({}));if(e(),this.captureApiErrorToSentry(t,o),503===t.status)return new Z(g.MAINTENANCE_ERROR,o.message||"We're performing scheduled maintenance. Please check back in a few minutes.",!1,t.status,void 0,void 0,null!==(n=o.organisation)&&void 0!==n?n:null);if(429===t.status)return new Z(g.API_ERROR,"Too many requests. Please wait a moment and try again.",!1,t.status,i||void 0);if(t.status>=500){const e=o.message||"Service temporarily unavailable. Please try again in a moment.";return new Z(g.API_ERROR,e,!1,t.status)}if(422===t.status)try{const e=o;return e.error&&e.error.details&&e.error.details.form_data?new Z(g.VALIDATION_ERROR,"Form validation failed. Please check your inputs.",!1,t.status,void 0,e.error.details):new Z(g.VALIDATION_ERROR,e.message||"Validation failed. Please check your inputs.",!1,t.status,void 0,null===(r=e.error)||void 0===r?void 0:r.details)}catch(e){return new Z(g.VALIDATION_ERROR,"Validation failed. Please check your inputs.",!1,t.status)}if(400===t.status)try{const e=o;return e.errors?new Z(g.VALIDATION_ERROR,e.message||"Form validation failed. Please check your inputs.",!1,t.status,void 0,e.errors):new Z(g.API_ERROR,e.message||"Invalid request. Please check your input and try again.",!1,t.status)}catch(e){return new Z(g.API_ERROR,"Invalid request. Please refresh the page and try again.",!1,t.status)}if(t.status>=400&&t.status<500){const e=o.message||"Invalid request. Please refresh the page and try again.";return new Z(g.API_ERROR,e,!1,t.status)}return new Z(g.API_ERROR,`Request failed: ${t.statusText}`,this.config.retryConfig.retryableStatusCodes.includes(t.status),t.status)}captureApiErrorToSentry(e,t){try{(e.status>=500||429===e.status)&&Promise.resolve().then(function(){return Dh}).then(({captureMessage:n,addBreadcrumb:r,isSentryInitialized:i})=>{i()&&(r({message:`API Error: ${e.status} ${e.statusText}`,category:"http",level:"error",data:{url:e.url,status:e.status,statusText:e.statusText}}),n(`API Error: ${e.status} - ${e.url}`,"error",{http:{status_code:e.status,url:e.url,method:"Unknown"},response:t}))}).catch(()=>{})}catch(e){}}}class J{constructor(){this.available=this.checkAvailability()}get(e){if(!this.available)return null;try{return localStorage.getItem(e)}catch(e){return null}}set(e,t){if(this.available)try{localStorage.setItem(e,t)}catch(e){}}remove(e){if(this.available)try{localStorage.removeItem(e)}catch(e){}}clear(){if(this.available)try{localStorage.clear()}catch(e){}}isAvailable(){return this.available}checkAvailability(){try{if("undefined"==typeof window||!window.localStorage)return!1;const e="__insure_os_storage_test__";return localStorage.setItem(e,"test"),localStorage.removeItem(e),!0}catch(e){return!1}}}class K{constructor(){this.available=this.checkAvailability()}get(e){if(!this.available)return null;try{return sessionStorage.getItem(e)}catch(e){return null}}set(e,t){if(this.available)try{sessionStorage.setItem(e,t)}catch(e){}}remove(e){if(this.available)try{sessionStorage.removeItem(e)}catch(e){}}clear(){if(this.available)try{sessionStorage.clear()}catch(e){}}isAvailable(){return this.available}checkAvailability(){try{if("undefined"==typeof window||!window.sessionStorage)return!1;const e="__insure_os_storage_test__";return sessionStorage.setItem(e,"test"),sessionStorage.removeItem(e),!0}catch(e){return!1}}}class X{constructor(){this.storage=new Map}get(e){return this.storage.get(e)||null}set(e,t){this.storage.set(e,t)}remove(e){this.storage.delete(e)}clear(){this.storage.clear()}isAvailable(){return!0}}class ee{static generateKey(e,t,n){const r=[this.KEY_PREFIX+e,t];return n&&r.push(n),r.join(this.SEPARATOR)}static serialize(e){try{return JSON.stringify({data:e,timestamp:Date.now(),version:"1.0"})}catch(e){throw new Error(`Failed to serialize data: ${e}`)}}static deserialize(e){try{const t=JSON.parse(e);return t&&"object"==typeof t&&t.data?t.data:null}catch(e){return null}}static getTimestamp(e){try{return JSON.parse(e).timestamp||null}catch(e){return null}}static isExpired(e,t){const n=this.getTimestamp(e);return!n||Date.now()-n>t}}ee.KEY_PREFIX="insure_os_",ee.SEPARATOR="_";class te{constructor(e,t={}){this.storageAdapter=e,this.config={defaultExpirationMs:t.defaultExpirationMs||te.DEFAULT_EXPIRATION_MS,namespace:t.namespace||te.DEFAULT_NAMESPACE}}saveQuoteIntent(e,t){if(this.storageAdapter.isAvailable())try{t.payment_transactions&&t.payment_transactions.length;const n=this.generateStorageKey(e),r=ee.serialize(t);this.storageAdapter.set(n,r)}catch(e){}}getQuoteIntent(e){if(!this.storageAdapter.isAvailable())return null;try{const t=this.generateStorageKey(e),n=this.storageAdapter.get(t);if(!n)return null;const r=ee.deserialize(n);return(null==r?void 0:r.payment_transactions)&&r.payment_transactions.length,r&&this.isQuoteIntentValid(r)?r:(this.removeQuoteIntent(e),null)}catch(e){return null}}removeQuoteIntent(e){if(this.storageAdapter.isAvailable())try{const t=this.generateStorageKey(e);this.storageAdapter.remove(t)}catch(e){}}isQuoteIntentValid(e){if(!e||"object"!=typeof e)return!1;if(!e.id||!e.url||!e.org_id)return!1;const t=Date.now();return!(e.expires_at&&t>e.expires_at||e.created_at&&t-e.created_at>this.config.defaultExpirationMs)}getAllQuoteIntents(){return{}}cleanupExpiredQuoteIntents(){}isStorageAvailable(){return this.storageAdapter.isAvailable()}generateStorageKey(e){return ee.generateKey(this.config.namespace,e)}}te.DEFAULT_EXPIRATION_MS=864e5,te.DEFAULT_NAMESPACE="quote_intent";class ne{constructor(e){this.stateManager=e}async getOrCreateQuoteIntent(e,t,n){const r=this.stateManager.getQuoteIntent(e);if(r&&this.stateManager.isQuoteIntentValid(r)){const t=await n(r.url);return this.stateManager.saveQuoteIntent(e,t),t}try{const n=await t();return this.stateManager.saveQuoteIntent(e,n),n}catch(t){throw r&&this.stateManager.removeQuoteIntent(e),t}}updateQuoteIntent(e,t){const n=this.stateManager.getQuoteIntent(e);if(!n)return null;const r={...n,...t};return this.stateManager.saveQuoteIntent(e,r),r}clearQuoteIntent(e){this.stateManager.removeQuoteIntent(e)}clearExpiredQuoteIntents(){this.stateManager.cleanupExpiredQuoteIntents()}hasValidQuoteIntent(e){const t=this.stateManager.getQuoteIntent(e);return null!==t&&this.stateManager.isQuoteIntentValid(t)}getQuoteIntentUrl(e){const t=this.stateManager.getQuoteIntent(e);return(null==t?void 0:t.url)||null}isStorageAvailable(){return this.stateManager.isStorageAvailable()}}class re{constructor(e,t){this.saveCallback=t,this.isPaused=!1,this.consecutiveFailures=0,this.lastErrorTime=0,this.isUserTyping=!1,this.config=e}start(){this.intervalId&&this.stop(),this.isPaused=!1,this.consecutiveFailures=0,this.lastErrorTime=0,this.config.autoSave&&(this.intervalId=window.setInterval(()=>{this.isPaused||this.isUserTyping||!this.shouldAttemptSave()||this.saveCallback().catch(this.handleSaveError.bind(this))},this.config.autoSaveInterval))}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.typingTimeoutId&&(clearTimeout(this.typingTimeoutId),this.typingTimeoutId=void 0)}pause(){this.isPaused=!0,setTimeout(()=>this.resume(),6e4)}resume(){this.isPaused=!1,this.consecutiveFailures=0}shouldAttemptSave(){return!!this.config.autoSave&&(0===this.lastErrorTime||Date.now()-this.lastErrorTime>=this.config.retryDelay*Math.pow(2,this.consecutiveFailures-1))}handleSaveError(e){this.lastErrorTime=Date.now(),this.consecutiveFailures++,this.consecutiveFailures>=3&&(this.pause(),this.dispatchErrorEvent(e))}dispatchErrorEvent(e){if("undefined"!=typeof window){const t=new CustomEvent("form-autosave-error",{detail:{error:e,message:"Auto-save has been paused due to repeated failures."}});window.dispatchEvent(t)}}onSaveSuccess(){this.consecutiveFailures=0,this.lastErrorTime=0,this.isPaused&&this.resume()}startTyping(){this.isUserTyping=!0,this.typingTimeoutId&&clearTimeout(this.typingTimeoutId),this.typingTimeoutId=window.setTimeout(()=>{this.stopTyping()},500)}stopTyping(){this.isUserTyping=!1,this.typingTimeoutId&&(clearTimeout(this.typingTimeoutId),this.typingTimeoutId=void 0)}get status(){return{isPaused:this.isPaused,consecutiveFailures:this.consecutiveFailures,isActive:!!this.intervalId,isUserTyping:this.isUserTyping}}}function ie(e,t){const n=t.operator,r=t.value,i=null==r?"":String(r),o=null==e?"":String(e);switch(n){case"=":return o===i;case"!=":return o!==i;case"contains":return o.includes(i);case"not_contains":return!o.includes(i);case"starts_with":return o.startsWith(i);case"ends_with":return o.endsWith(i);case"is_empty":return void 0===e||null==e||""===e||""===e.trim();case"is_not_empty":return void 0!==e&&null!=e&&""!==e&&!(""===e.trim());default:throw new Error(`Unsupported text operator: ${n}`)}}function oe(e,t){const n=t.operator,r=null==t.value?0:Number(t.value),i=null==e?0:Number(e.toString().replace(/,/g,"").trim());switch(n){case">":return i>r;case">=":return i>=r;case"<":return i<r;case"<=":return i<=r;case"=":return i===r;case"!=":return i!==r;case"is_empty":return void 0===e||null==e||""===e||""===e.toString().trim();case"is_not_empty":return void 0!==e&&null!=e&&""!==e&&!(""===e.toString().trim());default:throw new Error(`Unsupported numeric operator: ${n}`)}}function se(e){if(!0===e||1===e)return!0;if("string"==typeof e){const t=e.toLowerCase();return"true"===t||"yes"===t}return!1}function ae(e,t){const n=t.operator;switch(t.operator){case"true":case"=":return se(e);case"false":return function(e){if(!1===e||0===e||void 0===e)return!0;if("string"==typeof e){const t=e.toLowerCase();return"false"===t||"no"===t}return!1}(e);case"!=":return!se(e);default:throw new Error(`Unsupported boolean operator: ${n}`)}}function le(e,t){const n=t.operator,r=t.value,i=null==r?0:Number(t.value);if(null==e||""===e.toString().trim())return"is_empty"===n;const o=e.toString().trim(),s=/^\d{4}$/.test(o)&&Number(o)>=1900&&Number(o)<=2100?new Date(Number(o),0,1).getTime():Date.parse(o),a=Math.floor((Date.now()-s)/315576e5),l=Math.floor((Date.now()-s)/864e5),c=new Date(s),d=new Date,u=12*(d.getFullYear()-c.getFullYear())+(d.getMonth()-c.getMonth());switch(n){case">":return s>Date.parse(r);case">=":return s>=Date.parse(r);case"<":return s<Date.parse(r);case"<=":return s<=Date.parse(r);case"age_less_than":return a<i;case"age_less_than_or_equal":return a<=i;case"age_greater_than":return a>i;case"age_greater_than_or_equal":return a>=i;case"age_days_less_than":return l<i;case"age_days_less_than_or_equal":return l<=i;case"age_days_greater_than":return l>i;case"age_days_greater_than_or_equal":return l>=i;case"age_months_less_than":return u<i;case"age_months_less_than_or_equal":return u<=i;case"age_months_greater_than":return u>i;case"age_months_greater_than_or_equal":return u>=i;default:throw new Error(`Unsupported date operator: ${n}`)}}class ce{static create(e){switch(e){case"string":case"text":case"select":return ie;case"numeric":return oe;case"boolean":return ae;case"date":return le;default:throw new Error(`Unsupported condition type: ${e}`)}}}function de(e,t){const n=t.condition_type||"and";if(!t.conditions||0===t.conditions.length)return{matched:!0,conditions:[]};const r={matched:!1,conditions:t.conditions.map(t=>{const n={...t,matched:ue(e,t),string:`${t.field} ${t.operator}`};return t.value&&(n.string+=` ${t.value}`),n})};return"none"===n&&(r.matched=!0),"and"===n&&(r.matched=r.conditions.every(e=>e.matched)),"or"===n&&(r.matched=r.conditions.some(e=>e.matched)),"not"===n&&(r.matched=r.conditions.every(e=>!e.matched)),r}function ue(e,t){if("expression"===t.type)throw new Error("Expression conditions should not be evaluated through matchesCondition");if(!t.field)throw new Error("Field is required for non-expression conditions");const n=e[t.field],r=ce.create(t.type);if(!r)throw new Error(`Unsupported condition type: ${t.type}`);return r(n,t)}var he=Object.freeze({__proto__:null,TypeConditionEvaluatorFactory:ce,booleanMatchesCondition:ae,checkSimpleConditions:de,dateMatchesCondition:le,numericMatchesCondition:oe,textMatchesCondition:ie});function me(e,t){var n;const r=[];if("checkbox"===e.type&&e.required&&!0!==t&&"true"!==t)return r.push({field:e.code||e.id,message:`${e.label} must be accepted`}),r;"boolean"===e.type&&(null===(n=e.boolean_config)||void 0===n?void 0:n.enable_details_textbox)&&("yes"===e.boolean_config.show_details_on&&(!0===t||"true"===t)||e.boolean_config.show_details_on),"email"===e.type&&"string"==typeof t&&(t=t.trim());const i="boolean"===e.type?null==t:null==t||""===t;if(e.required&&i&&!0!==e.add_null_option)return r.push({field:e.code||e.id,message:`${e.label} is required`}),r;if(!e.required&&i)return r;const o=e.validation;if(!o)return r;const s=String(t),a="number"==typeof t?t:parseFloat(s);if(o.pattern&&("text"===e.type||"email"===e.type)){const t=new RegExp(o.pattern),n=s.trim();t.test(n)||r.push({field:e.code||e.id,message:`${e.label} format is invalid`})}if(o.minLength&&s.length<o.minLength&&r.push({field:e.code||e.id,message:`${e.label} must be at least ${o.minLength} characters`}),o.maxLength&&s.length>o.maxLength&&r.push({field:e.code||e.id,message:`${e.label} must be no more than ${o.maxLength} characters`}),"number"!==e.type||isNaN(a)||(void 0!==o.min&&a<o.min&&r.push({field:e.code||e.id,message:`${e.label} must be at least ${o.min}`}),void 0!==o.max&&a>o.max&&r.push({field:e.code||e.id,message:`${e.label} must be no more than ${o.max}`}),void 0!==o.step&&a%o.step!==0&&r.push({field:e.code||e.id,message:`${e.label} must be in increments of ${o.step}`})),("date"===e.type||"year"===e.type||"monthyear"===e.type)&&!1===o.canBeFuture){const t=new Date,n=t.getFullYear();let i=!1;if("year"===e.type){const e=parseInt(s,10);!isNaN(e)&&e>n&&(i=!0)}else if("date"===e.type){const e=new Date(s);if(!isNaN(e.getTime())){const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());new Date(e.getFullYear(),e.getMonth(),e.getDate())>n&&(i=!0)}}else if("monthyear"===e.type){const e=s.split("-");if(2===e.length){const n=parseInt(e[0],10),r=parseInt(e[1],10)-1;isNaN(n)||isNaN(r)||new Date(n,r,1)>new Date(t.getFullYear(),t.getMonth(),1)&&(i=!0)}}i&&r.push({field:e.code||e.id,message:`${e.label} cannot be in the future`})}return"date"===e.type&&o.softMaxDate&&s&&s>o.softMaxDate&&r.push({field:e.code||e.id,message:o.softMaxMessage||`${e.label} is too far in the future`}),r}function fe(e,t){var n,r;const i=[];for(const r of e.fields){const e=r.code||r.id;let o=!0;if(r.visibility){const e=de(t,{condition_type:r.visibility.condition_type,conditions:r.visibility.conditions});o="show"===r.visibility.action?e.matched:!e.matched}if(!o)continue;const s=t[e],a=me(r,s);if(i.push(...a),"boolean"===r.type&&(null===(n=r.boolean_config)||void 0===n?void 0:n.enable_details_textbox)&&("yes"===r.boolean_config.show_details_on&&(!0===s||"true"===s)||"no"===r.boolean_config.show_details_on&&(!1===s||"false"===s))){const n=(t.U||{})[e];n&&""!==n.trim()||i.push({field:e,message:r.boolean_config.details_label||"Please provide details"})}}if(null===(r=e.validation)||void 0===r?void 0:r.required_fields)for(const n of e.validation.required_fields){const r=e.fields.find(e=>(e.code||e.id)===n),o=t[n];if(r){const e=r.code||r.id,n=i.find(t=>t.field===e);if(n)continue;let s=!0;if(r.visibility){const e=de(t,{condition_type:r.visibility.condition_type,conditions:r.visibility.conditions});s="show"===r.visibility.action?e.matched:!e.matched}if(!s)continue;if("checkbox"===r.type){!0!==o&&"true"!==o&&i.push({field:e,message:`${r.label} must be accepted`});continue}("boolean"===r.type?null==o:null==o||""===o)&&(!0===r.add_null_option||i.push({field:e,message:`${r.label} is required`}))}}return{isValid:0===i.length,errors:i}}function pe(e){const t=[];let n;if("object"==typeof e&&null!==e&&("validation_errors"in e&&e.validation_errors&&"object"==typeof e.validation_errors?n=e.validation_errors:"errors"in e&&e.errors&&"object"==typeof e.errors?n=e.errors:"message"in e||"validation_errors"in e||"errors"in e||(n=e)),n)for(const[e,r]of Object.entries(n))if(Array.isArray(r))for(const n of r)t.push({field:e,message:n});return t}function ge(e){return e.reduce((e,t)=>(e[t.field]||(e[t.field]=[]),e[t.field].push(t),e),{})}class ye{constructor(e,t,n){this.httpClient=e,this.definition=t,this.quoteIntentStore=n}async load(e,t){if(this.quoteIntentStore&&this.quoteIntentStore.getQuoteIntentUrl(e)){const e=await this.httpClient.getQuoteIntent(t);if(e.quote_intent.form_data)return e.quote_intent.form_data}return(await this.httpClient.getQuoteIntent(t)).quote_intent.form_data||this.createEmptyFormData()}async save(e,t,n,r){try{const e=this.prepareSavePayload(n,r);return await this.httpClient.updateQuoteIntent(t,e),{success:!0}}catch(e){if(e&&"object"==typeof e&&"validationErrors"in e){const t=e.validationErrors;if(t&&"object"==typeof t)return{success:!1,validationErrors:pe(t)}}throw e}}prepareSavePayload(e,t){const n=this.getCurrentPageId(e);return{current_page_index:e.current_page,current_page_id:n,page_data:e.page_data,save_type:t.saveType}}getCurrentPageId(e){const t=this.definition;if(!t||!e.page_data)return;const n=e.current_page;if(n<0||n>=t.pages.length)return;const r=t.pages[n];return r&&r.id?r.id:void 0}createEmptyFormData(){return{current_page:0,completed_pages:[],page_data:{},last_updated:(new Date).toISOString()}}}class ve{constructor(e,t,n,r){this.formDefinition=e,this.getFormData=t,this.updateFormData=n,this.saveCallback=r}canNavigateToPage(e){const t=this.getFormData().current_page;if(e<=t)return!0;if(this.hasActiveBlocker(t))return!1;if(this.isStagingEnvironment())return!0;const n=this.getFormData().completed_pages;for(let r=0;r<e;r++)if(r!==t&&!n.includes(r))return!1;return!0}async navigateToPage(e){if(e<0||e>=this.getTotalPages())return!1;if(!this.canNavigateToPage(e))return!1;const t=this.getFormData().current_page;if(e>t)try{await this.saveCallback(!0,"page")}catch(e){return e&&"object"==typeof e&&e.isValidationError,!1}return e>t&&this.markPageCompleted(t),this.updateFormData({current_page:e,last_updated:(new Date).toISOString()}),!0}navigateToNext(){const e=this.getFormData().current_page;return this.navigateToPage(e+1)}navigateToPrevious(){const e=this.getFormData().current_page;return this.navigateToPage(e-1)}markPageCompleted(e){const t=this.getFormData();if(!t.completed_pages.includes(e)){const n=[...t.completed_pages,e].sort((e,t)=>e-t);this.updateFormData({completed_pages:n})}}getTotalPages(){return this.formDefinition.pages.length}getCompletionStatus(){const e=this.getFormData(),t=this.getTotalPages(),n=[...e.completed_pages];return{totalPages:t,currentPage:e.current_page,completedPages:n,percentComplete:n.length/t*100}}hasActiveBlocker(e){var t;const n=this.formDefinition.pages[e];if(!n)return!1;const r=(null===(t=this.getFormData().page_data)||void 0===t?void 0:t[n.id])||{};for(const e of n.fields)if(e.blocker)if(e.blocker.conditions&&e.blocker.conditions.length>0){if(de(r,{condition_type:e.blocker.condition_type||"or",conditions:e.blocker.conditions}).matched)return!0}else if(void 0!==e.blocker.trigger_value){const t=r[e.code||e.id];if(void 0!==t&&String(t)===String(e.blocker.trigger_value))return!0}return!1}isStagingEnvironment(){const e=window.location.hostname;return"localhost"===e||e.endsWith(".test")||e.includes("staging")}}class we{constructor(e){this.httpClient=e}async calculateQuote(t){const n=await this.httpClient.calculateQuoteIntent(t);return e(),n}}class be{constructor(e){this.httpClient=e}async calculate(t){const n=await this.httpClient.calculateQuoteIntentV2(t);return e(),n}async reprice(t,n){const r={selection:n},i=await this.httpClient.repriceQuoteIntentV2(t,r);return e(),i}async bind(t,n){const r=await this.httpClient.bindQuoteIntentV2(t,n);return e(),r}}function xe(e,t,n){var r,i,o,s,a,l,c,d,u;const h=Date.now(),m=`${e}-${h}`;if(function(e,t,n){try{Promise.resolve().then(function(){return Dh}).then(({captureException:r,addBreadcrumb:i,isSentryInitialized:o})=>{o()&&(i({message:`Error occurred: ${t}`,category:"error",level:"error",data:{errorType:t,customMessage:n}}),r(e,{errorType:t,customMessage:n}))}).catch(()=>{})}catch(e){}}(t,e,n),t&&"object"==typeof t){const f=null!==(o=null!==(r=t.organisation)&&void 0!==r?r:null===(i=t.data)||void 0===i?void 0:i.organisation)&&void 0!==o?o:null===(a=null===(s=t.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.organisation;if("statusCode"in t||"status"in t)return ke(m,e,t.statusCode||t.status||500,t.message||(null===(l=t.data)||void 0===l?void 0:l.message)||"Server error occurred",n,h,f);if("response"in t)return ke(m,e,(null===(c=t.response)||void 0===c?void 0:c.status)||500,(null===(u=null===(d=t.response)||void 0===d?void 0:d.data)||void 0===u?void 0:u.message)||t.message||"Network error occurred",n,h,f);if(t.message)return{id:m,type:e,severity:Se(e),title:Ne(e),message:n||_e(e),details:t.message,retryable:$e(e,0),timestamp:h,trackingId:m}}const f="string"==typeof t?t:"An unexpected error occurred";return{id:m,type:e,severity:Se(e),title:Ne(e),message:n||f,retryable:$e(e,0),timestamp:h,trackingId:m}}function ke(e,t,n,r,i,o,s){const a=n>=500?"critical":n>=400?"error":"warning",l=$e(t,n);return{id:e,type:t,severity:a,statusCode:n,title:Ne(t,n),message:i||Ce(t,n,r),details:r,retryable:l,timestamp:o,organisation:null!=s?s:void 0}}function Ne(e,t){if(t){if(404===t)return"Not Found";if(503===t)return"Under Maintenance";if(t>=500)return"Something Went Wrong";if(t>=400)return"Invalid Request"}switch(e){case"initialization":default:return"Something Went Wrong";case"calculation":return"Calculation Error";case"network":return"Connection Problem";case"validation":return"Please Check Your Details";case"maintenance":return"Under Maintenance"}}function Se(e){switch(e){case"initialization":case"maintenance":return"critical";case"calculation":case"network":default:return"error";case"validation":return"warning"}}function Ce(e,t,n){return"calculation"===e&&(n.toLowerCase().includes("no matching values found")||n.toLowerCase().includes("rating table")||n.toLowerCase().includes("not supported"))?n:n.toLowerCase().includes("no matching values found")?"The entered value is not supported by our calculator. Please try a different amount.":n.toLowerCase().includes("rating table")?"Unable to calculate with the provided information. Please check your entries and try again.":404===t?"initialization"===e?"The requested form could not be found. Please check the URL or contact support.":"The requested resource was not found.":503===t?"We're performing scheduled maintenance. Please check back in a few minutes.":t>=500?"calculation"===e?"We're experiencing technical difficulties with the calculation. Please try again in a moment.":"We're experiencing technical difficulties. Please try again in a moment.":429===t?"Too many requests. Please wait a moment and try again.":t>=400?"There was an issue with your request. Please adjust your details and re-submit.":"An unexpected error occurred. Please try again."}function _e(e){switch(e){case"initialization":return"We're unable to load the application at this time. Please try again.";case"calculation":return"We couldn't complete the calculation. Please check your details and try again.";case"network":return"We're having trouble connecting. Please check your internet connection and try again.";case"validation":return"Please check your details and try again.";case"maintenance":return"We're performing scheduled maintenance. Please check back in a few minutes.";default:return"An unexpected error occurred. Please try again."}}function $e(e,t){return"validation"!==e&&"maintenance"!==e&&404!==t&&503!==t&&!(t>=400&&t<500&&429!==t)&&("network"===e||"calculation"===e||t>=500&&503!==t||429===t)}function Ie(e){return"initialization"===e.type&&"critical"===e.severity}function Te(e){return"maintenance"===e.type||503===e.statusCode}function Ee(e){return e.trackingId?`If this problem persists, please contact support and reference error ID: ${e.trackingId.slice(0,8).toUpperCase()}`:"critical"===e.severity?"If this problem persists, please contact support with the error details.":"If you continue to experience issues, please contact support."}let Pe=null;function ze(e){Pe=e}function De(){return Pe}function Re(e,t){var n,r;return{event:t,quote_id:e.id,organisation_slug:null===(n=e.organisation)||void 0===n?void 0:n.slug,organisation_name:null===(r=e.organisation)||void 0===r?void 0:r.name,timestamp:(new Date).toISOString()}}function Me(e){var t,n;if(!(null==Pe?void 0:Pe.isEnabled()))return;const r={...Re(e,"quote_started"),quote_status:e.status,total_pages:null===(n=null===(t=e.form_definition)||void 0===t?void 0:t.pages)||void 0===n?void 0:n.length};Pe.push(r)}function Oe(e,t,n,r){var i,o;if(!(null==Pe?void 0:Pe.isEnabled()))return;const s=(null===(o=null===(i=e.form_definition)||void 0===i?void 0:i.pages)||void 0===o?void 0:o.length)||0,a=s>0?Math.round(n.length/s*100):0,l={...Re(e,"quote_form_progress"),current_page:t,total_pages:s,completed_pages:n.length,completion_percentage:a,page_title:r};Pe.push(l)}function je(e,t){if(!(null==Pe?void 0:Pe.isEnabled()))return;const n=t.calculations||[],r=t.payment_options||[],i=n.find(e=>e.id===t.default_excess_id),o=n.map(e=>e.premium_total),s=o.length>0?Math.min(...o):void 0,a=o.length>0?Math.max(...o):void 0,l=r.some(e=>"monthly"===e.amount.frequency),c={...Re(e,"quote_calculated"),excess_id:null==i?void 0:i.id,excess_amount:null==i?void 0:i.excess_amount,premium_subtotal:null==i?void 0:i.premium_subtotal,premium_total:null==i?void 0:i.premium_total,excess_options_count:n.length,payment_options_count:r.length,has_installments:l,min_premium:s,max_premium:a};Pe.push(c)}function We(e,t,n,r,i){if(!(null==Pe?void 0:Pe.isEnabled()))return;const o={...Re(e,"quote_at_checkout"),excess_id:t.id,excess_amount:t.excess_amount,premium_subtotal:t.premium_subtotal,premium_total:t.premium_total,payment_options_count:n,has_installments:r,form_completion:i,fees:t.fees};Pe.push(o)}function Ae(e,t){if(!(null==Pe?void 0:Pe.isEnabled()))return;const n=t.referrals||[],r={...Re(e,"quote_referred"),referral_reason:t.referral_reason,referrals_count:n.length,referral_ids:n.map(e=>e.id)};Pe.push(r)}function Le(e,t,n,r){if(!(null==Pe?void 0:Pe.isEnabled()))return;const i={...Re(e,"payment_initiated"),payment_amount:t.amount.dueToday,payment_gateway:t.gateway_id,payment_gateway_name:n,excess_amount:r||0,payment_frequency:t.amount.frequency,amount_due_today:t.amount.dueToday,installments_count:t.amount.numberOfInstallments};Pe.push(i)}function Be(e,t,n,r,i,o){if(!(null==Pe?void 0:Pe.isEnabled()))return;const s={...Re(e,"payment_completed"),transaction_id:t,payment_amount:n,payment_gateway:r,premium_total:i||n,excess_amount:o||0};Pe.push(s)}function qe(e,t,n,r,i,o){if(!(null==Pe?void 0:Pe.isEnabled()))return;const s={...Re(e,"payment_failed"),transaction_id:t,payment_amount:n,payment_gateway:r,payment_status:i,failure_reason:o};Pe.push(s)}class Fe{constructor(e,t,n,r={}){this.quoteIntent=e,this.httpClient=t,this.subscribers=new Set,this.pendingChanges={},this.isCalculating=!1,this.isRepricing=!1,this.isSaving=!1,this.selectedExcessId=null,this.selectedPaymentOption=null,this.selectionV2=null,this.validationErrors=[],this.serverValidationErrors=[],this.generalErrors=[],this.lastCalculationFailed=!1,this.config={autoSaveInterval:r.autoSaveInterval||1e3,autoSave:!1!==r.autoSave,maxRetryAttempts:r.maxRetryAttempts||3,retryDelay:r.retryDelay||2e3},this.formData=this.createEmptyFormData(),this.quoteIntentStore=n,this.lastCalculationFailed=this.getPersistedCalculationFailureState();const i=e.form_definition;this.persistenceManager=new ye(t,i,n),this.autoSaveManager=new re(this.config,this.saveFormData.bind(this)),this.navigationManager=new ve(i,this.getFormProgress.bind(this),this.updateFormDataInternal.bind(this),this.saveFormData.bind(this)),this.calculationManager=new we(t),this.calculationManagerV2=new be(t),this.config.autoSave&&this.autoSaveManager.start()}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}async loadFormProgress(){var e,t;return this.formData=await this.persistenceManager.load(this.quoteIntent.id,this.quoteIntent.url),this.lastCalculationFailed=!0===(null===(t=null===(e=this.formData.page_data)||void 0===e?void 0:e.Y)||void 0===t?void 0:t.lastCalculationFailed),this.config.autoSave=!1,this.autoSaveManager.stop(),this.notify(),this.formData}updatePageData(e,t){this.pendingChanges[e]={...this.pendingChanges[e],...t},this.formData.page_data={...this.formData.page_data,[e]:{...this.formData.page_data[e],...t}},this.formData.last_updated=(new Date).toISOString(),this.notify()}updateFieldValue(e,t,n){if(this.autoSaveManager.startTyping(),"string"==typeof n){const r=this.getFormDefinition().pages.find(t=>t.id===e),i=null==r?void 0:r.fields.find(e=>(e.code||e.id)===t);i&&"email"===i.type&&(n=n.trim())}this.pendingChanges[e]||(this.pendingChanges[e]={}),this.pendingChanges[e][t]=n,this.formData.page_data[e]||(this.formData.page_data[e]={}),this.formData.page_data[e][t]=n,this.formData.last_updated=(new Date).toISOString(),this.validateField(e,t,n),this.notify()}updateFieldAnswer(t,n,r,i){if(this.autoSaveManager.startTyping(),this.formData.page_data[t]||(this.formData.page_data[t]={}),this.formData.page_data[t].U||(this.formData.page_data[t].U={}),this.formData.page_data[t].U[n]=r,i){const n=this.getRatingFactorCodeById(i);n&&(this.formData.page_data[t][n]=r,e())}this.formData.last_updated=(new Date).toISOString(),this.notify()}restoreFormProgress(t){var n;if(this.isUserTyping())return;const r=t.completed_pages||[],i=(null===(n=this.quoteIntent.form_definition)||void 0===n?void 0:n.pages.length)||0;let o=0;for(let e=0;e<i;e++)if(!r.includes(e)){o=e;break}r.length===i&&i>0&&(o=i-1),e(t.current_page),this.formData={...t,current_page:o},this.notify()}restoreCalculationResult(t){e(),e(t.outcome_type),this.calculationResult=t,t.default_excess_id&&(this.selectedExcessId=t.default_excess_id),e(),this.notify(),e()}getRatingFactorCodeById(t){const n=this.getFormDefinition();for(const e of n.pages)for(const n of e.fields){if(n.rating_factor_id===t)return n.code||n.id;if(n.rating_factor_mappings)for(const e of n.rating_factor_mappings)if(e.rating_factor_id===t)return e.rating_factor_code||n.code||n.id}return e(),null}processRatingFactorMappings(e){const t=this.getFormDefinition(),n={};return t.pages.forEach(t=>{const r=e.page_data[t.id]||{};t.fields.forEach(e=>{const t=r[e.code||e.id];null!=t&&""!==t&&e.rating_factor_mappings&&e.rating_factor_mappings.length>0&&e.rating_factor_mappings.forEach(r=>{if("derived"===r.type&&r.derivation_rule){const i=this.applyDerivationRule(t,r.derivation_rule,r.metadata),o=r.rating_factor_code||`${e.code||e.id}_${r.derivation_rule}`;n[o]=i}})})}),n}applyDerivationRule(t,n,r){switch(e(JSON.stringify(r)),n){case"calculate_age":return this.calculateAge(t,r);case"invert_yes_no":return this.invertYesNo(t);default:return null}}invertYesNo(e){return"Yes"===e?"No":"Yes"}calculateAge(e,t){try{const n=new Date(e),r="current_date"===(null==t?void 0:t.reference_date)?new Date:new Date((null==t?void 0:t.reference_date)||Date.now());let i=r.getFullYear()-n.getFullYear();const o=r.getMonth()-n.getMonth();return(o<0||0===o&&r.getDate()<n.getDate())&&i--,i}catch(e){return null}}async saveFormData(t=!1,n="auto-save"){if(!t&&0===Object.keys(this.pendingChanges).length)return;this.isSaving=!0,this.notify();const r={...this.formData},i=this.processRatingFactorMappings(this.formData);e();const o={...this.formData,page_data:{...this.formData.page_data,V:i}};try{const e=await this.persistenceManager.save(this.quoteIntent.id,this.quoteIntent.url,o,{force:t,saveType:n});if(!e.success){if(e.validationErrors){this.setServerValidationErrors(e.validationErrors),this.notify();const t=new Error("Validation failed");throw t.isValidationError=!0,t}throw new Error("Failed to save form data")}{this.pendingChanges={},this.autoSaveManager.onSaveSuccess(),this.clearServerValidationErrors(),this.clearGeneralErrors();const e=this.formData;r.current_page===e.current_page?this.formData=o:this.formData={...o,current_page:e.current_page,completed_pages:e.completed_pages,last_updated:e.last_updated},this.notify()}}catch(e){if(e&&"object"==typeof e&&"type"in e&&"message"in e){const t=e;if(!t.validationErrors||0===Object.keys(t.validationErrors).length){const e=xe("validation",t);this.addGeneralError(e),this.notify()}}throw e}finally{this.isSaving=!1,this.notify()}}canNavigateToPage(e){return this.navigationManager.canNavigateToPage(e)}navigateToPage(e){return this.navigationManager.navigateToPage(e)}async navigateToNextPage(){var e,t;const n=await this.navigationManager.navigateToNext();if(n){const n=this.formData.current_page,r=this.formData.completed_pages||[],i=null===(t=null===(e=this.quoteIntent.form_definition)||void 0===e?void 0:e.pages[n-1])||void 0===t?void 0:t.title;Oe(this.quoteIntent,n,r,i)}return n}navigateToPreviousPage(){return this.navigationManager.navigateToPrevious()}getPageCompletionStatus(){return this.navigationManager.getCompletionStatus()}getFormProgress(){return this.formData}getFormDefinition(){return this.quoteIntent.form_definition}getTotalPages(){return this.navigationManager.getTotalPages()}getCurrentPageIndex(){return this.formData.current_page}isAutoSavePaused(){return this.autoSaveManager.status.isPaused}isUserTyping(){return this.autoSaveManager.status.isUserTyping}getIsCalculating(){return this.isCalculating}getIsRepricing(){return this.isRepricing}getIsSaving(){return this.isSaving}hasCalculationResponse(){return Boolean(this.calculationResult)}getCalculationResult(){return this.calculationResult}getConsecutiveFailures(){return this.autoSaveManager.status.consecutiveFailures}getSelectedExcessId(){return this.selectedExcessId}setSelectedExcessId(e){this.selectedExcessId=e,this.selectedPaymentOption=null,this.notify()}getSelectedPaymentOption(){return this.selectedPaymentOption}setSelectedPaymentOption(e){this.selectedPaymentOption=e,this.notify()}hasPendingChanges(){return Object.keys(this.pendingChanges).length>0}validateCurrentPage(){const e=this.getCurrentPageIndex(),t=this.getFormDefinition().pages[e];if(!t)return[];const n=fe(t,this.getAllFormDataFlattened());return this.validationErrors=n.errors,this.notify(),n.errors}validateField(e,t,n){const r=this.getFormDefinition().pages.find(t=>t.id===e),i=null==r?void 0:r.fields.find(e=>(e.code||e.id)===t);if(!i)return[];const o=me(i,n);return this.validationErrors=this.validationErrors.filter(e=>e.field!==t),this.validationErrors.push(...o),this.notify(),o}getValidationErrors(){return[...this.validationErrors,...this.serverValidationErrors]}getFieldErrors(e){return this.getValidationErrors().filter(t=>t.field===e)}hasErrors(){return this.validationErrors.length>0||this.serverValidationErrors.length>0}hasFieldErrors(e){return this.getFieldErrors(e).length>0}clearValidationErrors(){this.validationErrors=[],this.notify()}setServerValidationErrors(e){this.serverValidationErrors=e,this.notify()}clearServerValidationErrors(){this.serverValidationErrors=[],this.notify()}getGeneralErrors(){const e=this.generalErrors.filter(e=>!e.dismissed);return e.length>0?[e[e.length-1]]:[]}addGeneralError(e){this.generalErrors.push(e),this.notify()}dismissGeneralError(e){const t=this.generalErrors.find(t=>t.id===e);t&&(t.dismissed=!0,this.notify())}clearGeneralErrors(){this.generalErrors=[],this.notify()}hasGeneralErrors(){return this.getGeneralErrors().length>0}hasLastCalculationFailed(){return this.lastCalculationFailed}dispose(){this.autoSaveManager.stop(),Object.keys(this.pendingChanges).length>0&&!this.isAutoSavePaused()&&this.saveFormData(!0).catch(console.error),this.subscribers.clear()}async filterHiddenFieldsAndSave(){const e=this.getFormDefinition(),t={...this.formData},{checkSimpleConditions:n}=await Promise.resolve().then(function(){return he}),r=this.getAllFormDataFlattened();e.pages.forEach(e=>{const i=this.formData.page_data[e.id]||{},o={};Object.keys(i).forEach(e=>{e.startsWith("__")&&e.endsWith("__")&&(o[e]=i[e])}),e.fields.forEach(e=>{const t=e.code||e.id,s=i[t];let a=!0;if(e.visibility){const t=n(r,{condition_type:e.visibility.condition_type,conditions:e.visibility.conditions});a="show"===e.visibility.action?t.matched:!t.matched}a&&void 0!==s&&(o[t]=s)}),t.page_data[e.id]=o});const i=this.processRatingFactorMappings(t),o={...t,page_data:{...t.page_data,V:i}};await this.persistenceManager.save(this.quoteIntent.id,this.quoteIntent.url,o,{force:!0,saveType:"full"})}async calculateQuote(){e();const t=this.getFormDefinition(),n=[],r=this.getAllFormDataFlattened();for(const i of t.pages){const t=fe(i,r);e(i.title,t.errors.length>0&&t.errors),n.push(...t.errors)}if(n.length>0)throw e(),this.validationErrors=n,this.notify(),new Error("Form validation failed");e(),await this.filterHiddenFieldsAndSave();try{if(this.isCalculating=!0,this.notify(),2===this.quoteIntent.calculator_version&&this.quoteIntent.calculate_url_v2){const e=await this.calculationManagerV2.calculate(this.quoteIntent.calculate_url_v2);if("referral"===e.outcome_type){this.calculationResultV2=void 0,this.selectionV2=null,this.selectedExcessId=null;const t=this.buildV1CompatResponseFromV2(e);return this.calculationResult=t,this.lastCalculationFailed=!1,this.persistCalculationFailureState(),Ae(this.quoteIntent,t),t}this.calculationResultV2=e,this.selectionV2=e.selection;const t=this.buildV1CompatResponseFromV2(e);this.calculationResult=t,this.selectedExcessId=e.selection.excess_id,this.lastCalculationFailed=!1,this.persistCalculationFailureState();const n=this.generalErrors.filter(e=>"calculation"===e.type);return n.forEach(e=>this.dismissGeneralError(e.id)),"calculation"===t.outcome_type?je(this.quoteIntent,t):"referral"===t.outcome_type&&Ae(this.quoteIntent,t),t}const e=await this.calculationManager.calculateQuote(this.quoteIntent.calculate_url);this.calculationResult=e,this.selectedExcessId=e.default_excess_id||null,this.lastCalculationFailed=!1,this.persistCalculationFailureState();const t=this.generalErrors.filter(e=>"calculation"===e.type);return t.forEach(e=>this.dismissGeneralError(e.id)),"calculation"===e.outcome_type?je(this.quoteIntent,e):"referral"===e.outcome_type&&Ae(this.quoteIntent,e),e}catch(e){this.lastCalculationFailed=!0,this.persistCalculationFailureState();const t={outcome_type:"referral",referral_reason:"Your quote requires further review.",quote_intent:this.quoteIntent};return this.calculationResult=t,t}finally{this.isCalculating=!1,this.notify()}}async clearCalculationResults(){e();try{await this.httpClient.deleteCalculations(this.quoteIntent.delete_calculations_url),this.calculationResult=void 0,this.calculationResultV2=void 0,this.selectionV2=null,this.selectedExcessId=null,this.selectedPaymentOption=null,this.notify(),e()}catch(t){throw e(),t}}getCalculationResultV2(){return this.calculationResultV2}getSelectionV2(){return this.selectionV2}setV2Selection(e){var t,n,r,i;if(!this.calculationResultV2||!this.selectionV2)return;const o={cover_type_id:null!==(t=e.cover_type_id)&&void 0!==t?t:this.selectionV2.cover_type_id,excess_id:null!==(n=e.excess_id)&&void 0!==n?n:this.selectionV2.excess_id,coverage_option_ids:null!==(r=e.coverage_option_ids)&&void 0!==r?r:this.selectionV2.coverage_option_ids};if(e.cover_type_id&&e.cover_type_id!==this.selectionV2.cover_type_id){const e=this.calculationResultV2.variants.filter(e=>e.cover_type_id===o.cover_type_id),t=e.some(e=>e.excess_id===o.excess_id);if(!t){const t=null!==(i=e.find(e=>e.excess_id===this.calculationResultV2.default_excess_id))&&void 0!==i?i:e[0];t&&(o.excess_id=t.excess_id)}}this.selectionV2=o,this.selectedExcessId=o.excess_id,this.calculationResult=this.buildV1CompatResponseFromV2(this.calculationResultV2),this.notify()}async toggleV2CoverageOption(e){if(!this.calculationResultV2||!this.selectionV2||!this.quoteIntent.reprice_url_v2)return;const t=this.calculationResultV2.policy_coverage_options.find(t=>t.id===e);if(!t)return;const n=this.selectionV2.coverage_option_ids,r=n.includes(e)?n.filter(t=>t!==e):[...n,e],i={...this.selectionV2,coverage_option_ids:r};try{this.isRepricing=!0,this.notify();const e=await this.calculationManagerV2.reprice(this.quoteIntent.reprice_url_v2,i);this.calculationResultV2={...this.calculationResultV2,variants:e.variants,policy_coverage_options:e.policy_coverage_options},this.selectionV2=e.selection,this.calculationResult=this.buildV1CompatResponseFromV2(this.calculationResultV2)}catch(e){}finally{this.isRepricing=!1,this.notify()}}getV2DisplayedTotal(){if(!this.calculationResultV2||!this.selectionV2)return 0;const e=this.calculationResultV2.variants.find(e=>e.cover_type_id===this.selectionV2.cover_type_id&&e.excess_id===this.selectionV2.excess_id);return e?Math.round(100*e.pricing.total_payable)/100:0}async bindV2(e){if(!this.quoteIntent.bind_url_v2||!this.selectionV2)throw new Error("v2 bind unavailable — missing bind URL or selection");const t=this.getV2DisplayedTotal();return this.calculationManagerV2.bind(this.quoteIntent.bind_url_v2,{selection:this.selectionV2,client_claimed_total:t,email:e})}buildV1CompatResponseFromV2(e){var t;const n=null!==(t=this.selectionV2)&&void 0!==t?t:e.selection,r=e.variants.filter(e=>e.cover_type_id===n.cover_type_id),i=r.map(t=>{var n;const r=e.excess_options.find(e=>e.id===t.excess_id);return{id:t.excess_id,calculation_id:e.id,excess_amount:null!==(n=null==r?void 0:r.excess_amount)&&void 0!==n?n:0,excess_label:null==r?void 0:r.excess_label,description:void 0,premium_base:t.pricing.subtotal-t.pricing.fees,premium_subtotal:t.pricing.subtotal,premium_total:t.pricing.total_payable,fees:[]}});return{quote_intent:e.quote_intent,product_name:e.product_name,default_excess_id:e.default_excess_id,default_coverage_options:n.coverage_option_ids,outcome_type:e.outcome_type,referral_reason:e.referral_reason,calculations:i,referrals:e.referrals.map(e=>({id:e.id,reason:e.reason})),clauses:e.clauses,payment_options:[],payment_gateways:e.payment_gateways}}notify(){this.subscribers.forEach(e=>e(this))}getAllFormDataFlattened(){const e={};return Object.values(this.formData.page_data).forEach(t=>{const{U:n,...r}=t;Object.assign(e,r),n&&Object.keys(n).length>0&&(e.U||(e.U={}),Object.assign(e.U,n))}),e}updateFormDataInternal(e){if(this.isUserTyping()&&e.page_data){const t={...e};delete t.page_data,this.formData={...this.formData,...t}}else this.formData={...this.formData,...e};this.notify()}createEmptyFormData(){return{current_page:0,completed_pages:[],page_data:{},last_updated:(new Date).toISOString()}}getPersistedCalculationFailureState(){var e,t,n;return!!(null===(n=null===(t=null===(e=this.quoteIntent.form_data)||void 0===e?void 0:e.page_data)||void 0===t?void 0:t.Y)||void 0===n?void 0:n.lastCalculationFailed)&&!0===this.quoteIntent.form_data.page_data.Y.lastCalculationFailed}persistCalculationFailureState(){this.formData.page_data.Y||(this.formData.page_data.Y={}),this.formData.page_data.Y.lastCalculationFailed=this.lastCalculationFailed,this.formData.last_updated=(new Date).toISOString(),this.saveFormData(!0,"auto-save").catch(()=>{})}reset(){localStorage.clear();const e=new URL(window.location.href);e.searchParams.delete("url"),window.history.replaceState({},document.title,e.toString()),window.location.reload()}getQuoteIntent(){return this.quoteIntent}updateQuoteIntent(e){if(this.quoteIntentStore){const t=this.quoteIntentStore.updateQuoteIntent(this.quoteIntent.org_id,e);t&&(this.quoteIntent=t,this.notify())}}clearStoredQuoteIntent(){this.quoteIntentStore&&this.quoteIntentStore.clearQuoteIntent(this.quoteIntent.org_id)}async initiatePayment(t){var n,r,i;const o=((null===(n=this.calculationResult)||void 0===n?void 0:n.payment_gateways)||[]).find(e=>e.id===t.gatewayId);if(!o)throw new Error("Selected payment gateway not found in calculation response");e();const s=((null===(r=this.calculationResult)||void 0===r?void 0:r.payment_options)||[]).find(e=>e.gateway_id===t.gatewayId&&e.calculation_id===t.calculationId),a=((null===(i=this.calculationResult)||void 0===i?void 0:i.calculations)||[]).find(e=>e.id===t.calculationId);try{const e=await this.httpClient.initiatePayment(t,o);return s&&Le(this.quoteIntent,s,o.name,null==a?void 0:a.excess_amount),this.notify(),e}catch(e){throw e}}async getPaymentStatus(e){var t;const n=this.getSelectedPaymentOption();if(!n)throw new Error("No payment option selected");const r=((null===(t=this.calculationResult)||void 0===t?void 0:t.payment_gateways)||[]).find(e=>e.id===n.gateway_id);if(!r)throw new Error("Selected payment gateway not found in calculation response");try{const t=await this.httpClient.getPaymentStatus(e,r);return this.notify(),t}catch(e){throw e}}startPaymentStatusPolling(e,t,n=30){let r=0,i=!1;const o=async()=>{if(!(i||r>=n))try{const s=await this.getPaymentStatus(e);t(s),"pending"!==s.status&&"initiated"!==s.status||(r++,r<n&&!i&&setTimeout(o,1e4))}catch(e){r++,r<n&&!i&&setTimeout(o,1e4)}};return o(),()=>{i=!0}}}class He{constructor(e,t){this.httpClient=e,this.response=t}async get(){return await this.httpClient.getQuoteIntent(this.response.url)}async update(e){var t;const n=this.response.product.form_definition,r={...this.response.quote_intent.form_data};r.page_data||(r.page_data={});for(const i of n.pages){const n=r.page_data[i.id]||{};for(const r of i.fields){const i=r.code||r.id;if(e.hasOwnProperty(i)?n[i]=e[i]:("text"===r.type&&(n[i]="sample"),"number"===r.type&&(n[i]=1),"checkbox"===r.type&&(n[i]=!0)),"boolean"===r.type&&(null===(t=r.boolean_config)||void 0===t?void 0:t.enable_details_textbox)){const e="yes"===r.boolean_config.show_details_on,t=n[i];(t===e||t===String(e))&&(n.U||(n.U={}),n.U[i]=`Sample details for: ${i}`)}}r.page_data[i.id]=n}const i={current_page_index:0,save_type:"full",page_data:{...r.page_data}};return await this.httpClient.updateQuoteIntent(this.response.url,i)}}class Ue{constructor(e){this.httpClient=e}async createQuoteIntent(e,t){const n=await this.httpClient.createQuoteIntent({code:e,...t});return new He(this.httpClient,n)}}var Ye=0;function Ze(e,t,r,i,o,s){t||(t={});var a,l,c=t;if("ref"in c)for(l in c={},t)"ref"==l?a=t[l]:c[l]=t[l];var d={type:e,props:c,key:r,ref:a,i:null,m:null,p:0,v:null,k:null,constructor:void 0,N:--Ye,C:-1,_:0,J:o,K:s};if("function"==typeof e&&(a=e.defaultProps))for(l in a)void 0===c[l]&&(c[l]=a[l]);return n.vnode&&n.vnode(d),d}var Ge,Ve,Qe,Je,Ke=0,Xe=[],et=n,tt=et.p,nt=et.O,rt=et.diffed,it=et.k,ot=et.unmount,st=et.m;function at(e,t){et.W&&et.W(Ve,e,Ke||t),Ke=0;var n=Ve.X||(Ve.X={m:[],W:[]});return e>=n.m.length&&n.m.push({}),n.m[e]}function lt(e){return Ke=1,function(e,t){var n=at(Ge++,2);if(n.t=e,!n.k&&(n.m=[wt(void 0,t),function(e){var t=n.ee?n.ee[0]:n.m[0],r=n.t(t,e);t!==r&&(n.ee=[r,n.m[1]],n.k.setState({}))}],n.k=Ve,!Ve.te)){var r=function(e,t,r){if(!n.k.X)return!0;var o=n.k.X.m.filter(function(e){return e.k});if(o.every(function(e){return!e.ee}))return!i||i.call(this,e,t,r);var s=n.k.props!==e;return o.some(function(e){if(e.ee){var t=e.m[0];e.m=e.ee,e.ee=void 0,t!==e.m[0]&&(s=!0)}}),i&&i.call(this,e,t,r)||s};Ve.te=!0;var i=Ve.shouldComponentUpdate,o=Ve.componentWillUpdate;Ve.componentWillUpdate=function(e,t,n){if(this.v){var s=i;i=void 0,r(e,t,n),i=s}o&&o.call(this,e,t,n)},Ve.shouldComponentUpdate=r}return n.ee||n.m}(wt,e)}function ct(e,t){var n=at(Ge++,3);!et.L&&vt(n.X,t)&&(n.m=e,n.u=t,Ve.X.W.push(n))}function dt(e){return Ke=5,ut(function(){return{current:e}},[])}function ut(e,t){var n=at(Ge++,7);return vt(n.X,t)&&(n.m=e(),n.X=t,n.W=e),n.m}function ht(e,t){return Ke=8,ut(function(){return e},t)}function mt(){for(var e;e=Xe.shift();){var t=e.X;if(e.I&&t)try{t.W.some(gt),t.W.some(yt),t.W=[]}catch(n){t.W=[],et.v(n,e.N)}}}et.p=function(e){Ve=null,tt&&tt(e)},et.m=function(e,t){e&&t.i&&t.i.B&&(e.B=t.i.B),st&&st(e,t)},et.O=function(e){nt&&nt(e),Ge=0;var t=(Ve=e.k).X;t&&(Qe===Ve?(t.W=[],Ve.W=[],t.m.some(function(e){e.ee&&(e.m=e.ee),e.u=e.ee=void 0})):(t.W.some(gt),t.W.some(yt),t.W=[],Ge=0)),Qe=Ve},et.diffed=function(e){rt&&rt(e);var t=e.k;t&&t.X&&(t.X.W.length&&(1!==Xe.push(t)&&Je===et.requestAnimationFrame||((Je=et.requestAnimationFrame)||pt)(mt)),t.X.m.some(function(e){e.u&&(e.X=e.u),e.u=void 0})),Qe=Ve=null},et.k=function(e,t){t.some(function(e){try{e.W.some(gt),e.W=e.W.filter(function(e){return!e.m||yt(e)})}catch(n){t.some(function(e){e.W&&(e.W=[])}),t=[],et.v(n,e.N)}}),it&&it(e,t)},et.unmount=function(e){ot&&ot(e);var t,n=e.k;n&&n.X&&(n.X.m.some(function(e){try{gt(e)}catch(e){t=e}}),n.X=void 0,t&&et.v(t,n.N))};var ft="function"==typeof requestAnimationFrame;function pt(e){var t,n=function(){clearTimeout(r),ft&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ft&&(t=requestAnimationFrame(n))}function gt(e){var t=Ve,n=e.k;"function"==typeof n&&(e.k=void 0,n()),Ve=t}function yt(e){var t=Ve;e.k=e.m(),Ve=t}function vt(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function wt(e,t){return"function"==typeof t?t(e):t}const bt="insure-os";let xt=!1;const kt=new Map,Nt={[`--${bt}-radius`]:"0.75rem",[`--${bt}-radius-sm`]:"0.5rem",[`--${bt}-radius-lg`]:"1rem",[`--${bt}-background`]:"oklch(0.955 0 0)",[`--${bt}-foreground`]:"oklch(0.145 0 0)",[`--${bt}-card`]:"oklch(1 0 0)",[`--${bt}-card-foreground`]:"oklch(0.145 0 0)",[`--${bt}-popover`]:"oklch(1 0 0)",[`--${bt}-popover-foreground`]:"oklch(0.145 0 0)",[`--${bt}-primary`]:"oklch(0.205 0 0)",[`--${bt}-primary-foreground`]:"oklch(0.985 0 0)",[`--${bt}-secondary`]:"oklch(0.97 0 0)",[`--${bt}-secondary-foreground`]:"oklch(0.205 0 0)",[`--${bt}-muted`]:"oklch(0.97 0 0)",[`--${bt}-muted-foreground`]:"oklch(0.556 0 0)",[`--${bt}-accent`]:"oklch(0.97 0 0)",[`--${bt}-accent-foreground`]:"oklch(0.205 0 0)",[`--${bt}-destructive`]:"oklch(0.577 0.245 27.325)",[`--${bt}-border`]:"oklch(0.9 0 0)",[`--${bt}-input`]:"oklch(0.9 0 0)",[`--${bt}-ring`]:"oklch(0.708 0 0)",[`--${bt}-font-family`]:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",[`--${bt}-font-size-large`]:"18px",[`--${bt}-font-size-small`]:"14px",[`--${bt}-font-size`]:"16px",[`--${bt}-border-width`]:"1px",[`--${bt}-transition-duration`]:"200ms",[`--${bt}-transition-timing-function`]:"cubic-bezier(0.4, 0, 0.2, 1)",[`--${bt}-shadow-sm`]:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",[`--${bt}-shadow`]:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",[`--${bt}-shadow-md`]:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",[`--${bt}-shadow-lg`]:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",[`--${bt}-spacing-sm`]:"0.75rem",[`--${bt}-spacing`]:"1rem",[`--${bt}-spacing-md`]:"1.5rem",[`--${bt}-spacing-lg`]:"2rem",[`--${bt}-spacing-xl`]:"3rem"},St={colors:{background:`var(--${bt}-background)`,foreground:`var(--${bt}-foreground)`,card:`var(--${bt}-card)`,popover:`var(--${bt}-popover)`,popoverForeground:`var(--${bt}-popover-foreground)`,primary:`var(--${bt}-primary)`,primaryForeground:`var(--${bt}-primary-foreground)`,secondary:`var(--${bt}-secondary)`,muted:`var(--${bt}-muted)`,mutedForeground:`var(--${bt}-muted-foreground)`,accent:`var(--${bt}-accent)`,accentForeground:`var(--${bt}-accent-foreground)`,destructive:`var(--${bt}-destructive)`,border:`var(--${bt}-border)`,input:`var(--${bt}-input)`},fontSize:{small:`var(--${bt}-font-size-small)`,default:`var(--${bt}-font-size)`,large:`var(--${bt}-font-size-large)`},radius:{small:`var(--${bt}-radius-sm)`,default:`var(--${bt}-radius)`,large:`var(--${bt}-radius-lg)`},shadow:{sm:`var(--${bt}-shadow-sm)`,md:`var(--${bt}-shadow-md)`},spacing:{sm:`var(--${bt}-spacing-sm)`,default:`var(--${bt}-spacing)`,md:`var(--${bt}-spacing-md)`,lg:`var(--${bt}-spacing-lg)`,xl:`var(--${bt}-spacing-xl)`},fontFamily:`var(--${bt}-font-family)`,borderWidth:`var(--${bt}-border-width)`,transition:`var(--${bt}-transition-duration) var(--${bt}-transition-timing-function)`},Ct=new Set;let _t=!1;function $t(){_t||(It(`\n/* InsureOS Style Isolation Reset */\n.${bt}-root {\n all: revert;\n /* Re-apply our base styles after reset */\n font-family: var(--${bt}-font-family);\n background-color: var(--${bt}-background);\n color: var(--${bt}-foreground);\n font-size: var(--${bt}-font-size);\n line-height: 1.5;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.${bt}-root *,\n.${bt}-root *::before,\n.${bt}-root *::after {\n box-sizing: border-box;\n}\n\n.${bt}-root img,\n.${bt}-root picture,\n.${bt}-root video,\n.${bt}-root canvas,\n.${bt}-root svg {\n display: block;\n max-width: 100%;\n}\n\n.${bt}-root button,\n.${bt}-root input,\n.${bt}-root select,\n.${bt}-root textarea {\n font: inherit;\n color: inherit;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n}\n\n.${bt}-root button {\n cursor: pointer;\n}\n\n.${bt}-root a {\n color: inherit;\n text-decoration: inherit;\n}\n\n.${bt}-root h1,\n.${bt}-root h2,\n.${bt}-root h3,\n.${bt}-root h4,\n.${bt}-root h5,\n.${bt}-root h6 {\n font-size: inherit;\n font-weight: inherit;\n margin: 0;\n}\n\n.${bt}-root p,\n.${bt}-root ul,\n.${bt}-root ol,\n.${bt}-root blockquote,\n.${bt}-root figure {\n margin: 0;\n padding: 0;\n}\n\n.${bt}-root ul,\n.${bt}-root ol {\n list-style: none;\n}\n\n.${bt}-root table {\n border-collapse: collapse;\n border-spacing: 0;\n}\n\n.${bt}-root hr {\n margin: 0;\n border: none;\n border-top: 1px solid var(--${bt}-border);\n height: 0;\n}\n`),_t=!0,e())}function It(e){if(!document.getElementById(`${bt}-styles`)){const e=document.createElement("style");e.id=`${bt}-styles`,document.head.appendChild(e)}document.getElementById(`${bt}-styles`).textContent+=e+"\n"}function Tt(e){return Object.entries(e).map(([e,t])=>{return`${n=e,n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}: ${t}`;var n}).join("; ")}function Et(){xt||(It(`:root {\n${Object.entries(Nt).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`),xt=!0)}const Pt={name:e=>`${bt}-${e}`,selector(e){return`.${this.name(e)}`},create(e,t,n){Et();const r=Tt(t),i=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t).toString(36)}(`${e}:${r}:${n?JSON.stringify(n):""}`),o=`${e}-${i}`,s=kt.get(o);if(s)return s.fullClassName;let a=e;const l=this.name(a);return Ct.has(a)||(It(`.${l} { ${r} }`),Ct.add(a)),kt.set(o,{contentHash:i,fullClassName:l}),n&&Object.entries(n).forEach(([e,t])=>{this.media(e,{[a]:t})}),l},keyframes(e,t){const n=`${bt}-${e}`;return Ct.has(`keyframes-${e}`)||(It(`@keyframes ${n} {\n${Object.entries(t).map(([e,t])=>` ${e} { ${Tt(t)} }`).join("\n")}\n}`),Ct.add(`keyframes-${e}`)),n},media(e,t){const n=`media-${e}`;It(`@media ${e} {\n${Object.entries(t).map(([e,t])=>` .${bt}-${e} { ${Tt(t)} }`).join("\n")}\n}`),Ct.add(n)},pseudoElement(e,t,n){const r=`${bt}-${e}`,i=`${e}-${t}`;return Ct.has(i)||(It(`.${r}${t} { ${Tt(n)} }`),Ct.add(i)),r}};var zt=Object.freeze({__proto__:null,baseVariables:Nt,injectIsolationStyles:$t,styles:Pt,theme:St,updateBaseVariables:function(t){e(),Object.assign(Nt,t);const n=document.getElementById(`${bt}-styles`);if(n){const t=n.textContent||"",r=`:root {\n${Object.entries(Nt).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`,i=t.includes(":root {")?t.replace(/:root\s*\{[^}]*\}/g,r):r+"\n"+t;n.textContent=i,e()}else Et()}});function Dt(e){return e&&e.ne&&{}.hasOwnProperty.call(e,"default")?e.default:e}var Rt,Mt={exports:{}};function Ot(){return Rt||(Rt=1,e=Mt,function(){var t={}.hasOwnProperty;function n(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!=={}.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var r="";for(var o in e)t.call(e,o)&&e[o]&&(r=i(r,o));return r}function i(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):window.classNames=n}()),Mt.exports;var e}var jt=Dt(Ot());function Wt({size:e="small"}){const t=Pt.create("spinner-small",{width:"16px",height:"16px"}),n=Pt.create("spinner-large",{width:"64px",height:"64px"}),r="small"===e?t:n;return Pt.keyframes("spin",{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Ze("div",{className:Pt.create("loading-spinner",{display:"flex",justifyContent:"center",alignItems:"center",animation:"insure-os-spin 1s linear infinite"}),children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:jt(r),children:Ze("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})})}function At({className:e,children:t,size:n="md"}){const r={sm:St.spacing.sm,md:St.spacing.md,lg:St.spacing.lg,xl:St.spacing.xl},i=Pt.create(`padding-${n}`,{padding:r[n]},{"(max-width: 950px)":{padding:"xl"===n?St.spacing.lg:"lg"===n?St.spacing.md:r[n]},"(max-width: 480px)":{padding:St.spacing.sm}});return Ze("div",{className:jt(i,e),children:t})}const Lt=function(){function e(t){var n,r;return this.getChildContext||(n=new Set,(r={})[e.k]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.v=!0,E(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),t.children}return e.k="__cC"+p++,e.m=null,e.Provider=e.re=(e.Consumer=function(e,t){return e.children(t)}).contextType=e,e}();function Bt({children:e,httpClient:t,stateManager:n,quoteIntentStore:r,formStateManager:i,paymentLinkConfig:o,availableProducts:s,productCodes:a,urlPromoCode:l}){return Ze(Lt.Provider,{value:{httpClient:t,stateManager:n,quoteIntentStore:r,formStateManager:i,paymentLinkConfig:o,availableProducts:s,productCodes:a,urlPromoCode:l,currentRetryAttempt:0,maxRetryAttempts:3},children:e})}function qt(){const e=function(e){var t=Ve.context[e.k],n=at(Ge++,9);return n.c=e,t?(null==n.m&&(n.m=!0,t.sub(Ve)),t.props.value):e.m}(Lt);if(!e)throw new Error("useFormContext must be used within a FormContext provider");return e}function Ft(e){const t=qt(),{formStateManager:n}=t;if(!n||"function"!=typeof n.subscribe)throw new Error("useQuoteForm can only be used in quote mode. If you're in payment link mode, use usePaymentLink instead.");const[r,i]=lt(()=>e(n));return ct(()=>n.subscribe(()=>{i(e(n))}),[n,e]),{...r,fsm:n}}class Ht extends Error{}class Ut extends Ht{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Yt extends Ht{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Zt extends Ht{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class Gt extends Ht{}class Vt extends Ht{constructor(e){super(`Invalid unit ${e}`)}}class Qt extends Ht{}class Jt extends Ht{constructor(){super("Zone is an abstract class")}}const Kt="numeric",Xt="short",en="long",tn={year:Kt,month:Kt,day:Kt},nn={year:Kt,month:Xt,day:Kt},rn={year:Kt,month:Xt,day:Kt,weekday:Xt},on={year:Kt,month:en,day:Kt},sn={year:Kt,month:en,day:Kt,weekday:en},an={hour:Kt,minute:Kt},ln={hour:Kt,minute:Kt,second:Kt},cn={hour:Kt,minute:Kt,second:Kt,timeZoneName:Xt},dn={hour:Kt,minute:Kt,second:Kt,timeZoneName:en},un={hour:Kt,minute:Kt,hourCycle:"h23"},hn={hour:Kt,minute:Kt,second:Kt,hourCycle:"h23"},mn={hour:Kt,minute:Kt,second:Kt,hourCycle:"h23",timeZoneName:Xt},fn={hour:Kt,minute:Kt,second:Kt,hourCycle:"h23",timeZoneName:en},pn={year:Kt,month:Kt,day:Kt,hour:Kt,minute:Kt},gn={year:Kt,month:Kt,day:Kt,hour:Kt,minute:Kt,second:Kt},yn={year:Kt,month:Xt,day:Kt,hour:Kt,minute:Kt},vn={year:Kt,month:Xt,day:Kt,hour:Kt,minute:Kt,second:Kt},wn={year:Kt,month:Xt,day:Kt,weekday:Xt,hour:Kt,minute:Kt},bn={year:Kt,month:en,day:Kt,hour:Kt,minute:Kt,timeZoneName:Xt},xn={year:Kt,month:en,day:Kt,hour:Kt,minute:Kt,second:Kt,timeZoneName:Xt},kn={year:Kt,month:en,day:Kt,weekday:en,hour:Kt,minute:Kt,timeZoneName:en},Nn={year:Kt,month:en,day:Kt,weekday:en,hour:Kt,minute:Kt,second:Kt,timeZoneName:en};class Sn{get type(){throw new Jt}get name(){throw new Jt}get ianaName(){return this.name}get isUniversal(){throw new Jt}offsetName(e,t){throw new Jt}formatOffset(e,t){throw new Jt}offset(e){throw new Jt}equals(e){throw new Jt}get isValid(){throw new Jt}}let Cn=null;class _n extends Sn{static get instance(){return null===Cn&&(Cn=new _n),Cn}get type(){return"system"}get name(){return(new Intl.DateTimeFormat).resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Yr(e,t,n)}formatOffset(e,t){return Qr(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return"system"===e.type}get isValid(){return!0}}const $n=new Map,In={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6},Tn=new Map;class En extends Sn{static create(e){let t=Tn.get(e);return void 0===t&&Tn.set(e,t=new En(e)),t}static resetCache(){Tn.clear(),$n.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch(e){return!1}}constructor(e){super(),this.zoneName=e,this.valid=En.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Yr(e,t,n,this.name)}formatOffset(e,t){return Qr(this.offset(e),t)}offset(e){if(!this.valid)return NaN;const t=new Date(e);if(isNaN(t))return NaN;const n=function(e){let t=$n.get(e);return void 0===t&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),$n.set(e,t)),t}(this.name);let[r,i,o,s,a,l,c]=n.formatToParts?function(e,t){const n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){const{type:t,value:i}=n[e],o=In[t];"era"===t?r[o]=i:Cr(o)||(r[o]=parseInt(i,10))}return r}(n,t):function(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,i,o,s,a,l,c,d]=r;return[s,i,o,a,l,c,d]}(n,t);"BC"===s&&(r=1-Math.abs(r));let d=+t;const u=d%1e3;return d-=u>=0?u:1e3+u,(qr({year:r,month:i,day:o,hour:24===a?0:a,minute:l,second:c,millisecond:0})-d)/6e4}equals(e){return"iana"===e.type&&e.name===this.name}get isValid(){return this.valid}}let Pn={};const zn=new Map;function Dn(e,t={}){const n=JSON.stringify([e,t]);let r=zn.get(n);return void 0===r&&(r=new Intl.DateTimeFormat(e,t),zn.set(n,r)),r}const Rn=new Map,Mn=new Map;let On=null;const jn=new Map;function Wn(e){let t=jn.get(e);return void 0===t&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),jn.set(e,t)),t}const An=new Map;function Ln(e,t,n,r){const i=e.listingMode();return"error"===i?null:"en"===i?n(t):r(t)}class Bn{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:i,...o}=n;if(!t||Object.keys(o).length>0){const t={useGrouping:!1,...n};n.padTo>0&&(t.minimumIntegerDigits=n.padTo),this.inf=function(e,t={}){const n=JSON.stringify([e,t]);let r=Rn.get(n);return void 0===r&&(r=new Intl.NumberFormat(e,t),Rn.set(n,r)),r}(e,t)}}format(e){if(this.inf){const t=this.floor?Math.floor(e):e;return this.inf.format(t)}return Rr(this.floor?Math.floor(e):Wr(e,3),this.padTo)}}class qn{constructor(e,t,n){let r;if(this.opts=n,this.originalZone=void 0,this.opts.timeZone)this.dt=e;else if("fixed"===e.zone.type){const t=e.offset/60*-1,n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;0!==e.offset&&En.create(n).valid?(r=n,this.dt=e):(r="UTC",this.dt=0===e.offset?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else"system"===e.zone.type?this.dt=e:"iana"===e.zone.type?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=Dn(t,i)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(e=>{if("timeZoneName"===e.type){const t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}return e}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class Fn{constructor(e,t,n){this.opts={style:"long",...n},!t&&Ir()&&(this.rtf=function(e,t={}){const{base:n,...r}=t,i=JSON.stringify([e,r]);let o=Mn.get(i);return void 0===o&&(o=new Intl.RelativeTimeFormat(e,t),Mn.set(i,o)),o}(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):function(e,t,n="always",r=!1){const i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},o=-1===["hours","minutes","seconds"].indexOf(e);if("auto"===n&&o){const n="days"===e;switch(t){case 1:return n?"tomorrow":`next ${i[e][0]}`;case-1:return n?"yesterday":`last ${i[e][0]}`;case 0:return n?"today":`this ${i[e][0]}`}}const s=Object.is(t,-0)||t<0,a=Math.abs(t),l=1===a,c=i[e],d=r?l?c[1]:c[2]||c[1]:l?i[e][0]:e;return s?`${a} ${d} ago`:`in ${a} ${d}`}(t,e,this.opts.numeric,"long"!==this.opts.style)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}}const Hn={firstDay:1,minimalDays:4,weekend:[6,7]};class Un{static fromOpts(e){return Un.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,t,n,r,i=!1){const o=e||cr.defaultLocale,s=o||(i?"en-US":On||(On=(new Intl.DateTimeFormat).resolvedOptions().locale,On)),a=t||cr.defaultNumberingSystem,l=n||cr.defaultOutputCalendar,c=zr(r)||cr.defaultWeekSettings;return new Un(s,a,l,c,o)}static resetCache(){On=null,zn.clear(),Rn.clear(),Mn.clear(),jn.clear(),An.clear()}static fromObject({locale:e,numberingSystem:t,outputCalendar:n,weekSettings:r}={}){return Un.create(e,t,n,r)}constructor(e,t,n,r,i){const[o,s,a]=function(e){const t=e.indexOf("-x-");-1!==t&&(e=e.substring(0,t));const n=e.indexOf("-u-");if(-1===n)return[e];{let t,r;try{t=Dn(e).resolvedOptions(),r=e}catch(i){const o=e.substring(0,n);t=Dn(o).resolvedOptions(),r=o}const{numberingSystem:i,calendar:o}=t;return[r,i,o]}}(e);this.locale=o,this.numberingSystem=t||s||null,this.outputCalendar=n||a||null,this.weekSettings=r,this.intl=function(e,t,n){return n||t?(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){var e;return null==this.fastNumbersCached&&(this.fastNumbersCached=(!(e=this).numberingSystem||"latn"===e.numberingSystem)&&("latn"===e.numberingSystem||!e.locale||e.locale.startsWith("en")||"latn"===Wn(e.locale).numberingSystem)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),t=!(null!==this.numberingSystem&&"latn"!==this.numberingSystem||null!==this.outputCalendar&&"gregory"!==this.outputCalendar);return e&&t?"en":"intl"}clone(e){return e&&0!==Object.getOwnPropertyNames(e).length?Un.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,zr(e.weekSettings)||this.weekSettings,e.defaultToEN||!1):this}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return Ln(this,e,ti,()=>{const n="ja"===this.intl||this.intl.startsWith("ja-"),r=(t&=!n)?{month:e,day:"numeric"}:{month:e},i=t?"format":"standalone";if(!this.monthsCache[i][e]){const t=n?e=>this.dtFormatter(e,r).format():e=>this.extract(e,r,"month");this.monthsCache[i][e]=function(e){const t=[];for(let n=1;n<=12;n++){const r=is.utc(2009,n,1);t.push(e(r))}return t}(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Ln(this,e,oi,()=>{const n=t?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=t?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=function(e){const t=[];for(let n=1;n<=7;n++){const r=is.utc(2016,11,13+n);t.push(e(r))}return t}(e=>this.extract(e,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Ln(this,void 0,()=>si,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[is.utc(2016,11,13,9),is.utc(2016,11,13,19)].map(t=>this.extract(t,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Ln(this,e,di,()=>{const t={era:e};return this.eraCache[e]||(this.eraCache[e]=[is.utc(-40,1,1),is.utc(2017,1,1)].map(e=>this.extract(e,t,"era"))),this.eraCache[e]})}extract(e,t,n){const r=this.dtFormatter(e,t).formatToParts().find(e=>e.type.toLowerCase()===n);return r?r.value:null}numberFormatter(e={}){return new Bn(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new qn(e,this.intl,t)}relFormatter(e={}){return new Fn(this.intl,this.isEnglish(),e)}listFormatter(e={}){return function(e,t={}){const n=JSON.stringify([e,t]);let r=Pn[n];return r||(r=new Intl.ListFormat(e,t),Pn[n]=r),r}(this.intl,e)}isEnglish(){return"en"===this.locale||"en-us"===this.locale.toLowerCase()||Wn(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Tr()?function(e){let t=An.get(e);if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...Hn,...t}),An.set(e,t)}return t}(this.locale):Hn}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Yn=null;class Zn extends Sn{static get utcInstance(){return null===Yn&&(Yn=new Zn(0)),Yn}static instance(e){return 0===e?Zn.utcInstance:new Zn(e)}static parseSpecifier(e){if(e){const t=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(t)return new Zn(Zr(t[1],t[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return 0===this.fixed?"UTC":`UTC${Qr(this.fixed,"narrow")}`}get ianaName(){return 0===this.fixed?"Etc/UTC":`Etc/GMT${Qr(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,t){return Qr(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return"fixed"===e.type&&e.fixed===this.fixed}get isValid(){return!0}}class Gn extends Sn{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function Vn(e,t){if(Cr(e)||null===e)return t;if(e instanceof Sn)return e;if(function(e){return"string"==typeof e}(e)){const n=e.toLowerCase();return"default"===n?t:"local"===n||"system"===n?_n.instance:"utc"===n||"gmt"===n?Zn.utcInstance:Zn.parseSpecifier(n)||En.create(e)}return _r(e)?Zn.instance(e):"object"==typeof e&&"offset"in e&&"function"==typeof e.offset?e:new Gn(e)}const Qn={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},Jn={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},Kn=Qn.hanidec.replace(/[\[|\]]/g,"").split(""),Xn=new Map;function er({numberingSystem:e},t=""){const n=e||"latn";let r=Xn.get(n);void 0===r&&(r=new Map,Xn.set(n,r));let i=r.get(t);return void 0===i&&(i=new RegExp(`${Qn[n]}${t}`),r.set(t,i)),i}let tr,nr=()=>Date.now(),rr="system",ir=null,or=null,sr=null,ar=60,lr=null;class cr{static get now(){return nr}static set now(e){nr=e}static set defaultZone(e){rr=e}static get defaultZone(){return Vn(rr,_n.instance)}static get defaultLocale(){return ir}static set defaultLocale(e){ir=e}static get defaultNumberingSystem(){return or}static set defaultNumberingSystem(e){or=e}static get defaultOutputCalendar(){return sr}static set defaultOutputCalendar(e){sr=e}static get defaultWeekSettings(){return lr}static set defaultWeekSettings(e){lr=zr(e)}static get twoDigitCutoffYear(){return ar}static set twoDigitCutoffYear(e){ar=e%100}static get throwOnInvalid(){return tr}static set throwOnInvalid(e){tr=e}static resetCaches(){Un.resetCache(),En.resetCache(),is.resetCache(),Xn.clear()}}class dr{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const ur=[0,31,59,90,120,151,181,212,243,273,304,334],hr=[0,31,60,91,121,152,182,213,244,274,305,335];function mr(e,t){return new dr("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function fr(e,t,n){const r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const i=r.getUTCDay();return 0===i?7:i}function pr(e,t,n){return n+(Ar(e)?hr:ur)[t-1]}function gr(e,t){const n=Ar(e)?hr:ur,r=n.findIndex(e=>e<t);return{month:r+1,day:t-n[r]}}function yr(e,t){return(e-t+7)%7+1}function vr(e,t=4,n=1){const{year:r,month:i,day:o}=e,s=pr(r,i,o),a=yr(fr(r,i,o),n);let l,c=Math.floor((s-a+14-t)/7);return c<1?(l=r-1,c=Hr(l,t,n)):c>Hr(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:a,...Jr(e)}}function wr(e,t=4,n=1){const{weekYear:r,weekNumber:i,weekday:o}=e,s=yr(fr(r,1,t),n),a=Lr(r);let l,c=7*i+o-s-7+t;c<1?(l=r-1,c+=Lr(l)):c>a?(l=r+1,c-=Lr(r)):l=r;const{month:d,day:u}=gr(l,c);return{year:l,month:d,day:u,...Jr(e)}}function br(e){const{year:t,month:n,day:r}=e;return{year:t,ordinal:pr(t,n,r),...Jr(e)}}function xr(e){const{year:t,ordinal:n}=e,{month:r,day:i}=gr(t,n);return{year:t,month:r,day:i,...Jr(e)}}function kr(e,t){if(!Cr(e.localWeekday)||!Cr(e.localWeekNumber)||!Cr(e.localWeekYear)){if(!Cr(e.weekday)||!Cr(e.weekNumber)||!Cr(e.weekYear))throw new Gt("Cannot mix locale-based week fields with ISO-based week fields");return Cr(e.localWeekday)||(e.weekday=e.localWeekday),Cr(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),Cr(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}return{minDaysInFirstWeek:4,startOfWeek:1}}function Nr(e){const t=$r(e.year),n=Dr(e.month,1,12),r=Dr(e.day,1,Br(e.year,e.month));return t?n?!r&&mr("day",e.day):mr("month",e.month):mr("year",e.year)}function Sr(e){const{hour:t,minute:n,second:r,millisecond:i}=e,o=Dr(t,0,23)||24===t&&0===n&&0===r&&0===i,s=Dr(n,0,59),a=Dr(r,0,59),l=Dr(i,0,999);return o?s?a?!l&&mr("millisecond",i):mr("second",r):mr("minute",n):mr("hour",t)}function Cr(e){return void 0===e}function _r(e){return"number"==typeof e}function $r(e){return"number"==typeof e&&e%1==0}function Ir(){try{return"undefined"!=typeof Intl&&!!Intl.RelativeTimeFormat}catch(e){return!1}}function Tr(){try{return"undefined"!=typeof Intl&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch(e){return!1}}function Er(e,t,n){if(0!==e.length)return e.reduce((e,r)=>{const i=[t(r),r];return e&&n(e[0],i[0])===e[0]?e:i},null)[1]}function Pr(e,t){return{}.hasOwnProperty.call(e,t)}function zr(e){if(null==e)return null;if("object"!=typeof e)throw new Qt("Week settings must be an object");if(!Dr(e.firstDay,1,7)||!Dr(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!Dr(e,1,7)))throw new Qt("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Dr(e,t,n){return $r(e)&&e>=t&&e<=n}function Rr(e,t=2){let n;return n=e<0?"-"+(""+-e).padStart(t,"0"):(""+e).padStart(t,"0"),n}function Mr(e){return Cr(e)||null===e||""===e?void 0:parseInt(e,10)}function Or(e){return Cr(e)||null===e||""===e?void 0:parseFloat(e)}function jr(e){if(!Cr(e)&&null!==e&&""!==e){const t=1e3*parseFloat("0."+e);return Math.floor(t)}}function Wr(e,t,n="round"){const r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function Ar(e){return e%4==0&&(e%100!=0||e%400==0)}function Lr(e){return Ar(e)?366:365}function Br(e,t){const n=(r=t-1)-12*Math.floor(r/12)+1;var r;return 2===n?Ar(e+(t-n)/12)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function qr(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function Fr(e,t,n){return-yr(fr(e,1,t),n)+t-1}function Hr(e,t=4,n=1){const r=Fr(e,t,n),i=Fr(e+1,t,n);return(Lr(e)-r+i)/7}function Ur(e){return e>99?e:e>cr.twoDigitCutoffYear?1900+e:2e3+e}function Yr(e,t,n,r=null){const i=new Date(e),o={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(o.timeZone=r);const s={timeZoneName:t,...o},a=new Intl.DateTimeFormat(n,s).formatToParts(i).find(e=>"timezonename"===e.type.toLowerCase());return a?a.value:null}function Zr(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);const r=parseInt(t,10)||0;return 60*n+(n<0||Object.is(n,-0)?-r:r)}function Gr(e){const t=Number(e);if("boolean"==typeof e||""===e||!Number.isFinite(t))throw new Qt(`Invalid unit value ${e}`);return t}function Vr(e,t){const n={};for(const r in e)if(Pr(e,r)){const i=e[r];if(null==i)continue;n[t(r)]=Gr(i)}return n}function Qr(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?"+":"-";switch(t){case"short":return`${i}${Rr(n,2)}:${Rr(r,2)}`;case"narrow":return`${i}${n}${r>0?`:${r}`:""}`;case"techie":return`${i}${Rr(n,2)}${Rr(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function Jr(e){return function(e){return["hour","minute","second","millisecond"].reduce((t,n)=>(t[n]=e[n],t),{})}(e)}const Kr=["January","February","March","April","May","June","July","August","September","October","November","December"],Xr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ei=["J","F","M","A","M","J","J","A","S","O","N","D"];function ti(e){switch(e){case"narrow":return[...ei];case"short":return[...Xr];case"long":return[...Kr];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const ni=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],ri=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],ii=["M","T","W","T","F","S","S"];function oi(e){switch(e){case"narrow":return[...ii];case"short":return[...ri];case"long":return[...ni];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const si=["AM","PM"],ai=["Before Christ","Anno Domini"],li=["BC","AD"],ci=["B","A"];function di(e){switch(e){case"narrow":return[...ci];case"short":return[...li];case"long":return[...ai];default:return null}}function ui(e,t){let n="";for(const r of e)r.literal?n+=r.val:n+=t(r.val);return n}const hi={D:tn,DD:nn,DDD:on,DDDD:sn,t:an,tt:ln,ttt:cn,tttt:dn,T:un,TT:hn,TTT:mn,TTTT:fn,f:pn,ff:yn,fff:bn,ffff:kn,F:gn,FF:vn,FFF:xn,FFFF:Nn};class mi{static create(e,t={}){return new mi(e,t)}static parseFormat(e){let t=null,n="",r=!1;const i=[];for(let o=0;o<e.length;o++){const s=e.charAt(o);"'"===s?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:""===n?"'":n}),t=null,n="",r=!r):r||s===t?n+=s:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=s,t=s)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return hi[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){return null===this.systemLoc&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0,n){if(this.opts.forceSimple)return Rr(e,t);const r={...this.opts};return t>0&&(r.padTo=t),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,t){const n="en"===this.loc.listingMode(),r=this.loc.outputCalendar&&"gregory"!==this.loc.outputCalendar,i=(t,n)=>this.loc.extract(e,t,n),o=t=>e.isOffsetFixed&&0===e.offset&&t.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,t.format):"",s=(t,r)=>n?function(e,t){return ti(t)[e.month-1]}(e,t):i(r?{month:t}:{month:t,day:"numeric"},"month"),a=(t,r)=>n?function(e,t){return oi(t)[e.weekday-1]}(e,t):i(r?{weekday:t}:{weekday:t,month:"long",day:"numeric"},"weekday"),l=t=>{const n=mi.macroTokenToFormatOpts(t);return n?this.formatWithSystemDefault(e,n):t},c=t=>n?function(e,t){return di(t)[e.year<0?0:1]}(e,t):i({era:t},"era");return ui(mi.parseFormat(t),t=>{switch(t){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12==0?12:e.hour%12);case"hh":return this.num(e.hour%12==0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return n?function(e){return si[e.hour<12?0:1]}(e):i({hour:"numeric",hourCycle:"h12"},"dayperiod");case"d":return r?i({day:"numeric"},"day"):this.num(e.day);case"dd":return r?i({day:"2-digit"},"day"):this.num(e.day,2);case"c":case"E":return this.num(e.weekday);case"ccc":return a("short",!0);case"cccc":return a("long",!0);case"ccccc":return a("narrow",!0);case"EEE":return a("short",!1);case"EEEE":return a("long",!1);case"EEEEE":return a("narrow",!1);case"L":return r?i({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?i({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return s("short",!0);case"LLLL":return s("long",!0);case"LLLLL":return s("narrow",!0);case"M":return r?i({month:"numeric"},"month"):this.num(e.month);case"MM":return r?i({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return s("short",!1);case"MMMM":return s("long",!1);case"MMMMM":return s("narrow",!1);case"y":return r?i({year:"numeric"},"year"):this.num(e.year);case"yy":return r?i({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?i({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?i({year:"numeric"},"year"):this.num(e.year,6);case"G":return c("short");case"GG":return c("long");case"GGGGG":return c("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return l(t)}})}formatDurationFromString(e,t){const n="negativeLargestOnly"===this.opts.signMode?-1:1,r=e=>{switch(e[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=mi.parseFormat(t),o=i.reduce((e,{literal:t,val:n})=>t?e:e.concat(n),[]),s=e.shiftTo(...o.map(r).filter(e=>e));return ui(i,((e,t)=>i=>{const o=r(i);if(o){const r=t.isNegativeDuration&&o!==t.largestUnit?n:1;let s;return s="negativeLargestOnly"===this.opts.signMode&&o!==t.largestUnit?"never":"all"===this.opts.signMode?"always":"auto",this.num(e.get(o)*r,i.length,s)}return i})(s,{isNegativeDuration:s<0,largestUnit:Object.keys(s.values)[0]}))}}const fi=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function pi(...e){const t=e.reduce((e,t)=>e+t.source,"");return RegExp(`^${t}$`)}function gi(...e){return t=>e.reduce(([e,n,r],i)=>{const[o,s,a]=i(t,r);return[{...e,...o},s||n,a]},[{},null,1]).slice(0,2)}function yi(e,...t){if(null==e)return[null,null];for(const[n,r]of t){const t=n.exec(e);if(t)return r(t)}return[null,null]}function vi(...e){return(t,n)=>{const r={};let i;for(i=0;i<e.length;i++)r[e[i]]=Mr(t[n+i]);return[r,null,n+i]}}const wi=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,bi=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,xi=RegExp(`${bi.source}(?:${wi.source}?(?:\\[(${fi.source})\\])?)?`),ki=RegExp(`(?:[Tt]${xi.source})?`),Ni=vi("weekYear","weekNumber","weekDay"),Si=vi("year","ordinal"),Ci=RegExp(`${bi.source} ?(?:${wi.source}|(${fi.source}))?`),_i=RegExp(`(?: ${Ci.source})?`);function $i(e,t,n){const r=e[t];return Cr(r)?n:Mr(r)}function Ii(e,t){return[{hours:$i(e,t,0),minutes:$i(e,t+1,0),seconds:$i(e,t+2,0),milliseconds:jr(e[t+3])},null,t+4]}function Ti(e,t){const n=!e[t]&&!e[t+1],r=Zr(e[t+1],e[t+2]);return[{},n?null:Zn.instance(r),t+3]}function Ei(e,t){return[{},e[t]?En.create(e[t]):null,t+1]}const Pi=RegExp(`^T?${bi.source}$`),zi=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Di(e){const[t,n,r,i,o,s,a,l,c]=e,d="-"===t[0],u=l&&"-"===l[0],h=(e,t=!1)=>void 0!==e&&(t||e&&d)?-e:e;return[{years:h(Or(n)),months:h(Or(r)),weeks:h(Or(i)),days:h(Or(o)),hours:h(Or(s)),minutes:h(Or(a)),seconds:h(Or(l),"-0"===l),milliseconds:h(jr(c),u)}]}const Ri={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Mi(e,t,n,r,i,o,s){const a={year:2===t.length?Ur(Mr(t)):Mr(t),month:Xr.indexOf(n)+1,day:Mr(r),hour:Mr(i),minute:Mr(o)};return s&&(a.second=Mr(s)),e&&(a.weekday=e.length>3?ni.indexOf(e)+1:ri.indexOf(e)+1),a}const Oi=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function ji(e){const[,t,n,r,i,o,s,a,l,c,d,u]=e,h=Mi(t,i,r,n,o,s,a);let m;return m=l?Ri[l]:c?0:Zr(d,u),[h,new Zn(m)]}const Wi=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Ai=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Li=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Bi(e){const[,t,n,r,i,o,s,a]=e;return[Mi(t,i,r,n,o,s,a),Zn.utcInstance]}function qi(e){const[,t,n,r,i,o,s,a]=e;return[Mi(t,a,n,r,i,o,s),Zn.utcInstance]}const Fi=pi(/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,ki),Hi=pi(/(\d{4})-?W(\d\d)(?:-?(\d))?/,ki),Ui=pi(/(\d{4})-?(\d{3})/,ki),Yi=pi(xi),Zi=gi(function(e,t){return[{year:$i(e,t),month:$i(e,t+1,1),day:$i(e,t+2,1)},null,t+3]},Ii,Ti,Ei),Gi=gi(Ni,Ii,Ti,Ei),Vi=gi(Si,Ii,Ti,Ei),Qi=gi(Ii,Ti,Ei),Ji=gi(Ii),Ki=pi(/(\d{4})-(\d\d)-(\d\d)/,_i),Xi=pi(Ci),eo=gi(Ii,Ti,Ei),to="Invalid Duration",no={weeks:{days:7,hours:168,minutes:10080,seconds:604800,milliseconds:6048e5},days:{hours:24,minutes:1440,seconds:86400,milliseconds:864e5},hours:{minutes:60,seconds:3600,milliseconds:36e5},minutes:{seconds:60,milliseconds:6e4},seconds:{milliseconds:1e3}},ro={years:{quarters:4,months:12,weeks:52,days:365,hours:8760,minutes:525600,seconds:31536e3,milliseconds:31536e6},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:131040,seconds:7862400,milliseconds:78624e5},months:{weeks:4,days:30,hours:720,minutes:43200,seconds:2592e3,milliseconds:2592e6},...no},io={years:{quarters:4,months:12,weeks:52.1775,days:365.2425,hours:8765.82,minutes:525949.2,seconds:525949.2*60,milliseconds:525949.2*60*1e3},quarters:{months:3,weeks:13.044375,days:91.310625,hours:2191.455,minutes:131487.3,seconds:525949.2*60/4,milliseconds:7889237999.999999},months:{weeks:4.3481250000000005,days:30.436875,hours:730.485,minutes:43829.1,seconds:2629746,milliseconds:2629746e3},...no},oo=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],so=oo.slice(0).reverse();function ao(e,t,n=!1){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new ho(r)}function lo(e,t){let n=t.milliseconds??0;for(const r of so.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function co(e,t){const n=lo(e,t)<0?-1:1;oo.reduceRight((r,i)=>{if(Cr(t[i]))return r;if(r){const o=t[r]*n,s=e[i][r],a=Math.floor(o/s);t[i]+=a*n,t[r]-=a*s*n}return i},null),oo.reduce((n,r)=>{if(Cr(t[r]))return n;if(n){const i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function uo(e){const t={};for(const[n,r]of Object.entries(e))0!==r&&(t[n]=r);return t}class ho{constructor(e){const t="longterm"===e.conversionAccuracy||!1;let n=t?io:ro;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||Un.create(),this.conversionAccuracy=t?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,t){return ho.fromObject({milliseconds:e},t)}static fromObject(e,t={}){if(null==e||"object"!=typeof e)throw new Qt("Duration.fromObject: argument expected to be an object, got "+(null===e?"null":typeof e));return new ho({values:Vr(e,ho.normalizeUnit),loc:Un.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(_r(e))return ho.fromMillis(e);if(ho.isDuration(e))return e;if("object"==typeof e)return ho.fromObject(e);throw new Qt(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,t){const[n]=function(e){return yi(e,[zi,Di])}(e);return n?ho.fromObject(n,t):ho.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,t){const[n]=function(e){return yi(e,[Pi,Ji])}(e);return n?ho.fromObject(n,t):ho.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,t=null){if(!e)throw new Qt("need to specify a reason the Duration is invalid");const n=e instanceof dr?e:new dr(e,t);if(cr.throwOnInvalid)throw new Zt(n);return new ho({invalid:n})}static normalizeUnit(e){const t={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e?e.toLowerCase():e];if(!t)throw new Vt(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){const n={...t,floor:!1!==t.round&&!1!==t.floor};return this.isValid?mi.create(this.loc,n).formatDurationFromString(this,e):to}toHuman(e={}){if(!this.isValid)return to;const t=!1!==e.showZeros,n=oo.map(n=>{const r=this.values[n];return Cr(r)||0===r&&!t?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:n.slice(0,-1)}).format(r)}).filter(e=>e);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return 0!==this.years&&(e+=this.years+"Y"),0===this.months&&0===this.quarters||(e+=this.months+3*this.quarters+"M"),0!==this.weeks&&(e+=this.weeks+"W"),0!==this.days&&(e+=this.days+"D"),0===this.hours&&0===this.minutes&&0===this.seconds&&0===this.milliseconds||(e+="T"),0!==this.hours&&(e+=this.hours+"H"),0!==this.minutes&&(e+=this.minutes+"M"),0===this.seconds&&0===this.milliseconds||(e+=Wr(this.seconds+this.milliseconds/1e3,3)+"S"),"P"===e&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const t=this.toMillis();return t<0||t>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},is.fromMillis(t,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?lo(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const t=ho.fromDurationLike(e),n={};for(const e of oo)(Pr(t.values,e)||Pr(this.values,e))&&(n[e]=t.get(e)+this.get(e));return ao(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const t=ho.fromDurationLike(e);return this.plus(t.negate())}mapUnits(e){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values))t[n]=Gr(e(this.values[n],n));return ao(this,{values:t},!0)}get(e){return this[ho.normalizeUnit(e)]}set(e){return this.isValid?ao(this,{values:{...this.values,...Vr(e,ho.normalizeUnit)}}):this}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){return ao(this,{loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:r,conversionAccuracy:n})}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return co(this.matrix,e),ao(this,{values:e},!0)}rescale(){return this.isValid?ao(this,{values:uo(this.normalize().shiftToAll().toObject())},!0):this}shiftTo(...e){if(!this.isValid)return this;if(0===e.length)return this;e=e.map(e=>ho.normalizeUnit(e));const t={},n={},r=this.toObject();let i;for(const o of oo)if(e.indexOf(o)>=0){i=o;let e=0;for(const t in n)e+=this.matrix[t][o]*n[t],n[t]=0;_r(r[o])&&(e+=r[o]);const s=Math.trunc(e);t[o]=s,n[o]=(1e3*e-1e3*s)/1e3}else _r(r[o])&&(n[o]=r[o]);for(const e in n)0!==n[e]&&(t[i]+=e===i?n[e]:n[e]/this.matrix[i][e]);return co(this.matrix,t),ao(this,{values:t},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const t of Object.keys(this.values))e[t]=0===this.values[t]?0:-this.values[t];return ao(this,{values:e},!0)}removeZeros(){return this.isValid?ao(this,{values:uo(this.values)},!0):this}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return null===this.invalid}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid)return!1;if(!this.loc.equals(e.loc))return!1;function t(e,t){return void 0===e||0===e?void 0===t||0===t:e===t}for(const n of oo)if(!t(this.values[n],e.values[n]))return!1;return!0}}const mo="Invalid Interval";class fo{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,t=null){if(!e)throw new Qt("need to specify a reason the Interval is invalid");const n=e instanceof dr?e:new dr(e,t);if(cr.throwOnInvalid)throw new Yt(n);return new fo({invalid:n})}static fromDateTimes(e,t){const n=os(e),r=os(t),i=function(e,t){return e&&e.isValid?t&&t.isValid?t<e?fo.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null:fo.invalid("missing or invalid end"):fo.invalid("missing or invalid start")}(n,r);return null==i?new fo({start:n,end:r}):i}static after(e,t){const n=ho.fromDurationLike(t),r=os(e);return fo.fromDateTimes(r,r.plus(n))}static before(e,t){const n=ho.fromDurationLike(t),r=os(e);return fo.fromDateTimes(r.minus(n),r)}static fromISO(e,t){const[n,r]=(e||"").split("/",2);if(n&&r){let e,i,o,s;try{e=is.fromISO(n,t),i=e.isValid}catch(r){i=!1}try{o=is.fromISO(r,t),s=o.isValid}catch(r){s=!1}if(i&&s)return fo.fromDateTimes(e,o);if(i){const n=ho.fromISO(r,t);if(n.isValid)return fo.after(e,n)}else if(s){const e=ho.fromISO(n,t);if(e.isValid)return fo.before(o,e)}}return fo.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return null===this.invalidReason}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",t){if(!this.isValid)return NaN;const n=this.start.startOf(e,t);let r;return r=t?.useLocaleWeeks?this.end.reconfigure({locale:n.locale}):this.end,r=r.startOf(e,t),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return!!this.isValid&&(this.isEmpty()||this.e.minus(1).hasSame(this.s,e))}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return!!this.isValid&&this.s>e}isBefore(e){return!!this.isValid&&this.e<=e}contains(e){return!!this.isValid&&this.s<=e&&this.e>e}set({start:e,end:t}={}){return this.isValid?fo.fromDateTimes(e||this.s,t||this.e):this}splitAt(...e){if(!this.isValid)return[];const t=e.map(os).filter(e=>this.contains(e)).sort((e,t)=>e.toMillis()-t.toMillis()),n=[];let{s:r}=this,i=0;for(;r<this.e;){const e=t[i]||this.e,o=+e>+this.e?this.e:e;n.push(fo.fromDateTimes(r,o)),r=o,i+=1}return n}splitBy(e){const t=ho.fromDurationLike(e);if(!this.isValid||!t.isValid||0===t.as("milliseconds"))return[];let n,{s:r}=this,i=1;const o=[];for(;r<this.e;){const e=this.start.plus(t.mapUnits(e=>e*i));n=+e>+this.e?this.e:e,o.push(fo.fromDateTimes(r,n)),r=n,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return!!this.isValid&&+this.e===+e.s}abutsEnd(e){return!!this.isValid&&+e.e===+this.s}engulfs(e){return!!this.isValid&&this.s<=e.s&&this.e>=e.e}equals(e){return!(!this.isValid||!e.isValid)&&this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const t=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return t>=n?null:fo.fromDateTimes(t,n)}union(e){if(!this.isValid)return this;const t=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return fo.fromDateTimes(t,n)}static merge(e){const[t,n]=e.sort((e,t)=>e.s-t.s).reduce(([e,t],n)=>t?t.overlaps(n)||t.abutsStart(n)?[e,t.union(n)]:[e.concat([t]),n]:[e,n],[[],null]);return n&&t.push(n),t}static xor(e){let t=null,n=0;const r=[],i=e.map(e=>[{time:e.s,type:"s"},{time:e.e,type:"e"}]),o=[].concat(...i).sort((e,t)=>e.time-t.time);for(const e of o)n+="s"===e.type?1:-1,1===n?t=e.time:(t&&+t!==+e.time&&r.push(fo.fromDateTimes(t,e.time)),t=null);return fo.merge(r)}difference(...e){return fo.xor([this].concat(e)).map(e=>this.intersection(e)).filter(e=>e&&!e.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:mo}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=tn,t={}){return this.isValid?mi.create(this.s.loc.clone(t),e).formatInterval(this):mo}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:mo}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:mo}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:mo}toFormat(e,{separator:t=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:mo}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):ho.invalid(this.invalidReason)}mapEndpoints(e){return fo.fromDateTimes(e(this.s),e(this.e))}}class po{static hasDST(e=cr.defaultZone){const t=is.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return En.isValidZone(e)}static normalizeZone(e){return Vn(e,cr.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||Un.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||Un.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||Un.create(e)).getWeekendDays().slice()}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Un.create(t,n,i)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Un.create(t,n,i)).months(e,!0)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Un.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Un.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return Un.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return Un.create(t,null,"gregory").eras(e)}static features(){return{relative:Ir(),localeWeek:Tr()}}}function go(e,t){const n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(ho.fromMillis(r).as("days"))}function yo(e,t=e=>e){return{regex:e,deser:([e])=>t(function(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(-1!==e[n].search(Qn.hanidec))t+=Kn.indexOf(e[n]);else for(const e in Jn){const[n,i]=Jn[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}return t}(e))}}const vo=`[ ${String.fromCharCode(160)}]`,wo=new RegExp(vo,"g");function bo(e){return e.replace(/\./g,"\\.?").replace(wo,vo)}function xo(e){return e.replace(/\./g,"").replace(wo," ").toLowerCase()}function ko(e,t){return null===e?null:{regex:RegExp(e.map(bo).join("|")),deser:([n])=>e.findIndex(e=>xo(n)===xo(e))+t}}function No(e,t){return{regex:e,deser:([,e,t])=>Zr(e,t),groups:t}}function So(e){return{regex:e,deser:([e])=>e}}const Co={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};let _o=null;function $o(e,t){return[].concat(...e.map(e=>function(e,t){if(e.literal)return e;const n=Eo(mi.macroTokenToFormatOpts(e.val),t);return null==n||n.includes(void 0)?e:n}(e,t)))}class Io{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=$o(mi.parseFormat(t),e),this.units=this.tokens.map(t=>function(e,t){const n=er(t),r=er(t,"{2}"),i=er(t,"{3}"),o=er(t,"{4}"),s=er(t,"{6}"),a=er(t,"{1,2}"),l=er(t,"{1,3}"),c=er(t,"{1,6}"),d=er(t,"{1,9}"),u=er(t,"{2,4}"),h=er(t,"{4,6}"),m=e=>{return{regex:RegExp((t=e.val,t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&"))),deser:([e])=>e,literal:!0};var t},f=(f=>{if(e.literal)return m(f);switch(f.val){case"G":return ko(t.eras("short"),0);case"GG":return ko(t.eras("long"),0);case"y":return yo(c);case"yy":case"kk":return yo(u,Ur);case"yyyy":case"kkkk":return yo(o);case"yyyyy":return yo(h);case"yyyyyy":return yo(s);case"M":case"L":case"d":case"H":case"h":case"m":case"q":case"s":case"W":return yo(a);case"MM":case"LL":case"dd":case"HH":case"hh":case"mm":case"qq":case"ss":case"WW":return yo(r);case"MMM":return ko(t.months("short",!0),1);case"MMMM":return ko(t.months("long",!0),1);case"LLL":return ko(t.months("short",!1),1);case"LLLL":return ko(t.months("long",!1),1);case"o":case"S":return yo(l);case"ooo":case"SSS":return yo(i);case"u":return So(d);case"uu":return So(a);case"uuu":case"E":case"c":return yo(n);case"a":return ko(t.meridiems(),0);case"EEE":return ko(t.weekdays("short",!1),1);case"EEEE":return ko(t.weekdays("long",!1),1);case"ccc":return ko(t.weekdays("short",!0),1);case"cccc":return ko(t.weekdays("long",!0),1);case"Z":case"ZZ":return No(new RegExp(`([+-]${a.source})(?::(${r.source}))?`),2);case"ZZZ":return No(new RegExp(`([+-]${a.source})(${r.source})?`),2);case"z":return So(/[a-z_+-/]{1,256}?/i);case" ":return So(/[^\S\n\r]/);default:return m(f)}})(e)||{invalidReason:"missing Intl.DateTimeFormat.formatToParts support"};return f.token=e,f}(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){const[e,t]=function(e){const t=e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,"");return[`^${t}$`,e]}(this.units);this.regex=RegExp(e,"i"),this.handlers=t}}explainFromTokens(e){if(this.isValid){const[t,n]=function(e,t,n){const r=e.match(t);if(r){const e={};let t=1;for(const i in n)if(Pr(n,i)){const o=n[i],s=o.groups?o.groups+1:1;!o.literal&&o.token&&(e[o.token.val[0]]=o.deser(r.slice(t,t+s))),t+=s}return[r,e]}return[r,{}]}(e,this.regex,this.handlers),[r,i,o]=n?function(e){let t,n=null;Cr(e.z)||(n=En.create(e.z)),Cr(e.Z)||(n||(n=new Zn(e.Z)),t=e.Z),Cr(e.q)||(e.M=3*(e.q-1)+1),Cr(e.h)||(e.h<12&&1===e.a?e.h+=12:12===e.h&&0===e.a&&(e.h=0)),0===e.G&&e.y&&(e.y=-e.y),Cr(e.u)||(e.S=jr(e.u));const r=Object.keys(e).reduce((t,n)=>{const r=(e=>{switch(e){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}})(n);return r&&(t[r]=e[n]),t},{});return[r,n,t]}(n):[null,null,void 0];if(Pr(n,"a")&&Pr(n,"H"))throw new Gt("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:o}}return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function To(e,t,n){return new Io(e,n).explainFromTokens(t)}function Eo(e,t){if(!e)return null;const n=mi.create(t,e).dtFormatter((_o||(_o=is.fromMillis(1555555555555)),_o)),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>function(e,t,n){const{type:r,value:i}=e;if("literal"===r){const e=/^\s+$/.test(i);return{literal:!e,val:e?" ":i}}const o=t[r];let s=r;"hour"===r&&(s=null!=t.hour12?t.hour12?"hour12":"hour24":null!=t.hourCycle?"h11"===t.hourCycle||"h12"===t.hourCycle?"hour12":"hour24":n.hour12?"hour12":"hour24");let a=Co[s];if("object"==typeof a&&(a=a[o]),a)return{literal:!1,val:a}}(t,e,i))}const Po="Invalid DateTime",zo=864e13;function Do(e){return new dr("unsupported zone",`the zone "${e.name}" is not supported`)}function Ro(e){return null===e.weekData&&(e.weekData=vr(e.c)),e.weekData}function Mo(e){return null===e.localWeekData&&(e.localWeekData=vr(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Oo(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new is({...n,...t,old:n})}function jo(e,t,n){let r=e-60*t*1e3;const i=n.offset(r);if(t===i)return[r,t];r-=60*(i-t)*1e3;const o=n.offset(r);return i===o?[r,i]:[e-60*Math.min(i,o)*1e3,Math.max(i,o)]}function Wo(e,t){const n=new Date(e+=60*t*1e3);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Ao(e,t,n){return jo(qr(e),t,n)}function Lo(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+3*Math.trunc(t.quarters),o={...e.c,year:r,month:i,day:Math.min(e.c.day,Br(r,i))+Math.trunc(t.days)+7*Math.trunc(t.weeks)},s=ho.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),a=qr(o);let[l,c]=jo(a,n,e.zone);return 0!==s&&(l+=s,c=e.zone.offset(l)),{ts:l,o:c}}function Bo(e,t,n,r,i,o){const{setZone:s,zone:a}=n;if(e&&0!==Object.keys(e).length||t){const r=t||a,i=is.fromObject(e,{...n,zone:r,specificOffset:o});return s?i:i.setZone(a)}return is.invalid(new dr("unparsable",`the input "${i}" can't be parsed as ${r}`))}function qo(e,t,n=!0){return e.isValid?mi.create(Un.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function Fo(e,t,n){const r=e.c.year>9999||e.c.year<0;let i="";if(r&&e.c.year>=0&&(i+="+"),i+=Rr(e.c.year,r?6:4),"year"===n)return i;if(t){if(i+="-",i+=Rr(e.c.month),"month"===n)return i;i+="-"}else if(i+=Rr(e.c.month),"month"===n)return i;return i+=Rr(e.c.day),i}function Ho(e,t,n,r,i,o,s){let a=!n||0!==e.c.millisecond||0!==e.c.second,l="";switch(s){case"day":case"month":case"year":break;default:if(l+=Rr(e.c.hour),"hour"===s)break;if(t){if(l+=":",l+=Rr(e.c.minute),"minute"===s)break;a&&(l+=":",l+=Rr(e.c.second))}else{if(l+=Rr(e.c.minute),"minute"===s)break;a&&(l+=Rr(e.c.second))}if("second"===s)break;!a||r&&0===e.c.millisecond||(l+=".",l+=Rr(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&0===e.offset&&!o?l+="Z":e.o<0?(l+="-",l+=Rr(Math.trunc(-e.o/60)),l+=":",l+=Rr(Math.trunc(-e.o%60))):(l+="+",l+=Rr(Math.trunc(e.o/60)),l+=":",l+=Rr(Math.trunc(e.o%60)))),o&&(l+="["+e.zone.ianaName+"]"),l}const Uo={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Yo={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Zo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Go=["year","month","day","hour","minute","second","millisecond"],Vo=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Qo=["year","ordinal","hour","minute","second","millisecond"];function Jo(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new Vt(e);return t}function Ko(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Jo(e)}}function Xo(e,t){const n=Vn(t.zone,cr.defaultZone);if(!n.isValid)return is.invalid(Do(n));const r=Un.fromObject(t);let i,o;if(Cr(e.year))i=cr.now();else{for(const t of Go)Cr(e[t])&&(e[t]=Uo[t]);const t=Nr(e)||Sr(e);if(t)return is.invalid(t);const r=function(e){if(void 0===ns&&(ns=cr.now()),"iana"!==e.type)return e.offset(ns);const t=e.name;let n=rs.get(t);return void 0===n&&(n=e.offset(ns),rs.set(t,n)),n}(n);[i,o]=Ao(e,r,n)}return new is({ts:i,zone:n,loc:r,o:o})}function es(e,t,n){const r=!!Cr(n.round)||n.round,i=Cr(n.rounding)?"trunc":n.rounding,o=(e,o)=>(e=Wr(e,r||n.calendary?0:2,n.calendary?"round":i),t.loc.clone(n).relFormatter(n).format(e,o)),s=r=>n.calendary?t.hasSame(e,r)?0:t.startOf(r).diff(e.startOf(r),r).get(r):t.diff(e,r).get(r);if(n.unit)return o(s(n.unit),n.unit);for(const e of n.units){const t=s(e);if(Math.abs(t)>=1)return o(t,e)}return o(e>t?-0:0,n.units[n.units.length-1])}function ts(e){let t,n={};return e.length>0&&"object"==typeof e[e.length-1]?(n=e[e.length-1],t=Array.from(e).slice(0,e.length-1)):t=Array.from(e),[n,t]}let ns;const rs=new Map;class is{constructor(e){const t=e.zone||cr.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new dr("invalid input"):null)||(t.isValid?null:Do(t));this.ts=Cr(e.ts)?cr.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[r,i]=[e.old.c,e.old.o];else{const o=_r(e.o)&&!e.old?e.o:t.offset(this.ts);r=Wo(this.ts,o),n=Number.isNaN(r.year)?new dr("invalid input"):null,r=n?null:r,i=n?null:o}this.ie=t,this.loc=e.loc||Un.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new is({})}static local(){const[e,t]=ts(arguments),[n,r,i,o,s,a,l]=t;return Xo({year:n,month:r,day:i,hour:o,minute:s,second:a,millisecond:l},e)}static utc(){const[e,t]=ts(arguments),[n,r,i,o,s,a,l]=t;return e.zone=Zn.utcInstance,Xo({year:n,month:r,day:i,hour:o,minute:s,second:a,millisecond:l},e)}static fromJSDate(e,t={}){const n=function(e){return"[object Date]"==={}.toString.call(e)}(e)?e.valueOf():NaN;if(Number.isNaN(n))return is.invalid("invalid input");const r=Vn(t.zone,cr.defaultZone);return r.isValid?new is({ts:n,zone:r,loc:Un.fromObject(t)}):is.invalid(Do(r))}static fromMillis(e,t={}){if(_r(e))return e<-zo||e>zo?is.invalid("Timestamp out of range"):new is({ts:e,zone:Vn(t.zone,cr.defaultZone),loc:Un.fromObject(t)});throw new Qt(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,t={}){if(_r(e))return new is({ts:1e3*e,zone:Vn(t.zone,cr.defaultZone),loc:Un.fromObject(t)});throw new Qt("fromSeconds requires a numerical input")}static fromObject(e,t={}){e=e||{};const n=Vn(t.zone,cr.defaultZone);if(!n.isValid)return is.invalid(Do(n));const r=Un.fromObject(t),i=Vr(e,Ko),{minDaysInFirstWeek:o,startOfWeek:s}=kr(i,r),a=cr.now(),l=Cr(t.specificOffset)?n.offset(a):t.specificOffset,c=!Cr(i.ordinal),d=!Cr(i.year),u=!Cr(i.month)||!Cr(i.day),h=d||u,m=i.weekYear||i.weekNumber;if((h||c)&&m)throw new Gt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(u&&c)throw new Gt("Can't mix ordinal dates with month/day");const f=m||i.weekday&&!h;let p,g,y=Wo(a,l);f?(p=Vo,g=Yo,y=vr(y,o,s)):c?(p=Qo,g=Zo,y=br(y)):(p=Go,g=Uo);let v=!1;for(const e of p)Cr(i[e])?i[e]=v?g[e]:y[e]:v=!0;const w=f?function(e,t=4,n=1){const r=$r(e.weekYear),i=Dr(e.weekNumber,1,Hr(e.weekYear,t,n)),o=Dr(e.weekday,1,7);return r?i?!o&&mr("weekday",e.weekday):mr("week",e.weekNumber):mr("weekYear",e.weekYear)}(i,o,s):c?function(e){const t=$r(e.year),n=Dr(e.ordinal,1,Lr(e.year));return t?!n&&mr("ordinal",e.ordinal):mr("year",e.year)}(i):Nr(i),b=w||Sr(i);if(b)return is.invalid(b);const x=f?wr(i,o,s):c?xr(i):i,[k,N]=Ao(x,l,n),S=new is({ts:k,zone:n,o:N,loc:r});return i.weekday&&h&&e.weekday!==S.weekday?is.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${S.toISO()}`):S.isValid?S:is.invalid(S.invalid)}static fromISO(e,t={}){const[n,r]=function(e){return yi(e,[Fi,Zi],[Hi,Gi],[Ui,Vi],[Yi,Qi])}(e);return Bo(n,r,t,"ISO 8601",e)}static fromRFC2822(e,t={}){const[n,r]=function(e){return yi(function(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}(e),[Oi,ji])}(e);return Bo(n,r,t,"RFC 2822",e)}static fromHTTP(e,t={}){const[n,r]=function(e){return yi(e,[Wi,Bi],[Ai,Bi],[Li,qi])}(e);return Bo(n,r,t,"HTTP",t)}static fromFormat(e,t,n={}){if(Cr(e)||Cr(t))throw new Qt("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:i=null}=n,o=Un.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),[s,a,l,c]=function(e,t,n){const{result:r,zone:i,specificOffset:o,invalidReason:s}=To(e,t,n);return[r,i,o,s]}(o,e,t);return c?is.invalid(c):Bo(s,a,n,`format ${t}`,e,l)}static fromString(e,t,n={}){return is.fromFormat(e,t,n)}static fromSQL(e,t={}){const[n,r]=function(e){return yi(e,[Ki,Zi],[Xi,eo])}(e);return Bo(n,r,t,"SQL",e)}static invalid(e,t=null){if(!e)throw new Qt("need to specify a reason the DateTime is invalid");const n=e instanceof dr?e:new dr(e,t);if(cr.throwOnInvalid)throw new Ut(n);return new is({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){const n=Eo(e,Un.fromObject(t));return n?n.map(e=>e?e.val:null).join(""):null}static expandFormat(e,t={}){return $o(mi.parseFormat(e),Un.fromObject(t)).map(e=>e.val).join("")}static resetCache(){ns=void 0,rs.clear()}get(e){return this[e]}get isValid(){return null===this.invalid}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this.ie}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Ro(this).weekYear:NaN}get weekNumber(){return this.isValid?Ro(this).weekNumber:NaN}get weekday(){return this.isValid?Ro(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Mo(this).weekday:NaN}get localWeekNumber(){return this.isValid?Mo(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Mo(this).weekYear:NaN}get ordinal(){return this.isValid?br(this.c).ordinal:NaN}get monthShort(){return this.isValid?po.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?po.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?po.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?po.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return!this.isOffsetFixed&&(this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset)}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,t=6e4,n=qr(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),o=this.zone.offset(n-r*t),s=this.zone.offset(n-i*t);if(o===s)return[this];const a=n-o*t,l=n-s*t,c=Wo(a,o),d=Wo(l,s);return c.hour===d.hour&&c.minute===d.minute&&c.second===d.second&&c.millisecond===d.millisecond?[Oo(this,{ts:a}),Oo(this,{ts:l})]:[this]}get isInLeapYear(){return Ar(this.year)}get daysInMonth(){return Br(this.year,this.month)}get daysInYear(){return this.isValid?Lr(this.year):NaN}get weeksInWeekYear(){return this.isValid?Hr(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Hr(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:t,numberingSystem:n,calendar:r}=mi.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(Zn.instance(e),t)}toLocal(){return this.setZone(cr.defaultZone)}setZone(e,{keepLocalTime:t=!1,keepCalendarTime:n=!1}={}){if((e=Vn(e,cr.defaultZone)).equals(this.zone))return this;if(e.isValid){let r=this.ts;if(t||n){const t=e.offset(this.ts),n=this.toObject();[r]=Ao(n,t,e)}return Oo(this,{ts:r,zone:e})}return is.invalid(Do(e))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){return Oo(this,{loc:this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n})})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const t=Vr(e,Ko),{minDaysInFirstWeek:n,startOfWeek:r}=kr(t,this.loc),i=!Cr(t.weekYear)||!Cr(t.weekNumber)||!Cr(t.weekday),o=!Cr(t.ordinal),s=!Cr(t.year),a=!Cr(t.month)||!Cr(t.day),l=s||a,c=t.weekYear||t.weekNumber;if((l||o)&&c)throw new Gt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(a&&o)throw new Gt("Can't mix ordinal dates with month/day");let d;i?d=wr({...vr(this.c,n,r),...t},n,r):Cr(t.ordinal)?(d={...this.toObject(),...t},Cr(t.day)&&(d.day=Math.min(Br(d.year,d.month),d.day))):d=xr({...br(this.c),...t});const[u,h]=Ao(d,this.o,this.zone);return Oo(this,{ts:u,o:h})}plus(e){return this.isValid?Oo(this,Lo(this,ho.fromDurationLike(e))):this}minus(e){return this.isValid?Oo(this,Lo(this,ho.fromDurationLike(e).negate())):this}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;const n={},r=ho.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0}if("weeks"===r)if(t){const e=this.loc.getStartOfWeek(),{weekday:t}=this;t<e&&(n.weekNumber=this.weekNumber-1),n.weekday=e}else n.weekday=1;if("quarters"===r){const e=Math.ceil(this.month/3);n.month=3*(e-1)+1}return this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?mi.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Po}toLocaleString(e=tn,t={}){return this.isValid?mi.create(this.loc.clone(t),e).formatDateTime(this):Po}toLocaleParts(e={}){return this.isValid?mi.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;const s="extended"===e;let a=Fo(this,s,o=Jo(o));return Go.indexOf(o)>=3&&(a+="T"),a+=Ho(this,s,t,n,r,i,o),a}toISODate({format:e="extended",precision:t="day"}={}){return this.isValid?Fo(this,"extended"===e,Jo(t)):null}toISOWeekDate(){return qo(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:o="extended",precision:s="milliseconds"}={}){return this.isValid?(s=Jo(s),(r&&Go.indexOf(s)>=3?"T":"")+Ho(this,"extended"===o,t,e,n,i,s)):null}toRFC2822(){return qo(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return qo(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Fo(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(t||e)&&(n&&(r+=" "),t?r+="z":e&&(r+="ZZ")),qo(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Po}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t="milliseconds",n={}){if(!this.isValid||!e.isValid)return ho.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=(a=t,Array.isArray(a)?a:[a]).map(ho.normalizeUnit),o=e.valueOf()>this.valueOf(),s=function(e,t,n,r){let[i,o,s,a]=function(e,t,n){const r=[["years",(e,t)=>t.year-e.year],["quarters",(e,t)=>t.quarter-e.quarter+4*(t.year-e.year)],["months",(e,t)=>t.month-e.month+12*(t.year-e.year)],["weeks",(e,t)=>{const n=go(e,t);return(n-n%7)/7}],["days",go]],i={},o=e;let s,a;for(const[l,c]of r)n.indexOf(l)>=0&&(s=l,i[l]=c(e,t),a=o.plus(i),a>t?(i[l]--,(e=o.plus(i))>t&&(a=e,i[l]--,e=o.plus(i))):e=a);return[e,i,a,s]}(e,t,n);const l=t-i,c=n.filter(e=>["hours","minutes","seconds","milliseconds"].indexOf(e)>=0);0===c.length&&(s<t&&(s=i.plus({[a]:1})),s!==i&&(o[a]=(o[a]||0)+l/(s-i)));const d=ho.fromObject(o,r);return c.length>0?ho.fromMillis(l,r).shiftTo(...c).plus(d):d}(o?this:e,o?e:this,i,r);var a;return o?s.negate():s}diffNow(e="milliseconds",t={}){return this.diff(is.now(),e,t)}until(e){return this.isValid?fo.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return!1;const r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const t=e.base||is.fromObject({},{zone:this.zone}),n=e.padding?this<t?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],i=e.unit;return Array.isArray(e.unit)&&(r=e.unit,i=void 0),es(t,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){return this.isValid?es(e.base||is.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(is.isDateTime))throw new Qt("min requires all arguments be DateTimes");return Er(e,e=>e.valueOf(),Math.min)}static max(...e){if(!e.every(is.isDateTime))throw new Qt("max requires all arguments be DateTimes");return Er(e,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){const{locale:r=null,numberingSystem:i=null}=n;return To(Un.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),e,t)}static fromStringExplain(e,t,n={}){return is.fromFormatExplain(e,t,n)}static buildFormatParser(e,t={}){const{locale:n=null,numberingSystem:r=null}=t,i=Un.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Io(i,e)}static fromFormatParser(e,t,n={}){if(Cr(e)||Cr(t))throw new Qt("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:i=null}=n,o=Un.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});if(!o.equals(t.locale))throw new Qt(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${t.locale}`);const{result:s,zone:a,specificOffset:l,invalidReason:c}=t.explainFromTokens(e);return c?is.invalid(c):Bo(s,a,n,`format ${t.format}`,e,l)}static get DATE_SHORT(){return tn}static get DATE_MED(){return nn}static get DATE_MED_WITH_WEEKDAY(){return rn}static get DATE_FULL(){return on}static get DATE_HUGE(){return sn}static get TIME_SIMPLE(){return an}static get TIME_WITH_SECONDS(){return ln}static get TIME_WITH_SHORT_OFFSET(){return cn}static get TIME_WITH_LONG_OFFSET(){return dn}static get TIME_24_SIMPLE(){return un}static get TIME_24_WITH_SECONDS(){return hn}static get TIME_24_WITH_SHORT_OFFSET(){return mn}static get TIME_24_WITH_LONG_OFFSET(){return fn}static get DATETIME_SHORT(){return pn}static get DATETIME_SHORT_WITH_SECONDS(){return gn}static get DATETIME_MED(){return yn}static get DATETIME_MED_WITH_SECONDS(){return vn}static get DATETIME_MED_WITH_WEEKDAY(){return wn}static get DATETIME_FULL(){return bn}static get DATETIME_FULL_WITH_SECONDS(){return xn}static get DATETIME_HUGE(){return kn}static get DATETIME_HUGE_WITH_SECONDS(){return Nn}}function os(e){if(is.isDateTime(e))return e;if(e&&e.valueOf&&_r(e.valueOf()))return is.fromJSDate(e);if(e&&"object"==typeof e)return is.fromObject(e);throw new Qt(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function ss({title:e,description:t,children:n,noSubscription:r,hideHeader:i}){return Ze("div",{className:Pt.create("page-container",{minHeight:"100vh",display:"flex",flexDirection:"column",backgroundColor:St.colors.accent}),children:Ze("div",{className:Pt.create("page-content-container",{maxWidth:"1200px",margin:"0 auto",width:"100%",flex:"1",boxSizing:"border-box",overflowX:"hidden"}),children:[!i&&Ze("div",{className:Pt.create("page-heading-wrapper",{width:"100%",marginBottom:St.spacing.lg}),children:Ze(At,{children:Ze("div",{className:Pt.create("page-heading-container",{backgroundColor:St.colors.primary,color:St.colors.primaryForeground,borderRadius:St.radius.large,padding:`${St.spacing.lg} ${St.spacing.xl}`,boxShadow:St.shadow.md}),children:Ze("div",{className:Pt.create("page-heading-content",{display:"flex",alignItems:"center",justifyContent:"space-between",gap:St.spacing.lg}),children:Ze("div",{className:Pt.create("page-heading-text",{flex:"1",minWidth:"0"}),children:[Ze("h1",{className:Pt.create("page-template-title",{margin:"0",fontSize:"1.5rem",fontWeight:"700",lineHeight:"1.3",color:St.colors.primaryForeground,letterSpacing:"-0.025em"}),children:e}),t&&Ze("p",{className:Pt.create("page-template-description",{margin:"0",marginTop:St.spacing.sm,fontSize:St.fontSize.small,lineHeight:"1.5",color:St.colors.primaryForeground,opacity:"0.85"}),children:t})]})})})})}),n]})})}function as({title:e="Loading",message:t}){const n=Pt.create("loading-container",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:St.spacing.md,minHeight:"500px"}),r=Pt.create("loading-title",{margin:"0",fontSize:"1.125rem",fontWeight:"600",color:St.colors.foreground,letterSpacing:"-0.01em"}),i=Pt.create("loading-message",{margin:"0",fontSize:St.fontSize.small,color:St.colors.mutedForeground}),o=Pt.create("loading-text-group",{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.25rem",textAlign:"center"});return Ze(ss,{title:"Loading",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze("div",{className:n,children:[Ze(Wt,{size:"large"}),Ze("div",{className:o,children:[Ze("p",{className:r,children:e}),t&&Ze("p",{className:i,children:t})]})]})})})}function ls({variant:e="primary",type:t="button",onClick:n,disabled:r,loading:i=!1,children:o,className:s,...a}){const l={primary:{backgroundColor:St.colors.primary,color:St.colors.primaryForeground,boxShadow:St.shadow.sm},outline:{border:`${St.borderWidth} solid ${St.colors.primary}`,backgroundColor:St.colors.card,color:St.colors.primary,boxShadow:St.shadow.sm}},c=Pt.create("button",{height:"2.75rem",paddingLeft:"1.5rem",paddingRight:"1.5rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",border:"none",borderRadius:St.radius.default,cursor:"pointer",fontSize:St.fontSize.default,fontWeight:"500",transition:St.transition,fontFamily:St.fontFamily,display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem"},{"(max-width: 600px)":{fontSize:"14px",paddingLeft:"1.25rem",paddingRight:"1.25rem"}}),d=Pt.pseudoElement("button",":disabled",{opacity:"50%",cursor:"not-allowed"});Pt.pseudoElement(`button-${e}`,":hover:not(:disabled)",{transform:"translateY(-1px)",boxShadow:St.shadow.md}),Pt.pseudoElement(`button-${e}`,":active:not(:disabled)",{transform:"translateY(0)",boxShadow:St.shadow.sm});const u=Pt.create(`button-${e}`,{...l[e]});return Ze("button",{type:t,className:jt(c,d,u,s),onClick:r||i?void 0:n,disabled:r||i,...a,children:[i&&Ze(Wt,{size:"small"}),o]})}function cs({error:e}){const t=e||{title:"Something Went Wrong",message:"We're unable to load the application at this time."},n=t.trackingId?t.trackingId.replace(/[^a-zA-Z0-9]/g,"").slice(0,8).toUpperCase():null;return Ze(ss,{title:t.title,noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze("div",{className:Pt.create("error-page-layout",{display:"flex",justifyContent:"center",width:"100%"}),children:Ze("div",{className:Pt.create("error-page-card",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,display:"flex",flexDirection:"column",width:"100%",maxWidth:"500px"}),children:[Ze("div",{className:Pt.create("error-page-header",{paddingInline:St.spacing.xl,paddingTop:St.spacing.xl,paddingBottom:St.spacing.lg,textAlign:"center"},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("div",{className:Pt.create("error-page-icon-wrapper",{display:"flex",justifyContent:"center",marginBottom:St.spacing.lg}),children:Ze("div",{className:Pt.create("error-page-icon-circle",{width:"4rem",height:"4rem",borderRadius:"50%",backgroundColor:"rgba(239, 68, 68, 0.1)",display:"flex",alignItems:"center",justifyContent:"center"}),children:Ze("svg",{className:Pt.create("error-page-icon",{width:"2rem",height:"2rem",color:St.colors.destructive}),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Ze("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})})}),Ze("h2",{className:Pt.create("error-page-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"1.75rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.25rem"}}),children:t.title}),Ze("p",{className:Pt.create("error-page-description",{margin:"0",marginTop:St.spacing.sm,fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.mutedForeground}),children:t.message})]}),Ze("div",{className:Pt.create("error-page-content",{paddingInline:St.spacing.xl,paddingBottom:St.spacing.xl},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingBottom:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingBottom:St.spacing.md}}),children:[n&&Ze("p",{className:Pt.create("error-page-support",{margin:"0",marginBottom:St.spacing.lg,fontSize:St.fontSize.small,lineHeight:"1.5",color:St.colors.mutedForeground,textAlign:"center"}),children:["If this problem persists, please contact support with reference"," ",Ze("span",{className:Pt.create("error-page-ref",{fontFamily:"monospace",fontWeight:"600",color:St.colors.foreground}),children:n})]}),Ze(ls,{onClick:()=>{window.location.reload()},className:Pt.create("error-page-button",{width:"100%"}),children:"Try Again"})]})]})})})})}function ds({className:e,children:t}){const n=Pt.create("center",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:"500px"});return Ze("div",{className:jt(n,e),children:t})}function us({message:e,estimatedTime:t,organisation:n}){const r=(null==n?void 0:n.name)||null,i=(null==n?void 0:n.admin_email)||null,o=(null==n?void 0:n.phone)||null,s=Boolean(i||o),a=Pt.create("maintenance-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,boxShadow:St.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:St.spacing.lg},"(max-width: 480px)":{padding:St.spacing.md}}),l=Pt.create("maintenance-icon-container",{display:"flex",justifyContent:"center",marginBottom:St.spacing.lg}),c=Pt.create("maintenance-icon",{width:"4rem",height:"4rem",color:St.colors.primary}),d=Pt.create("maintenance-header",{textAlign:"center",marginBottom:St.spacing.xl}),u=Pt.create("maintenance-title",{fontSize:"2rem",fontWeight:"700",color:St.colors.primary,marginBottom:St.spacing.sm,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),h=Pt.create("maintenance-subtitle",{fontSize:St.fontSize.default,color:St.colors.foreground,lineHeight:"1.6",opacity:"0.8"}),m=Pt.create("maintenance-estimated-time",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginTop:St.spacing.sm}),f=Pt.create("maintenance-refresh-actions",{display:"flex",justifyContent:"center",marginBottom:s?"0":St.spacing.sm}),p=Pt.create("maintenance-contact-section",{borderTop:`1px solid ${St.colors.border}`,paddingTop:St.spacing.xl,marginTop:St.spacing.xl,textAlign:"center"}),g=Pt.create("maintenance-contact-text",{fontSize:St.fontSize.default,color:St.colors.foreground,marginBottom:St.spacing.lg}),y=Pt.create("maintenance-contact-actions",{display:"flex",gap:St.spacing.md,flexWrap:"wrap",justifyContent:"center"});return Ze(ss,{title:"We'll be right back",description:"Quotes are temporarily unavailable",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze(ds,{children:Ze("div",{className:a,children:[Ze("div",{className:l,children:Ze(()=>Ze("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",className:c,children:Ze("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),{})}),Ze("div",{className:d,children:[Ze("h1",{className:u,children:"We'll be right back"}),Ze("p",{className:h,children:e||"We're temporarily unable to issue new quotes. Please try again shortly."}),t&&Ze("p",{className:m,children:[Ze("strong",{children:"Estimated time:"})," ",t]})]}),Ze("div",{className:f,children:Ze(ls,{onClick:()=>{window.location.reload()},children:"Refresh Page"})}),s&&Ze("div",{className:p,children:[Ze("p",{className:g,children:r?`Need assistance? Contact ${r}`:"Need assistance? Contact us"}),Ze("div",{className:y,children:[o&&Ze(ls,{variant:"outline",onClick:()=>window.open(`tel:${o}`),children:[Ze(()=>Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Ze("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),{}),"Call Us"]}),i&&Ze(ls,{variant:"outline",onClick:()=>window.open(`mailto:${i}`),children:[Ze(()=>Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Ze("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Ze("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),{}),"Email Us"]})]})]})]})})})})}function hs({size:e="default",style:t="normal",className:n,children:r}){const i=Pt.create("text",{marginTop:"0",marginBottom:"0"}),o=Pt.create("text-small",{fontSize:St.fontSize.small}),s=Pt.create("text-default",{fontSize:St.fontSize.default}),a=Pt.create("text-italic",{fontStyle:"italic"}),l=Pt.create("text-bold",{fontWeight:"bold"}),c=Pt.create("text-underline",{textDecoration:"underline"}),d=jt({[a]:"italic"===t,[l]:"bold"===t,[c]:"underline"===t}),u=jt({[o]:"small"===e,[s]:"default"===e});return Ze("p",{className:jt(i,u,d,n),children:r})}function ms({title:e,description:t}){return Ze("div",{className:Pt.create("section-header",{}),children:[Ze("h3",{className:Pt.create("section-title",{fontSize:St.fontSize.large,fontWeight:"600",margin:"0",color:St.colors.foreground}),children:e}),t&&Ze(hs,{className:Pt.create("section-description",{color:St.colors.mutedForeground,margin:"0.25rem 0 0 0"}),children:"Choose your excess amount - the amount you'll pay if you need to make a claim"})]})}function fs({selected:e}){return Ze("div",{className:jt(Pt.create("selected-indicator",{height:"14px",width:"14px",borderRadius:"100%",border:`${St.borderWidth} solid transparent`}),e?Pt.create("selected-indicator-selected",{backgroundColor:St.colors.primary}):Pt.create("selected-indicator-unselected",{border:`${St.borderWidth} solid ${St.colors.border}`}))})}function ps({excessOptions:e,selectedExcessId:t,onExcessSelect:n}){const r=[...e].sort((e,t)=>e.excess_amount-t.excess_amount),i=e.find(e=>e.id===t);return Ze("div",{className:Pt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Ze(ms,{title:1===e.length?"Excess":"Excess Options"}),Ze("div",{className:Pt.create("excess-options-grid",{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"1rem"}),children:r.map(e=>{const r=e.id===t;return Ze("div",{className:jt(Pt.create("excess-option-card",{borderRadius:St.radius.default,minWidth:"125px",padding:"0.5rem 1rem 0.5rem 0.5rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"center",gap:"1rem"}),r?Pt.create("excess-option-card-selected",{border:`2px solid ${St.colors.primary}`,backgroundColor:St.colors.accent}):Pt.create("excess-option-card-unselected",{border:`2px solid ${St.colors.border}`,backgroundColor:St.colors.card})),onClick:()=>n(e.id),children:[Ze(fs,{selected:r}),Ze("div",{className:Pt.create("excess-amount",{color:St.colors.foreground}),children:[e.excess_label||`$${Number(e.excess_amount).toFixed(0)}`,e.description?"*":""]})]},e.id)})}),(null==i?void 0:i.description)&&Ze("div",{className:Pt.create("excess-description",{padding:"0.75rem",backgroundColor:St.colors.muted,borderRadius:St.radius.default,border:`1px solid ${St.colors.border}`}),children:Ze(hs,{className:Pt.create("excess-description-text",{fontSize:St.fontSize.small,color:St.colors.foreground,margin:"0"}),children:i.description})})]})}function gs(e,t="NZD",n="en-NZ"){return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(e)}function ys(e,t){return"bank_transfer"===t?"Bank Transfer":"one-time"===e?"Online Payment":"monthly"===e?"Monthly Installments":`${e.charAt(0).toUpperCase()}${e.slice(1)} Installments`}function vs({paymentOptions:e,paymentGateways:t,selectedExcessId:n,selectedPaymentOption:r,onPaymentSelect:i}){const o=ut(()=>{if(!n)return[];const r=e.filter(e=>e.excess_id===n).map(e=>{const n=t.find(t=>t.id===e.gateway_id);if(!n)throw new Error(`Gateway not found for option: ${e.gateway_id}`);return{...e,gateway:n}});return r.sort((e,t)=>{var n,r;return e.amount.success!==t.amount.success?e.amount.success?-1:1:("one-time"===e.amount.frequency?Number(e.amount.dueToday):Number(null!==(n=e.amount.installmentAmount)&&void 0!==n?n:0))-("one-time"===t.amount.frequency?Number(t.amount.dueToday):Number(null!==(r=t.amount.installmentAmount)&&void 0!==r?r:0))})},[e,t,n]);return n?Ze(ws,{sortedOptions:o,selectedPaymentOption:r,onPaymentSelect:i}):Ze("div",{className:Pt.create("payment-section-disabled",{opacity:"0.5",pointerEvents:"none"}),children:Ze(ws,{sortedOptions:[],selectedPaymentOption:null,onPaymentSelect:i})})}function ws({sortedOptions:e,selectedPaymentOption:t,onPaymentSelect:n}){const r=e.length>0;return Ze("div",{className:Pt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"}),children:[Ze(ms,{title:"Payment Options"}),Ze("div",r?{className:Pt.create("payment-options-container",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:e.map(e=>{var r;return Ze(bs,{option:e,selectedPaymentOption:t,onPaymentSelect:n},`${e.gateway_id}-${null!==(r=e.gateway_method)&&void 0!==r?r:"default"}-${e.excess_id}`)})}:{className:Pt.create("no-options-placeholder",{padding:"2rem",textAlign:"center",border:`1px dashed ${St.colors.border}`,borderRadius:St.radius.default,backgroundColor:St.colors.muted}),children:Ze(hs,{className:Pt.create("placeholder-text",{color:St.colors.mutedForeground,margin:"0"}),children:"Payment options will appear here after selecting an excess amount"})})]})}function bs({option:e,selectedPaymentOption:t,onPaymentSelect:n}){var r,i,o,s,a,l;const c=(null!==(r=null==t?void 0:t.gateway_method)&&void 0!==r?r:null)===(null!==(i=e.gateway_method)&&void 0!==i?i:null)&&(null==t?void 0:t.gateway_id)===e.gateway_id&&(null==t?void 0:t.excess_id)===e.excess_id,d=e.amount.success,u=null!==(s=null!==(o=e.display_title)&&void 0!==o?o:e.gateway.display_title)&&void 0!==s?s:null,h=null!==(l=null!==(a=e.description)&&void 0!==a?a:e.gateway.description)&&void 0!==l?l:null,m=()=>d?"one-time"===e.amount.frequency?gs(e.amount.dueToday):`${gs(e.amount.installmentAmount||0)} x ${e.amount.numberOfInstallments}`:"Currently Unavailable",f=()=>h||("bank_transfer"===e.gateway.code?"Manual":`via ${e.gateway.name}`);return Ze("div",{className:jt(Pt.create("payment-option-row",{borderRadius:St.radius.default,padding:"0.75rem 1rem",cursor:d?"pointer":"not-allowed",transition:"all 150ms ease",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",opacity:d?"1":"0.6"},{"(max-width: 950px)":{padding:"0.75rem",flexDirection:"column",alignItems:"stretch",gap:"0.25rem"}}),c?Pt.create("payment-option-row-selected",{border:`2px solid ${St.colors.primary}`,backgroundColor:St.colors.accent}):Pt.create("payment-option-row-unselected",{border:`2px solid ${St.colors.border}`,backgroundColor:St.colors.card})),onClick:()=>d&&n(e),children:[Ze("div",{className:Pt.create("payment-option-desktop-wrapper",{display:"flex",flexDirection:"column",flex:"1"},{"(max-width: 950px)":{display:"none"}}),children:[Ze("div",{className:Pt.create("frequency-title",{fontSize:St.fontSize.default,fontWeight:"500",color:St.colors.foreground}),children:u||ys(e.amount.frequency,e.gateway.code)}),Ze("div",{className:Pt.create("gateway-description",{fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:f()})]}),Ze("div",{className:Pt.create("payment-option-amount-desktop",{display:"flex",flexDirection:"column",alignItems:"flex-end"},{"(max-width: 950px)":{display:"none"}}),children:[Ze(hs,{className:d?Pt.create("amount-text",{textAlign:"right",color:St.colors.foreground,fontStyle:"normal"}):Pt.create("amount-text-unavailable",{textAlign:"right",color:St.colors.mutedForeground,fontStyle:"italic"}),children:m()}),d&&Ze(hs,{size:"small",className:Pt.create("gateway-fee-text",{textAlign:"right",color:St.colors.mutedForeground}),children:"bank_transfer"!==e.gateway.code&&e.amount.gatewayFee>0?`${gs(e.amount.gatewayFee)} fee`:"No fees"})]}),Ze("div",{className:Pt.create("payment-option-mobile-wrapper",{display:"none"},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:"0.125rem"}}),children:[Ze("div",{className:Pt.create("payment-option-title-mobile",{fontSize:St.fontSize.default,fontWeight:"500",color:St.colors.foreground}),children:u||ys(e.amount.frequency,e.gateway.code)}),Ze(hs,{className:d?Pt.create("amount-text-mobile",{fontWeight:"500",color:St.colors.foreground,fontStyle:"normal"}):Pt.create("amount-text-mobile-unavailable",{fontWeight:"500",color:St.colors.mutedForeground,fontStyle:"italic"}),children:[m(),d&&e.amount.gatewayFee>0&&Ze("span",{className:Pt.create("gateway-fee-inline",{fontWeight:"400",fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginLeft:"0.375rem"}),children:["(",gs(e.amount.gatewayFee)," fee)"]})]}),Ze("div",{className:Pt.create("gateway-description-mobile",{fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:f()})]})]})}const xs=e=>{try{return new Date(e).toLocaleDateString("en-NZ",{year:"numeric",month:"long",day:"numeric"})}catch(t){return e}};function ks({excessOptions:e,selectedExcessId:t,onEditQuote:n,isEditingQuote:r=!1,productName:i,quoteIntent:o,embedded:s=!1}){const a=ut(()=>t?e.find(e=>e.id===t):null,[e,t]),l=(null==a?void 0:a.line_item_display)||[],{formProgress:c}=Ft(e=>({formProgress:e.getFormProgress()})),d=ut(()=>{var e;const t=(null==c?void 0:c.page_data)||(null===(e=null==o?void 0:o.form_data)||void 0===e?void 0:e.page_data);if(!t)return null;let n={};for(const e in t){const r=t[e];r&&"object"==typeof r&&(r.client_first_name&&(n.firstName=r.client_first_name),r.client_last_name&&(n.lastName=r.client_last_name),r.client_email&&(n.email=r.client_email),r.client_phone&&(n.phone=r.client_phone),r.client_dob&&(n.dob=r.client_dob))}return Object.keys(n).length>0?n:null},[c,o]);return Ze("div",{className:Pt.create(s?"cart-summary-container-embedded":"cart-summary-container",s?{}:{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.lg,boxShadow:St.shadow.sm},s?{}:{"(max-width: 768px)":{padding:St.spacing.md}}),children:[Ze("h3",{className:Pt.create("cart-summary-title",{fontSize:St.fontSize.large,fontWeight:"600",marginBottom:St.spacing.md,color:St.colors.foreground}),children:"Insurance Details"}),d&&Ze(C,{children:[Ze("div",{className:Pt.create("cart-client-details",{display:"flex",flexDirection:"column",gap:St.spacing.sm,marginBottom:St.spacing.md}),children:[d.firstName&&d.lastName&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Name"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:[d.firstName," ",d.lastName]})]}),d.email&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Email"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:d.email})]}),d.phone&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Phone"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:d.phone})]}),d.dob&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Date of Birth"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:xs(d.dob)})]})]}),Ze("hr",{className:Pt.create("divider",{border:"none",borderTop:`1px solid ${St.colors.border}`,margin:`${St.spacing.md} 0`})})]}),Ze("div",{className:Pt.create("cart-product-section",{display:"flex",flexDirection:"column",gap:St.spacing.sm,marginBottom:St.spacing.lg}),children:l.map((e,t)=>Ze("div",{className:Pt.create("cart-item",{display:"flex",flexDirection:"column",gap:St.spacing.sm}),children:[Ze("div",{className:Pt.create("cart-item-description",{fontSize:St.fontSize.small,fontWeight:"500",color:St.colors.foreground}),children:e.description}),e.show_sum_insured&&e.sum_insured&&Ze("div",{className:Pt.create("cart-item-sum-insured",{fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:["Sum Insured: ",gs(e.sum_insured)]})]},t))}),Ze(ls,{onClick:n,disabled:r,variant:"outline",className:Pt.create("edit-quote-button",{width:"100%"}),children:r?"Clearing quote...":"Edit details"})]})}function Ns({clauses:e}){const[t,n]=lt(!0);return 0===e.length?null:Ze("div",{className:Pt.create("policy-clauses-section",{borderRadius:St.radius.default,border:`1px solid ${St.colors.border}`,overflow:"hidden"}),children:[Ze("button",{type:"button",onClick:()=>n(!t),className:Pt.create("policy-clauses-toggle",{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:`${St.spacing.sm} ${St.spacing.md}`,background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",textAlign:"left"}),children:[Ze("div",{className:Pt.create("policy-clauses-header",{display:"flex",alignItems:"center",gap:St.spacing.sm}),children:[Ze("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:St.colors.mutedForeground,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Ze("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),Ze("polyline",{points:"14 2 14 8 20 8"}),Ze("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),Ze("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),Ze("polyline",{points:"10 9 9 9 8 9"})]}),Ze("span",{className:Pt.create("policy-clauses-title",{fontSize:St.fontSize.small,fontWeight:"500",color:St.colors.foreground,opacity:"0.7"}),children:"Policy Clauses"})]}),Ze("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:St.colors.mutedForeground,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{transition:"transform 0.2s ease",transform:t?"rotate(180deg)":"rotate(0deg)"},children:Ze("polyline",{points:"6 9 12 15 18 9"})})]}),t&&Ze("div",{className:Pt.create("policy-clauses-content",{padding:`0 ${St.spacing.md} ${St.spacing.md}`,borderTop:`1px solid ${St.colors.border}`,paddingTop:St.spacing.md}),children:Ze("ul",{className:Pt.create("policy-clauses-list",{margin:"0",padding:"0",listStyle:"none",display:"flex",flexDirection:"column",gap:St.spacing.sm}),children:e.map((e,t)=>Ze("li",{className:Pt.create("policy-clause-item",{fontSize:St.fontSize.small,color:St.colors.foreground,opacity:"0.7",lineHeight:"1.5",paddingLeft:St.spacing.md,position:"relative"}),children:[Ze("span",{className:Pt.create("policy-clause-bullet",{position:"absolute",left:"0",top:"0.6em",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:St.colors.mutedForeground,opacity:"0.5"})}),e.note||e.reference||""]},t))})})]})}function Ss({label:e,value:t,isTotal:n=!1,className:r}){return Ze("div",{className:jt(Pt.create("summary-item",{display:"flex",justifyContent:"space-between",alignItems:"center"}),r),children:[Ze("span",{className:Pt.create("summary-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:e}),Ze("span",{className:Pt.create("summary-value",{fontWeight:n?"600":"500",color:St.colors.foreground,fontSize:n?St.fontSize.large:"inherit"}),children:t})]})}function Cs({excessOptions:e,paymentGateways:t,selectedExcessId:n,selectedPaymentOption:r,onPurchase:i,canPurchase:o,onContinueLater:s,continueLaterLoading:a=!1,showContinueLaterSuccess:l=!1}){ut(()=>n?e.find(e=>e.id===n):null,[e,n]);const c=ut(()=>r?t.find(e=>e.id===r.gateway_id):null,[t,r]);return Ze("div",{className:Pt.create("payment-summary",{display:"flex",flex:"1",flexDirection:"column",gap:"1rem"}),children:[r&&Ze("div",{className:Pt.create("summary-section",{paddingBottom:"1rem"}),children:Ze("div",{className:Pt.create("payment-breakdown",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:"one-time"===r.amount.frequency?Ze(C,{children:[r.amount.gatewayFee>0&&Ze(Ss,{label:"windcave"===(null==c?void 0:c.code)?"Credit card surcharge:":"Provider Fee:",value:gs(r.amount.gatewayFee)}),Ze(Ss,{label:"Due Today:",value:gs(Number(r.amount.dueToday)+Number(r.amount.gatewayFee)),isTotal:!0})]}):Ze(C,{children:[r.amount.gatewayFee>0&&Ze(Ss,{label:"windcave"===(null==c?void 0:c.code)?"Credit card surcharge:":"Provider Fee:",value:gs(r.amount.gatewayFee)}),r.amount.totalRepayable&&Ze(Ss,{label:"Total Payable:",value:gs(Number(r.amount.totalRepayable))}),Ze(Ss,{label:"Due Today:",value:gs(r.amount.dueToday)}),r.amount.installmentAmount&&r.amount.numberOfInstallments&&r.amount.numberOfInstallments>1&&Ze(Ss,{label:"Remaining payments:",value:`${r.amount.numberOfInstallments-1} x ${gs(r.amount.installmentAmount)}`})]})})}),s&&Ze(ls,{onClick:s,disabled:a||l,variant:"outline",className:Pt.create("continue-later-button",{width:"100%",height:"2.75rem",fontSize:St.fontSize.default,fontWeight:"500"},{"(max-width: 380px)":{fontSize:St.fontSize.small,height:"2.5rem"}}),children:l?"Email sent":a?"Sending...":"Continue Later"}),Ze(ls,{onClick:i,disabled:!o,className:Pt.create("purchase-button",{width:"100%",height:"3rem",fontSize:St.fontSize.default,fontWeight:"600"},{"(max-width: 380px)":{fontSize:St.fontSize.small,height:"2.75rem"}}),children:o?"Go to Payment":n?"Select Payment Option":"Select Excess"})]})}function _s({details:e,onClose:t}){const n=(e,t)=>{navigator.clipboard.writeText(e).then(()=>{alert(`${t} copied to clipboard!`)}).catch(()=>{})};return Ze("div",{className:Pt.create("bank-transfer-container",{display:"flex",flexDirection:"column",gap:St.spacing.lg}),children:[Ze("div",{className:Pt.create("success-message",{backgroundColor:St.colors.accent,border:`2px solid ${St.colors.primary}`,borderRadius:St.radius.default,padding:St.spacing.lg,textAlign:"center"}),children:[Ze("div",{className:Pt.create("success-icon",{fontSize:"3rem",marginBottom:St.spacing.sm}),children:"✓"}),Ze("h3",{className:Pt.create("success-title",{margin:"0",marginBottom:St.spacing.sm,color:St.colors.primary,fontSize:St.fontSize.large,fontWeight:"600"}),children:"Quote Reserved"}),Ze(hs,{className:Pt.create("success-description",{margin:"0",color:St.colors.foreground,opacity:"0.9"}),children:"Your quote has been reserved. Please complete the bank transfer to finalize your coverage."})]}),Ze("div",{className:Pt.create("transfer-instructions",{backgroundColor:St.colors.card,border:`1px solid ${St.colors.border}`,borderRadius:St.radius.default,padding:St.spacing.lg}),children:[Ze("h4",{className:Pt.create("instructions-title",{margin:"0",marginBottom:St.spacing.md,fontSize:St.fontSize.default,fontWeight:"600",color:St.colors.foreground}),children:"Bank Transfer Instructions"}),Ze("div",{className:Pt.create("instructions-grid",{display:"grid",gap:St.spacing.md}),children:[Ze("div",{className:Pt.create("detail-row-highlighted",{backgroundColor:St.colors.accent,border:`2px solid ${St.colors.primary}`,borderRadius:St.radius.default,padding:St.spacing.md}),children:[Ze("div",{className:Pt.create("detail-label",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginBottom:"0.25rem",fontWeight:"500"}),children:"Reference Number (IMPORTANT)"}),Ze("div",{className:Pt.create("detail-value-wrapper",{display:"flex",alignItems:"center",gap:"0.5rem"}),children:[Ze("code",{className:Pt.create("detail-value-code",{fontFamily:"monospace",fontSize:St.fontSize.large,fontWeight:"700",color:St.colors.primary,letterSpacing:"0.05em"}),children:e.reference}),Ze("button",{onClick:()=>n(e.reference,"Reference"),className:Pt.create("copy-button",{background:"transparent",border:`1px solid ${St.colors.primary}`,borderRadius:St.radius.small,padding:"0.25rem 0.5rem",cursor:"pointer",fontSize:St.fontSize.small,color:St.colors.primary,transition:"all 150ms ease"}),children:"Copy"})]}),Ze(hs,{size:"small",className:Pt.create("reference-note",{marginTop:"0.5rem",marginBottom:"0",color:St.colors.foreground,fontWeight:"500"}),children:"⚠️ Please include this reference in your transfer particulars"})]}),Ze("div",{className:Pt.create("detail-row",{}),children:[Ze("div",{className:Pt.create("detail-label",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginBottom:"0.25rem"}),children:"Amount"}),Ze("div",{className:Pt.create("detail-value",{fontSize:St.fontSize.large,fontWeight:"600",color:St.colors.foreground}),children:["$",e.amount.toFixed(2)," ",e.currency]})]}),Ze("div",{className:Pt.create("detail-row",{}),children:[Ze("div",{className:Pt.create("detail-label",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginBottom:"0.25rem"}),children:"Account Name"}),Ze("div",{className:Pt.create("detail-value-wrapper",{display:"flex",alignItems:"center",gap:"0.5rem"}),children:[Ze("span",{className:Pt.create("detail-value",{fontFamily:"monospace",fontSize:St.fontSize.default,color:St.colors.foreground}),children:e.bank_account_name}),Ze("button",{onClick:()=>n(e.bank_account_name,"Account name"),className:Pt.create("copy-button-small",{background:"transparent",border:`1px solid ${St.colors.border}`,borderRadius:St.radius.small,padding:"0.125rem 0.375rem",cursor:"pointer",fontSize:St.fontSize.small,color:St.colors.mutedForeground,transition:"all 150ms ease"}),children:"Copy"})]})]}),Ze("div",{className:Pt.create("detail-row",{}),children:[Ze("div",{className:Pt.create("detail-label",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginBottom:"0.25rem"}),children:"Account Number"}),Ze("div",{className:Pt.create("detail-value-wrapper",{display:"flex",alignItems:"center",gap:"0.5rem"}),children:[Ze("span",{className:Pt.create("detail-value",{fontFamily:"monospace",fontSize:St.fontSize.default,color:St.colors.foreground}),children:e.bank_account_number}),Ze("button",{onClick:()=>n(e.bank_account_number,"Account number"),className:Pt.create("copy-button-small",{background:"transparent",border:`1px solid ${St.colors.border}`,borderRadius:St.radius.small,padding:"0.125rem 0.375rem",cursor:"pointer",fontSize:St.fontSize.small,color:St.colors.mutedForeground,transition:"all 150ms ease"}),children:"Copy"})]})]})]}),e.instructions_html&&Ze("div",{className:Pt.create("additional-instructions",{marginTop:St.spacing.md,paddingTop:St.spacing.md,borderTop:`1px solid ${St.colors.border}`}),children:Ze("div",{className:Pt.create("instructions-content",{fontSize:St.fontSize.small,color:St.colors.foreground,lineHeight:"1.6"}),dangerouslySetInnerHTML:{H:e.instructions_html}})})]}),Ze("div",{className:Pt.create("important-note",{backgroundColor:St.colors.muted,border:`1px solid ${St.colors.border}`,borderRadius:St.radius.default,padding:St.spacing.md}),children:Ze(hs,{size:"small",className:Pt.create("note-text",{margin:"0",color:St.colors.foreground,lineHeight:"1.5"}),children:[Ze("strong",{children:"Important:"})," Your coverage will be activated once we verify receipt of your payment. This typically takes 1-2 business days. We'll send you a confirmation email once your payment is processed."]})}),Ze("div",{className:Pt.create("actions",{display:"flex",justifyContent:"center"}),children:Ze(ls,{onClick:t,variant:"primary",children:"I've Made the Transfer"})})]})}function $s({isOpen:e,onClose:t,onSuccess:n,paymentRequest:r}){const{fsm:i}=Ft(()=>({})),[o,s]=lt("initiating"),[a,l]=lt(null),[c,d]=lt(null),[u,h]=lt(null),[m,f]=lt(null);ct(()=>{e&&r&&p()},[e,r]);const p=async()=>{if(r)try{s("initiating"),l(null);const e={...r,returnUrl:window.location.href},t=await i.initiatePayment(e);if(h(t.transaction_id),t.bank_account_name&&t.reference){s("bank_transfer");const e=i.getQuoteIntent(),t=await i.httpClient.getQuoteIntent(e.url);i.updateQuoteIntent({status:t.quote_intent.status,payment_transactions:t.payment_transactions}),i.getQuoteIntent(),setTimeout(()=>{g()},500)}else{if(!t.gateway_acceptance_url)throw new Error("Invalid payment response");s("redirecting"),window.location.href=t.gateway_acceptance_url}}catch(e){l(e.message||"Failed to initiate payment"),s("failed")}},g=()=>{c&&!c.closed&&c.close(),s("initiating"),l(null),h(null),d(null),f(null),t()},y=()=>{g(),n()};return e?Ze("div","bank_transfer"===o&&m?{className:Pt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000",overflowY:"auto",padding:"1rem"}),onClick:e=>{e.target===e.currentTarget&&y()},children:Ze("div",{className:Pt.create("modal-content",{backgroundColor:St.colors.background,borderRadius:St.radius.large,padding:"2rem",maxWidth:"600px",width:"100%",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${St.colors.border}`,margin:"auto"}),onClick:e=>e.stopPropagation(),children:Ze(_s,{details:m,onClose:y})})}:{className:Pt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),children:[Ze("div",{className:Pt.create("modal-content",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:"2rem",minWidth:"400px",maxWidth:"500px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${St.colors.border}`}),children:[Ze("div",{className:Pt.create("modal-header",{textAlign:"center",marginBottom:"1.5rem"}),children:[Ze("div",{className:Pt.create("status-icon",{fontSize:"3rem",marginBottom:"1rem"}),children:(()=>{switch(o){case"completed":return"✅";case"cancelled":return"❌";case"failed":return"⚠️";default:return"⏳"}})()}),Ze("h2",{className:Pt.create("modal-title",{margin:"0",color:St.colors.foreground,fontSize:St.fontSize.large}),children:"Payment Processing"})]}),Ze("div",{className:Pt.create("modal-body",{textAlign:"center",marginBottom:"2rem"}),children:[Ze(hs,{className:Pt.create("status-message",{fontSize:St.fontSize.default,color:St.colors.mutedForeground,marginBottom:"1rem"}),children:(()=>{switch(o){case"initiating":return"Setting up your payment...";case"redirecting":return"Redirecting to payment portal...";case"processing":default:return"Processing payment...";case"polling":return"Checking payment status...";case"completed":return"Payment completed successfully!";case"cancelled":return"Payment was cancelled";case"failed":return"Payment failed"}})()}),a&&Ze(hs,{className:Pt.create("error-message",{color:St.colors.destructive,fontSize:St.fontSize.small,padding:"0.75rem",backgroundColor:St.colors.destructive+"10",borderRadius:St.radius.default,border:`1px solid ${St.colors.destructive}30`}),children:a}),("redirecting"===o||"initiating"===o)&&Ze("div",{className:Pt.create("loading-indicator",{display:"inline-block",width:"20px",height:"20px",marginTop:"1rem",border:`3px solid ${St.colors.border}`,borderTop:`3px solid ${St.colors.primary}`,borderRadius:"50%",animation:"spin 1s linear infinite"})})]}),Ze("div",{className:Pt.create("modal-actions",{display:"flex",gap:"1rem",justifyContent:"center"}),children:"failed"===o||"cancelled"===o?Ze(C,{children:[Ze(ls,{onClick:g,variant:"outline",children:"Close"}),"cancelled"===o&&Ze(ls,{onClick:()=>{s("initiating"),l(null),p()},children:"Try Again"})]}):Ze(ls,"completed"===o?{onClick:g,children:"Continue"}:{onClick:g,variant:"outline",disabled:"initiating"===o,children:"Cancel"})})]}),Ze("style",{children:"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "})]}):null}function Is({type:e,transactionId:t,isOpen:n,onClose:r}){if(!n)return null;const i=(()=>{switch(e){case"success":return{title:"Payment Successful!",message:"Your payment has been processed successfully and your policy is now active.",icon:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:St.colors.primary||"#10b981"},children:Ze("path",{d:"M20 6 9 17l-5-5"})}),buttonText:"Close"};case"declined":return{title:"Payment Declined",message:"Your payment was declined by the payment processor. Please try a different payment method or contact your bank.",icon:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:St.colors.destructive},children:[Ze("circle",{cx:"12",cy:"12",r:"10"}),Ze("path",{d:"m15 9-6 6"}),Ze("path",{d:"m9 9 6 6"})]}),buttonText:"Close"};case"cancelled":return{title:"Payment Cancelled",message:"You cancelled the payment process. You can try again when you're ready.",icon:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:St.colors.secondary},children:[Ze("circle",{cx:"12",cy:"12",r:"10"}),Ze("path",{d:"m15 9-6 6"}),Ze("path",{d:"m9 9 6 6"})]}),buttonText:"Continue"};default:return{title:"Payment Error",message:"There was an issue processing your payment. Please try again or contact support if the problem persists.",icon:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:St.colors.destructive},children:[Ze("circle",{cx:"12",cy:"12",r:"10"}),Ze("path",{d:"M12 8v4"}),Ze("path",{d:"m12 16 .01 0"})]}),buttonText:"Try Again"}}})(),o=Pt.create("modal-overlay",{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000",padding:"1rem"}),s=Pt.create("modal-content",{backgroundColor:St.colors.background,borderRadius:St.radius.default,padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",border:`${St.borderWidth} solid ${St.colors.border}`}),a=Pt.create("modal-body",{display:"flex",flexDirection:"column",alignItems:"center",gap:"1.5rem",textAlign:"center"}),l=Pt.create("modal-title",{fontSize:"1.25rem",fontWeight:"600",color:St.colors.foreground,margin:"0"}),c=Pt.create("modal-message",{color:St.colors.foreground,lineHeight:"1.5",margin:"0"});Pt.create("transaction-info",{backgroundColor:St.colors.muted||"#f8f9fa",padding:"0.75rem",borderRadius:St.radius.small,border:`${St.borderWidth} solid ${St.colors.border}`,fontSize:St.fontSize.small,color:St.colors.mutedForeground,wordBreak:"break-all"});const d=Pt.create("modal-button",{backgroundColor:St.colors.primary,color:St.colors.primaryForeground,border:"none",borderRadius:St.radius.default,padding:"0.75rem 1.5rem",fontSize:St.fontSize.default,fontWeight:"500",cursor:"pointer",minWidth:"120px",transition:"background-color 0.2s"}),u=Pt.create("message-container",{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem",marginTop:"0.5rem"});return Ze("div",{className:o,onClick:r,children:Ze("div",{className:s,onClick:e=>e.stopPropagation(),children:Ze("div",{className:a,children:[i.icon,Ze("div",{className:u,children:[Ze("h2",{className:l,children:i.title}),Ze("p",{className:c,children:i.message})]}),Ze("button",{className:d,onClick:r,children:i.buttonText})]})})})}function Ts({httpClient:e,transactionId:t,onResolved:n,onError:r}){const[i,o]=lt(!1),s=dt(!1);return ct(()=>{if(s.current)return;s.current=!0;let i=!1;return(async()=>{var s;try{const r=await e.resolvePaymentTransaction(t);if(i)return;n(r.status,r.recovery,r.fallback)}catch(e){if(i)return;r(null!==(s=null==e?void 0:e.message)&&void 0!==s?s:"Failed to confirm payment status"),o(!0)}})(),()=>{i=!0}},[e,t]),Ze("div",{role:"status","aria-live":"polite",className:Pt.create("payment-processing-overlay",{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:"1000",display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"}),children:Ze("div",{className:Pt.create("payment-processing-card",{backgroundColor:St.colors.background,borderRadius:St.radius.default,border:`${St.borderWidth} solid ${St.colors.border}`,boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",padding:"2rem",maxWidth:"400px",width:"100%",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:St.spacing.md}),children:[Ze(Es,{}),Ze("h2",{className:Pt.create("payment-processing-title",{margin:"0",fontSize:St.fontSize.large,fontWeight:"600",color:St.colors.foreground}),children:"Payment Processing"}),Ze(hs,{children:i?"Just a moment, we're still finishing up. Hang tight, this page will update automatically.":"Hang tight, we're finalising your payment. This page will update automatically in a few seconds."})]})})}function Es(){return Pt.keyframes("payment-processing-spin",{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Ze("span",{"aria-hidden":"true",className:Pt.create("payment-processing-spinner",{width:"2.5rem",height:"2.5rem",borderRadius:"50%",border:`3px solid ${St.colors.border}`,borderTopColor:St.colors.primary,animation:"insure-os-payment-processing-spin 0.9s linear infinite",display:"block"})})}function Ps({isOpen:e,onClose:t,title:n,description:r,children:i,footer:o,width:s="440px"}){if(ct(()=>{if(e)return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n);function n(e){"Escape"===e.key&&t()}},[e,t]),!e)return null;const a=Pt.create("modal-overlay",{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000",padding:"1rem"}),l=Pt.create("modal-content-card",{backgroundColor:St.colors.background,borderRadius:St.radius.large,boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",border:`${St.borderWidth} solid ${St.colors.border}`,width:"100%",maxWidth:s,display:"flex",flexDirection:"column",gap:St.spacing.md,padding:St.spacing.lg}),c=Pt.create("modal-card-header-row",{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:St.spacing.md}),d=Pt.create("modal-card-title",{margin:"0",fontSize:"1.125rem",fontWeight:"600",color:St.colors.foreground}),u=Pt.create("modal-card-description",{margin:"0",fontSize:St.fontSize.small,color:St.colors.mutedForeground,lineHeight:"1.5"}),h=Pt.create("modal-card-body",{display:"flex",flexDirection:"column",gap:St.spacing.sm}),m=Pt.create("modal-card-footer",{display:"flex",gap:St.spacing.sm,marginTop:St.spacing.sm,flexWrap:"wrap",justifyContent:"flex-end"}),f=Pt.create("modal-card-close",{background:"none",border:"none",padding:"0.25rem",margin:"-0.25rem -0.25rem 0 0",color:St.colors.mutedForeground,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:St.radius.default,lineHeight:"0"});return Pt.pseudoElement("modal-card-close",":hover",{color:St.colors.foreground,backgroundColor:St.colors.muted}),Ze("div",{className:a,onClick:t,children:Ze("div",{className:l,onClick:e=>e.stopPropagation(),children:[Ze("div",{className:h,children:[Ze("div",{className:c,children:[Ze("h2",{className:d,children:n}),Ze("button",{type:"button",onClick:t,"aria-label":"Close",className:f,children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Ze("path",{d:"M18 6 6 18"}),Ze("path",{d:"m6 6 12 12"})]})})]}),r&&Ze("p",{className:u,children:r}),i]}),o&&Ze("div",{className:m,children:o})]})})}function zs({isOpen:e,onClose:t,status:n,onSendEmail:r,onCopyLink:i,email:o}){const s="sending"===n.kind,a="sent"===n.kind,l=s||a,c=Pt.create("continue-later-status",{margin:"0",fontSize:St.fontSize.small,color:St.colors.primary}),d=Pt.create("continue-later-status-error",{margin:"0",fontSize:St.fontSize.small,color:St.colors.destructive});let u=null;return"sent"===n.kind?u=Ze("p",{className:c,children:o?`A link will be sent to ${o} shortly.`:"A link will be sent to your email shortly."}):"copied"===n.kind?u=Ze("p",{className:c,children:"Link copied to your clipboard."}):"error"===n.kind&&(u=Ze("p",{className:d,children:n.message})),Ze(Ps,{isOpen:e,onClose:t,title:"Save and continue later",description:"We'll save your progress and give you a link to come back to. Your details stay safe and only the people you share the link with can resume.",footer:Ze(C,{children:[Ze(ls,{variant:"outline",onClick:i,disabled:s,children:"Copy link"}),Ze(ls,{onClick:r,disabled:l,loading:s,children:a?"Email sent":o?"Email me a link":"Send email"})]}),children:u})}function Ds(e=0){const t=new Date;return t.setDate(t.getDate()+e),`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Rs({results:e}){const{fsm:t,selectedExcessId:n,selectedPaymentOption:r,quoteIntent:i,httpClient:o}=Ft(e=>({selectedExcessId:e.getSelectedExcessId(),selectedPaymentOption:e.getSelectedPaymentOption(),quoteIntent:e.getQuoteIntent(),httpClient:e.httpClient})),[s,a]=lt(!1),[l,c]=lt(null),[d,u]=lt(!1),[h,m]=lt({kind:"idle"}),[f,p]=lt(!1),g=ut(()=>{var e,t;const n=null!==(t=null===(e=null==i?void 0:i.form_data)||void 0===e?void 0:e.page_data)&&void 0!==t?t:{};for(const e of Object.values(n))if(e&&"object"==typeof e&&e.cover_start_date)return String(e.cover_start_date);return null},[null==i?void 0:i.form_data]),y=ut(()=>{if(!g)return!1;const e=new Date(g);if(Number.isNaN(e.getTime()))return!1;e.setHours(0,0,0,0);const t=new Date;return t.setHours(0,0,0,0),e<t},[g]),v=Ds(),[w,b]=lt(()=>y?v:null!=g?g:v),[x,k]=lt(null),[N,S]=lt(null),[C,_]=lt(!1),[$,I]=lt(!y),T=new URLSearchParams(window.location.search),E=T.get("status"),P=T.get("transactionId")||T.get("transaction_id"),[z,D]=lt(null),[R,M]=lt(null),O="processing"===E&&!!P&&!z&&!R,j=null!=z?z:E,[W,A]=lt(!(!E||"failed"!==E&&"declined"!==E&&"cancelled"!==E)),L=e.calculations,B=e.payment_options,q=e.payment_gateways;ct(()=>{const e=L.find(e=>e.id===n);if(e&&i){const n=B.some(e=>"monthly"===e.amount.frequency),r=t.getPageCompletionStatus(),o=Math.round(r.completedPages.length/r.totalPages*100);We(i,e,B.length,n,o)}},[]),ct(()=>{if(!r||!n)return;const e=L.find(e=>e.id===n);if(!e)return;if(r.calculation_id===e.calculation_id)return;const i=B.find(t=>t.gateway_id===r.gateway_id&&t.calculation_id===e.calculation_id&&t.amount.frequency===r.amount.frequency);i?t.setSelectedPaymentOption(i):t.setSelectedPaymentOption(null)},[n,r,L,B,t]);const F=async e=>{var t,n,r;if(o&&(null==i?void 0:i.id)){_(!0),k(null),S(null);try{const r=await o.validateQuoteCoverStartDate(i.id,e);r.valid?I(!0):(I(!1),k(null!==(t=r.message)&&void 0!==t?t:"Cover start date is invalid"),S(null!==(n=r.quote_page_url)&&void 0!==n?n:null))}catch(e){I(!1),k(null!==(r=null==e?void 0:e.message)&&void 0!==r?r:"Failed to validate cover start date")}finally{_(!1)}}},H=e=>{b(e),I(!1),k(null),S(null),e&&F(e)};ct(()=>{y&&w&&!$&&!C&&F(w)},[y,null==i?void 0:i.id]);const U=()=>{if(!n||!r)return void alert("Please select both an excess amount and payment option");if(y&&!$)return void alert("Please choose and validate a new cover start date before continuing.");const t={quoteIntentId:e.quote_intent.id,excessId:n,gatewayId:r.gateway_id,calculationId:r.calculation_id,clientDetails:{legalName:"Test"},...r.gateway_method?{gateway_method:r.gateway_method}:{},...y&&w?{coverStartDate:w}:{}};c(t),a(!0)},Y=async()=>{try{p(!0),await t.clearCalculationResults()}catch(e){alert("Failed to edit quote. Please try again.")}finally{p(!1)}},Z=()=>{const e=null==i?void 0:i.form_data;if(!(null==e?void 0:e.page_data))return null;for(const t in e.page_data){const n=e.page_data[t];if(n&&"object"==typeof n&&n.client_email)return n.client_email}return null},G=()=>{m(e=>"sent"===e.kind?e:{kind:"idle"}),u(!0)},V=Boolean(n&&r&&(!y||$)),Q=null==i?void 0:i.payment_return,J=Q&&("declined"===Q.paymentStatus||"cancelled"===Q.paymentStatus||"error"===Q.paymentStatus)||W,K=(null==Q?void 0:Q.paymentStatus)||("failed"===j?"declined":"cancelled"===j?"cancelled":"error"),X=(null==Q?void 0:Q.paymentTransactionId)||P||void 0;return Ze(ss,{title:"Complete Your Purchase",description:"Choose your coverage and payment options",hideHeader:!0,children:[O&&o&&P&&Ze(Ts,{httpClient:o,transactionId:P,onResolved:async e=>{const n="completed"===e?"approved":"cancelled"===e?"cancelled":"failed"===e?"declined":"error",r=new URL(window.location.href);if(r.searchParams.set("status",n),P&&r.searchParams.set("transactionId",P),window.history.replaceState({},"",r.toString()),"completed"===e&&o&&(null==i?void 0:i.url))try{const e=await o.getQuoteIntent(i.url);t.updateQuoteIntent({status:e.quote_intent.status,payment_transactions:e.payment_transactions})}catch(e){}D(n),"declined"!==n&&"cancelled"!==n&&"error"!==n||A(!0)},onError:e=>{M(e),A(!0)}}),Ze(At,{children:[Ze("div",{className:Pt.create("checkout-layout",{display:"grid",gridTemplateColumns:"1fr 380px",gap:St.spacing.lg},{"(max-width: 950px)":{display:"none"}}),children:[Ze("div",{className:Pt.create("checkout-main-wrapper",{minWidth:"0",backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,display:"flex",flexDirection:"column",alignSelf:"start"}),children:[Ze("div",{className:Pt.create("checkout-header",{paddingInline:St.spacing.xl,paddingTop:St.spacing.xl,paddingBottom:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("h2",{className:Pt.create("checkout-title",{margin:"0",marginBottom:St.spacing.md,fontSize:"1.75rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.25rem"}}),children:"Complete Your Purchase"}),Ze("p",{className:Pt.create("checkout-description",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:L.length>1?"Choose your excess amount and payment option to secure your coverage.":"Choose your payment method to secure your coverage."}),(null==i?void 0:i.reference)&&Ze("p",{className:Pt.create("checkout-quote-reference",{margin:"0",marginTop:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:["Quote reference: ",Ze("strong",{style:{color:St.colors.foreground,fontWeight:600},children:i.reference})]}),Ze("hr",{className:Pt.create("checkout-header-border",{marginTop:St.spacing.lg,border:"0",borderTop:`1px solid ${St.colors.border}`,height:"0"})})]}),Ze("div",{className:Pt.create("checkout-sections",{paddingInline:St.spacing.xl,paddingBottom:St.spacing.xl,display:"flex",flexDirection:"column",gap:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingBottom:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingBottom:St.spacing.md}}),children:[e.clauses&&e.clauses.length>0&&Ze(Ns,{clauses:e.clauses}),y&&Ze(Ms,{value:w,onChange:H,validating:C,validated:$,error:x,quotePageUrl:N}),Ze(ps,{excessOptions:L,selectedExcessId:n,onExcessSelect:e=>t.setSelectedExcessId(e)}),Ze(vs,{paymentOptions:B,paymentGateways:q,selectedExcessId:n,selectedPaymentOption:r,onPaymentSelect:e=>t.setSelectedPaymentOption(e)})]})]}),Ze("div",{className:Pt.create("checkout-sidebar",{display:"flex",flexDirection:"column"},{"(max-width: 950px)":{display:"block"}}),children:Ze("div",{className:Pt.create("checkout-sidebar-sticky",{}),children:[Ze(ks,{excessOptions:L,selectedExcessId:n,onEditQuote:Y,isEditingQuote:f,productName:e.product_name,quoteIntent:i}),Ze("div",{className:Pt.create("checkout-sidebar-spacer",{height:St.spacing.lg},{"(max-width: 950px)":{height:St.spacing.md}})}),Ze("div",{className:Pt.create("checkout-sidebar-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,boxShadow:St.shadow.sm,padding:St.spacing.lg},{"(max-width: 768px)":{padding:St.spacing.md}}),children:Ze(Cs,{excessOptions:L,paymentGateways:q,selectedExcessId:n,selectedPaymentOption:r,onPurchase:U,canPurchase:V,onContinueLater:G,continueLaterLoading:"sending"===h.kind,showContinueLaterSuccess:"sent"===h.kind})})]})})]}),Ze("div",{className:Pt.create("checkout-mobile-layout",{display:"none"},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:St.spacing.md}}),children:[Ze("div",{className:Pt.create("mobile-card-summary",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md}),children:[Ze("h2",{className:Pt.create("mobile-checkout-title",{margin:"0",marginBottom:St.spacing.md,fontSize:"1.5rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:"Complete Your Purchase"}),Ze("p",{className:Pt.create("mobile-checkout-description",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:L.length>1?"Choose your excess amount and payment option to secure your coverage.":"Choose your payment method to secure your coverage."}),Ze("hr",{className:Pt.create("mobile-summary-divider",{marginTop:St.spacing.md,marginBottom:St.spacing.md,borderColor:St.colors.border})}),Ze(ks,{excessOptions:L,selectedExcessId:n,onEditQuote:Y,isEditingQuote:f,productName:e.product_name,quoteIntent:i,embedded:!0})]}),e.clauses&&e.clauses.length>0&&Ze("div",{className:Pt.create("mobile-card-clauses",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md}),children:Ze(Ns,{clauses:e.clauses})}),Ze("div",{className:Pt.create("mobile-card-options",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md}),children:[y&&Ze(Ms,{value:w,onChange:H,validating:C,validated:$,error:x,quotePageUrl:N}),Ze(ps,{excessOptions:L,selectedExcessId:n,onExcessSelect:e=>t.setSelectedExcessId(e)})]}),Ze("div",{className:Pt.create("mobile-card-payment",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md}),children:[Ze(vs,{paymentOptions:B,paymentGateways:q,selectedExcessId:n,selectedPaymentOption:r,onPaymentSelect:e=>t.setSelectedPaymentOption(e)}),Ze("hr",{className:Pt.create("mobile-payment-divider",{border:"none",borderTop:`1px solid ${St.colors.border}`,margin:`${St.spacing.md} 0`})}),Ze(Cs,{excessOptions:L,paymentGateways:q,selectedExcessId:n,selectedPaymentOption:r,onPurchase:U,canPurchase:V,onContinueLater:G,continueLaterLoading:"sending"===h.kind,showContinueLaterSuccess:"sent"===h.kind})]})]}),J&&Ze(Is,{type:K,transactionId:X,isOpen:!0,onClose:()=>{t.updateQuoteIntent({payment_return:void 0}),A(!1);const e=new URL(window.location.href);e.searchParams.delete("status"),e.searchParams.delete("transactionId"),e.searchParams.delete("transaction_id"),window.history.replaceState({},"",e.toString())}}),Ze($s,{isOpen:s,onClose:()=>{a(!1),c(null)},onSuccess:()=>{a(!1),c(null),alert("Payment completed successfully!")},onError:e=>{alert("Payment failed: "+e)},paymentRequest:l}),Ze(zs,{isOpen:d,onClose:()=>u(!1),status:h,onSendEmail:async()=>{const t=Z();if(!t)return void m({kind:"error",message:"Email address not found. Please fill in your email first."});const n=e.quote_intent.id;try{m({kind:"sending"}),await o.continueLater(n,t),m({kind:"sent"})}catch(e){m({kind:"error",message:"Failed to send link. Please try again."})}},onCopyLink:async()=>{var t;const n=(e=>{var t;const n=null===(t=null==i?void 0:i.organisation)||void 0===t?void 0:t.quote_page_url;if(n){const t=n.replace(/\/+$/,""),r=t.includes("?")?"&":"?";return`${t}${r}q=${e}`}return`${window.location.origin}${window.location.pathname}?q=${e}`})(e.quote_intent.id);try{if(null===(t=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===t?void 0:t.writeText)await navigator.clipboard.writeText(n);else{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}m({kind:"copied"})}catch(e){m({kind:"error",message:"Could not copy link. Please copy manually."})}},email:Z()})]})]})}function Ms({value:e,onChange:t,validating:n,validated:r,error:i,quotePageUrl:o}){const s=Ds();return Ze("div",{className:Pt.create("cover-date-field",{}),children:[Ze(ms,{title:"Cover Start Date"}),Ze("div",{className:Pt.create("cover-date-row",{display:"flex",alignItems:"center",gap:St.spacing.sm,marginTop:St.spacing.sm}),children:[Ze("input",{type:"date",value:e,min:s,onChange:e=>t(e.target.value),className:Pt.create("cover-date-input",{padding:"0.5rem 1rem",border:`1px solid ${i?"#dc2626":St.colors.border}`,borderRadius:St.radius.large,fontSize:St.fontSize.default,backgroundColor:St.colors.card,color:St.colors.foreground,boxSizing:"border-box",width:"auto",maxWidth:"16rem"})}),!n&&r&&!i&&Ze("span",{"aria-label":"Date confirmed",className:Pt.create("cover-date-tick",{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.75rem",height:"1.75rem",borderRadius:"9999px",backgroundColor:St.colors.primary,color:St.colors.card,flexShrink:"0"}),children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("polyline",{points:"20 6 9 17 4 12"})})})]}),!n&&i&&Ze("div",{className:Pt.create("cover-date-error",{marginTop:St.spacing.sm}),children:[Ze("p",{className:Pt.create("cover-date-error-text",{margin:"0",fontSize:St.fontSize.small,color:"#dc2626",lineHeight:"1.5"}),children:i}),o&&Ze("a",{href:o,className:Pt.create("cover-date-new-quote",{display:"inline-block",marginTop:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.primary,textDecoration:"underline"}),children:"Start a new quote"})]})]})}function Os({coverTypes:e,selectedCoverTypeId:t,onCoverTypeSelect:n}){const r=[...e].sort((e,t)=>e.sort_order-t.sort_order),i=e.find(e=>e.id===t);return Ze("div",{className:Pt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Ze(ms,{title:"Cover Type"}),Ze("div",{className:Pt.create("cover-type-options-grid",{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"1rem"}),children:r.map(e=>{const r=e.id===t;return Ze("div",{className:jt(Pt.create("cover-type-card",{borderRadius:St.radius.default,minWidth:"180px",padding:"0.5rem 1rem 0.5rem 0.5rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"center",gap:"1rem"}),r?Pt.create("cover-type-card-selected",{border:`2px solid ${St.colors.primary}`,backgroundColor:St.colors.accent}):Pt.create("cover-type-card-unselected",{border:`2px solid ${St.colors.border}`,backgroundColor:St.colors.card})),onClick:()=>n(e.id),children:[Ze(fs,{selected:r}),Ze("div",{className:Pt.create("cover-type-label",{color:St.colors.foreground}),children:[e.label,e.description?"*":""]})]},e.id)})}),(null==i?void 0:i.description)&&Ze("div",{className:Pt.create("cover-type-description",{padding:"0.75rem",backgroundColor:St.colors.muted,borderRadius:St.radius.default,border:`1px solid ${St.colors.border}`}),children:Ze(hs,{className:Pt.create("cover-type-description-text",{fontSize:St.fontSize.small,color:St.colors.foreground,margin:"0"}),children:i.description})})]})}function js({offers:e,selectedIds:t,onToggle:n,isCalculating:r}){if(0===e.length)return null;const i=[...e].sort((e,t)=>e.sort_order-t.sort_order);return Ze("div",{className:Pt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Ze(ms,{title:"Add-ons"}),Ze("div",{className:Pt.create("coverage-options-grid",{display:"flex",flexDirection:"column",gap:"0.75rem"}),children:i.map(e=>{const i=t.includes(e.id),o=null!=e.delta_total;return Ze("div",{onClick:()=>!r&&n(e.id),className:jt(Pt.create("coverage-option-card",{borderRadius:St.radius.default,padding:"0.75rem 1rem",cursor:r?"wait":"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"flex-start",gap:"1rem",opacity:r?"0.6":"1"}),i?Pt.create("coverage-option-card-selected",{border:`2px solid ${St.colors.primary}`,backgroundColor:St.colors.accent}):Pt.create("coverage-option-card-unselected",{border:`2px solid ${St.colors.border}`,backgroundColor:St.colors.card})),children:[Ze("div",{className:Pt.create("coverage-option-indicator",{marginTop:"0.125rem"}),children:Ze(fs,{selected:i})}),Ze("div",{className:Pt.create("coverage-option-body",{flex:"1",display:"flex",flexDirection:"column",gap:"0.25rem",minWidth:"0"}),children:[Ze("div",{className:Pt.create("coverage-option-label",{fontWeight:"600",color:St.colors.foreground}),children:e.label}),e.description&&Ze(hs,{className:Pt.create("coverage-option-description",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,margin:"0"}),children:e.description}),!o&&Ze(hs,{className:Pt.create("coverage-option-roundtrip",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,fontStyle:"italic",margin:"0"}),children:"Price updates when you toggle this option."})]}),Ze("div",{className:Pt.create("coverage-option-price",{fontWeight:"600",whiteSpace:"nowrap",color:St.colors.foreground}),children:o?`+${gs(e.delta_total)}`:"See total"})]},e.id)})})]})}function Ws({value:e,className:t,durationMs:n=500}){const[r,i]=lt(e),o=dt(e),s=dt(null);return ct(()=>{if(null!==s.current&&(cancelAnimationFrame(s.current),s.current=null),"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||o.current===e)return o.current=e,void i(e);const t=o.current,r=e,a=performance.now(),l=e=>{const c=e-a,d=Math.min(1,c/n);i(t+(r-t)*(1-(1-d)*(1-d))),d<1?s.current=requestAnimationFrame(l):(o.current=r,s.current=null)};return s.current=requestAnimationFrame(l),()=>{null!==s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[e,n]),Ze("span",{className:t,children:gs(r)})}function As(){var e,t,n,r,i,o,s,a,l,c;const{fsm:d,v2Result:u,selection:h,isCalculating:m,isRepricing:f,selectedExcessId:p,quoteIntent:g,calculationResult:y}=Ft(e=>({v2Result:e.getCalculationResultV2(),selection:e.getSelectionV2(),isCalculating:e.getIsCalculating(),isRepricing:e.getIsRepricing(),selectedExcessId:e.getSelectedExcessId(),quoteIntent:e.getQuoteIntent(),calculationResult:e.getCalculationResult()})),[v,w]=lt(null),[b,x]=lt(!1),[k,N]=lt(!1),S=ut(()=>{var e;return null!==(e=null==y?void 0:y.calculations)&&void 0!==e?e:[]},[y]);if(ct(()=>{w(null)},[null==h?void 0:h.cover_type_id,null==h?void 0:h.excess_id,null==h?void 0:h.coverage_option_ids.join(",")]),!u||!h)return Ze(ss,{title:"Complete Your Purchase",description:"Choose your coverage and payment options",hideHeader:!0,children:Ze(At,{children:Ze("p",{style:{color:St.colors.mutedForeground},children:"Loading calculation…"})})});const C=null!==(t=null!==(e=u.product_name)&&void 0!==e?e:null==g?void 0:g.product_name)&&void 0!==t?t:"Insurance",_=u.cover_types.length>1,$=S.length>1,I=(null!==(r=null===(n=null==y?void 0:y.clauses)||void 0===n?void 0:n.length)&&void 0!==r?r:0)>0||_||$||(null!==(o=null===(i=u.policy_coverage_options)||void 0===i?void 0:i.length)&&void 0!==o?o:0)>0,T=!(!h.cover_type_id||!h.excess_id||m||f),E=async()=>{x(!0);try{const e=await d.bindV2();w(e)}catch(e){}finally{x(!1)}},P=async()=>{try{N(!0),await d.clearCalculationResults()}catch(e){}finally{N(!1)}};return Ze(ss,{title:"Complete Your Purchase",description:"Choose your coverage and payment options",hideHeader:!0,children:Ze(At,{children:[Ze("div",{className:Pt.create("checkout-layout",{display:"grid",gridTemplateColumns:"1fr 380px",gap:St.spacing.lg},{"(max-width: 950px)":{display:"none"}}),children:[Ze("div",{className:Pt.create("checkout-main-wrapper",{minWidth:"0",backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,display:"flex",flexDirection:"column",alignSelf:"start"}),children:[Ze(Ls,{showCoverType:_,showExcess:$}),Ze("div",{className:Pt.create("checkout-sections",{paddingInline:St.spacing.xl,paddingBottom:St.spacing.xl,display:"flex",flexDirection:"column",gap:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingBottom:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingBottom:St.spacing.md}}),children:[(null==y?void 0:y.clauses)&&y.clauses.length>0&&Ze(Ns,{clauses:y.clauses}),_&&Ze(Os,{coverTypes:u.cover_types,selectedCoverTypeId:h.cover_type_id,onCoverTypeSelect:e=>d.setV2Selection({cover_type_id:e})}),$&&Ze(ps,{excessOptions:S,selectedExcessId:p,onExcessSelect:e=>d.setV2Selection({excess_id:e})}),Ze(js,{offers:u.policy_coverage_options,selectedIds:h.coverage_option_ids,onToggle:e=>d.toggleV2CoverageOption(e),isCalculating:f}),!I&&Ze(qs,{adminEmail:null===(s=null==g?void 0:g.organisation)||void 0===s?void 0:s.admin_email,phone:null===(a=null==g?void 0:g.organisation)||void 0===a?void 0:a.phone})]})]}),Ze("div",{className:Pt.create("checkout-sidebar",{display:"flex",flexDirection:"column"}),children:Ze("div",{className:Pt.create("checkout-sidebar-sticky",{position:"sticky",top:St.spacing.lg}),children:[Ze(ks,{excessOptions:S,selectedExcessId:p,onEditQuote:P,isEditingQuote:k,productName:C,quoteIntent:g}),Ze("div",{className:Pt.create("checkout-sidebar-spacer",{height:St.spacing.lg})}),Ze("div",{className:Pt.create("checkout-sidebar-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,boxShadow:St.shadow.sm,padding:St.spacing.lg},{"(max-width: 768px)":{padding:St.spacing.md}}),children:Ze(Bs,{fsm:d,onBind:E,binding:b,canContinue:T,bindOutcome:v,isRepricing:f})})]})})]}),Ze("div",{className:Pt.create("checkout-mobile-layout",{display:"none"},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:St.spacing.md}}),children:[Ze("div",{className:Pt.create("mobile-card-summary",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md}),children:[Ze("h2",{className:Pt.create("mobile-checkout-title",{margin:"0",marginBottom:St.spacing.md,fontSize:"1.5rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:"Complete Your Purchase"}),Ze("p",{className:Pt.create("mobile-checkout-description",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:_||$?"Choose your cover and add-ons to secure your policy.":"Review your cover and add-ons to secure your policy."}),Ze("hr",{className:Pt.create("mobile-summary-divider",{marginTop:St.spacing.md,marginBottom:St.spacing.md,borderColor:St.colors.border})}),Ze(ks,{excessOptions:S,selectedExcessId:p,onEditQuote:P,isEditingQuote:k,productName:C,quoteIntent:g,embedded:!0})]}),(null==y?void 0:y.clauses)&&y.clauses.length>0&&Ze("div",{className:Pt.create("mobile-card-clauses",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md}),children:Ze(Ns,{clauses:y.clauses})}),Ze("div",{className:Pt.create("mobile-card-options",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md,display:"flex",flexDirection:"column",gap:St.spacing.lg}),children:[_&&Ze(Os,{coverTypes:u.cover_types,selectedCoverTypeId:h.cover_type_id,onCoverTypeSelect:e=>d.setV2Selection({cover_type_id:e})}),$&&Ze(ps,{excessOptions:S,selectedExcessId:p,onExcessSelect:e=>d.setV2Selection({excess_id:e})}),Ze(js,{offers:u.policy_coverage_options,selectedIds:h.coverage_option_ids,onToggle:e=>d.toggleV2CoverageOption(e),isCalculating:m}),!I&&Ze(qs,{adminEmail:null===(l=null==g?void 0:g.organisation)||void 0===l?void 0:l.admin_email,phone:null===(c=null==g?void 0:g.organisation)||void 0===c?void 0:c.phone})]}),Ze("div",{className:Pt.create("mobile-card-payment",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,padding:St.spacing.md}),children:Ze(Bs,{fsm:d,onBind:E,binding:b,canContinue:T,bindOutcome:v,isRepricing:f})})]})]})})}function Ls({showCoverType:e,showExcess:t}){let n="Review your cover and add-ons to secure your policy.";return e&&t?n="Choose your cover type, excess amount, and add-ons to secure your policy.":e?n="Choose your cover type and add-ons to secure your policy.":t&&(n="Choose your excess amount and add-ons to secure your policy."),Ze("div",{className:Pt.create("checkout-header",{paddingInline:St.spacing.xl,paddingTop:St.spacing.xl,paddingBottom:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("h2",{className:Pt.create("checkout-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"1.75rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.125rem"}}),children:"Complete Your Purchase"}),Ze("p",{className:Pt.create("checkout-description",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:n}),Ze("hr",{className:Pt.create("checkout-header-border",{marginTop:St.spacing.lg,borderColor:St.colors.border})})]})}function Bs({fsm:e,onBind:t,binding:n,canContinue:r,bindOutcome:i,isRepricing:o}){const s=e.getV2DisplayedTotal();return Ze("div",{className:Pt.create("payment-summary",{display:"flex",flex:"1",flexDirection:"column",gap:"1rem"}),children:[Ze(ms,{title:"Payment"}),Ze("div",{className:Pt.create("summary-item",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("summary-label",{display:"flex",alignItems:"center",gap:"0.5rem",color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:["Total payable",Ze("span",{className:Pt.create("summary-label-spinner",{display:"inline-flex",color:St.colors.mutedForeground,opacity:o?"1":"0",transition:"opacity 200ms ease"}),"aria-hidden":!o,children:Ze(Wt,{size:"small"})})]}),Ze(Ws,{value:s,className:Pt.create("summary-value-total",{fontWeight:"600",fontSize:St.fontSize.large,color:St.colors.foreground,fontVariantNumeric:"tabular-nums"})})]}),"verified"===(null==i?void 0:i.status)&&Ze("div",{className:Pt.create("verified-banner",{padding:"0.75rem 1rem",border:`1px solid ${St.colors.primary}`,borderRadius:St.radius.default,backgroundColor:St.colors.accent,fontSize:St.fontSize.small}),children:["Verified at ",gs(i.server_total),". Payment gateway integration for v2 is pending, quote is ready."]}),"mismatch"===(null==i?void 0:i.status)&&Ze("div",{className:Pt.create("mismatch-banner",{padding:"0.75rem 1rem",border:`1px solid ${St.colors.destructive}`,borderRadius:St.radius.default,color:St.colors.destructive,fontSize:St.fontSize.small}),children:[Ze("strong",{children:"Price updated."})," The server calculated ",gs(i.server_total),". Please review and try again."]}),Ze(ls,{onClick:t,disabled:!r||n,children:n?"Verifying…":"verified"===(null==i?void 0:i.status)?"Continue to payment":"Verify & continue"}),Ze(hs,{className:Pt.create("payment-footer-note",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,margin:"0"}),children:'Payment gateway integration for v2 products is scoped for a later phase. The "verify" step confirms your selection against the server.'})]})}function qs({adminEmail:e,phone:t}){const n=!!e||!!t;return Ze("div",{className:Pt.create("v2-no-options",{padding:St.spacing.lg,textAlign:"center",color:St.colors.foreground,border:`1px dashed ${St.colors.border}`,borderRadius:St.radius.default,display:"flex",flexDirection:"column",alignItems:"center",gap:St.spacing.md}),children:[Ze("p",{className:Pt.create("v2-no-options-title",{margin:"0",fontSize:St.fontSize.default,fontWeight:"600"}),children:"Sorry, there are no payment options available at this time."}),n?Ze(C,{children:[Ze("p",{className:Pt.create("v2-no-options-body",{margin:"0",fontSize:St.fontSize.small,color:St.colors.mutedForeground,lineHeight:"1.6"}),children:"Please get in touch and we'll help you complete your purchase."}),Ze("div",{className:Pt.create("v2-no-options-actions",{display:"flex",flexWrap:"wrap",gap:St.spacing.sm,justifyContent:"center"}),children:[t&&Ze(ls,{variant:"outline",onClick:()=>window.open(`tel:${t}`),children:"Call Us"}),e&&Ze(ls,{variant:"outline",onClick:()=>window.open(`mailto:${e}`),children:"Email Us"})]})]}):Ze("p",{className:Pt.create("v2-no-options-body-no-contact",{margin:"0",fontSize:St.fontSize.small,color:St.colors.mutedForeground,lineHeight:"1.6"}),children:"Please get in touch with the provider directly to complete your purchase."})]})}function Fs({results:e}){var t,n,r;const{quoteIntent:i,fsm:o}=Ft(e=>({quoteIntent:null==e?void 0:e.getQuoteIntent()})),s=null===(t=null==i?void 0:i.organisation)||void 0===t?void 0:t.admin_email,a=null===(n=null==i?void 0:i.organisation)||void 0===n?void 0:n.phone,l=s||a,c=Pt.create("referral-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,boxShadow:St.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:St.spacing.lg},"(max-width: 480px)":{padding:St.spacing.md}}),d=Pt.create("referral-icon-container",{display:"flex",justifyContent:"center",marginBottom:St.spacing.lg}),u=Pt.create("referral-icon",{width:"4rem",height:"4rem",color:St.colors.primary}),h=Pt.create("referral-header",{textAlign:"center",marginBottom:St.spacing.xl}),m=Pt.create("referral-title",{fontSize:"2rem",fontWeight:"700",color:St.colors.primary,marginBottom:St.spacing.sm,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),f=Pt.create("referral-subtitle",{fontSize:St.fontSize.default,color:St.colors.foreground,lineHeight:"1.6",opacity:"0.8"}),p=Pt.create("referral-process-box",{backgroundColor:St.colors.accent,borderRadius:St.radius.default,padding:St.spacing.lg,marginBottom:St.spacing.xl}),g=Pt.create("referral-process-title",{fontSize:"1.125rem",fontWeight:"600",color:St.colors.accentForeground,marginBottom:St.spacing.md,marginTop:"0"}),y=Pt.create("referral-process-list",{listStyle:"none",padding:"0",margin:"0",display:"flex",flexDirection:"column",gap:St.spacing.sm}),v=Pt.create("referral-process-item",{display:"flex",alignItems:"flex-start",fontSize:St.fontSize.small,color:St.colors.accentForeground,lineHeight:"1.6"}),w=Pt.create("referral-bullet",{width:"1.5rem",height:"1.5rem",backgroundColor:St.colors.primary,color:St.colors.primaryForeground,borderRadius:"50%",marginRight:St.spacing.sm,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.75rem",fontWeight:"600"}),b=Pt.create("referral-contact-section",{borderTop:`1px solid ${St.colors.border}`,paddingTop:St.spacing.xl,marginTop:St.spacing.xl,textAlign:"center"}),x=Pt.create("referral-contact-text",{fontSize:St.fontSize.default,color:St.colors.foreground,marginBottom:St.spacing.lg}),k=Pt.create("referral-actions",{display:"flex",gap:St.spacing.md,flexWrap:"wrap",justifyContent:"center",marginBottom:St.spacing.lg}),N=Pt.create("referral-reference",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginTop:St.spacing.md}),S=Pt.create("referral-new-request",{textAlign:"center",marginTop:St.spacing.md}),C=Pt.create("referral-new-request-link",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,textDecoration:"underline",cursor:"pointer",background:"none",border:"none",padding:"0",fontFamily:"inherit"});return Ze(ss,{title:"Quote Under Review",description:"We'll get back to you",hideHeader:!0,children:Ze(At,{children:Ze(ds,{children:Ze("div",{className:c,children:[Ze("div",{className:d,children:Ze(()=>Ze("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",className:u,children:[Ze("path",{d:"M7 10v12"}),Ze("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]}),{})}),Ze("div",{className:h,children:[Ze("h1",{className:m,children:"Thanks for your quote request!"}),Ze("p",{className:f,children:"Our team is reviewing your details and will come back to you with a personalised quote."})]}),Ze("div",{className:p,children:[Ze("h3",{className:g,children:"What happens next?"}),Ze("ul",{className:y,children:[Ze("li",{className:v,children:[Ze("span",{className:w,children:"1"}),Ze("span",{children:"Our team will review your application within 1-2 business days"})]}),Ze("li",{className:v,children:[Ze("span",{className:w,children:"2"}),Ze("span",{children:"We'll contact you with either approval or additional requirements"})]}),Ze("li",{className:v,children:[Ze("span",{className:w,children:"3"}),Ze("span",{children:"If approved, we'll provide you with payment options to complete your purchase"})]})]})]}),l&&Ze("div",{className:b,children:[Ze("p",{className:x,children:"Need to speak with someone about your quote?"}),Ze("div",{className:k,children:[a&&Ze(ls,{variant:"outline",onClick:()=>window.open(`tel:${a}`),children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Ze("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),"Call Us"]}),s&&Ze(ls,{variant:"outline",onClick:()=>window.open(`mailto:${s}`),children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Ze("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Ze("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Email Us"]})]}),(null===(r=e.quote_intent)||void 0===r?void 0:r.reference)&&Ze("div",{className:N,children:["Quote Reference: ",Ze("strong",{children:e.quote_intent.reference})]})]}),Ze("div",{className:S,children:Ze("button",{type:"button",className:C,onClick:()=>null==o?void 0:o.reset(),children:"Start a new quote"})})]})})})})}function Hs({results:e}){const{calculationResultV2:t}=Ft(e=>({calculationResultV2:e.getCalculationResultV2()}));return"referral"===e.outcome_type?Ze(Fs,{results:e}):t?Ze(As,{}):Ze(Rs,{results:e})}function Us(e,t){return n=e?.use_custom_options?t||e?.options||[]:e?.options||t||[],r=e?.options_sort,r&&"default"!==r?[...n].sort((e,t)=>e.label.localeCompare(t.label,void 0,"numerical"===r?{numeric:!0}:void 0)):[...n];var n,r}function Ys({value:e,onChange:t,name:n,id:r,placeholder:i,required:o,disabled:s,className:a,hasError:l,prefix:c="$"}){const d=dt(null),[u,h]=lt("");function m(e){if(!e)return"";const t=e.replace(/[^\d.]/g,"");if(!t)return"";const n=t.split(".");let r=n[0];const i=n[1];r=r.replace(/^0+/,"")||"0";const o=r.replace(/\B(?=(\d{3})+(?!\d))/g,",");return void 0!==i?o+"."+i:o}ct(()=>{h(null!=e&&""!==e?m(e):"")},[e]);const f=Pt.create("money-input-wrapper",{position:"relative",display:"flex",alignItems:"center"}),p=Pt.create("money-input-prefix",{position:"absolute",left:"1rem",color:St.colors.mutedForeground,pointerEvents:"none",fontSize:"14px",userSelect:"none"}),g=Pt.create("money-input-with-prefix",{paddingLeft:c?"2rem":"1rem"});return Ze("div",{className:f,children:[c&&Ze("span",{className:p,children:c}),Ze("input",{ref:d,type:"text",inputMode:"decimal",name:n,id:r,value:u,onInput:function(e){const n=e.currentTarget,r=n.selectionStart||0,i=u,o=n.value.replace(/[^\d.]/g,""),s=m(o);h(s),t(o),requestAnimationFrame(()=>{if(d.current){const e=function(e,t,n){let r=n+(t.length-e.length);return r=Math.max(0,Math.min(r,t.length)),r}(i,s,r);d.current.setSelectionRange(e,e)}})},onBlur:function(){u&&u.includes(".")},placeholder:i,required:o,disabled:s,className:jt(a,c&&g)})]})}function Zs(e){var t,n;const r=Pt.create("input",{width:"100%",maxWidth:"100%",minWidth:"0",boxSizing:"border-box",height:"2.75rem",paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",border:`${St.borderWidth} solid ${St.colors.input}`,borderRadius:St.radius.default,fontSize:St.fontSize.default,backgroundColor:St.colors.card,color:St.colors.foreground,transition:St.transition,outline:"none",boxShadow:"none"},{"(max-width: 480px)":{paddingLeft:"0.75rem",paddingRight:"0.75rem"}}),i=Pt.create("input-error",{border:`${St.borderWidth} solid ${St.colors.destructive}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${St.colors.destructive} 20%, transparent)`}),o=e.hasError?`${r} ${i}`:r,s=Pt.name("input");Pt.pseudoElement("input",":focus",{border:`${St.borderWidth} solid ${St.colors.primary}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${St.colors.primary} 20%, transparent)`,borderRadius:St.radius.default});const a=Pt.create("select",{width:"100%",minWidth:"0",boxSizing:"border-box",height:`calc(2.75rem - (${St.borderWidth} * 2))`,paddingLeft:"1.25rem",paddingRight:"2.5rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",border:"none",fontSize:St.fontSize.default,backgroundColor:"transparent",color:St.colors.foreground,outline:"none",WebkitAppearance:"none",appearance:"none",textOverflow:"ellipsis"},{"(max-width: 480px)":{paddingLeft:"0.75rem",paddingRight:"2rem"}}),l=Pt.create("select-wrapper",{position:"relative",minWidth:"0",border:`${St.borderWidth} solid ${St.colors.input}`,borderRadius:St.radius.default,backgroundColor:St.colors.card,transition:St.transition,outline:"none",boxShadow:"none"}),c=Pt.create("select-wrapper-error",{border:`${St.borderWidth} solid ${St.colors.destructive}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${St.colors.destructive} 20%, transparent)`}),d=e.hasError?`${l} ${c}`:l,u=Pt.name("select-wrapper");Pt.pseudoElement("select-wrapper",":focus-within",{border:`${St.borderWidth} solid ${St.colors.primary}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${St.colors.primary} 20%, transparent)`,borderRadius:St.radius.default});const{onChange:h,onBlur:m,onKeyDown:f,className:p,validation:g,errors:y,suffix:v,...w}=e;function b(e){h(e.currentTarget.value)}function x(e){h(e.currentTarget.value)}function k(e){m&&m(e.currentTarget.value)}if("select"===e.type){const N=e.null_option_label||"N/A",S=Us(e.validation,e.options),C=!w.value&&!e.add_null_option,_=Pt.create("select-placeholder",{color:St.colors.mutedForeground}),$=Pt.create("select-chevron",{position:"absolute",right:"0.75rem",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:St.colors.mutedForeground});return Ze("div",{className:jt(d,u),children:[Ze("select",{...w,onChange:b,className:jt(a,C&&_),children:[C&&Ze("option",{value:"",disabled:!0,selected:!0,children:"Select..."}),e.add_null_option&&Ze("option",{value:"",children:N}),S.map(e=>Ze("option",{value:e.value,children:e.label},e.value))]}),Ze("svg",{className:$,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M6 9l6 6 6-6"})})]})}if("radio"===e.type){const I=e.null_option_label||"N/A",T=Us(e.validation,e.options),E=Pt.create(e.inline?"radio-container-inline":"radio-container",{display:"flex",flexDirection:e.inline?"row":"column",gap:e.inline?"1rem":"0.5rem",flexWrap:e.inline?"wrap":"nowrap"}),P=Pt.create("radio-label",{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer",fontSize:St.fontSize.default,color:St.colors.foreground}),z=Pt.create("radio-input",{accentColor:St.colors.primary,width:"1.25rem",height:"1.25rem",cursor:"pointer",marginRight:"0.25rem"}),D=Pt.name("radio-input");return Pt.pseudoElement("radio-input",":focus",{outline:`3px solid color-mix(in srgb, ${St.colors.primary} 30%, transparent)`,outlineOffset:"2px"}),Ze("div",{className:E,children:[e.add_null_option&&Ze("label",{className:P,children:[Ze("input",{type:"radio",name:e.name,value:"",checked:""===e.value,onChange:()=>h(""),className:jt(z,D)}),Ze("span",{children:I})]}),T.map(t=>Ze("label",{className:P,children:[Ze("input",{type:"radio",name:e.name,value:t.value,checked:e.value===t.value,onChange:()=>h(t.value),className:jt(z,D)}),Ze("span",{children:t.label})]},t.value))]})}if("date"===e.type){const R=Pt.create("input-date",{height:"2.75rem",minHeight:"2.75rem",maxHeight:"2.75rem",WebkitAppearance:"none",appearance:"none"});return Ze("input",{...w,type:"date",min:null===(t=e.validation)||void 0===t?void 0:t.minDate,max:null===(n=e.validation)||void 0===n?void 0:n.maxDate,onInput:x,onChange:b,className:jt(o,s,R,p)})}if("monthyear"===e.type)return Ze(Vs,{id:e.id,name:e.name,value:e.value,required:e.required,disabled:e.disabled,hasError:e.hasError,onChange:h,selectWrapperBaseClass:l,selectWrapperErrorClass:c,selectWrapperBaseClassName:u,selectBaseClassName:a});if("year"===e.type){const M=(new Date).getFullYear();return Ze("input",{...w,type:"number",min:M-100,max:M,placeholder:"YYYY",onInput:x,onChange:b,className:jt(o,s,p)})}if("money"===e.type)return Ze(Ys,{value:e.value,onChange:h,name:e.name,id:e.id,placeholder:e.placeholder,required:e.required,disabled:e.disabled,className:jt(o,s,p),hasError:e.hasError});if("checkbox"===e.type){const O=!0===e.value||"true"===e.value||"true"===e.value,j=Pt.create("checkbox-wrapper",{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.25rem",height:"1.25rem",flexShrink:"0"}),W=Pt.create("checkbox-"+(O?"checked":"unchecked"),{appearance:"none",width:"1.25rem",height:"1.25rem",border:`2px solid ${O?St.colors.primary:e.hasError?St.colors.destructive:St.colors.input}`,borderRadius:"0.375rem",cursor:"pointer",backgroundColor:O?St.colors.primary:St.colors.card,transition:St.transition,position:"absolute"}),A=Pt.name("checkbox-"+(O?"checked":"unchecked"));function L(e){e.preventDefault(),h(O?"false":"true")}return Pt.pseudoElement("checkbox-"+(O?"checked":"unchecked"),":focus",{outline:"none",boxShadow:`0 0 0 3px color-mix(in srgb, ${St.colors.primary} 20%, transparent)`,borderRadius:"0.375rem"}),Ze("div",{className:j,children:[Ze("input",{type:"checkbox",id:e.id,name:e.name,checked:O,onClick:L,className:jt(W,A,p),required:e.required,readOnly:!0}),O&&Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:St.colors.primaryForeground,"stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",style:{pointerEvents:"none",position:"relative",zIndex:1},children:Ze("path",{d:"M20 6 9 17l-5-5"})})]})}if("boolean"===e.type){const B=Pt.create("boolean-container",{display:"flex",flexDirection:"column",gap:"1rem"}),q=Pt.create("boolean-radio-group",{display:"flex",gap:"1rem"}),F=Pt.create("boolean-radio-label",{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"}),H=Pt.create("boolean-radio",{accentColor:St.colors.primary,width:"1.25rem",height:"1.25rem",cursor:"pointer",marginRight:"0.25rem"}),U=Pt.name("boolean-radio");Pt.pseudoElement("boolean-radio",":focus",{outline:`3px solid color-mix(in srgb, ${St.colors.primary} 30%, transparent)`,outlineOffset:"2px"});const Y=Pt.create("boolean-textarea",{width:"100%",boxSizing:"border-box",minHeight:"5rem",padding:"1rem",border:`${St.borderWidth} solid ${St.colors.input}`,borderRadius:St.radius.default,fontSize:St.fontSize.default,backgroundColor:St.colors.card,color:St.colors.foreground,transition:St.transition,outline:"none",boxShadow:"none",resize:"vertical",fontFamily:St.fontFamily}),Z=Pt.create("boolean-textarea-error",{border:`${St.borderWidth} solid ${St.colors.destructive}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${St.colors.destructive} 20%, transparent)`}),G=e.hasError?`${Y} ${Z}`:Y,V=Pt.name("boolean-textarea");Pt.pseudoElement("boolean-textarea",":focus",{border:`${St.borderWidth} solid ${St.colors.primary}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${St.colors.primary} 20%, transparent)`,borderRadius:St.radius.default});const Q=!0===e.value||"true"===e.value,J=!1===e.value||"false"===e.value,K=e.answer||"",X=e.booleanConfig,ee=(null==X?void 0:X.enable_details_textbox)&&("yes"===X.show_details_on&&Q||"no"===X.show_details_on&&J);function te(t){h(t),(!(null==X?void 0:X.enable_details_textbox)||!("yes"===X.show_details_on&&"true"===t||"no"===X.show_details_on&&"false"===t))&&e.onAnswerChange&&K&&e.onAnswerChange("")}return Ze("div",{className:jt(B,p),children:[Ze("div",{className:q,children:[Ze("label",{className:F,children:[Ze("input",{type:"radio",name:e.name,checked:Q,onChange:()=>te("true"),className:jt(H,U)}),Ze("span",{children:"Yes"})]}),Ze("label",{className:F,children:[Ze("input",{type:"radio",name:e.name,checked:J,onChange:()=>te("false"),className:jt(H,U)}),Ze("span",{children:"No"})]})]}),ee&&Ze("textarea",{placeholder:(null==X?void 0:X.details_placeholder)||"Please provide details",value:K,required:!0,onInput:t=>{return n=t.target.value,void(e.onAnswerChange&&e.onAnswerChange(n));var n},className:jt(G,V)})]})}return v?Ze("div",{className:Pt.create("input-with-suffix",{display:"flex",alignItems:"center",gap:St.spacing.sm,minWidth:"0",maxWidth:"100%"}),children:[Ze("input",{...w,onInput:x,onChange:b,onBlur:k,onKeyDown:f,className:jt(o,s,p),style:{flex:1,minWidth:0}}),v]}):Ze("input",{...w,onInput:x,onChange:b,onBlur:k,onKeyDown:f,className:jt(o,s,p)})}const Gs=[{value:"01",label:"January"},{value:"02",label:"February"},{value:"03",label:"March"},{value:"04",label:"April"},{value:"05",label:"May"},{value:"06",label:"June"},{value:"07",label:"July"},{value:"08",label:"August"},{value:"09",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}];function Vs(e){const t=e.value||"",n=t.length>=7?t.substring(5,7):"",r=t.length>=4?t.substring(0,4):"",[i,o]=lt(n),[s,a]=lt(r),[l,c]=lt(!1),[d,u]=lt(!1),[h,m]=lt(!(!n||!r));ct(()=>{o(n),a(r),m(!(!n||!r))},[e.value]);const f=(new Date).getFullYear(),p=[];for(let e=f;e>=f-100;e--)p.push(e);function g(t,n){if(t&&n)return m(!0),void e.onChange(`${n}-${t}-01`);h&&e.onChange("")}const y=!!i!=!!s&&l&&d&&!e.required,v=!i&&l&&(e.hasError||y),w=!s&&d&&(e.hasError||y),b=v?`${e.selectWrapperBaseClass} ${e.selectWrapperErrorClass}`:e.selectWrapperBaseClass,x=w?`${e.selectWrapperBaseClass} ${e.selectWrapperErrorClass}`:e.selectWrapperBaseClass,k=Pt.create("monthyear-row",{display:"flex",gap:St.spacing.sm,minWidth:"0"}),N=Pt.create("monthyear-item",{flex:"1 1 0",minWidth:"0"}),S=Pt.create("monthyear-placeholder",{color:St.colors.mutedForeground}),C=Pt.create("monthyear-chevron",{position:"absolute",right:"0.75rem",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:St.colors.mutedForeground}),_=Pt.create("monthyear-partial-error",{marginTop:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.destructive}),$=Ze("svg",{className:C,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M6 9l6 6 6-6"})}),I=!i,T=!s,E=!e.required;return Ze("div",{children:[Ze("div",{className:k,children:[Ze("div",{className:jt(b,e.selectWrapperBaseClassName,N),children:[Ze("select",{id:e.id,name:e.name,required:e.required,disabled:e.disabled,value:i,onChange:function(e){const t=e.currentTarget.value;o(t),c(!0),g(t,s)},onBlur:function(){c(!0)},className:jt(e.selectBaseClassName,I&&S),children:[I?Ze("option",{value:"",disabled:!0,selected:!0,children:"Month"}):E&&Ze("option",{value:"",children:"— None —"}),Gs.map(e=>Ze("option",{value:e.value,children:e.label},e.value))]}),$]}),Ze("div",{className:jt(x,e.selectWrapperBaseClassName,N),children:[Ze("select",{id:`${e.id}__year`,required:e.required,disabled:e.disabled,value:s,onChange:function(e){const t=e.currentTarget.value;a(t),u(!0),g(i,t)},onBlur:function(){u(!0)},className:jt(e.selectBaseClassName,T&&S),children:[T?Ze("option",{value:"",disabled:!0,selected:!0,children:"Year"}):E&&Ze("option",{value:"",children:"— None —"}),p.map(e=>Ze("option",{value:String(e),children:e},e))]}),$]})]}),y&&Ze("div",{className:_,children:"Please select both month and year, or clear both."})]})}function Qs(e,t){const{fsm:n,lastUpdated:r}=Ft(e=>{var t,n;return{lastUpdated:null!==(n=null===(t=e.getFormProgress())||void 0===t?void 0:t.last_updated)&&void 0!==n?n:null}}),[i,o]=lt({kind:"idle"}),s=ut(()=>{var t;for(let n=0;n<e.length;n++)if((null!==(t=e[n].fields)&&void 0!==t?t:[]).some(e=>"client_email"===e.code))return n;return-1},[e]);return{showContinueLater:s>=0&&t.includes(s),lastUpdated:r,continueLaterStatus:i,sendContinueLaterEmail:async function(){var e,t;const r=function(){const e=null==n?void 0:n.getFormProgress(),t=null==e?void 0:e.page_data;if(!t)return null;for(const e in t){const n=t[e];if(null==n?void 0:n.client_email)return n.client_email}return null}();if(!r)return void o({kind:"error",message:"Email address not found. Please fill in your email first."});const i=null===(e=null==n?void 0:n.getQuoteIntent())||void 0===e?void 0:e.id;if(i)try{o({kind:"sending"}),await(null===(t=null==n?void 0:n.httpClient)||void 0===t?void 0:t.continueLater(i,r)),o({kind:"sent"})}catch(e){o({kind:"error",message:"Failed to send link. Please try again."})}},copyContinueLaterLink:async function(){var e,t;const r=null===(e=null==n?void 0:n.getQuoteIntent())||void 0===e?void 0:e.id;if(!r)return;const i=function(e){var t,r;const i=null===(r=null===(t=null==n?void 0:n.getQuoteIntent())||void 0===t?void 0:t.organisation)||void 0===r?void 0:r.quote_page_url;if(i){const t=i.replace(/\/+$/,""),n=t.includes("?")?"&":"?";return`${t}${n}q=${e}`}return`${window.location.origin}${window.location.pathname}?q=${e}`}(r);try{if(null===(t=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===t?void 0:t.writeText)await navigator.clipboard.writeText(i);else{const e=document.createElement("textarea");e.value=i,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}o({kind:"copied"})}catch(e){o({kind:"error",message:"Could not copy link. Please copy manually."})}},resetContinueLaterStatus:function(){o({kind:"idle"})},clearTransientStatus:function(){o(e=>"sent"===e.kind?e:{kind:"idle"})},confirmReset:function(){null==n||n.reset()}}}function Js({isOpen:e,onClose:t,onConfirm:n}){return Ze(Ps,{isOpen:e,onClose:t,title:"Reset your progress?",description:"This will clear everything you've entered so far and start the form over. This cannot be undone.",footer:Ze(C,{children:[Ze(ls,{variant:"outline",onClick:t,children:"Cancel"}),Ze(ls,{onClick:function(){n(),t()},children:"Reset progress"})]})})}function Ks({pages:t,currentPageIndex:n,completedPages:r}){const{fsm:i,isSaving:o}=Ft(e=>({isSaving:e.getIsSaving()})),{showContinueLater:s,lastUpdated:a,continueLaterStatus:l,sendContinueLaterEmail:c,copyContinueLaterLink:d,clearTransientStatus:u,confirmReset:h}=Qs(t,r),[m,f]=lt(!1),[p,g]=lt(!1),y=dt(null),v=dt(null);e(t.length),e(t.map((e,t)=>({index:t,id:e.id,title:e.title})));const w=(()=>{var e;const t=null===(e=null==i?void 0:i.getFormProgress())||void 0===e?void 0:e.page_data;if(!t)return null;for(const e in t){const n=t[e];if(null==n?void 0:n.client_email)return n.client_email}return null})();ct(()=>{if(y.current&&v.current){const e=v.current,t=y.current,n=e.getBoundingClientRect(),r=t.getBoundingClientRect();(r.top<n.top||r.bottom>n.bottom)&&t.scrollIntoView({behavior:"smooth",block:"nearest"})}},[n]);const b=Math.round((n+1)/t.length*100),x=Pt.create("sidebar-nav-item-base",{display:"flex",alignItems:"flex-start",gap:St.spacing.sm,padding:`${St.spacing.sm} ${St.spacing.sm}`,borderRadius:St.radius.default,border:"none",backgroundColor:"transparent",color:St.colors.foreground,cursor:"pointer",transition:St.transition,textAlign:"left",width:"100%",fontFamily:St.fontFamily,fontSize:St.fontSize.small,opacity:"1"}),k=Pt.create("sidebar-nav-item-active",{backgroundColor:St.colors.accent,color:St.colors.accentForeground}),N=Pt.create("sidebar-nav-item-disabled",{cursor:"not-allowed",opacity:"0.5"});Pt.pseudoElement("sidebar-nav-item-base",":hover",{backgroundColor:St.colors.muted}),Pt.pseudoElement("sidebar-nav-item-active",":hover",{backgroundColor:St.colors.accent});const S=Pt.create("sidebar-indicator-base",{width:"1.25rem",height:"1.25rem",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:"0",marginTop:"0.125rem",backgroundColor:St.colors.muted,color:St.colors.mutedForeground,fontSize:"0.75rem",fontWeight:"600"}),C=Pt.create("sidebar-indicator-active",{backgroundColor:St.colors.accentForeground,color:St.colors.accent}),_=Pt.create("sidebar-indicator-completed",{backgroundColor:St.colors.primary,color:St.colors.primaryForeground}),$=Pt.create("sidebar-page-title-base",{fontWeight:"500",fontSize:"0.875rem",lineHeight:"1.7",wordWrap:"break-word",overflowWrap:"break-word"}),I=Pt.create("sidebar-page-title-active",{fontWeight:"600"});return Ze("div",{className:Pt.create("sidebar-navigation",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.lg,boxShadow:St.shadow.sm,alignSelf:"flex-start",display:"flex",flexDirection:"column",gap:St.spacing.lg}),children:[Ze("div",{className:Pt.create("sidebar-progress-container",{display:"flex",flexDirection:"column",gap:St.spacing.sm}),children:[Ze("span",{className:Pt.create("sidebar-progress-text",{fontSize:St.fontSize.small,fontWeight:"600",color:St.colors.foreground}),children:["Step ",n+1," of ",t.length]}),Ze("div",{className:Pt.create("sidebar-progress-bg",{width:"100%",height:"0.5rem",backgroundColor:St.colors.muted,borderRadius:St.radius.small,overflow:"hidden"}),children:Ze("div",{className:Pt.create("sidebar-progress-fill",{height:"100%",backgroundColor:St.colors.primary,borderRadius:St.radius.small,transition:St.transition}),style:{width:`${b}%`}})})]}),Ze("hr",{className:Pt.create("sidebar-divider",{borderColor:St.colors.border})}),Ze("nav",{ref:v,className:Pt.create("sidebar-nav",{display:"flex",flexDirection:"column",gap:St.spacing.sm,maxHeight:"calc(100vh - 400px)",overflowY:"auto",overflowX:"hidden",paddingRight:St.spacing.sm}),children:t.map((t,s)=>{const a=s===n,l=r.includes(s),c=i.canNavigateToPage(s);s===n&&e(t.title);const d=[x];a&&d.push(k),c&&!o||d.push(N);const u=d.join(" "),h=[S];l?h.push(_):a&&h.push(C);const m=h.join(" ");return Ze("button",{ref:a?y:null,onClick:()=>{return e=s,void((null==i?void 0:i.canNavigateToPage(e))&&i.navigateToPage(e));var e},disabled:!c||o,className:u,children:[Ze("div",{className:m,children:l?Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M20 6 9 17l-5-5"})}):s+1}),Ze("div",{className:Pt.create("sidebar-nav-text",{display:"flex",flexDirection:"column",gap:"0.125rem",flex:"1",minWidth:"0"}),children:Ze("span",{className:a?`${$} ${I}`:$,children:t.title})})]},t.id)})}),a&&Ze("div",{className:Pt.create("sidebar-footer",{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"}),children:[Ze("div",{className:Pt.create("sidebar-last-saved",{fontSize:"0.6875rem",color:St.colors.mutedForeground,textAlign:"center",opacity:"0.6",fontStyle:"italic"}),children:["Last saved: ",is.fromJSDate(new Date(a)).toFormat("T")]}),Ze("button",{onClick:()=>g(!0),className:Pt.create("sidebar-reset-link",{background:"none",border:"none",padding:"0",fontSize:"0.6875rem",color:St.colors.mutedForeground,opacity:"0.5",cursor:"pointer",textDecoration:"underline",fontFamily:St.fontFamily}),children:"Reset progress"})]}),s&&Ze("button",{onClick:()=>{u(),f(!0)},className:Pt.create("sidebar-continue-later-button",{padding:`${St.spacing.sm} ${St.spacing.md}`,border:`${St.borderWidth} solid ${St.colors.border}`,borderRadius:St.radius.default,backgroundColor:"transparent",color:St.colors.mutedForeground,fontSize:St.fontSize.small,fontFamily:St.fontFamily,cursor:"pointer",transition:St.transition,textAlign:"center",width:"100%"}),children:"Continue Later"}),Ze(zs,{isOpen:m,onClose:()=>f(!1),status:l,onSendEmail:c,onCopyLink:d,email:w}),Ze(Js,{isOpen:p,onClose:()=>g(!1),onConfirm:h})]})}function Xs({pages:e,currentPageIndex:t,completedPages:n}){const{fsm:r,isSaving:i}=Ft(e=>({fsm:e,isSaving:null==e?void 0:e.getIsSaving()})),[o,s]=lt(!1),a=Math.round((t+1)/e.length*100),l=Pt.create("mobile-sidebar-item-base",{display:"flex",alignItems:"center",gap:St.spacing.sm,padding:St.spacing.sm,border:"none",borderRadius:St.radius.default,backgroundColor:"transparent",color:St.colors.foreground,cursor:"pointer",opacity:"1",transition:St.transition,width:"100%",textAlign:"left",fontFamily:St.fontFamily}),c=Pt.create("mobile-sidebar-item-active",{backgroundColor:St.colors.accent,color:St.colors.accentForeground}),d=Pt.create("mobile-sidebar-item-disabled",{cursor:"not-allowed",opacity:"0.5"}),u=Pt.create("mobile-sidebar-indicator-base",{width:"1.25rem",height:"1.25rem",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:"0",backgroundColor:St.colors.muted,color:St.colors.mutedForeground,fontSize:"0.75rem",fontWeight:"600"}),h=Pt.create("mobile-sidebar-indicator-active",{backgroundColor:St.colors.accentForeground,color:St.colors.accent}),m=Pt.create("mobile-sidebar-indicator-completed",{backgroundColor:St.colors.primary,color:St.colors.primaryForeground}),f=Pt.create("mobile-sidebar-page-title-base",{fontSize:St.fontSize.small,fontWeight:"500"}),p=Pt.create("mobile-sidebar-page-title-active",{fontWeight:"600"});return Ze("div",{className:Pt.create("mobile-sidebar",{overflow:"hidden"}),children:[Ze("button",{onClick:()=>s(!o),className:Pt.create("mobile-sidebar-header",{width:"100%",padding:St.spacing.md,border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",flexDirection:"column",gap:St.spacing.sm}),children:[Ze("div",{className:Pt.create("mobile-sidebar-header-row",{display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[Ze("span",{className:Pt.create("mobile-sidebar-step-text",{fontSize:St.fontSize.small,fontWeight:"600",color:St.colors.foreground}),children:["Step ",t+1," of ",e.length]}),Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:Pt.create("mobile-sidebar-chevron",{transition:St.transition,transform:o?"rotate(180deg)":"rotate(0deg)",color:St.colors.mutedForeground}),children:Ze("path",{d:"m6 9 6 6 6-6"})})]}),Ze("div",{className:Pt.create("mobile-sidebar-progress-bg",{width:"100%",height:"0.5rem",backgroundColor:St.colors.muted,borderRadius:St.radius.small,overflow:"hidden"}),children:Ze("div",{className:Pt.create("mobile-sidebar-progress-fill",{height:"100%",backgroundColor:St.colors.primary,borderRadius:St.radius.small,transition:St.transition}),style:{width:`${a}%`}})})]}),Ze("hr",{className:Pt.create("mobile-sidebar-border",{borderColor:St.colors.border})}),o&&Ze("div",{className:Pt.create("mobile-sidebar-content",{padding:St.spacing.sm,display:"flex",flexDirection:"column",gap:"0.25rem",maxHeight:"300px",overflowY:"auto"}),children:e.map((e,o)=>{const a=o===t,g=n.includes(o),y=r.canNavigateToPage(o),v=[l];a&&v.push(c),y&&!i||v.push(d);const w=v.join(" "),b=[u];g?b.push(m):a&&b.push(h);const x=b.join(" ");return Ze("button",{onClick:()=>{return e=o,void((null==r?void 0:r.canNavigateToPage(e))&&(r.navigateToPage(e),s(!1)));var e},disabled:!y||i,className:w,children:[Ze("div",{className:x,children:g?Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M20 6 9 17l-5-5"})}):o+1}),Ze("span",{className:a?`${f} ${p}`:f,children:e.title})]},e.id)})})]})}function ea({pages:e,completedPages:t}){const{fsm:n}=Ft(()=>({})),{showContinueLater:r,lastUpdated:i,continueLaterStatus:o,sendContinueLaterEmail:s,copyContinueLaterLink:a,clearTransientStatus:l,confirmReset:c}=Qs(e,t),[d,u]=lt(!1),[h,m]=lt(!1);if(!i&&!r)return null;const f=(()=>{var e;const t=null===(e=null==n?void 0:n.getFormProgress())||void 0===e?void 0:e.page_data;if(!t)return null;for(const e in t){const n=t[e];if(null==n?void 0:n.client_email)return n.client_email}return null})(),p=Pt.create("mobile-form-actions-container",{display:"flex",justifyContent:"center",alignItems:"center",gap:St.spacing.lg,paddingTop:St.spacing.sm,paddingBottom:St.spacing.sm}),g=Pt.create("mobile-form-actions-link",{background:"none",border:"none",padding:"0",fontSize:"0.75rem",color:St.colors.mutedForeground,opacity:"0.6",cursor:"pointer",textDecoration:"underline",fontFamily:St.fontFamily});return Ze("div",{className:p,children:[i&&Ze("button",{type:"button",onClick:()=>m(!0),className:g,children:"Reset progress"}),r&&Ze("button",{type:"button",onClick:()=>{l(),u(!0)},className:g,children:"Continue later"}),Ze(zs,{isOpen:d,onClose:()=>u(!1),status:o,onSendEmail:s,onCopyLink:a,email:f}),Ze(Js,{isOpen:h,onClose:()=>m(!1),onConfirm:c})]})}function ta({organisation:e}){return Ze("div",{className:Pt.create("welcome-card",{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},{"(max-width: 950px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("h2",{className:Pt.create("welcome-title",{margin:"0",marginBottom:St.spacing.md,fontSize:"1.75rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 950px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.25rem",marginBottom:St.spacing.sm}}),children:["Thank you for choosing ",e.name,"."]}),Ze("p",{className:Pt.create("welcome-text",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:"Getting a quote online is quick and easy. Simply complete the form below with your details, and we'll provide you with a personalied quote. Our secure platform ensures your information is protected every step of the way."}),Ze("hr",{className:Pt.create("welcome-border",{marginTop:St.spacing.lg,borderColor:St.colors.border})})]})}function na({title:e,description:t}){return Ze(ss,{title:e,description:t,children:Ze(At,{children:Ze(ds,{className:Pt.name("error-container"),children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:"lucide lucide-ban-icon lucide-ban",children:[Ze("path",{d:"M4.929 4.929 19.07 19.071"}),Ze("circle",{cx:"12",cy:"12",r:"10"})]})})})})}function ra({errors:e,className:t}){return e&&0!==e.length?Ze("div",{className:Pt.create("field-error",{color:St.colors.destructive,fontSize:St.fontSize.small,marginTop:"0.25rem",display:"flex",flexDirection:"column",gap:"0.125rem"}),children:e.map((e,t)=>Ze("span",{className:Pt.create("field-error-message",{lineHeight:"1.4"}),children:e.message},t))}):null}function ia({htmlFor:e,label:t,children:n,required:r,tooltip:i,...o}){const[s,a]=lt({visible:!1,top:0,left:0,flipped:!1}),l=dt(null),c=ht(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect(),n=!(t.top>68),r=n?t.bottom+8:t.top-8,i=t.left+t.width/2;a({visible:!0,top:r,left:i,flipped:n})},[]),d=ht(()=>{a(e=>({...e,visible:!1}))},[]);return Ze("label",{for:e,className:Pt.create("label",{display:"flex",flexDirection:"column",minWidth:"0"}),...o,children:[Ze("span",{className:Pt.create("label-text",{marginBottom:St.spacing.sm,fontSize:St.fontSize.default,fontWeight:"600",display:"flex",alignItems:"center",gap:St.spacing.sm,color:St.colors.foreground}),children:[Ze("span",{children:r?Ze(C,{children:[t.includes(" ")?t.substring(0,t.lastIndexOf(" ")+1):"",Ze("span",{style:{whiteSpace:"nowrap"},children:[t.includes(" ")?t.substring(t.lastIndexOf(" ")+1):t,Ze("span",{className:Pt.create("label-required-indicator",{color:St.colors.destructive}),children:"*"})]})]}):t}),i&&Ze("span",{ref:l,className:Pt.create("tooltip-container",{position:"relative",display:"inline-flex"}),onMouseEnter:c,onMouseLeave:d,children:[Ze("svg",{className:Pt.create("tooltip-icon",{width:"1rem",height:"1rem",color:St.colors.mutedForeground,cursor:"help"}),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[Ze("circle",{cx:"12",cy:"12",r:"10",strokeWidth:"2"}),Ze("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Ze("circle",{cx:"12",cy:"17",r:"0.5",fill:"currentColor",strokeWidth:"0"})]}),s.visible&&Ze("span",{style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,transform:s.flipped?"translateX(-50%)":"translateX(-50%) translateY(-100%)",padding:"0.5rem 0.75rem",backgroundColor:St.colors.popover,color:St.colors.popoverForeground,fontSize:"0.875rem",borderRadius:St.radius.default,whiteSpace:"normal",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",zIndex:1e4,minWidth:"200px",maxWidth:"300px",pointerEvents:"none"},children:[i,Ze("span",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",width:"0",height:"0",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...s.flipped?{bottom:"100%",borderBottom:`6px solid ${St.colors.popover}`}:{top:"100%",borderTop:`6px solid ${St.colors.popover}`}}})]})]})]}),n]})}function oa(e){const t={"(max-width: 600px)":{gridColumn:"span 12 / span 12"}};switch(null!=e?e:100){case 25:return Pt.create("field-wrapper-25",{gridColumn:"span 3 / span 3"},t);case 33:return Pt.create("field-wrapper-33",{gridColumn:"span 4 / span 4"},t);case 50:return Pt.create("field-wrapper-50",{gridColumn:"span 6 / span 6"},t);case 66:return Pt.create("field-wrapper-66",{gridColumn:"span 8 / span 8"},t);case 75:return Pt.create("field-wrapper-75",{gridColumn:"span 9 / span 9"},t);default:return Pt.create("field-wrapper-100",{gridColumn:"span 12 / span 12"})}}function sa(e){return e?e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=n.trim();return r.match(/^(https?:\/\/|mailto:)/i)?`<a href="${r}" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:text-blue-800 underline">${t}</a>`:e}):""}function aa({field:e,errors:t,children:n,className:r}){const i=e.code||e.id,o=(null==t?void 0:t.filter(e=>e.field===i))||[],s=Pt.create("validated-field",{display:"flex",flexDirection:"column",gap:St.spacing.sm,minWidth:"0"});if("notice"===e.type){const t=Pt.create("notice-field",{display:"flex",gap:St.spacing.sm,padding:St.spacing.md,backgroundColor:St.colors.accent,borderRadius:St.radius.default,border:`1px solid ${St.colors.border}`}),n=Pt.create("notice-icon",{flexShrink:"0",fontSize:St.fontSize.default,lineHeight:"1.6"}),r=Pt.create("notice-text",{fontSize:St.fontSize.small,color:St.colors.foreground,lineHeight:"1.6"});return Ze("div",{className:jt(oa(e.width)),children:Ze("div",{className:t,children:[Ze("span",{className:n,children:"ⓘ"}),Ze("div",{className:r,children:[e.label&&Ze("strong",{children:e.label}),e.label&&e.description&&Ze("br",{}),e.description&&Ze("span",{children:e.description})]})]})})}if("section"===e.type){const t=Pt.create("section-separator",{display:"flex",alignItems:"center",gap:St.spacing.md}),n=Pt.create("section-line",{flex:"1",height:"1px",backgroundColor:St.colors.border}),r=Pt.create("section-title",{fontSize:St.fontSize.small,fontWeight:"600",color:St.colors.mutedForeground,whiteSpace:"nowrap"});return Ze("div",{className:jt(oa(e.width)),children:Ze("div",{className:t,children:e.label?Ze(C,{children:[Ze("div",{className:n}),Ze("span",{className:r,children:e.label}),Ze("div",{className:n})]}):Ze("div",{className:n})})})}if("checkbox"===e.type){const t=Pt.create("checkbox-field-container",{display:"flex",flexDirection:"column",gap:St.spacing.sm}),a=Pt.create("checkbox-field-row",{display:"flex",alignItems:"flex-start",gap:"0.75rem",cursor:"pointer"}),l=Pt.create("checkbox-field-label",{display:"flex",flexDirection:"column",gap:"0.25rem",flex:"1"}),c=Pt.create("checkbox-label-text",{fontSize:St.fontSize.default,fontWeight:"600",color:St.colors.foreground,display:"flex",alignItems:"center",gap:"0.25rem"});return Ze("div",{className:jt(s,oa(e.width),r),children:[Ze("div",{className:t,children:Ze("div",{className:a,children:[Ze("label",{htmlFor:i,style:{display:"flex",cursor:"pointer"},children:n}),Ze("label",{htmlFor:i,className:l,children:[Ze("span",{className:c,children:[e.label,e.required&&Ze("span",{className:Pt.create("checkbox-required-indicator",{color:St.colors.destructive}),children:"*"})]}),e.description&&Ze("div",{className:Pt.create("checkbox-field-description",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,lineHeight:"1.6"}),dangerouslySetInnerHTML:{H:sa(e.description)}})]})]})}),Ze(ra,{errors:o})]})}return Ze("div",{className:jt(s,oa(e.width),r),children:[Ze(ia,{htmlFor:i,label:e.label,required:e.required,tooltip:e.tooltip,children:[e.description&&Ze("div",{className:Pt.create("field-description",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginBottom:St.spacing.sm,lineHeight:"1.6"}),dangerouslySetInnerHTML:{H:sa(e.description)}}),n]}),Ze(ra,{errors:o})]})}function la({error:e,onDismiss:t,className:n}){const r=globalThis.insureOSDebug,i={warning:{backgroundColor:St.colors.secondary+"08",borderColor:St.colors.secondary+"30",iconColor:St.colors.secondary,titleColor:St.colors.foreground},error:{backgroundColor:St.colors.destructive+"08",borderColor:St.colors.destructive,iconColor:St.colors.destructive,titleColor:St.colors.destructive},critical:{backgroundColor:St.colors.destructive+"10",borderColor:St.colors.destructive,iconColor:St.colors.destructive,titleColor:St.colors.destructive}}[e.severity],o=Pt.create("error-card",{padding:St.spacing.md,borderRadius:St.radius.default,border:`2px solid ${i.borderColor}`,backgroundColor:i.backgroundColor,margin:St.spacing.lg,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.06)"}),s=Pt.create("error-card-header",{display:"flex",alignItems:"flex-start",gap:"0.75rem"}),a=Pt.create("error-card-icon",{width:"1.25rem",height:"1.25rem",color:i.iconColor,flexShrink:"0",marginTop:"0.125rem"}),l=Pt.create("error-card-content-wrapper",{flex:"1",minWidth:"0",display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"0.75rem"}),c=Pt.create("error-card-content",{flex:"1",minWidth:"0",display:"flex",flexDirection:"column",gap:"0.5rem"}),d=Pt.create("error-card-title",{fontSize:St.fontSize.default,fontWeight:"600",color:i.titleColor,lineHeight:"1.4"}),u=Pt.create("error-card-message",{fontSize:St.fontSize.small,color:St.colors.foreground,lineHeight:"1.5",opacity:"0.9"}),h=Pt.create("error-card-details",{fontSize:"0.8125rem",color:St.colors.mutedForeground,fontFamily:"monospace",backgroundColor:St.colors.muted,padding:"0.625rem",borderRadius:St.radius.small,wordBreak:"break-word",lineHeight:"1.4"}),m=Pt.create("error-card-support",{fontSize:"0.8125rem",color:St.colors.mutedForeground,lineHeight:"1.4"}),f=Pt.create("error-card-dismiss",{padding:"0.25rem",border:"none",backgroundColor:"transparent",color:St.colors.mutedForeground,cursor:"pointer",borderRadius:St.radius.small,lineHeight:"1",display:"flex",alignItems:"center",justifyContent:"center",width:"1.75rem",height:"1.75rem",flexShrink:"0",transition:St.transition});return Pt.pseudoElement("error-card-dismiss",":hover",{backgroundColor:St.colors.muted,color:St.colors.foreground}),Ze("div",{className:jt(o,n),children:Ze("div",{className:s,children:[Ze(()=>"warning"===e.severity?Ze("svg",{className:a,fill:"currentColor",viewBox:"0 0 20 20",children:Ze("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}):Ze("svg",{className:a,fill:"currentColor",viewBox:"0 0 20 20",children:Ze("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),{}),Ze("div",{className:l,children:[Ze("div",{className:c,children:[Ze("div",{className:d,children:e.title}),Ze("div",{className:u,children:e.message}),r&&e.details&&Ze("div",{className:h,children:e.details}),Ze("div",{className:m,children:Ee(e)})]}),t&&Ze("button",{className:f,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":"Dismiss error",title:"Dismiss",type:"button",children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{pointerEvents:"none"},children:[Ze("path",{d:"M18 6 6 18"}),Ze("path",{d:"m6 6 12 12"})]})})]})]})})}function ca(){const{definition:t,currentPageIndex:n,totalPages:r,validationErrors:i,generalErrors:o,quoteIntent:s,isSaving:a,fsm:l}=Ft(e=>({definition:e.getFormDefinition(),currentPageIndex:e.getCurrentPageIndex(),totalPages:e.getTotalPages(),results:e.getCalculationResult(),validationErrors:e.getValidationErrors(),generalErrors:e.getGeneralErrors(),quoteIntent:e.getQuoteIntent(),isSaving:e.getIsSaving()})),{httpClient:c,urlPromoCode:d}=qt(),[u,h]=lt({status:"idle"}),[m,f]=lt(""),p=ht(async t=>{const n=null!=t?t:m;if(n&&n.trim()){if((null==s?void 0:s.id)&&c){h({status:"validating"});try{const e=await c.validatePromoCode(s.id,n.trim());e.valid?h({status:"valid",name:e.name||n}):h({status:"invalid",message:e.message})}catch(t){e(),h({status:"invalid",message:"Unable to validate promo code"})}}}else h({status:"idle"})},[null==s?void 0:s.id,c,m]),g=ht(e=>{"Enter"===e.key&&(e.preventDefault(),p())},[p]),y=dt(!1);ct(()=>{d&&!y.current&&(null==s?void 0:s.id)&&c&&(y.current=!0,f(d),(async()=>{try{const e=await c.validatePromoCode(s.id,d.trim());if(e.valid){h({status:"valid",name:e.name||d});const t=l.getFormDefinition().pages.find(e=>e.fields.some(e=>"promo_code"===(e.code||e.id)));t&&l.updateFieldValue(t.id,"promo_code",d)}else{f("");const e=l.getFormDefinition().pages.find(e=>e.fields.some(e=>"promo_code"===(e.code||e.id)));e&&l.updateFieldValue(e.id,"promo_code","")}}catch(e){f("")}})())},[d,null==s?void 0:s.id,c]);const v=t.pages[n];if(!v)return Ze(na,{title:"Unexpected Error",description:"No page available"});const w=dt(new Map),b=(e,t)=>{var n;const r=l.getFormProgress().page_data[v.id],i=null==r?void 0:r[e];if(null!=i&&""!==i)return i;if(t&&("date"===t.type||"monthyear"===t.type)&&(null===(n=t.validation)||void 0===n?void 0:n.defaultDate)){const n=x(t.validation.defaultDate,"monthyear"===t.type);if(n)return l.updateFieldValue(v.id,e,n),n}return""},x=(e,t)=>{var n;const r=(null===(n=null==s?void 0:s.organisation)||void 0===n?void 0:n.timezone)||"Pacific/Auckland",i=(new Date).toLocaleString("en-US",{timeZone:r}),o=new Date(i);let a=new Date(i);switch(e){case"today":a=o;break;case"+1week":a.setDate(o.getDate()+7);break;case"+1month":a.setMonth(o.getMonth()+1);break;case"+1year":a.setFullYear(o.getFullYear()+1);break;default:return""}const l=a.getFullYear(),c=String(a.getMonth()+1).padStart(2,"0"),d=String(a.getDate()).padStart(2,"0");return t?`${l}-${c}-01`:`${l}-${c}-${d}`},k=e=>{const t=l.getFormProgress().page_data[v.id];return((null==t?void 0:t.U)||{})[e]||""},N=l.getFormProgress(),S={};Object.values(N.page_data).forEach(e=>{const{U:t,...n}=e;Object.assign(S,n),t&&Object.keys(t).length>0&&(S.U||(S.U={}),Object.assign(S.U,t))});const C=t=>{if(!t.visibility)return!0;const n=t.visibility.conditions.map(e=>"field"in e?e.field:null).filter(Boolean);n.length>0&&(e((t.label,t.code)),e(Object.keys(S)),n.forEach(t=>{t&&e((S[t],S[t]))}));const r=de(S,{condition_type:t.visibility.condition_type,conditions:t.visibility.conditions}),i="show"===t.visibility.action?r.matched:!r.matched;return w.current.get(t.id)!==i&&(e((t.label,t.code)),e(),w.current.set(t.id,i)),i},_=(()=>{for(const e of v.fields)if(e.blocker&&C(e))if(e.blocker.conditions&&e.blocker.conditions.length>0){if(de(S,{condition_type:e.blocker.condition_type||"or",conditions:e.blocker.conditions}).matched)return{field:e,config:e.blocker}}else if(void 0!==e.blocker.trigger_value){const t=e.code||e.id,n=b(t,e);if(String(n)===String(e.blocker.trigger_value))return{field:e,config:e.blocker}}return null})(),$=null==s?void 0:s.payment_return,I=$&&("declined"===$.paymentStatus||"cancelled"===$.paymentStatus||"error"===$.paymentStatus),T=l.getFormProgress().completed_pages||[];return Ze(ss,{title:v.title,description:v.description,hideHeader:!0,children:Ze("div",{children:[I&&Ze(Is,{type:$.paymentStatus,transactionId:$.paymentTransactionId||void 0,isOpen:!0,onClose:()=>{l.updateQuoteIntent({payment_return:void 0})}}),Ze(At,{children:[Ze("div",{className:Pt.create("form-layout",{display:"grid",gridTemplateColumns:"1fr 320px",gap:St.spacing.lg},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:St.spacing.sm}}),children:[Ze("div",{className:Pt.create("form-content-wrapper",{minWidth:"0",backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,display:"flex",flexDirection:"column",minHeight:"100%"},{"(max-width: 950px)":{minHeight:"auto"}}),children:[Ze("div",{className:Pt.create("mobile-sidebar-container",{display:"none"},{"(max-width: 950px)":{display:"block"}}),children:Ze(Xs,{pages:t.pages,currentPageIndex:n,completedPages:T})}),n>0&&Ze("div",{className:Pt.create("page-heading-container",{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},{"(max-width: 950px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("div",{className:Pt.create("page-heading-content",{display:"flex",alignItems:"center",justifyContent:"space-between",gap:St.spacing.lg}),children:Ze("div",{className:Pt.create("page-heading-text",{flex:"1",minWidth:"0"}),children:[Ze("h1",{className:Pt.create("page-template-title",{margin:"0",fontSize:"1.5rem",fontWeight:"700",lineHeight:"1.3",color:St.colors.primary,letterSpacing:"-0.025em"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:v.title}),v.description&&Ze("p",{className:Pt.create("page-template-description",{margin:"0",marginTop:St.spacing.sm,fontSize:St.fontSize.small,lineHeight:"1.5",color:St.colors.foreground,opacity:"0.7"}),children:v.description})]})}),Ze("hr",{className:Pt.create("page-heading-border",{marginTop:St.spacing.lg,border:"0",borderTop:`1px solid ${St.colors.border}`,height:"0"})})]}),0===n&&(null==s?void 0:s.organisation)&&Ze(ta,{organisation:s.organisation}),o.length>0&&o.map(e=>Ze(la,{error:e,onDismiss:()=>l.dismissGeneralError(e.id)},e.id)),Ze("div",{className:Pt.create("form-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.lg,boxShadow:St.shadow.sm,display:"flex",flexDirection:"column",gap:St.spacing.xl,flex:"1",minWidth:"0",overflow:"hidden"},{"(max-width: 950px)":{padding:St.spacing.md,gap:St.spacing.lg,flex:"initial"},"(max-width: 480px)":{padding:St.spacing.md,gap:St.spacing.md}}),children:[Ze("form",{onSubmit:e=>e.preventDefault(),className:Pt.create("form-fields-container",{flex:"1"},{"(max-width: 950px)":{flex:"initial"}}),children:Ze("div",{className:Pt.create("form-content-page",{display:"grid",gap:St.spacing.md,rowGap:St.spacing.lg,gridTemplateColumns:"repeat(12, minmax(0, 1fr))",minWidth:"0"},{"(max-width: 600px)":{display:"flex",flexDirection:"column"}}),children:v.fields.map(e=>{const t=e.code||e.id,n="promo_code"===t;if(!C(e))return null;if("section"===e.type)return Ze(aa,{field:e,errors:[],children:Ze("span",{})},e.id);if("notice"===e.type)return Ze(aa,{field:e,errors:[],children:Ze("span",{})},e.id);const r="validating"===u.status,o=n?Ze("button",{type:"button",onClick:()=>p(),disabled:!m.trim()||r,style:{height:"2.75rem",minWidth:"5rem",padding:"0 1rem",fontSize:St.fontSize.small,backgroundColor:St.colors.primary,color:St.colors.primaryForeground,border:"none",borderRadius:St.radius.default,cursor:m.trim()&&!r?"pointer":"not-allowed",opacity:m.trim()&&!r?1:.5,whiteSpace:"nowrap"},children:r?Ze(Wt,{size:"small"}):"Apply"}):void 0,s=!n||"valid"!==u.status&&"invalid"!==u.status?null:Ze("div",{style:{marginTop:"0.5rem"},children:["valid"===u.status&&Ze("span",{style:{color:"#22c55e",fontSize:St.fontSize.small,display:"flex",alignItems:"center",gap:"0.25rem"},children:[Ze("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:Ze("path",{d:"M20 6 9 17l-5-5"})}),'Promo code "',u.name,'" applied']}),"invalid"===u.status&&Ze("span",{style:{color:St.colors.destructive,fontSize:St.fontSize.small,display:"flex",alignItems:"center",gap:"0.25rem"},children:[Ze("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Ze("circle",{cx:"12",cy:"12",r:"10"}),Ze("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),Ze("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),u.message]})]});return Ze(aa,{field:e,errors:i,children:[Ze(Zs,{value:b(t,e).toString(),onChange:r=>{let i=r;"boolean"!==e.type&&"checkbox"!==e.type||(i="true"===r),l.updateFieldValue(v.id,t,i),n&&(f(r),h({status:"idle"}))},onKeyDown:n?g:void 0,answer:k(t),onAnswerChange:n=>{var r;l.updateFieldAnswer(v.id,t,n,null===(r=e.boolean_config)||void 0===r?void 0:r.details_rating_factor_id)},id:t,name:t,type:e.type,placeholder:e.placeholder,required:e.required,options:e.options,validation:e.validation,booleanConfig:e.boolean_config,add_null_option:e.add_null_option,null_option_label:e.null_option_label,inline:e.inline,hasError:l.hasFieldErrors(t),errors:l.getFieldErrors(t),suffix:o}),s]},e.id)})})}),_&&Ze("div",{className:Pt.create("form-blocker",{backgroundColor:St.colors.accent,borderRadius:St.radius.default,padding:St.spacing.lg,borderLeft:`4px solid ${St.colors.primary}`}),children:[Ze("h3",{className:Pt.create("form-blocker-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"1.125rem",fontWeight:"600",color:St.colors.accentForeground}),children:_.config.title}),Ze("p",{className:Pt.create("form-blocker-message",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.accentForeground,opacity:"0.9"}),children:_.config.message}),_.config.link&&Ze("a",{href:_.config.link.url,target:"_blank",rel:"noopener noreferrer",className:Pt.create("form-blocker-link",{display:"inline-flex",alignItems:"center",gap:"0.375rem",marginTop:St.spacing.md,fontSize:St.fontSize.default,fontWeight:"600",color:St.colors.primary,textDecoration:"none"}),children:[_.config.link.label,Ze("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Ze("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),Ze("polyline",{points:"15 3 21 3 21 9"}),Ze("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})]}),Ze("hr",{className:Pt.create("form-navigation-border",{border:"0",borderTop:`1px solid ${St.colors.border}`,height:"0"})}),Ze("div",{className:0===n?Pt.create("form-navigation-inline-first",{paddingTop:St.spacing.lg,display:"flex",alignItems:"center",justifyContent:"flex-end"}):Pt.create("form-navigation-inline",{paddingTop:St.spacing.lg,display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[n>0&&Ze(ls,{onClick:()=>null==l?void 0:l.navigateToPreviousPage(),variant:"outline",children:"Back"}),!_&&Ze(ls,{onClick:async function(){l.validateCurrentPage().length>0||(n===r-1?await(null==l?void 0:l.calculateQuote()):await(null==l?void 0:l.navigateToNextPage()))},disabled:a,loading:a,children:n===r-1?"Get Quote":"Continue"})]})]})]}),Ze("div",{className:Pt.create("form-sidebar",{display:"block"},{"(max-width: 950px)":{display:"none"}}),children:Ze(Ks,{pages:t.pages,currentPageIndex:n,completedPages:T})}),Ze("div",{className:Pt.create("form-mobile-actions",{display:"none"},{"(max-width: 950px)":{display:"block"}}),children:Ze(ea,{pages:t.pages,completedPages:T})})]}),(null==s?void 0:s.reference)&&Ze("p",{className:Pt.create("form-quote-reference",{margin:"0",marginTop:St.spacing.md,textAlign:"center",fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:["Quote reference: ",Ze("strong",{style:{color:St.colors.foreground,fontWeight:600},children:s.reference})]})]})]})})}function da(){var e,t,n;const{quoteIntent:r,fsm:i}=Ft(e=>({quoteIntent:e.getQuoteIntent(),fsm:e})),o=null==r?void 0:r.payment_return,s=null==o?void 0:o.paymentTransactionId,a=null==o?void 0:o.transactionStatus,l=null===(e=null==r?void 0:r.organisation)||void 0===e?void 0:e.name,c=null===(t=null==r?void 0:r.organisation)||void 0===t?void 0:t.admin_email,d=null===(n=null==r?void 0:r.organisation)||void 0===n?void 0:n.phone,u=c||d;ct(()=>{if(s&&r){const e=null==o?void 0:o.paymentStatus,t=null==a?void 0:a.amount;"success"===e&&a?Be(r,s,t||0,a.gateway_code,t,void 0):e&&["declined","cancelled","error"].includes(e)&&qe(r,s,t,null==a?void 0:a.gateway_code,e,null==a?void 0:a.status)}const e=setTimeout(()=>{null==i||i.clearStoredQuoteIntent()},2e3);return()=>clearTimeout(e)},[i,s,o,r]);const h=Pt.create("success-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,boxShadow:St.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:St.spacing.lg},"(max-width: 480px)":{padding:St.spacing.md}}),m=Pt.create("success-icon-container",{display:"flex",justifyContent:"center",marginBottom:St.spacing.lg}),f=Pt.create("success-icon",{width:"5rem",height:"5rem",borderRadius:"50%",backgroundColor:"#10b981",color:"white",display:"flex",alignItems:"center",justifyContent:"center"}),p=Pt.create("success-header",{textAlign:"center",marginBottom:St.spacing.xl}),g=Pt.create("success-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"2rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),y=Pt.create("success-message",{fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9",margin:"0"}),v=Pt.create("success-contact-section",{borderTop:`1px solid ${St.colors.border}`,paddingTop:St.spacing.xl,marginTop:St.spacing.xl}),w=Pt.create("success-contact-title",{fontSize:"1.125rem",fontWeight:"600",color:St.colors.foreground,marginBottom:St.spacing.md,textAlign:"center"}),b=Pt.create("success-contact-details",{backgroundColor:St.colors.accent,borderRadius:St.radius.default,padding:St.spacing.md,display:"flex",flexDirection:"column",gap:St.spacing.sm,marginBottom:St.spacing.lg}),x=Pt.create("success-contact-item",{display:"flex",alignItems:"center",gap:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.accentForeground}),k=Pt.create("success-actions",{display:"flex",gap:St.spacing.md,flexWrap:"wrap",justifyContent:"center"}),N=Pt.create("success-reference",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,textAlign:"center",marginTop:St.spacing.md});return Ze(ss,{title:"Payment Successful",description:"Your payment has been processed successfully",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze(ds,{children:Ze("div",{className:h,children:[Ze("div",{className:m,children:Ze("div",{className:f,children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M20 6 9 17l-5-5"})})})}),Ze("div",{className:p,children:[Ze("h1",{className:g,children:"Payment Complete!"}),Ze("p",{className:y,children:["Your payment has been processed successfully and your policy is being set up. You will receive your policy documentation by email."," ","For now, you can relax knowing you're ",l?`covered by ${l}`:"covered","."]})]}),u&&Ze("div",{className:v,children:[Ze("h3",{className:w,children:"Need assistance?"}),Ze("div",{className:b,children:[c&&Ze("div",{className:x,children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Ze("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Ze("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Ze("span",{children:c})]}),d&&Ze("div",{className:x,children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),Ze("span",{children:d})]})]}),Ze("div",{className:k,children:[d&&Ze(ls,{variant:"outline",onClick:()=>window.open(`tel:${d}`),children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Ze("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),"Call Us"]}),c&&Ze(ls,{variant:"outline",onClick:()=>window.open(`mailto:${c}`),children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Ze("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Ze("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Email Us"]})]})]}),r.reference&&Ze("div",{className:N,children:["Quote Reference: ",Ze("strong",{children:r.reference})]})]})})})})}function ua({isOpen:e,onClose:t,onSuccess:n,paymentRequest:r,httpClient:i}){const[o,s]=lt("initiating"),[a,l]=lt(null),[c,d]=lt(null),[u,h]=lt(null);ct(()=>{e&&r&&m()},[e,r]);const m=async()=>{var e;if(r)try{s("initiating"),l(null);const t={...r,returnUrl:window.location.href},n=null===(e=r.metadata)||void 0===e?void 0:e.gateway;if(!n)throw new Error("Payment gateway not found");const o=await i.initiatePayment(t,n);h(o.transaction_id),s("redirecting"),window.location.href=o.gateway_acceptance_url}catch(e){l(e.message||"Failed to initiate payment"),s("failed")}},f=()=>{c&&!c.closed&&c.close(),s("initiating"),l(null),h(null),d(null),t()};return e?Ze("div",{className:Pt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),children:[Ze("div",{className:Pt.create("modal-content",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:"2rem",minWidth:"400px",maxWidth:"500px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${St.colors.border}`}),children:[Ze("div",{className:Pt.create("modal-header",{textAlign:"center",marginBottom:"1.5rem"}),children:[Ze("div",{className:Pt.create("status-icon",{fontSize:"3rem",marginBottom:"1rem"}),children:(()=>{switch(o){case"completed":return"✅";case"cancelled":return"❌";case"failed":return"⚠️";default:return"⏳"}})()}),Ze("h2",{className:Pt.create("modal-title",{margin:"0",color:St.colors.foreground,fontSize:St.fontSize.large}),children:"Payment Processing"})]}),Ze("div",{className:Pt.create("modal-body",{textAlign:"center",marginBottom:"2rem"}),children:[Ze(hs,{className:Pt.create("status-message",{fontSize:St.fontSize.default,color:St.colors.mutedForeground,marginBottom:"1rem"}),children:(()=>{switch(o){case"initiating":return"Setting up your payment...";case"redirecting":return"Redirecting to payment portal...";case"processing":default:return"Processing payment...";case"polling":return"Checking payment status...";case"completed":return"Payment completed successfully!";case"cancelled":return"Payment was cancelled";case"failed":return"Payment failed"}})()}),a&&Ze(hs,{className:Pt.create("error-message",{color:St.colors.destructive,fontSize:St.fontSize.small,padding:"0.75rem",backgroundColor:St.colors.destructive+"10",borderRadius:St.radius.default,border:`1px solid ${St.colors.destructive}30`}),children:a}),("redirecting"===o||"initiating"===o)&&Ze("div",{className:Pt.create("loading-indicator",{display:"inline-block",width:"20px",height:"20px",marginTop:"1rem",border:`3px solid ${St.colors.border}`,borderTop:`3px solid ${St.colors.primary}`,borderRadius:"50%",animation:"spin 1s linear infinite"})})]}),Ze("div",{className:Pt.create("modal-actions",{display:"flex",gap:"1rem",justifyContent:"center"}),children:"failed"===o||"cancelled"===o?Ze(C,{children:[Ze(ls,{onClick:f,variant:"outline",children:"Close"}),"cancelled"===o&&Ze(ls,{onClick:()=>{s("initiating"),l(null),m()},children:"Try Again"})]}):Ze(ls,"completed"===o?{onClick:f,children:"Continue"}:{onClick:f,variant:"outline",disabled:"initiating"===o,children:"Cancel"})})]}),Ze("style",{children:"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "})]}):null}function ha({transactionId:e,organisationId:t,allowCancel:n=!0}){const{httpClient:r}=qt(),[i,o]=lt(!0),[s,a]=lt(null),[l,c]=lt(null),[d,u]=lt(!1),[h,m]=lt(!1),[f,p]=lt(!1);ct(()=>{g()},[e]);const g=async()=>{try{if(o(!0),a(null),!r)throw new Error("HTTP client not available");const n=r.getBaseUrl(),i=await fetch(`${n}/payments/bank-transfer/${e}?orgId=${t}`);if(!i.ok)throw new Error(`Failed to load bank transfer details: ${i.statusText}`);const s=await i.json(),l=s.data||s;c({bank_account_name:l.bank_account_name,bank_account_number:l.bank_account_number,instructions_html:l.instructions_html,reference:l.reference,amount:Number(l.amount),currency:l.currency})}catch(e){a(e.message||"Failed to load bank transfer details")}finally{o(!1)}};return i?Ze(as,{message:"Loading payment details..."}):s?Ze(ss,{title:"Error",description:"Failed to load bank transfer details",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze(ds,{children:Ze("div",{className:Pt.create("error-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,boxShadow:St.shadow.sm,maxWidth:"42rem",margin:"0 auto",textAlign:"center"},{"(max-width: 480px)":{padding:St.spacing.lg}}),children:[Ze("div",{className:Pt.create("error-icon",{fontSize:"3rem",marginBottom:St.spacing.md,color:St.colors.destructive}),children:"⚠️"}),Ze("h2",{className:Pt.create("error-title",{margin:"0",marginBottom:St.spacing.sm,color:St.colors.foreground}),children:"Error Loading Payment Details"}),Ze("p",{className:Pt.create("error-message",{color:St.colors.mutedForeground}),children:s})]})})})}):l?Ze(ss,{title:"Bank Transfer Payment",description:"Complete your payment via bank transfer",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:[Ze(ds,{children:Ze("div",{className:Pt.create("bank-transfer-container",{backgroundColor:St.colors.card,borderRadius:St.radius.large,maxWidth:"42rem",margin:"0 auto",overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.1)"}),children:[Ze("div",{style:{backgroundColor:St.colors.primary},className:Pt.create("bank-transfer-header",{color:"white",padding:"2.5rem 2rem",textAlign:"center"},{"(max-width: 480px)":{padding:"1.5rem 1rem"}}),children:[Ze("h1",{className:Pt.create("header-title",{fontSize:"1.75rem",fontWeight:"700",margin:"0",marginBottom:"0.5rem"},{"(max-width: 480px)":{fontSize:"1.25rem",marginBottom:"0.25rem"}}),children:"Bank Transfer Payment"}),Ze("p",{className:Pt.create("header-subtitle",{fontSize:"1rem",margin:"0",opacity:"0.9"},{"(max-width: 480px)":{fontSize:St.fontSize.small}}),children:"Complete your payment using the details below"})]}),Ze("div",{className:Pt.create("bank-transfer-content",{padding:"2rem"},{"(max-width: 480px)":{padding:"1rem"}}),children:[Ze("div",{className:Pt.create("payment-details-card",{backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:St.radius.default,padding:"1.5rem",marginBottom:"1.5rem"},{"(max-width: 480px)":{padding:"1rem",marginBottom:"1rem"}}),children:[Ze("div",{className:Pt.create("detail-row-amount",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0",borderBottom:"1px solid #e5e7eb"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.5rem"}}),children:[Ze("span",{className:Pt.create("detail-label",{color:"#6b7280",fontSize:St.fontSize.default}),children:"Amount to Transfer"}),Ze("span",{className:Pt.create("detail-value-amount",{color:St.colors.primary,fontSize:"1.5rem",fontWeight:"700"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:["$",l.amount.toFixed(2)," ",l.currency]})]}),Ze("div",{className:Pt.create("detail-row-name",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0",borderBottom:"1px solid #e5e7eb"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.25rem"}}),children:[Ze("span",{className:Pt.create("detail-label-name",{color:"#6b7280",fontSize:St.fontSize.default}),children:"Account Name"}),Ze("span",{className:Pt.create("detail-value-name",{color:St.colors.foreground,fontSize:St.fontSize.default,fontWeight:"600"}),children:l.bank_account_name})]}),Ze("div",{className:Pt.create("detail-row-number",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0",borderBottom:"1px solid #e5e7eb"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.25rem"}}),children:[Ze("span",{className:Pt.create("detail-label-number",{color:"#6b7280",fontSize:St.fontSize.default}),children:"Account Number"}),Ze("span",{className:Pt.create("detail-value-number",{color:St.colors.foreground,fontSize:St.fontSize.default,fontWeight:"600"}),children:l.bank_account_number})]}),Ze("div",{className:Pt.create("detail-row-ref",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.25rem"}}),children:[Ze("span",{className:Pt.create("detail-label-ref",{color:"#6b7280",fontSize:St.fontSize.default}),children:"Payment Reference"}),Ze("span",{className:Pt.create("detail-value-ref",{color:St.colors.foreground,fontSize:St.fontSize.default,fontWeight:"600"}),children:l.reference})]})]}),Ze("div",{className:Pt.create("instructions-card",{backgroundColor:St.colors.muted,border:`1px solid ${St.colors.border}`,borderRadius:St.radius.default,padding:"1.25rem",marginBottom:"1.5rem"},{"(max-width: 480px)":{padding:"1rem",marginBottom:"1rem"}}),children:[Ze("h3",{className:Pt.create("instructions-title",{margin:"0 0 0.75rem 0",fontSize:St.fontSize.default,fontWeight:"600",color:St.colors.foreground}),children:"Payment Instructions"}),Ze("p",{className:Pt.create("instructions-text",{margin:"0 0 0.75rem 0",fontSize:St.fontSize.small,lineHeight:"1.6",color:St.colors.foreground}),children:[Ze("strong",{children:"Important:"})," Please include the payment reference when making your transfer to ensure your payment is processed correctly."]}),Ze("p",{className:Pt.create("instructions-text",{margin:"0",fontSize:St.fontSize.small,lineHeight:"1.6",color:St.colors.foreground}),children:"Once we receive your payment, we'll process your quote and send you a confirmation email."})]}),Ze("div",{className:Pt.create("button-wrapper",{textAlign:"center",marginBottom:"1.5rem",display:"flex",gap:"1rem",justifyContent:"center",flexWrap:"wrap"},{"(max-width: 480px)":{flexDirection:"column",gap:"0.75rem",marginBottom:"1rem"}}),children:[Ze("button",{onClick:()=>{u(!0)},style:{backgroundColor:St.colors.primary},className:Pt.create("confirm-button",{color:"white",border:"none",borderRadius:St.radius.default,padding:"0.75rem 2rem",fontSize:St.fontSize.default,fontWeight:"600",cursor:"pointer",transition:"opacity 150ms ease"},{"(max-width: 480px)":{width:"100%",padding:"0.625rem 1.5rem"}}),children:"I've Made the Transfer"}),n&&Ze("button",{onClick:()=>{m(!0)},className:Pt.create("cancel-button",{color:"#6b7280",backgroundColor:"white",border:"2px solid #e5e7eb",borderRadius:St.radius.default,padding:"0.75rem 2rem",fontSize:St.fontSize.default,fontWeight:"600",cursor:"pointer",transition:"all 150ms ease"},{"(max-width: 480px)":{width:"100%",padding:"0.625rem 1.5rem"}}),children:"Cancel"})]}),Ze("p",{className:Pt.create("footer-text",{textAlign:"center",color:"#6b7280",fontSize:St.fontSize.small,margin:"0"}),children:"Your quote has been saved. We'll process it once payment is received."})]})]})}),h&&Ze("div",{className:Pt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),onClick:()=>!f&&m(!1),children:Ze("div",{className:Pt.create("modal-content",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,maxWidth:"400px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${St.colors.border}`,textAlign:"center"},{"(max-width: 480px)":{padding:St.spacing.lg,margin:"0 1rem"}}),onClick:e=>e.stopPropagation(),children:[Ze("div",{className:Pt.create("warning-icon",{fontSize:"4rem",marginBottom:St.spacing.md}),children:"⚠️"}),Ze("h3",{className:Pt.create("modal-title",{margin:"0",marginBottom:St.spacing.sm,color:St.colors.foreground,fontSize:St.fontSize.large,fontWeight:"600"}),children:"Are you sure?"}),Ze("p",{className:Pt.create("modal-message",{margin:"0",marginBottom:St.spacing.lg,color:St.colors.foreground,lineHeight:"1.6"}),children:"This will take you back to the checkout page."}),Ze("div",{className:Pt.create("modal-buttons",{display:"flex",flexDirection:"column-reverse",gap:"0.75rem",justifyContent:"center"}),children:[Ze("button",{onClick:()=>m(!1),disabled:f,className:Pt.create("no-button",{backgroundColor:"#f3f4f6",color:St.colors.foreground,border:"none",borderRadius:St.radius.default,padding:`${St.spacing.sm} ${St.spacing.lg}`,fontSize:St.fontSize.default,fontWeight:"500",cursor:f?"not-allowed":"pointer",transition:"opacity 150ms ease",opacity:f?"0.5":"1",width:"100%"}),children:"No, Go Back"}),Ze("button",{onClick:async()=>{if(r)try{p(!0);const n=r.getBaseUrl();if(!(await fetch(`${n}/payments/${e}/cancel-bank-transfer?orgId=${t}`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to cancel payment");window.location.reload()}catch(e){a("Failed to cancel payment. Please try again."),m(!1),p(!1)}},disabled:f,className:Pt.create("yes-button",{backgroundColor:"#ef4444",color:"white",border:"none",borderRadius:St.radius.default,padding:`${St.spacing.sm} ${St.spacing.lg}`,fontSize:St.fontSize.default,fontWeight:"500",cursor:f?"not-allowed":"pointer",transition:"opacity 150ms ease",opacity:f?"0.5":"1",width:"100%"}),children:f?"Cancelling...":"Yes, Cancel Payment"})]})]})}),d&&Ze("div",{className:Pt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),onClick:()=>u(!1),children:Ze("div",{className:Pt.create("modal-content",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,maxWidth:"400px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${St.colors.border}`,textAlign:"center"},{"(max-width: 480px)":{padding:St.spacing.lg,margin:"0 1rem"}}),onClick:e=>e.stopPropagation(),children:[Ze("div",{className:Pt.create("success-icon",{fontSize:"4rem",marginBottom:St.spacing.md}),children:"✓"}),Ze("h3",{className:Pt.create("modal-title",{margin:"0",marginBottom:St.spacing.sm,color:St.colors.primary,fontSize:St.fontSize.large,fontWeight:"600"}),children:"Thank You!"}),Ze("p",{className:Pt.create("modal-message",{margin:"0",marginBottom:St.spacing.lg,color:St.colors.foreground,lineHeight:"1.6"}),children:"We'll process your payment as soon as we receive it. You'll receive a confirmation email once your coverage is activated."}),Ze("button",{onClick:()=>u(!1),className:Pt.create("close-button",{backgroundColor:St.colors.primary,color:"white",border:"none",borderRadius:St.radius.default,padding:`${St.spacing.sm} ${St.spacing.lg}`,fontSize:St.fontSize.default,fontWeight:"500",cursor:"pointer",transition:"opacity 150ms ease"}),children:"Close"})]})})]})}):null}Pt.pseudoElement("sidebar-continue-later-button",":hover",{backgroundColor:St.colors.muted,borderColor:St.colors.primary,color:St.colors.primary});class ma{static async loadTheme(t){try{if(e(t.slug),e(t.theme_url),this.loadedThemes.has(t.slug))return void e(t.slug);const n=await fetch(t.theme_url,{method:"GET",headers:{Accept:"text/css"}});if(!n.ok)throw new Error(`Failed to load theme: ${n.status} ${n.statusText}`);const r=await n.text();e(r.substring(0,200));const i=this.parseCSSContent(r);e(i.mappedVariables),e(i.classRules.length),this.applyParsedTheme(t.slug,i),this.loadedThemes.add(t.slug),e(t.slug)}catch(n){throw e(t.slug),n}}static parseCSSContent(t){e();const n={},r={};let i="";const o=t.match(/:root\s*\{([^}]+)\}/);if(o){const t=o[1];e(null==t||t.substring(0,100));const i=/--([\w-]+):\s*([^;]+);/g;let s;for(;null!==(s=i.exec(t));){const t=`--${s[1]}`,i=s[2].trim();n[t]=i;const o=this.variableMapping[t];o?(r[o]=i,e()):e()}}else e();return i=t.replace(/:root\s*\{[^}]+\}/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim(),i&&e(i.substring(0,100)),{variables:n,classRules:i,mappedVariables:r}}static applyParsedTheme(t,n){e(),Promise.resolve().then(function(){return zt}).then(({updateBaseVariables:t})=>{Object.keys(n.mappedVariables).length>0&&(e(n.mappedVariables),t(n.mappedVariables))}).catch(()=>{e()}),n.classRules&&this.applyClassRules(t,n.classRules),this.injectOriginalCSS(t,n)}static applyClassRules(t,n){const r=document.getElementById(`insure-os-theme-classes-${t}`);if(r&&r.remove(),n.trim()){const r=document.createElement("style");r.id=`insure-os-theme-classes-${t}`,r.type="text/css",r.textContent=n,document.head.appendChild(r),e()}}static injectOriginalCSS(t,n){const r=document.getElementById(`insure-os-theme-original-${t}`);r&&r.remove();const i={};for(const[e,t]of Object.entries(n.variables))this.variableMapping[e]||(i[e]=t);if(Object.keys(i).length>0){const n=`:root {\n${Object.entries(i).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`,r=document.createElement("style");r.id=`insure-os-theme-original-${t}`,r.type="text/css",r.textContent=n,document.head.appendChild(r),e()}}static removeTheme(t){let n=!1;[`insure-os-theme-classes-${t}`,`insure-os-theme-original-${t}`].forEach(e=>{const t=document.getElementById(e);t&&(t.remove(),n=!0)}),n&&(this.loadedThemes.delete(t),e())}static isThemeLoaded(e){return this.loadedThemes.has(e)}static getLoadedThemes(){return Array.from(this.loadedThemes)}}ma.loadedThemes=new Set,ma.variableMapping={"--color-primary":"--insure-os-primary","--color-primary-foreground":"--insure-os-primary-foreground","--color-secondary":"--insure-os-secondary","--color-secondary-foreground":"--insure-os-secondary-foreground","--color-accent":"--insure-os-accent","--color-accent-foreground":"--insure-os-accent-foreground","--color-background":"--insure-os-background","--color-foreground":"--insure-os-foreground","--color-card":"--insure-os-card","--color-card-foreground":"--insure-os-card-foreground","--color-popover":"--insure-os-popover","--color-popover-foreground":"--insure-os-popover-foreground","--color-muted":"--insure-os-muted","--color-muted-foreground":"--insure-os-muted-foreground","--color-destructive":"--insure-os-destructive","--color-border":"--insure-os-border","--color-input":"--insure-os-input","--color-ring":"--insure-os-ring","--font-sans":"--insure-os-font-family","--radius":"--insure-os-radius","--radius-sm":"--insure-os-radius-sm","--radius-lg":"--insure-os-radius-lg"};var fa=Object.freeze({__proto__:null,ThemeLoader:ma});function pa(e,t){return"windcave"!==e?"Provider Fee:":"account2account"===t?"Account2Account surcharge:":"Credit card surcharge:"}function ga(e){var t;return(null===(t=e.metadata)||void 0===t?void 0:t.gateway_method)?`${e.gateway_code}:${e.metadata.gateway_method}`:e.gateway_code}function ya({paymentLinkId:t,signedUrl:n}){var r,i,o,s,a,l,c,d,u,h,m,f;const p=qt().httpClient,[g,y]=lt(null),[v,w]=lt(!0),[b,x]=lt(null),[k,N]=lt(!1),[S,_]=lt(null),[$,I]=lt(null),[T,E]=lt(null),[P,z]=lt(!1),[D,R]=lt(null),[M,O]=lt(null),[j,W]=lt(!0),A="undefined"!=typeof window?new URLSearchParams(window.location.search):new URLSearchParams,[L,B]=lt("processing"===A.get("status")?A.get("transactionId"):null),[q,F]=lt(()=>Ds()),[H,U]=lt(null),[Y,Z]=lt(!1),[G,V]=lt(null),[Q,J]=lt(null),[K,X]=lt(null);ct(()=>{ee()},[t]);const ee=async()=>{var r,i,o;try{w(!0);const s=new URLSearchParams(window.location.search),a=s.get("transactionId"),l=s.get("status"),c=s.get("gateway_code"),d=s.get("method"),u=s.get("excess_id");a&&l&&(z(!0),R(l),O(a)),c&&E(d?`${c}:${d}`:c);const h=n?await p.getPaymentLinkDetails(n):await p.getPaymentLinkById(t);if(h.organisation&&h.organisation.theme)try{await ma.loadTheme({slug:h.organisation.slug,theme_url:h.organisation.theme.css_url})}catch(t){e()}if("paid"===h.status&&!P&&(!a||"completed"!==l&&"success"!==l))return y(h),void x("This payment link has already been used.");if("superseded"===h.status)return y(h),void x("This payment link has been replaced by a newer one. Please use the latest link you received.");if("confirmed"===h.status)return y(h),void J({message:"Your renewal is confirmed. Your premium funding will continue automatically on the policy start date.",effectiveDate:null===(r=h.metadata)||void 0===r?void 0:r.effective_date});if("expired"===h.status)return y(h),void x("This payment link has expired.");if("cancelled"===h.status)return y(h),void x("This payment link has been cancelled.");if("outdated"===h.status)return y(h),void x("This payment link is no longer valid because the quote has been updated. Please request a new payment link.");const m=Array.isArray(h.payment_options)&&h.payment_options.some(e=>{var t,n;return Number(null!==(n=null===(t=e.amount)||void 0===t?void 0:t.total)&&void 0!==n?n:0)>0}),f=Array.isArray(h.calculations)&&h.calculations.some(e=>{var t;return Number(null!==(t=e.premium_payable)&&void 0!==t?t:0)>0});if(!m&&!f)return y(h),void x("This payment link is not available. Please contact support.");if("awaiting_payment"===h.status&&h.pending_bank_transfer){const t=h.pending_bank_transfer;return e(),void X({transactionId:t.transaction_id,organisationId:(null===(i=h.organisation)||void 0===i?void 0:i.id)||""})}if(u){const e=h.calculations.find(e=>e.excess_id===u);e?I(e.id):1===h.calculations.length&&h.calculations[0]&&I(h.calculations[0].id)}else 1===h.calculations.length&&h.calculations[0]&&I(h.calculations[0].id);!c&&1===h.payment_options.length&&h.payment_options[0]&&E(ga(h.payment_options[0])),y(h),(null===(o=h.organisation)||void 0===o?void 0:o.quote_page_url)&&V(h.organisation.quote_page_url)}catch(e){x("Failed to load payment details. Please check your link.")}finally{w(!1)}},te=ut(()=>g&&$?g.calculations.find(e=>e.id===$):null,[g,$]),ne=ut(()=>g&&T?g.payment_options.find(e=>ga(e)===T):null,[g,T]);if(K)return Ze(ha,{transactionId:K.transactionId,organisationId:K.organisationId,allowCancel:!0});if(Q){const e=null==g?void 0:g.organisation,t=null==e?void 0:e.admin_email,n=null==e?void 0:e.phone,r=t||n;return Ze(ss,{title:"Renewal Confirmed",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze("div",{className:Pt.create("auto-renew-success-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,boxShadow:St.shadow.sm,maxWidth:"42rem",margin:"0 auto"}),children:[Ze("div",{className:Pt.create("success-icon-container",{display:"flex",justifyContent:"center",marginBottom:St.spacing.lg}),children:Ze("div",{className:Pt.create("success-icon",{width:"5rem",height:"5rem",borderRadius:"50%",backgroundColor:"#10b981",color:"white",display:"flex",alignItems:"center",justifyContent:"center"}),children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M20 6 9 17l-5-5"})})})}),Ze("div",{className:Pt.create("success-header",{textAlign:"center",marginBottom:St.spacing.xl}),children:[Ze("h1",{className:Pt.create("success-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"2rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.2",letterSpacing:"-0.025em"}),children:"Renewal Confirmed"}),Ze("p",{className:Pt.create("success-message",{fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9",margin:"0"}),children:Q.message})]}),Q.effectiveDate&&Ze("div",{className:Pt.create("payment-date-box",{backgroundColor:St.colors.accent,borderRadius:St.radius.default,padding:St.spacing.lg,marginBottom:St.spacing.lg,textAlign:"center"}),children:[Ze("p",{className:Pt.create("payment-date-label",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,margin:"0",marginBottom:St.spacing.sm}),children:"Your first payment will be on"}),Ze("p",{className:Pt.create("payment-date-value",{fontSize:"1.25rem",fontWeight:"600",color:St.colors.foreground,margin:"0"}),children:new Date(Q.effectiveDate).toLocaleDateString("en-NZ",{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),Ze("div",{className:Pt.create("info-box",{backgroundColor:St.colors.muted,borderRadius:St.radius.default,padding:St.spacing.md,marginBottom:St.spacing.lg}),children:Ze("p",{className:Pt.create("info-text",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,margin:"0",textAlign:"center"}),children:"No further action is required. Your monthly payments will continue as normal."})}),r&&Ze("div",{className:Pt.create("contact-section",{borderTop:`1px solid ${St.colors.border}`,paddingTop:St.spacing.xl,marginTop:St.spacing.xl}),children:[Ze("h3",{className:Pt.create("contact-title",{fontSize:"1.125rem",fontWeight:"600",color:St.colors.foreground,marginBottom:St.spacing.md,textAlign:"center"}),children:"Need assistance?"}),Ze("div",{className:Pt.create("contact-details",{backgroundColor:St.colors.accent,borderRadius:St.radius.default,padding:St.spacing.md,display:"flex",flexDirection:"column",gap:St.spacing.sm}),children:[t&&Ze("div",{className:Pt.create("contact-item",{display:"flex",alignItems:"center",gap:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.accentForeground}),children:Ze("span",{children:["Email: ",t]})}),n&&Ze("div",{className:Pt.create("contact-item",{display:"flex",alignItems:"center",gap:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.accentForeground}),children:Ze("span",{children:["Phone: ",n]})})]})]})]})})})}if(L&&p)return Ze(ss,{title:"Payment Processing",noSubscription:!0,hideHeader:!0,children:Ze(Ts,{httpClient:p,transactionId:L,onResolved:async e=>{const t="completed"===e?"success":"cancelled"===e?"cancelled":"failed"===e?"declined":"error",n=new URL(window.location.href);n.searchParams.set("status",t),L&&n.searchParams.set("transactionId",L),window.history.replaceState({},"",n.toString()),B(null),await ee()},onError:async()=>{const e=new URL(window.location.href);e.searchParams.set("status","error"),window.history.replaceState({},"",e.toString()),B(null),await ee()}})});if(v)return Ze(as,{message:"Loading payment details..."});if(b){const e=null==g?void 0:g.organisation,t=null==e?void 0:e.quote_page_url,n=null==e?void 0:e.name,r=null==e?void 0:e.admin_email,i=null==e?void 0:e.phone,o=r||i,s="paid"===(null==g?void 0:g.status),a=s?"Payment Completed":"Payment Link Unavailable",l=s?"Thank you, your payment was received.":b,c=Pt.create("pl-error-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,boxShadow:St.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:St.spacing.lg},"(max-width: 480px)":{padding:St.spacing.md}}),d=Pt.create("pl-error-icon-container",{display:"flex",justifyContent:"center",marginBottom:St.spacing.lg}),u=Pt.create("pl-error-icon",{width:"4rem",height:"4rem",color:St.colors.primary}),h=Pt.create("pl-error-header",{textAlign:"center",marginBottom:St.spacing.xl}),m=Pt.create("pl-error-title",{fontSize:"2rem",fontWeight:"700",color:St.colors.primary,marginBottom:St.spacing.sm,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),f=Pt.create("pl-error-subtitle",{fontSize:St.fontSize.default,color:St.colors.foreground,lineHeight:"1.6",opacity:"0.8"}),p=Pt.create("pl-error-contact-section",{borderTop:`1px solid ${St.colors.border}`,paddingTop:St.spacing.xl,marginTop:St.spacing.xl,textAlign:"center"}),y=Pt.create("pl-error-contact-text",{fontSize:St.fontSize.default,color:St.colors.foreground,marginBottom:St.spacing.lg}),v=Pt.create("pl-error-actions",{display:"flex",gap:St.spacing.md,flexWrap:"wrap",justifyContent:"center",marginBottom:St.spacing.lg}),w=()=>Ze("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",className:u,children:[Ze("circle",{cx:"12",cy:"12",r:"10"}),Ze("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),Ze("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),x=()=>Ze("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",className:u,children:[Ze("circle",{cx:"12",cy:"12",r:"10"}),Ze("polyline",{points:"8 12.5 11 15.5 16 9.5"})]});return Ze(ss,{title:"Payment Link",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze(ds,{children:Ze("div",{className:c,children:[Ze("div",{className:d,children:Ze(s?x:w,{})}),Ze("div",{className:h,children:[Ze("h1",{className:m,children:a}),Ze("p",{className:f,children:l})]}),t&&Ze("div",{className:Pt.create("pl-error-quote-action",{display:"flex",justifyContent:"center",marginBottom:o?"0":St.spacing.sm}),children:Ze(ls,{variant:"primary",onClick:()=>{window.location.href=t},children:"Start a New Quote"})}),o&&Ze("div",{className:p,children:[Ze("p",{className:y,children:n?`Need assistance? Contact ${n}`:"Need assistance? Contact us"}),Ze("div",{className:v,children:[i&&Ze(ls,{variant:"outline",onClick:()=>window.open(`tel:${i}`),children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Ze("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),"Call Us"]}),r&&Ze(ls,{variant:"outline",onClick:()=>window.open(`mailto:${r}`),children:[Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Ze("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Ze("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Email Us"]})]})]})]})})})})}if(!g)return null;const re=new URLSearchParams(window.location.search),ie=re.get("transactionId"),oe=re.get("status"),se=ie&&oe;if("paid"===g.status&&("completed"===oe||"success"===oe||se||P||"completed"===D)){const e=null===(r=g.organisation)||void 0===r?void 0:r.admin_email,t=null===(i=g.organisation)||void 0===i?void 0:i.phone,n=e||t;return Ze(ss,{title:"Payment Successful",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze("div",{className:Pt.create("payment-success-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.xl,boxShadow:St.shadow.sm,maxWidth:"42rem",margin:"0 auto"}),children:[Ze("div",{className:Pt.create("success-icon-container",{display:"flex",justifyContent:"center",marginBottom:St.spacing.lg}),children:Ze("div",{className:Pt.create("success-icon",{width:"5rem",height:"5rem",borderRadius:"50%",backgroundColor:"#10b981",color:"white",display:"flex",alignItems:"center",justifyContent:"center"}),children:Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Ze("path",{d:"M20 6 9 17l-5-5"})})})}),Ze("div",{className:Pt.create("success-header",{textAlign:"center",marginBottom:St.spacing.xl}),children:[Ze("h1",{className:Pt.create("success-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"2rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.2",letterSpacing:"-0.025em"}),children:"Payment Complete!"}),Ze("p",{className:Pt.create("success-message",{fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9",margin:"0"}),children:"Your payment has been processed successfully! You will receive your documentation by email."})]}),n&&Ze("div",{className:Pt.create("contact-section",{borderTop:`1px solid ${St.colors.border}`,paddingTop:St.spacing.xl,marginTop:St.spacing.xl}),children:[Ze("h3",{className:Pt.create("contact-title",{fontSize:"1.125rem",fontWeight:"600",color:St.colors.foreground,marginBottom:St.spacing.md,textAlign:"center"}),children:"Need assistance?"}),Ze("div",{className:Pt.create("contact-details",{backgroundColor:St.colors.accent,borderRadius:St.radius.default,padding:St.spacing.md,display:"flex",flexDirection:"column",gap:St.spacing.sm,marginBottom:St.spacing.lg}),children:[e&&Ze("div",{className:Pt.create("contact-item",{display:"flex",alignItems:"center",gap:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.accentForeground}),children:Ze("span",{children:["Email: ",e]})}),t&&Ze("div",{className:Pt.create("contact-item",{display:"flex",alignItems:"center",gap:St.spacing.sm,fontSize:St.fontSize.small,color:St.colors.accentForeground}),children:Ze("span",{children:["Phone: ",t]})})]}),(M||ie)&&Ze("div",{className:Pt.create("reference",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,textAlign:"center",marginTop:St.spacing.md}),children:["Transaction ID: ",Ze("strong",{children:null===(o=M||ie)||void 0===o?void 0:o.slice(0,8).toUpperCase()})]})]})]})})})}const ae=j&&se&&("failed"===oe||"declined"===oe||"cancelled"===oe||"failed"===D||"declined"===D||"cancelled"===D),le="cancelled"===oe||"cancelled"===D?"cancelled":"failed"===oe||"declined"===oe||"failed"===D||"declined"===D?"declined":"error",ce=g.calculations,de=ce.length>1,ue=ce.length>0,he=ue,me=(null===(s=g.metadata)||void 0===s?void 0:s.product_name)||(null===(a=g.policy_details)||void 0===a?void 0:a.product_name)||"Payment",fe=Boolean(null===(l=null==g?void 0:g.metadata)||void 0===l?void 0:l.quote_intent_id),pe=Boolean((!ue||$)&&T&&!H&&!Y),ge=ut(()=>{var e,t;const n=null===(e=null==g?void 0:g.metadata)||void 0===e?void 0:e.client_details;if(n)return{firstName:n.first_name,lastName:n.last_name,email:n.email,phone:n.phone};const r=null===(t=null==g?void 0:g.policy_details)||void 0===t?void 0:t.client_name;if(r){const e=r.trim().split(/\s+/);return{firstName:e[0]||r,lastName:e.slice(1).join(" ")||"",email:void 0,phone:void 0}}return null},[g]),ye=ut(()=>{var e;const t=null==g?void 0:g.policy_details;if(!t)return null;const n=e=>{if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString()},r=n(t.insured_from),i=n(t.insured_to),o=r&&i?`${r} – ${i}`:r||i||null,s=null!=t.sum_insured&&t.sum_insured>0?t.sum_insured:null,a=null!=t.excess&&t.excess>=0?t.excess:null;return t.external_policy_number||o||null!=s||null!=a?{externalPolicyNumber:null!==(e=t.external_policy_number)&&void 0!==e?e:null,insurancePeriod:o,sumInsured:s,excess:a}:null},[g]),ve=ut(()=>te&&te.line_item_display||null,[te]),we=null===(c=null==g?void 0:g.metadata)||void 0===c?void 0:c.type,be="renewal"===we?"Complete Your Renewal":"endorsement"===we?"Complete Your Payment":"Complete Your Purchase";return Ze(ss,{title:be,noSubscription:!0,hideHeader:!0,children:Ze(At,{children:[Ze("div",{className:Pt.create("checkout-layout",{display:"grid",gridTemplateColumns:"1fr 380px",gap:St.spacing.lg},{"(max-width: 950px)":{display:"flex",flexDirection:"column"},"(max-width: 480px)":{gap:St.spacing.md}}),children:[Ze("div",{className:Pt.create("checkout-main-wrapper",{minWidth:"0",backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,display:"flex",flexDirection:"column"}),children:[Ze("div",{className:Pt.create("checkout-header",{paddingInline:St.spacing.xl,paddingTop:St.spacing.xl,paddingBottom:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("h2",{className:Pt.create("checkout-title",{margin:"0",marginBottom:St.spacing.md,fontSize:"1.75rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.25rem"}}),children:be}),Ze("p",{className:Pt.create("checkout-description",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:ue?de?"Choose your excess amount and payment option to secure your coverage.":"Choose your payment method to secure your coverage.":"Choose your payment option to complete your purchase."}),Ze("hr",{className:Pt.create("checkout-header-border",{marginTop:St.spacing.lg,border:"0",borderTop:`1px solid ${St.colors.border}`,height:"0"})})]}),Ze("div",{className:Pt.create("checkout-sections",{paddingInline:St.spacing.xl,paddingBottom:St.spacing.xl,display:"flex",flexDirection:"column",gap:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingBottom:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingBottom:St.spacing.md}}),children:[fe&&Ze("div",{className:Pt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Ze(ms,{title:"Cover Start Date"}),Ze("div",{className:Pt.create("cover-date-container",{display:"flex",flexDirection:"column",gap:"0.75rem"}),children:[Ze("input",{type:"date",value:q,onChange:e=>{return t=e.target.value,F(t),void(async e=>{var t;if(g&&p&&(null===(t=g.metadata)||void 0===t?void 0:t.quote_intent_id)){Z(!0),U(null);try{const t=await p.validateCoverStartDate(g.payment_link_id,e);t.valid?U(null):(U(t.message||"This cover start date is not valid."),t.quote_page_url&&V(t.quote_page_url))}catch(e){U("Failed to validate cover date. Please try again.")}finally{Z(!1)}}})(t);var t},min:Ds(),disabled:Y,className:Pt.create("cover-date-input",{padding:"0.75rem 1rem",fontSize:St.fontSize.default,border:`2px solid ${H?St.colors.destructive:St.colors.border}`,borderRadius:St.radius.default,backgroundColor:St.colors.background,color:St.colors.foreground,width:"auto",maxWidth:"200px",cursor:Y?"wait":"pointer"})}),Y&&Ze("p",{className:Pt.create("validating-text",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,margin:"0"}),children:"Validating..."}),H&&Ze("div",{className:Pt.create("cover-date-error",{backgroundColor:`${St.colors.destructive}10`,border:`1px solid ${St.colors.destructive}`,borderRadius:St.radius.default,padding:"1rem"}),children:[Ze("p",{className:Pt.create("error-message",{color:St.colors.destructive,fontSize:St.fontSize.small,margin:"0",marginBottom:G?St.spacing.md:"0"}),children:H}),G&&Ze("a",{href:G,className:Pt.create("new-quote-link",{display:"inline-flex",alignItems:"center",gap:"0.5rem",color:St.colors.primary,fontSize:St.fontSize.small,fontWeight:"500",textDecoration:"none"}),children:["Start New Quote",Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Ze("path",{d:"M5 12h14"}),Ze("path",{d:"m12 5 7 7-7 7"})]})]})]})]})]}),he&&ue&&Ze("div",{className:Pt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Ze(ms,{title:1===ce.length?"Excess":"Excess Options"}),Ze("div",{className:Pt.create("excess-options-grid",{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"1rem"}),children:[...ce].sort((e,t)=>e.excess_amount-t.excess_amount).map(e=>{const t=e.id===$;return Ze("div",{className:jt(Pt.create("excess-option-card",{borderRadius:St.radius.default,minWidth:"125px",padding:"0.5rem 1rem 0.5rem 0.5rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"center",gap:"1rem"}),t?Pt.create("excess-option-card-selected",{border:`2px solid ${St.colors.primary}`,backgroundColor:St.colors.accent}):Pt.create("excess-option-card-unselected",{border:`2px solid ${St.colors.border}`,backgroundColor:St.colors.card})),onClick:()=>I(e.id),children:[Ze(fs,{selected:t}),Ze("div",{className:Pt.create("excess-amount",{color:St.colors.foreground}),children:[e.excess_label||`$${Number(e.excess_amount).toFixed(0)}`,e.description?"*":""]})]},e.id)})}),(null==te?void 0:te.description)&&Ze("div",{className:Pt.create("excess-description",{padding:"0.75rem",backgroundColor:St.colors.muted,borderRadius:St.radius.default,border:`1px solid ${St.colors.border}`}),children:Ze(hs,{className:Pt.create("excess-description-text",{fontSize:St.fontSize.small,color:St.colors.foreground,margin:"0"}),children:te.description})})]}),g.payment_options.length>0&&Ze("div",{className:Pt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"}),children:[Ze(ms,{title:"Payment Options"}),Ze("div",{className:Pt.create("payment-options-container",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:g.payment_options.map(e=>{var t,n;const r=ga(e),i=T===r,o="monthly"===e.payment_frequency,s=!!((null===(t=e.metadata)||void 0===t?void 0:t.gateway_fee)&&parseFloat(e.metadata.gateway_fee)>0),a=!0===(null===(n=e.metadata)||void 0===n?void 0:n.unavailable),l=()=>{var t;return a?"Currently Unavailable":o&&e.amount.monthly?`${gs(parseFloat(e.amount.monthly))} x ${(null===(t=e.metadata)||void 0===t?void 0:t.number_of_instalments)||12}`:gs(parseFloat(e.amount.due_today))},c=()=>e.description?e.description:"bank_transfer"===e.gateway_code?"Manual":`via ${e.gateway_name}`;return Ze("div",{title:a?"Currently Unavailable":void 0,className:jt(Pt.create("payment-option-row",{borderRadius:St.radius.default,padding:"0.75rem 1rem",cursor:a?"not-allowed":"pointer",opacity:a?"0.55":"1",transition:"all 150ms ease",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem"},{"(max-width: 480px)":{padding:"0.625rem 0.75rem",gap:"0.25rem",flexWrap:"wrap",alignItems:"flex-start"}}),i?Pt.create("payment-option-row-selected",{border:`2px solid ${St.colors.primary}`,backgroundColor:St.colors.accent}):Pt.create("payment-option-row-unselected",{border:`2px solid ${St.colors.border}`,backgroundColor:St.colors.card})),onClick:()=>{a||E(r)},children:[Ze("div",{className:Pt.create("payment-option-desktop-wrapper",{display:"flex",alignItems:"center",gap:"1rem",flex:"1"},{"(max-width: 480px)":{display:"none"}}),children:[Ze(fs,{selected:i}),Ze("div",{className:Pt.create("payment-option-info-desktop",{display:"flex",flexDirection:"column",flex:"1"}),children:[Ze("div",{className:Pt.create("frequency-title",{fontSize:St.fontSize.default,fontWeight:"500",color:St.colors.foreground}),children:e.display_title||ys(o?"monthly":"one-time",e.gateway_code)}),Ze("div",{className:Pt.create("gateway-description",{fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:c()})]})]}),Ze("div",{className:Pt.create("payment-option-amount-desktop",{display:"flex",flexDirection:"column",alignItems:"flex-end"},{"(max-width: 480px)":{display:"none"}}),children:[Ze(hs,{className:Pt.create("amount-text",{textAlign:"right",color:St.colors.foreground}),children:l()}),!a&&Ze(hs,{size:"small",className:Pt.create("gateway-fee-text",{textAlign:"right",color:St.colors.mutedForeground}),children:s?`${(()=>{var t;return"bank_transfer"===e.gateway_code?null:(null===(t=e.metadata)||void 0===t?void 0:t.gateway_fee)?gs(parseFloat(e.metadata.gateway_fee)):gs(0)})()} fee`:"No fees"})]}),Ze("div",{className:Pt.create("payment-option-title-mobile-wrapper",{display:"none"},{"(max-width: 480px)":{display:"flex",alignItems:"center",gap:"0.5rem",flex:"1 1 100%"}}),children:[Ze(fs,{selected:i}),Ze("div",{className:Pt.create("payment-option-title-mobile",{fontSize:St.fontSize.default,fontWeight:"500",color:St.colors.foreground}),children:e.display_title||ys(o?"monthly":"one-time",e.gateway_code)})]}),Ze("div",{className:Pt.create("payment-option-bottom-mobile",{display:"none"},{"(max-width: 480px)":{display:"flex",flex:"1 1 100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"1.5rem"}}),children:[Ze("div",{className:Pt.create("gateway-description-mobile",{fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:c()}),Ze(hs,{className:Pt.create("amount-text-mobile",{fontWeight:"500",color:St.colors.foreground}),children:l()})]})]},r)})})]})]})]}),Ze("div",{className:Pt.create("checkout-sidebar",{display:"flex",flexDirection:"column"},{"(max-width: 950px)":{display:"block"}}),children:Ze("div",{className:Pt.create("checkout-sidebar-sticky",{}),children:[(ge||ye||ve&&ve.length>0)&&Ze("div",{className:Pt.create("insurance-details-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,padding:St.spacing.lg,boxShadow:St.shadow.sm},{"(max-width: 768px)":{padding:St.spacing.md}}),children:[Ze("h3",{className:Pt.create("cart-summary-title",{fontSize:St.fontSize.large,fontWeight:"600",marginBottom:St.spacing.md,color:St.colors.foreground}),children:"Insurance Details"}),(ge||ye||"Payment"!==me)&&Ze(C,{children:[Ze("div",{className:Pt.create("client-details",{display:"flex",flexDirection:"column",gap:St.spacing.sm}),children:[(null==ge?void 0:ge.firstName)&&(null==ge?void 0:ge.lastName)&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Name"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:[null==ge?void 0:ge.firstName," ",null==ge?void 0:ge.lastName]})]}),(null==ge?void 0:ge.email)&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Email"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:null==ge?void 0:ge.email})]}),(null==ge?void 0:ge.phone)&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Phone"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:null==ge?void 0:ge.phone})]}),"Payment"!==me&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Product"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:me})]}),(null==ye?void 0:ye.externalPolicyNumber)&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Policy Number"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:ye.externalPolicyNumber})]}),(null==g?void 0:g.quote_reference)&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Quote Reference"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:g.quote_reference})]}),null!=(null==ye?void 0:ye.sumInsured)&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Sum Insured"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:gs(ye.sumInsured)})]}),null!=(null==ye?void 0:ye.excess)&&Ze("div",{className:Pt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("detail-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:"Excess"}),Ze("span",{className:Pt.create("detail-value",{fontWeight:"500",color:St.colors.foreground,fontSize:St.fontSize.small}),children:gs(ye.excess)})]})]}),ve&&ve.length>0&&Ze("hr",{className:Pt.create("divider",{border:"none",borderTop:`1px solid ${St.colors.border}`,margin:`${St.spacing.md} 0`})})]}),ve&&ve.length>0&&Ze("div",{className:Pt.create("line-items-section",{display:"flex",flexDirection:"column",gap:St.spacing.md}),children:ve.map((e,t)=>Ze("div",{className:Pt.create("line-item",{}),children:[Ze("div",{className:Pt.create("line-item-description",{fontSize:St.fontSize.small,fontWeight:"500",color:St.colors.foreground}),children:e.description}),e.show_sum_insured&&null!=e.sum_insured&&e.sum_insured>0&&Ze("div",{className:Pt.create("line-item-sum-insured",{fontSize:St.fontSize.small,color:St.colors.mutedForeground,marginTop:St.spacing.sm}),children:["Sum Insured: ",gs(e.sum_insured)]})]},t))})]}),(ge||ye||ve&&ve.length>0)&&Ze("div",{className:Pt.create("checkout-sidebar-spacer",{height:St.spacing.lg},{"(max-width: 950px)":{height:St.spacing.md}})}),Ze("div",{className:Pt.create("checkout-sidebar-card",{backgroundColor:St.colors.card,borderRadius:St.radius.large,boxShadow:St.shadow.sm,padding:St.spacing.lg},{"(max-width: 768px)":{padding:St.spacing.md}}),children:Ze("div",{className:Pt.create("payment-summary",{display:"flex",flex:"1",flexDirection:"column",gap:"1rem"}),children:[Ze("h3",{className:Pt.create("cart-summary-title",{fontSize:St.fontSize.large,fontWeight:"600",marginBottom:St.spacing.sm,color:St.colors.foreground}),children:"Payment Details"}),ne&&Ze("div",{className:Pt.create("summary-section",{paddingBottom:"1rem"}),children:Ze("div",{className:Pt.create("payment-breakdown",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:"monthly"!==ne.payment_frequency?Ze(C,{children:[(null===(d=ne.metadata)||void 0===d?void 0:d.gateway_fee)&&parseFloat(ne.metadata.gateway_fee)>0&&Ze(va,{label:pa(ne.gateway_code,null===(u=ne.metadata)||void 0===u?void 0:u.gateway_method),value:gs(parseFloat(ne.metadata.gateway_fee))}),Ze(va,{label:"Total Due Today:",value:gs(parseFloat(ne.amount.due_today)),isTotal:!0})]}):Ze(C,{children:[(null===(h=ne.metadata)||void 0===h?void 0:h.gateway_fee)&&parseFloat(ne.metadata.gateway_fee)>0&&Ze(va,{label:pa(ne.gateway_code,null===(m=ne.metadata)||void 0===m?void 0:m.gateway_method),value:gs(parseFloat(ne.metadata.gateway_fee))}),ne.amount.total&&Ze(va,{label:"Total Payable:",value:gs(parseFloat(ne.amount.total))}),Ze(va,{label:"Due Today:",value:gs(parseFloat(ne.amount.due_today))}),ne.amount.monthly&&(null===(f=ne.metadata)||void 0===f?void 0:f.number_of_instalments)&&ne.metadata.number_of_instalments>1&&Ze(va,{label:"Remaining payments:",value:`${ne.metadata.number_of_instalments-1} x ${gs(parseFloat(ne.amount.monthly))}`})]})})}),Ze(ls,{onClick:async()=>{var e,t,n,r,i,o;if(!g)return;const s=g.calculations.length>0,a=!s;if(s&&!$)return void alert("Please select an excess amount before proceeding.");if(!T)return void alert("Please select a payment method before proceeding.");const l=s?g.calculations.find(e=>e.id===$):null;if(s&&!l)return void alert("Payment configuration error. Please try again.");const c=g.payment_options.find(e=>ga(e)===T);if(!c)return void alert("Payment method not available. Please try again.");const d=c.gateway_code,u=null===(e=c.metadata)||void 0===e?void 0:e.gateway_method;let h="Customer";if(null===(t=g.metadata)||void 0===t?void 0:t.client_name)h=g.metadata.client_name;else if(null===(n=g.metadata)||void 0===n?void 0:n.client_details){const e=g.metadata.client_details;e.first_name&&(h=`${e.first_name} ${e.last_name||""}`.trim())}if(a){if(!p)return void alert("Payment service not available. Please try again.");try{w(!0);const e=await p.initiateFixedPayment(g.payment_link_id,d,h,u);if("auto_renew_confirmed"===e.status)return void J({message:e.message||"Your renewal is confirmed. Your premium funding will continue automatically on the policy start date.",effectiveDate:e.effective_date});if("bank_transfer"===d&&e.transaction_id)return void X({transactionId:e.transaction_id,organisationId:(null===(r=g.organisation)||void 0===r?void 0:r.id)||""});e.gateway_acceptance_url?window.location.href=e.gateway_acceptance_url:alert("Payment initiated successfully")}catch(e){alert(e.message||"Failed to initiate payment")}finally{w(!1)}return}const m=null===(i=g.metadata)||void 0===i?void 0:i.quote_intent_id,f={...m?{quoteIntentId:m}:{paymentLinkId:g.payment_link_id},paymentLinkId:g.payment_link_id,excessId:(null==l?void 0:l.excess_id)||"",gatewayId:d,calculationId:$||"",clientDetails:{legalName:h},metadata:{payment_link_id:g.payment_link_id,payment_type:m?"quote":"rate",gateway_code:d,gateway:d,...u?{gateway_method:u}:{}},...fe&&q?{coverStartDate:q}:{}};if("bank_transfer"!==d)_(f),N(!0);else{if(!p)return void alert("Payment service not available. Please try again.");try{w(!0);const e={...f,returnUrl:window.location.href},t=await p.initiatePayment(e,d);if(!(t.bank_account_name&&t.reference&&t.transaction_id))throw new Error("Invalid bank transfer response");X({transactionId:t.transaction_id,organisationId:(null===(o=g.organisation)||void 0===o?void 0:o.id)||""})}catch(e){alert(e.message||"Failed to initiate bank transfer")}finally{w(!1)}}},disabled:!pe,className:Pt.create("purchase-button",{width:"100%",height:"3rem",fontSize:St.fontSize.default,fontWeight:"600"}),children:pe?"Go to Payment":"Select Options to Continue"})]})})]})})]}),k&&S&&p&&Ze(ua,{isOpen:k,onClose:()=>{N(!1),_(null)},onSuccess:()=>{N(!1),_(null),alert("Payment completed successfully!")},paymentRequest:S,httpClient:p}),ae&&Ze(Is,{type:le,transactionId:ie||M||void 0,isOpen:!0,onClose:()=>{W(!1);const e=new URL(window.location.href);e.searchParams.delete("status"),e.searchParams.delete("transactionId"),e.searchParams.delete("transaction_id"),window.history.replaceState({},"",e.toString())}})]})})}function va({label:e,value:t,isTotal:n=!1,className:r}){return Ze("div",{className:jt(Pt.create("summary-item",{display:"flex",justifyContent:"space-between",alignItems:"center"}),r),children:[Ze("span",{className:Pt.create("summary-label",{color:St.colors.mutedForeground,fontSize:St.fontSize.small}),children:e}),Ze("span",{className:Pt.create("summary-value",{fontWeight:n?"600":"500",color:St.colors.foreground,fontSize:n?St.fontSize.large:"inherit"}),children:t})]})}function wa({products:e,onSelectProduct:t}){const[n,r]=lt(null),i=(e,t)=>{t&&(t.preventDefault(),t.stopPropagation()),r(e)};return Ze(ss,{title:"Select cover",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze("div",{className:Pt.create("product-selection-layout",{display:"flex",justifyContent:"center",width:"100%"}),children:Ze("div",{className:Pt.create("product-selection-card",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,display:"flex",flexDirection:"column",width:"100%",maxWidth:"600px"}),children:[Ze("div",{className:Pt.create("product-selection-header",{paddingInline:St.spacing.xl,paddingTop:St.spacing.xl,paddingBottom:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("h2",{className:Pt.create("product-selection-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"1.75rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.125rem"}}),children:"Select Your Cover"}),Ze("p",{className:Pt.create("product-selection-description",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:"What type of vessel are you insuring?"}),Ze("hr",{className:Pt.create("product-selection-header-border",{marginTop:St.spacing.lg,borderColor:St.colors.border})})]}),Ze("div",{className:Pt.create("product-selection-content",{paddingInline:St.spacing.xl,paddingBottom:St.spacing.xl},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingBottom:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingBottom:St.spacing.md}}),children:[0===e.length?Ze("div",{className:Pt.create("no-products-placeholder",{padding:"2rem",textAlign:"center",border:`1px dashed ${St.colors.border}`,borderRadius:St.radius.default,backgroundColor:St.colors.muted}),children:[Ze("div",{style:{marginBottom:St.spacing.default},children:Ze("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",style:{margin:"0 auto",opacity:.5},children:[Ze("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),Ze("polyline",{points:"14 2 14 8 20 8"})]})}),Ze("p",{className:Pt.create("placeholder-text",{color:St.colors.mutedForeground,margin:"0"}),children:"No products available for quoting."})]}):Ze("div",{className:Pt.create("product-options-container",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:e.map(e=>Ze(ba,{product:e,isSelected:(null==n?void 0:n.id)===e.id,onSelect:i},e.id))}),e.length>0&&Ze("div",{className:Pt.create("product-selection-actions",{marginTop:St.spacing.lg}),children:Ze(ls,{onClick:()=>{n&&t(n)},disabled:!n,className:Pt.create("product-selection-continue-button",{width:"100%"}),children:"Continue"})})]})]})})})})}function ba({product:e,isSelected:t,onSelect:n}){return Ze("div",{className:jt(Pt.create("product-option-row",{borderRadius:St.radius.default,padding:"0.75rem 1rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",alignItems:"center",gap:"1rem"},{"(max-width: 480px)":{padding:"0.625rem 0.75rem"}}),t?Pt.create("product-option-row-selected",{border:`2px solid ${St.colors.primary}`,backgroundColor:St.colors.accent}):Pt.create("product-option-row-unselected",{border:`2px solid ${St.colors.border}`,backgroundColor:St.colors.card})),onClick:t=>n(e,t),role:"button",tabIndex:0,onKeyPress:t=>{"Enter"!==t.key&&" "!==t.key||n(e,t)},children:[Ze(fs,{selected:t}),Ze("div",{className:Pt.create("product-option-content",{display:"flex",alignItems:"center",justifyContent:"space-between",flex:"1",gap:"1rem"}),children:[Ze("div",{className:Pt.create("product-option-info",{display:"flex",flexDirection:"column"}),children:[e.description&&Ze("div",{className:Pt.create("product-option-description",{fontSize:St.fontSize.default,fontWeight:"500",color:St.colors.foreground}),children:e.description}),Ze("div",{className:Pt.create("product-option-name",{fontSize:St.fontSize.small,color:St.colors.mutedForeground}),children:e.name})]}),e.icon_svg&&Ze("div",{className:Pt.create("product-option-icon",{width:"2.5rem",height:"2.5rem",flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center",color:t?St.colors.primary:St.colors.mutedForeground,transition:"color 150ms ease"}),dangerouslySetInnerHTML:{H:e.icon_svg.replace(/^<svg(?![^>]*\bwidth\b)/,'<svg width="100%" height="100%"')}})]})]})}function xa(){var e,t;const n=qt(),{paymentLinkConfig:r,availableProducts:i,formStateManager:o}=n;if(i&&!o)return Ze(wa,{products:i,onSelectProduct:()=>{}});if(r)return Ze(ya,{paymentLinkId:r.paymentLinkId,signedUrl:r.signedUrl});const s=new URLSearchParams(window.location.search),a=s.get("p")||s.get("pl_ref");if(a&&!o)return Ze(ya,{paymentLinkId:a});const l=window.location.pathname,c=l.match(/\/pay\/([a-f0-9-]+)/);if(c&&c[1])return Ze(ya,{paymentLinkId:c[1],signedUrl:window.location.href});const d=l.match(/\/payments\/bank-transfer\/([a-f0-9-]+)/),u=s.get("orgId");if(d&&d[1]&&u)return Ze(ha,{transactionId:d[1],organisationId:u});const{isCalculating:h,results:m,quoteIntent:f}=Ft(e=>({isCalculating:null==e?void 0:e.getIsCalculating(),results:null==e?void 0:e.getCalculationResult(),quoteIntent:null==e?void 0:e.getQuoteIntent(),fsm:e})),p="hold"===(null==f?void 0:f.status),g=null===(e=null==f?void 0:f.payment_transactions)||void 0===e?void 0:e.find(e=>"bank_transfer"===e.gateway_code&&"pending"===e.status),y="paid"===(null==f?void 0:f.status)||"completed"===(null==f?void 0:f.status);return h?Ze(as,{title:"Calculating premium",message:"Crunching the numbers now"}):p&&g&&(null===(t=null==f?void 0:f.organisation)||void 0===t?void 0:t.id)?Ze(ha,{transactionId:g.id,organisationId:f.organisation.id,allowCancel:!0}):y?Ze(da,{}):m?Ze(Hs,{results:m}):Ze(ca,{})}function ka(e){return Ze(Bt,{...e,children:Ze(xa,{})})}function Na({reference:e,productName:t,firstName:n,lastUpdated:r,onContinue:i,onStartFresh:o}){const[s,a]=lt(null);return Ze(ss,{title:"Resume Quote",noSubscription:!0,hideHeader:!0,children:Ze(At,{children:Ze("div",{className:Pt.create("resume-prompt-layout",{display:"flex",justifyContent:"center",width:"100%"}),children:Ze("div",{className:Pt.create("resume-prompt-card",{backgroundColor:St.colors.card,boxShadow:St.shadow.sm,borderRadius:St.radius.large,display:"flex",flexDirection:"column",width:"100%",maxWidth:"600px"}),children:[Ze("div",{className:Pt.create("resume-prompt-header",{paddingInline:St.spacing.xl,paddingTop:St.spacing.xl,paddingBottom:St.spacing.lg},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingTop:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingTop:St.spacing.md}}),children:[Ze("h2",{className:Pt.create("resume-prompt-title",{margin:"0",marginBottom:St.spacing.sm,fontSize:"1.75rem",fontWeight:"700",color:St.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.125rem"}}),children:"Existing Quote Found"}),Ze("p",{className:Pt.create("resume-prompt-description",{margin:"0",fontSize:St.fontSize.default,lineHeight:"1.6",color:St.colors.foreground,opacity:"0.9"}),children:"There is a quote in progress. Would you like to continue where you left off or start a new quote?"}),(e||t||n||r)&&Ze("div",{className:Pt.create("resume-prompt-details",{marginTop:St.spacing.md,padding:St.spacing.md,backgroundColor:St.colors.background,borderRadius:St.radius.default,display:"flex",flexDirection:"column",gap:St.spacing.sm}),children:[t&&Ze("div",{className:Pt.create("resume-prompt-detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("resume-prompt-detail-label",{fontSize:St.fontSize.small,color:St.colors.foreground,opacity:"0.6"}),children:"Product"}),Ze("span",{className:Pt.create("resume-prompt-detail-value",{fontSize:St.fontSize.small,fontWeight:"600",color:St.colors.foreground}),children:t})]}),n&&Ze("div",{className:Pt.create("resume-prompt-detail-row-name",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("resume-prompt-detail-label-name",{fontSize:St.fontSize.small,color:St.colors.foreground,opacity:"0.6"}),children:"Client"}),Ze("span",{className:Pt.create("resume-prompt-detail-value-name",{fontSize:St.fontSize.small,fontWeight:"600",color:St.colors.foreground}),children:n})]}),e&&Ze("div",{className:Pt.create("resume-prompt-detail-row-ref",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("resume-prompt-detail-label-ref",{fontSize:St.fontSize.small,color:St.colors.foreground,opacity:"0.6"}),children:"Reference"}),Ze("span",{className:Pt.create("resume-prompt-detail-value-ref",{fontSize:St.fontSize.small,fontWeight:"600",color:St.colors.foreground}),children:e})]}),r&&Ze("div",{className:Pt.create("resume-prompt-detail-row-date",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Ze("span",{className:Pt.create("resume-prompt-detail-label-date",{fontSize:St.fontSize.small,color:St.colors.foreground,opacity:"0.6"}),children:"Last updated"}),Ze("span",{className:Pt.create("resume-prompt-detail-value-date",{fontSize:St.fontSize.small,fontWeight:"600",color:St.colors.foreground}),children:r})]})]}),Ze("hr",{className:Pt.create("resume-prompt-header-border",{marginTop:St.spacing.lg,borderColor:St.colors.border})})]}),Ze("div",{className:Pt.create("resume-prompt-content",{paddingInline:St.spacing.xl,paddingBottom:St.spacing.xl,display:"flex",flexDirection:"column",gap:St.spacing.md},{"(max-width: 768px)":{paddingInline:St.spacing.lg,paddingBottom:St.spacing.lg},"(max-width: 480px)":{paddingInline:St.spacing.md,paddingBottom:St.spacing.md}}),children:[Ze(ls,{onClick:()=>{a("continue"),i()},loading:"continue"===s,disabled:null!==s,className:Pt.create("resume-prompt-continue-btn",{width:"100%"}),children:"Continue where I left off"}),Ze(ls,{variant:"outline",onClick:()=>{a("fresh"),o()},loading:"fresh"===s,disabled:null!==s,className:Pt.create("resume-prompt-fresh-btn",{width:"100%"}),children:"Start a new quote"})]})]})})})})}class Sa extends _{constructor(e){super(e),this.state={hasError:!1}}componentDidCatch(t,n){e();try{Promise.resolve().then(function(){return Dh}).then(({captureException:e,addBreadcrumb:r,isSentryInitialized:i})=>{i()&&(r({message:"Component error",category:"ui",level:"error",data:{componentStack:n.componentStack}}),e(t,{componentStack:n.componentStack}))}).catch(()=>{})}catch(e){}const r=xe("initialization",t,"A component error occurred");this.setState({hasError:!0,error:r})}render(){if(this.state.hasError){const e=this.state.error;return Te(e)?Ze(us,{message:e.message,organisation:e.organisation}):Ze(cs,{error:e})}return this.props.children}}function Ca({config:t,initializeFormContext:n}){const[r,i]=lt({type:"loading",message:"Loading application..."}),o=n=>{if(n.resumePrompt)return e(),void i({type:"resume_prompt",resumeData:n.resumePrompt});const r=n.availableProducts&&n.availableProducts.length>0;if(r&&!n.formStateManager)return e(),void i({type:"product_selection",products:n.availableProducts});if(!("payment"===t.mode||n.paymentLinkConfig||r||n.formStateManager&&"function"==typeof n.formStateManager.getFormProgress))throw new Error("FormStateManager was not properly initialized");e(),i({type:"success",formContextProps:n})},s=async(r="Loading application...")=>{i({type:"loading",message:r});try{e();const r=await n(t);o(r)}catch(t){let n;e(),n=t&&"object"==typeof t&&"type"in t&&"MAINTENANCE_ERROR"===t.type||t&&"object"==typeof t&&"statusCode"in t&&503===t.statusCode||t&&"object"==typeof t&&"status"in t&&503===t.status?xe("maintenance",t):xe("initialization",t),e((n.type,n.severity,n.statusCode)),i({type:"error",error:n})}};ct(()=>{t.isolateStyles&&$t(),s()},[t,n]);const a=async t=>{if("resume_prompt"!==r.type)return;const{onContinue:n,onStartFresh:s}=r.resumeData;i({type:"loading",message:"continue"===t?"Loading your quote...":"Starting a new quote..."});try{const e="continue"===t?await n():await s();o(e)}catch(t){e();const n=xe("initialization",t);i({type:"error",error:n})}},l=async t=>{e(t.code),localStorage.setItem("insure-os-selected-product",t.code),await s("Loading...")};return Ze(Sa,{children:Ze("div",{className:Pt.create("root",{fontFamily:St.fontFamily,backgroundColor:St.colors.background,minHeight:"100vh",color:St.colors.foreground,maxWidth:"100vw",overflowX:"hidden",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"}),children:function(){switch(r.type){case"loading":return Ze(as,{message:r.message});case"error":return Te(r.error)?Ze(us,{message:r.error.message,organisation:r.error.organisation}):Ze(cs,{error:r.error});case"product_selection":return Ze(wa,{products:r.products,onSelectProduct:l});case"resume_prompt":return Ze(Na,{reference:r.resumeData.reference,productName:r.resumeData.productName,firstName:r.resumeData.firstName,lastUpdated:r.resumeData.lastUpdated,onContinue:()=>a("continue"),onStartFresh:()=>a("fresh")});case"success":return Ze(ka,{...r.formContextProps});default:return Ze(cs,{})}}()})})}const _a="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,$a=globalThis,Ia="10.48.0";function Ta(){return Ea($a),$a}function Ea(e){const t=e.oe=e.oe||{};return t.version=t.version||Ia,t[Ia]=t[Ia]||{}}function Pa(e,t,n=$a){const r=n.oe=n.oe||{},i=r[Ia]=r[Ia]||{};return i[e]||(i[e]=t())}const za=["debug","info","warn","error","log","assert","trace"],Da={};function Ra(e){if(!("console"in $a))return e();const t=$a.console,n={},r=Object.keys(Da);r.forEach(e=>{const r=Da[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function Ma(){return ja().enabled}function Oa(e,...t){_a&&Ma()&&Ra(()=>{$a.console[e](`Sentry Logger [${e}]:`,...t)})}function ja(){return _a?Pa("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Wa=function(){ja().enabled=!0},Aa=function(...e){Oa("log",...e)},La=function(...e){Oa("warn",...e)},Ba=function(...e){Oa("error",...e)},qa="?",Fa=/\(error: (.*)\)/,Ha=/captureMessage|captureException/;function Ua(...e){const t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{const i=[],o=e.split("\n");for(let e=n;e<o.length;e++){let n=o[e];n.length>1024&&(n=n.slice(0,1024));const s=Fa.test(n)?n.replace(Fa,"$1"):n;if(!s.includes("Error: ")){for(const e of t){const t=e(s);if(t){i.push(t);break}}if(i.length>=50+r)break}}return function(e){if(!e.length)return[];const t=Array.from(e);return/sentryWrapped/.test(Ya(t).function||"")&&t.pop(),t.reverse(),Ha.test(Ya(t).function||"")&&(t.pop(),Ha.test(Ya(t).function||"")&&t.pop()),t.slice(0,50).map(e=>({...e,filename:e.filename||Ya(t).filename,function:e.function||qa}))}(i.slice(r))}}function Ya(e){return e[e.length-1]||{}}const Za="<anonymous>";function Ga(e){try{return e&&"function"==typeof e&&e.name||Za}catch{return Za}}function Va(e){const t=e.exception;if(t){const e=[];try{return t.values.forEach(t=>{t.stacktrace.frames&&e.push(...t.stacktrace.frames)}),e}catch{return}}}function Qa(e){return"se"in e&&e.se?"[VueVNode]":"[VueViewModel]"}const Ja={},Ka={};function Xa(e,t){Ja[e]=Ja[e]||[],Ja[e].push(t)}function el(e,t){if(!Ka[e]){Ka[e]=!0;try{t()}catch(t){_a&&Ba(`Error while instrumenting ${e}`,t)}}}function tl(e,t){const n=e&&Ja[e];if(n)for(const r of n)try{r(t)}catch(t){_a&&Ba(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${Ga(r)}\nError:`,t)}}let nl=null;function rl(){nl=$a.onerror,$a.onerror=function(e,t,n,r,i){return tl("error",{column:r,error:i,line:n,msg:e,url:t}),!!nl&&nl.apply(this,arguments)},$a.onerror.ae=!0}let il=null;function ol(){il=$a.onunhandledrejection,$a.onunhandledrejection=function(e){return tl("unhandledrejection",e),!il||il.apply(this,arguments)},$a.onunhandledrejection.ae=!0}const sl={}.toString;function al(e){switch(sl.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return yl(e,Error)}}function ll(e,t){return sl.call(e)===`[object ${t}]`}function cl(e){return ll(e,"ErrorEvent")}function dl(e){return ll(e,"DOMError")}function ul(e){return ll(e,"String")}function hl(e){return"object"==typeof e&&null!==e&&"le"in e&&"ce"in e}function ml(e){return null===e||hl(e)||"object"!=typeof e&&"function"!=typeof e}function fl(e){return ll(e,"Object")}function pl(e){return"undefined"!=typeof Event&&yl(e,Event)}function gl(e){return Boolean(e?.then&&"function"==typeof e.then)}function yl(e,t){try{return e instanceof t}catch{return!1}}function vl(e){return!("object"!=typeof e||null===e||!(e.de||e.ue||e.se))}function wl(e){return"undefined"!=typeof Request&&yl(e,Request)}const bl=$a;function xl(e,t={}){if(!e)return"<unknown>";try{let n=e;const r=5,i=[];let o=0,s=0;const a=" > ",l=a.length;let c;const d=Array.isArray(t)?t:t.keyAttrs,u=!Array.isArray(t)&&t.maxStringLength||80;for(;n&&o++<r&&(c=kl(n,d),!("html"===c||o>1&&s+i.length*l+c.length>=u));)i.push(c),s+=c.length,n=n.parentNode;return i.reverse().join(a)}catch{return"<unknown>"}}function kl(e,t){const n=e,r=[];if(!n?.tagName)return"";if(bl.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());const i=t?.length?t.filter(e=>n.getAttribute(e)).map(e=>[e,n.getAttribute(e)]):null;if(i?.length)i.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else{n.id&&r.push(`#${n.id}`);const e=n.className;if(e&&ul(e)){const t=e.split(/\s+/);for(const e of t)r.push(`.${e}`)}}for(const e of["aria-label","type","name","title","alt"]){const t=n.getAttribute(e);t&&r.push(`[${e}="${t}"]`)}return r.join("")}function Nl(){try{return bl.document.location.href}catch{return""}}function Sl(e,t,n){if(!(t in e))return;const r=e[t];if("function"!=typeof r)return;const i=n(r);"function"==typeof i&&_l(i,r);try{e[t]=i}catch{_a&&Aa(`Failed to replace method "${t}" in object`,e)}}function Cl(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{_a&&Aa(`Failed to add non-enumerable property "${t}" to object`,e)}}function _l(e,t){try{const n=t.prototype||{};e.prototype=t.prototype=n,Cl(e,"__sentry_original__",t)}catch{}}function $l(e){return e.he}function Il(e){if(al(e))return{message:e.message,name:e.name,stack:e.stack,...El(e)};if(pl(e)){const t={type:e.type,target:Tl(e.target),currentTarget:Tl(e.currentTarget),...El(e)};return"undefined"!=typeof CustomEvent&&yl(e,CustomEvent)&&(t.detail=e.detail),t}return e}function Tl(e){try{return"undefined"!=typeof Element&&yl(e,Element)?xl(e):{}.toString.call(e)}catch{return"<unknown>"}}function El(e){return"object"==typeof e&&null!==e?Object.fromEntries(Object.entries(e)):{}}let Pl,zl,Dl;function Rl(e){if(void 0!==Pl)return Pl?Pl(e):e();const t=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=$a;return t in n&&"function"==typeof n[t]?(Pl=n[t],Pl(e)):(Pl=null,e())}function Ml(){return Rl(()=>Math.random())}function Ol(){return Rl(()=>Date.now())}function jl(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function Wl(e,t){if(!Array.isArray(e))return"";const n=[];for(let t=0;t<e.length;t++){const r=e[t];try{vl(r)?n.push(Qa(r)):n.push(String(r))}catch{n.push("[value cannot be serialized]")}}return n.join(t)}function Al(e,t,n=!1){return!!ul(e)&&(ll(t,"RegExp")?t.test(e):ul(t)?n?e===t:e.includes(t):"function"==typeof t&&t(e))}function Ll(e,t=[],n=!1){return t.some(t=>Al(e,t,n))}function Bl(e=function(){const e=$a;return e.crypto||e.msCrypto}()){try{if(e?.randomUUID)return Rl(()=>e.randomUUID()).replace(/-/g,"")}catch{}return zl||(zl=[1e7]+1e3+4e3+8e3+1e11),zl.replace(/[018]/g,e=>(e^(16*Ml()&15)>>e/4).toString(16))}function ql(e){return e.exception?.values?.[0]}function Fl(e){const{message:t,event_id:n}=e;if(t)return t;const r=ql(e);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function Hl(e,t){const n=e.exception=e.exception||{},r=n.values=n.values||[],i=r[0]=r[0]||{};i.value||(i.value=t||""),i.type||(i.type="Error")}function Ul(e,t){const n=ql(e);if(!n)return;const r=n.mechanism;if(n.mechanism={type:"generic",handled:!0,...r,...t},t&&"data"in t){const e={...r?.data,...t.data};n.mechanism.data=e}}function Yl(e){if(function(e){try{return e.me}catch{}}(e))return!0;try{Cl(e,"__sentry_captured__",!0)}catch{}return!1}function Zl(){return Ol()/1e3}function Gl(){return(Dl??(Dl=function(){const{performance:e}=$a;if(!e?.now||!e.timeOrigin)return Zl;const t=e.timeOrigin;return()=>(t+Rl(()=>e.now()))/1e3}()))()}function Vl(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||Gl(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:Bl()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function Ql(e,t,n=2){if(!t||"object"!=typeof t||n<=0)return t;if(e&&0===Object.keys(t).length)return e;const r={...e};for(const e in t)({}).hasOwnProperty.call(t,e)&&(r[e]=Ql(r[e],t[e],n-1));return r}function Jl(){return Bl()}function Kl(){return Bl().substring(16)}const Xl="_sentrySpan";function ec(e,t){t?Cl(e,Xl,t):delete e[Xl]}function tc(e){return e[Xl]}class nc{constructor(){this.fe=!1,this.pe=[],this.ge=[],this.ye=[],this.ve=[],this.we={},this.be={},this.xe={},this.ke={},this.Ne={},this.Se={},this.Ce={traceId:Jl(),sampleRand:Ml()}}clone(){const e=new nc;return e.ye=[...this.ye],e.be={...this.be},e.xe={...this.xe},e.ke={...this.ke},e.Ne={...this.Ne},this.Ne.flags&&(e.Ne.flags={values:[...this.Ne.flags.values]}),e.we=this.we,e._e=this._e,e.$e=this.$e,e.Ie=this.Ie,e.Te=this.Te,e.ge=[...this.ge],e.ve=[...this.ve],e.Se={...this.Se},e.Ce={...this.Ce},e.Ee=this.Ee,e.Pe=this.Pe,e.ze=this.ze,ec(e,tc(this)),e}setClient(e){this.Ee=e}setLastEventId(e){this.Pe=e}getClient(){return this.Ee}lastEventId(){return this.Pe}addScopeListener(e){this.pe.push(e)}addEventProcessor(e){return this.ge.push(e),this}setUser(e){return this.we=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.$e&&Vl(this.$e,{user:e}),this.De(),this}getUser(){return this.we}setConversationId(e){return this.ze=e||void 0,this.De(),this}setTags(e){return this.be={...this.be,...e},this.De(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this.xe={...this.xe,...e},this.De(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this.xe&&(delete this.xe[e],this.De()),this}setExtras(e){return this.ke={...this.ke,...e},this.De(),this}setExtra(e,t){return this.ke={...this.ke,[e]:t},this.De(),this}setFingerprint(e){return this.Te=e,this.De(),this}setLevel(e){return this._e=e,this.De(),this}setTransactionName(e){return this.Ie=e,this.De(),this}setContext(e,t){return null===t?delete this.Ne[e]:this.Ne[e]=t,this.De(),this}setSession(e){return e?this.$e=e:delete this.$e,this.De(),this}getSession(){return this.$e}update(e){if(!e)return this;const t="function"==typeof e?e(this):e,n=t instanceof nc?t.getScopeData():fl(t)?e:void 0,{tags:r,attributes:i,extra:o,user:s,contexts:a,level:l,fingerprint:c=[],propagationContext:d,conversationId:u}=n||{};return this.be={...this.be,...r},this.xe={...this.xe,...i},this.ke={...this.ke,...o},this.Ne={...this.Ne,...a},s&&Object.keys(s).length&&(this.we=s),l&&(this._e=l),c.length&&(this.Te=c),d&&(this.Ce=d),u&&(this.ze=u),this}clear(){return this.ye=[],this.be={},this.xe={},this.ke={},this.we={},this.Ne={},this._e=void 0,this.Ie=void 0,this.Te=void 0,this.$e=void 0,this.ze=void 0,ec(this,void 0),this.ve=[],this.setPropagationContext({traceId:Jl(),sampleRand:Ml()}),this.De(),this}addBreadcrumb(e,t){const n="number"==typeof t?t:100;if(n<=0)return this;const r={timestamp:Zl(),...e,message:e.message?jl(e.message,2048):e.message};return this.ye.push(r),this.ye.length>n&&(this.ye=this.ye.slice(-n),this.Ee?.recordDroppedEvent("buffer_overflow","log_item")),this.De(),this}getLastBreadcrumb(){return this.ye[this.ye.length-1]}clearBreadcrumbs(){return this.ye=[],this.De(),this}addAttachment(e){return this.ve.push(e),this}clearAttachments(){return this.ve=[],this}getScopeData(){return{breadcrumbs:this.ye,attachments:this.ve,contexts:this.Ne,tags:this.be,attributes:this.xe,extra:this.ke,user:this.we,level:this._e,fingerprint:this.Te||[],eventProcessors:this.ge,propagationContext:this.Ce,sdkProcessingMetadata:this.Se,transactionName:this.Ie,span:tc(this),conversationId:this.ze}}setSDKProcessingMetadata(e){return this.Se=Ql(this.Se,e,2),this}setPropagationContext(e){return this.Ce=e,this}getPropagationContext(){return this.Ce}captureException(e,t){const n=t?.event_id||Bl();if(!this.Ee)return _a&&La("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this.Ee.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},this),n}captureMessage(e,t,n){const r=n?.event_id||Bl();if(!this.Ee)return _a&&La("No client configured on scope - will not capture message!"),r;const i=n?.syntheticException??new Error(e);return this.Ee.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r},this),r}captureEvent(e,t){const n=e.event_id||t?.event_id||Bl();return this.Ee?(this.Ee.captureEvent(e,{...t,event_id:n},this),n):(_a&&La("No client configured on scope - will not capture event!"),n)}De(){this.fe||(this.fe=!0,this.pe.forEach(e=>{e(this)}),this.fe=!1)}}const rc=e=>e instanceof Promise&&!e[ic],ic=Symbol("chained PromiseLike");class oc{constructor(e,t){let n,r;n=e||new nc,r=t||new nc,this.Re=[{scope:n}],this.Me=r}withScope(e){const t=this.Oe();let n;try{n=e(t)}catch(e){throw this.je(),e}return gl(n)?((e,t,n)=>{const r=e.then(e=>(t(),e),e=>{throw n(),e});return rc(r)&&rc(e)?r:((e,t)=>{let n=!1;for(const r in e){if(r in t)continue;n=!0;const i=e[r];"function"==typeof i?Object.defineProperty(t,r,{value:(...t)=>i.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[r]=i}return n&&Object.assign(t,{[ic]:!0}),t})(e,r)})(n,()=>this.je(),()=>this.je()):(this.je(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.Me}getStackTop(){return this.Re[this.Re.length-1]}Oe(){const e=this.getScope().clone();return this.Re.push({client:this.getClient(),scope:e}),e}je(){return!(this.Re.length<=1||!this.Re.pop())}}function sc(){const e=Ea(Ta());return e.stack=e.stack||new oc(Pa("defaultCurrentScope",()=>new nc),Pa("defaultIsolationScope",()=>new nc))}function ac(e){return sc().withScope(e)}function lc(e,t){const n=sc();return n.withScope(()=>(n.getStackTop().scope=e,t(e)))}function cc(e){return sc().withScope(()=>e(sc().getIsolationScope()))}function dc(e){const t=Ea(e);return t.acs?t.acs:{withIsolationScope:cc,withScope:ac,withSetScope:lc,withSetIsolationScope:(e,t)=>cc(t),getCurrentScope:()=>sc().getScope(),getIsolationScope:()=>sc().getIsolationScope()}}function uc(){return dc(Ta()).getCurrentScope()}function hc(){return dc(Ta()).getIsolationScope()}function mc(...e){const t=dc(Ta());if(2===e.length){const[n,r]=e;return n?t.withSetScope(n,r):t.withScope(r)}return t.withScope(e[0])}function fc(){return uc().getClient()}function pc(e){const t=e.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:i}=t,o={trace_id:n,span_id:i||Kl()};return r&&(o.parent_span_id=r),o}const gc="sentry.profile_id",yc="sentry.exclusive_time";function vc(e){if(e){if("object"==typeof e&&"deref"in e&&"function"==typeof e.deref)try{return e.deref()}catch{return}return e}}function wc(e){const t=e;return{scope:t.We,isolationScope:vc(t.Ae)}}function bc(e){return e.split(",").map(e=>{const t=e.indexOf("=");return-1===t?[]:[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,n])=>(t&&n&&(e[t]=n),e),{})}const xc=/^o(\d+)\./,kc=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Nc(e,t=!1){const{host:n,path:r,pass:i,port:o,projectId:s,protocol:a,publicKey:l}=e;return`${a}://${l}${t&&i?`:${i}`:""}@${n}${o?`:${o}`:""}/${r?`${r}/`:r}${s}`}function Sc(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function Cc(e){const t=e.getOptions(),{host:n}=e.getDsn()||{};let r;return t.orgId?r=String(t.orgId):n&&(r=function(e){const t=e.match(xc);return t?.[1]}(n)),r}let _c=!1;function $c(e){const{spanId:t,traceId:n,isRemote:r}=e.spanContext(),i=r?t:Pc(e).parent_span_id,o=wc(e).scope;return{parent_span_id:i,span_id:r?o?.getPropagationContext().propagationSpanId||Kl():t,trace_id:n}}function Ic(e){return e&&e.length>0?e.map(({context:{spanId:e,traceId:t,traceFlags:n,...r},attributes:i})=>({span_id:e,trace_id:t,sampled:1===n,attributes:i,...r})):void 0}function Tc(e){return"number"==typeof e?Ec(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?Ec(e.getTime()):Gl()}function Ec(e){return e>9999999999?e/1e3:e}function Pc(e){if(function(e){return"function"==typeof e.getSpanJSON}(e))return e.getSpanJSON();const{spanId:t,traceId:n}=e.spanContext();if(function(e){const t=e;return!!(t.attributes&&t.startTime&&t.name&&t.endTime&&t.status)}(e)){const{attributes:r,startTime:i,name:o,endTime:s,status:a,links:l}=e;return{span_id:t,trace_id:n,data:r,description:o,parent_span_id:zc(e),start_timestamp:Tc(i),timestamp:Tc(s)||void 0,status:Dc(a),op:r["sentry.op"],origin:r["sentry.origin"],links:Ic(l)}}return{span_id:t,trace_id:n,start_timestamp:0,data:{}}}function zc(e){return"parentSpanId"in e?e.parentSpanId:"parentSpanContext"in e?e.parentSpanContext?.spanId:void 0}function Dc(e){if(e&&0!==e.code)return 1===e.code?"ok":e.message||"internal_error"}const Rc=function(e){return e.Le||e};function Mc(){_c||(Ra(()=>{}),_c=!0)}function Oc(e){Aa(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function jc(e,t){if(!t?.length||!e.description)return!1;for(const n of t){if(Ac(n)){if(Al(e.description,n))return _a&&Oc(e),!0;continue}if(!n.name&&!n.op)continue;const t=!n.name||Al(e.description,n.name),r=!n.op||e.op&&Al(e.op,n.op);if(t&&r)return _a&&Oc(e),!0}return!1}function Wc(e,t){const n=t.parent_span_id,r=t.span_id;if(n)for(const t of e)t.parent_span_id===r&&(t.parent_span_id=n)}function Ac(e){return"string"==typeof e||e instanceof RegExp}const Lc="production";function Bc(e,t){const n=t.getOptions(),{publicKey:r}=t.getDsn()||{},i={environment:n.environment||Lc,release:n.release,public_key:r,trace_id:e,org_id:Cc(t)};return t.emit("createDsc",i),i}function qc(e){const t=fc();if(!t)return{};const n=Rc(e),r=Pc(n),i=r.data,o=n.spanContext().traceState,s=o?.get("sentry.sample_rate")??i["sentry.sample_rate"]??i["sentry.previous_trace_sample_rate"];function a(e){return"number"!=typeof s&&"string"!=typeof s||(e.sample_rate=`${s}`),e}const l=n.Be;if(l)return a(l);const c=o?.get("sentry.dsc"),d=c&&function(e){const t=function(e){if(e&&(ul(e)||Array.isArray(e)))return Array.isArray(e)?e.reduce((e,t)=>{const n=bc(t);return Object.entries(n).forEach(([t,n])=>{e[t]=n}),e},{}):bc(e)}(e);if(!t)return;const n=Object.entries(t).reduce((e,[t,n])=>(t.startsWith("sentry-")&&(e[t.slice(7)]=n),e),{});return Object.keys(n).length>0?n:void 0}(c);if(d)return a(d);const u=Bc(e.spanContext().traceId,t),h=i["sentry.source"]??i["sentry.span.source"],m=r.description;return"url"!==h&&m&&(u.transaction=m),function(){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const e=fc()?.getOptions();return!(!e||null==e.tracesSampleRate&&!e.tracesSampler)}()&&(u.sampled=String(function(e){const{traceFlags:t}=e.spanContext();return 1===t}(n)),u.sample_rand=o?.get("sentry.sample_rand")??wc(n).scope?.getPropagationContext().sampleRand.toString()),a(u),t.emit("createDsc",u,n),u}function Fc(e,t=100,n=1/0){try{return Uc("",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function Hc(e,t=3,n=102400){const r=Fc(e,t);return i=r,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(i))>n?Hc(e,t-1,n):r;var i}function Uc(e,t,n=1/0,r=1/0,i=function(){const e=new WeakSet;return[function(t){return!!e.has(t)||(e.add(t),!1)},function(t){e.delete(t)}]}()){const[o,s]=i;if(null==t||["boolean","string"].includes(typeof t)||"number"==typeof t&&Number.isFinite(t))return t;const a=function(e,t){try{if("domain"===e&&t&&"object"==typeof t&&t.qe)return"[Domain]";if("domainEmitter"===e)return"[DomainEmitter]";if("undefined"!=typeof global&&t===global)return"[Global]";if("undefined"!=typeof window&&t===window)return"[Window]";if("undefined"!=typeof document&&t===document)return"[Document]";if(vl(t))return Qa(t);if(fl(n=t)&&"nativeEvent"in n&&"preventDefault"in n&&"stopPropagation"in n)return"[SyntheticEvent]";if("number"==typeof t&&!Number.isFinite(t))return`[${t}]`;if("function"==typeof t)return`[Function: ${Ga(t)}]`;if("symbol"==typeof t)return`[${String(t)}]`;if("bigint"==typeof t)return`[BigInt: ${String(t)}]`;const r=function(e){const t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:"null prototype"}(t);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(e){return`**non-serializable** (${e})`}var n}(e,t);if(!a.startsWith("[object "))return a;if(t.Fe)return t;const l="number"==typeof t.He?t.He:n;if(0===l)return a.replace("object ","");if(o(t))return"[Circular ~]";const c=t;if(c&&"function"==typeof c.toJSON)try{return Uc("",c.toJSON(),l-1,r,i)}catch{}const d=Array.isArray(t)?[]:{};let u=0;const h=Il(t);for(const e in h){if(!{}.hasOwnProperty.call(h,e))continue;if(u>=r){d[e]="[MaxProperties ~]";break}const t=h[e];d[e]=Uc(e,t,l-1,r,i),u++}return s(t),d}function Yc(e,t=[]){return[e,t]}function Zc(e,t){const[n,r]=e;return[n,[...r,t]]}function Gc(e,t){const n=e[1];for(const e of n)if(t(e,e[0].type))return!0;return!1}function Vc(e){const t=Ea($a);return t.encodePolyfill?t.encodePolyfill(e):(new TextEncoder).encode(e)}function Qc(e){const[t,n]=e;let r=JSON.stringify(t);function i(e){"string"==typeof r?r="string"==typeof e?r+e:[Vc(r),e]:r.push("string"==typeof e?Vc(e):e)}for(const e of n){const[t,n]=e;if(i(`\n${JSON.stringify(t)}\n`),"string"==typeof n||n instanceof Uint8Array)i(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(Fc(n))}i(e)}}return"string"==typeof r?r:function(e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(r)}function Jc(e){const t="string"==typeof e.data?Vc(e.data):e.data;return[{type:"attachment",length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}const Kc={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function Xc(e){return function(e){return e in Kc}(e)?Kc[e]:e}function ed(e){if(!e?.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}function td(e,t){const{extra:n,tags:r,attributes:i,user:o,contexts:s,level:a,sdkProcessingMetadata:l,breadcrumbs:c,fingerprint:d,eventProcessors:u,attachments:h,propagationContext:m,transactionName:f,span:p}=t;nd(e,"extra",n),nd(e,"tags",r),nd(e,"attributes",i),nd(e,"user",o),nd(e,"contexts",s),e.sdkProcessingMetadata=Ql(e.sdkProcessingMetadata,l,2),a&&(e.level=a),f&&(e.transactionName=f),p&&(e.span=p),c.length&&(e.breadcrumbs=[...e.breadcrumbs,...c]),d.length&&(e.fingerprint=[...e.fingerprint,...d]),u.length&&(e.eventProcessors=[...e.eventProcessors,...u]),h.length&&(e.attachments=[...e.attachments,...h]),e.propagationContext={...e.propagationContext,...m}}function nd(e,t,n){e[t]=Ql(e[t],n,1)}function rd(e,t){const n=Pa("globalScope",()=>new nc).getScopeData();return e&&td(n,e.getScopeData()),t&&td(n,t.getScopeData()),n}function id(e){return new sd(t=>{t(e)})}function od(e){return new sd((t,n)=>{n(e)})}class sd{constructor(e){this.Ue=0,this.Ye=[],this.Ze(e)}then(e,t){return new sd((n,r)=>{this.Ye.push([!1,t=>{if(e)try{n(e(t))}catch(e){r(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){r(e)}else r(e)}]),this.Ge()})}catch(e){return this.then(e=>e,e)}finally(e){return new sd((t,n)=>{let r,i;return this.then(t=>{i=!1,r=t,e&&e()},t=>{i=!0,r=t,e&&e()}).then(()=>{i?n(r):t(r)})})}Ge(){if(0===this.Ue)return;const e=this.Ye.slice();this.Ye=[],e.forEach(e=>{e[0]||(1===this.Ue&&e[1](this.Ve),2===this.Ue&&e[2](this.Ve),e[0]=!0)})}Ze(e){const t=(e,t)=>{0===this.Ue&&(gl(t)?t.then(n,r):(this.Ue=e,this.Ve=t,this.Ge()))},n=e=>{t(1,e)},r=e=>{t(2,e)};try{e(n,r)}catch(e){r(e)}}}function ad(e,t,n,r=0){try{const i=ld(t,n,e,r);return gl(i)?i:id(i)}catch(e){return od(e)}}function ld(e,t,n,r){const i=n[r];if(!e||!i)return e;const o=i({...e},t);return _a&&null===o&&Aa(`Event processor "${i.id||"?"}" dropped event`),gl(o)?o.then(e=>ld(e,t,n,r+1)):ld(o,t,n,r+1)}let cd,dd,ud,hd;function md(e,t,n,r,i,o){const{normalizeDepth:s=3,normalizeMaxBreadth:a=1e3}=e,l={...t,event_id:t.event_id||n.event_id||Bl(),timestamp:t.timestamp||Zl()},c=n.integrations||e.integrations.map(e=>e.name);!function(e,t){const{environment:n,release:r,dist:i,maxValueLength:o}=t;e.environment=e.environment||n||Lc,!e.release&&r&&(e.release=r),!e.dist&&i&&(e.dist=i);const s=e.request;s?.url&&o&&(s.url=jl(s.url,o)),o&&e.exception?.values?.forEach(e=>{e.value&&(e.value=jl(e.value,o))})}(l,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(l,c),i&&i.emit("applyFrameMetadata",t),void 0===t.type&&function(e,t){const n=function(e){const t=$a.Qe,n=$a.Je;if(!t&&!n)return{};const r=t?Object.keys(t):[],i=n?Object.keys(n):[];if(hd&&r.length===dd&&i.length===ud)return hd;dd=r.length,ud=i.length,hd={},cd||(cd={});const o=(t,n)=>{for(const r of t){const t=n[r],i=cd?.[r];if(i&&hd&&t)hd[i[0]]=t,cd&&(cd[r]=[i[0],t]);else if(t){const n=e(r);for(let e=n.length-1;e>=0;e--){const i=n[e],o=i?.filename;if(o&&hd&&cd){hd[o]=t,cd[r]=[o,t];break}}}}};return t&&o(r,t),n&&o(i,n),hd}(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=n[e.filename])})})}(l,e.stackParser);const d=function(e,t){if(!t)return e;const n=e?e.clone():new nc;return n.update(t),n}(r,n.captureContext);n.mechanism&&Ul(l,n.mechanism);const u=i?i.getEventProcessors():[],h=rd(o,d),m=[...n.attachments||[],...h.attachments];m.length&&(n.attachments=m),function(e,t){const{fingerprint:n,span:r,breadcrumbs:i,sdkProcessingMetadata:o}=t;!function(e,t){const{extra:n,tags:r,user:i,contexts:o,level:s,transactionName:a}=t;Object.keys(n).length&&(e.extra={...n,...e.extra}),Object.keys(r).length&&(e.tags={...r,...e.tags}),Object.keys(i).length&&(e.user={...i,...e.user}),Object.keys(o).length&&(e.contexts={...o,...e.contexts}),s&&(e.level=s),a&&"transaction"!==e.type&&(e.transaction=a)}(e,t),r&&function(e,t){e.contexts={trace:$c(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:qc(t),...e.sdkProcessingMetadata};const n=Pc(Rc(t)).description;n&&!e.transaction&&"transaction"===e.type&&(e.transaction=n)}(e,r),function(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint.length||delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,i),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,o)}(l,h);const f=[...u,...h.eventProcessors];return(n.data&&!0===n.data.Ke?id(l):ad(f,l,n)).then(e=>(e&&function(e){const t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{n.push({type:"sourcemap",code_file:e,debug_id:t})})}(e),"number"==typeof s&&s>0?function(e,t,n){if(!e)return null;const r={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Fc(e.data,t,n)}}))},...e.user&&{user:Fc(e.user,t,n)},...e.contexts&&{contexts:Fc(e.contexts,t,n)},...e.extra&&{extra:Fc(e.extra,t,n)}};return e.contexts?.trace&&r.contexts&&(r.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(r.contexts.trace.data=Fc(e.contexts.trace.data,t,n))),e.spans&&(r.spans=e.spans.map(e=>({...e,...e.data&&{data:Fc(e.data,t,n)}}))),e.contexts?.flags&&r.contexts&&(r.contexts.flags=Fc(e.contexts.flags,3,n)),r}(e,s,a):e))}function fd(e){return uc().captureException(e,void 0)}function pd(e,t){const n="string"==typeof t?t:void 0,r="string"!=typeof t?{captureContext:t}:void 0;return uc().captureMessage(e,n,r)}function gd(e,t){return uc().captureEvent(e,t)}function yd(e){const t=hc(),{user:n}=rd(t,uc()),{userAgent:r}=$a.navigator||{},i=function(e){const t=Gl(),n={sid:Bl(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return{sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}}}(n)};return e&&Vl(n,e),n}({user:n,...r&&{userAgent:r},...e}),o=t.getSession();return"ok"===o?.status&&Vl(o,{status:"exited"}),vd(),t.setSession(i),i}function vd(){const e=hc(),t=uc().getSession()||e.getSession();t&&function(e){let t={};"ok"===e.status&&(t={status:"exited"}),Vl(e,t)}(t),wd(),e.setSession()}function wd(){const e=hc(),t=fc(),n=e.getSession();n&&t&&t.captureSession(n)}function bd(e=!1){e?vd():wd()}const xd=[];function kd(e){const t=e.defaultIntegrations||[],n=e.integrations;let r;if(t.forEach(e=>{e.isDefaultInstance=!0}),Array.isArray(n))r=[...t,...n];else if("function"==typeof n){const e=n(t);r=Array.isArray(e)?e:[e]}else r=t;return function(e){const t={};return e.forEach(e=>{const{name:n}=e,r=t[n];r&&!r.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)}),Object.values(t)}(r)}function Nd(e,t){for(const n of t)n?.afterAllSetup&&n.afterAllSetup(e)}function Sd(e,t,n){if(n[t.name])_a&&Aa(`Integration skipped because it was already installed: ${t.name}`);else{if(n[t.name]=t,xd.includes(t.name)||"function"!=typeof t.setupOnce||(t.setupOnce(),xd.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),"function"==typeof t.preprocessEvent){const n=t.preprocessEvent.bind(t);e.on("preprocessEvent",(t,r)=>n(t,r,e))}if("function"==typeof t.processEvent){const n=t.processEvent.bind(t),r=Object.assign((t,r)=>n(t,r,e),{id:t.name});e.addEventProcessor(r)}_a&&Aa(`Integration installed: ${t.name}`)}}function Cd(e,t){const n=t??function(e){return _d().get(e)}(e)??[];if(0===n.length)return;const r=e.getOptions(),i=function(e,t,n,r){const i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=Nc(r)),Yc(i,[(o=e,[{type:"log",item_count:o.length,content_type:"application/vnd.sentry.items.log+json"},{items:o}])]);var o}(n,r.Xe,r.tunnel,e.getDsn());_d().set(e,[]),e.emit("flushLogs"),e.sendEnvelope(i)}function _d(){return Pa("clientToLogBufferMap",()=>new WeakMap)}function $d(e,t){const n=t??function(e){return Id().get(e)}(e)??[];if(0===n.length)return;const r=e.getOptions(),i=function(e,t,n,r){const i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=Nc(r)),Yc(i,[(o=e,[{type:"trace_metric",item_count:o.length,content_type:"application/vnd.sentry.items.trace-metric+json"},{items:o}])]);var o}(n,r.Xe,r.tunnel,e.getDsn());Id().set(e,[]),e.emit("flushMetrics"),e.sendEnvelope(i)}function Id(){return Pa("clientToMetricBufferMap",()=>new WeakMap)}function Td(e){return"object"==typeof e&&"function"==typeof e.unref&&e.unref(),e}const Ed=Symbol.for("SentryBufferFullError");function Pd(e=100){const t=new Set;function n(e){t.delete(e)}return{get $(){return Array.from(t)},add:function(r){if(!(t.size<e))return od(Ed);const i=r();return t.add(i),i.then(()=>n(i),()=>n(i)),i},drain:function(e){if(!t.size)return id(!0);const n=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return n;const r=[n,new Promise(t=>Td(setTimeout(()=>t(!1),e)))];return Promise.race(r)}}}function zd(e,t,n=Pd(e.bufferSize||64)){let r={};return{send:function(i){const o=[];if(Gc(i,(t,n)=>{const i=Xc(n);!function(e,t,n=Ol()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(r,i)?o.push(t):e.recordDroppedEvent("ratelimit_backoff",i)}),0===o.length)return Promise.resolve({});const s=Yc(i[0],o),a=t=>{!function(e,t){return Gc(e,(e,n)=>t.includes(n))}(s,["client_report"])?Gc(s,(n,r)=>{e.recordDroppedEvent(t,Xc(r))}):_a&&La(`Dropping client report. Will not send outcomes (reason: ${t}).`)};return n.add(()=>t({body:Qc(s)}).then(e=>413===e.statusCode?(_a&&Ba("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),a("send_error"),e):(_a&&void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&La(`Sentry responded with status code ${e.statusCode} to sent event.`),r=function(e,{statusCode:t,headers:n},r=Ol()){const i={...e},o=n?.["x-sentry-rate-limits"],s=n?.["retry-after"];if(o)for(const e of o.trim().split(",")){const[t,n,,,o]=e.split(":",5),s=parseInt(t,10),a=1e3*(isNaN(s)?60:s);if(n)for(const e of n.split(";"))"metric_bucket"===e&&o&&!o.split(";").includes("custom")||(i[e]=r+a);else i.all=r+a}else s?i.all=r+function(e,t=Ol()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const r=Date.parse(`${e}`);return isNaN(r)?6e4:r-t}(s,r):429===t&&(i.all=r+6e4);return i}(r,e),e),e=>{throw a("network_error"),_a&&Ba("Encountered error running transport request:",e),e})).then(e=>e,e=>{if(e===Ed)return _a&&Ba("Skipped sending event because buffer is full."),a("queue_overflow"),Promise.resolve({});throw e})},flush:e=>n.drain(e)}}function Dd(e){const t=[];e.message&&t.push(e.message);try{const n=e.exception.values[e.exception.values.length-1];n?.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`))}catch{}return t}const Rd="Not capturing exception because it's already been captured.",Md="Discarded session because of missing or non-string release",Od=Symbol.for("SentryInternalError"),jd=Symbol.for("SentryDoNotSendEventError");function Wd(e){return{message:e,[Od]:!0}}function Ad(e){return{message:e,[jd]:!0}}function Ld(e){return!!e&&"object"==typeof e&&Od in e}function Bd(e){return!!e&&"object"==typeof e&&jd in e}function qd(e,t,n,r,i){let o,s=0,a=!1;e.on(n,()=>{s=0,clearTimeout(o),a=!1}),e.on(t,t=>{s+=r(t),s>=8e5?i(e):a||(a=!0,o=Td(setTimeout(()=>{i(e)},5e3)))}),e.on("flush",()=>{i(e)})}class Fd{constructor(e){if(this.et=e,this.nt={},this.rt=0,this.it={},this.ot={},this.ge=[],this.st=Pd(e.transportOptions?.bufferSize??64),e.dsn?this.lt=function(e){const t="string"==typeof e?function(e){const t=kc.exec(e);if(!t)return void Ra(()=>{});const[n,r,i="",o="",s="",a=""]=t.slice(1);let l="",c=a;const d=c.split("/");if(d.length>1&&(l=d.slice(0,-1).join("/"),c=d.pop()),c){const e=c.match(/^\d+/);e&&(c=e[0])}return Sc({host:o,pass:i,path:l,projectId:c,port:s,protocol:n,publicKey:r})}(e):Sc(e);if(t&&function(e){if(!_a)return!0;const{port:t,projectId:n,protocol:r}=e;return!(["protocol","publicKey","host","projectId"].find(t=>!e[t]&&(Ba(`Invalid Sentry Dsn: ${t} missing`),!0))||(n.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(r)?t&&isNaN(parseInt(t,10))&&(Ba(`Invalid Sentry Dsn: Invalid port ${t}`),1):(Ba(`Invalid Sentry Dsn: Invalid protocol ${r}`),1):(Ba(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}(e.dsn):_a&&La("No DSN provided, client will not send events."),this.lt){const i=(t=this.lt,n=e.tunnel,r=e.Xe?e.Xe.sdk:void 0,n||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",n=e.port?`:${e.port}`:"";return`${t}//${e.host}${n}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(t)}?${function(e,t){const n={sentry_version:"7"};return e.publicKey&&(n.sentry_key=e.publicKey),t&&(n.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(n).toString()}(t,r)}`);this.ct=e.transport({tunnel:this.et.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:i})}var t,n,r;this.et.enableLogs=this.et.enableLogs??this.et.ut?.enableLogs,this.et.enableLogs&&qd(this,"afterCaptureLog","flushLogs",Gd,Cd),(this.et.enableMetrics??this.et.ut?.enableMetrics??1)&&qd(this,"afterCaptureMetric","flushMetrics",Zd,$d)}captureException(e,t,n){const r=Bl();if(Yl(e))return _a&&Aa(Rd),r;const i={event_id:r,...t};return this.ht(()=>this.eventFromException(e,i).then(e=>this.ft(e,i,n)).then(e=>e),"error"),i.event_id}captureMessage(e,t,n,r){const i={event_id:Bl(),...n},o=hl(e)?e:String(e),s=ml(e),a=s?this.eventFromMessage(o,t,i):this.eventFromException(e,i);return this.ht(()=>a.then(e=>this.ft(e,i,r)),s?"unknown":"error"),i.event_id}captureEvent(e,t,n){const r=Bl();if(t?.originalException&&Yl(t.originalException))return _a&&Aa(Rd),r;const i={event_id:r,...t},o=e.sdkProcessingMetadata||{},s=o.capturedSpanScope,a=o.capturedSpanIsolationScope,l=Hd(e.type);return this.ht(()=>this.ft(e,i,s||n,a),l),i.event_id}captureSession(e){this.sendSession(e),Vl(e,{init:!1})}getDsn(){return this.lt}getOptions(){return this.et}getSdkMetadata(){return this.et.Xe}getTransport(){return this.ct}async flush(e){const t=this.ct;if(!t)return!0;this.emit("flush");const n=await this.gt(e),r=await t.flush(e);return n&&r}async close(e){Cd(this);const t=await this.flush(e);return this.getOptions().enabled=!1,this.emit("close"),t}getEventProcessors(){return this.ge}addEventProcessor(e){this.ge.push(e)}init(){(this.yt()||this.et.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this.vt()}getIntegrationByName(e){return this.nt[e]}addIntegration(e){const t=this.nt[e.name];!t&&e.beforeSetup&&e.beforeSetup(this),Sd(this,e,this.nt),t||Nd(this,[e])}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);let n=function(e,t,n,r){const i=ed(n),o=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){if(!t)return e;const n=e.sdk||{};e.sdk={...n,name:n.name||t.name,version:n.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0}}(e,n?.sdk);const s=function(e,t,n,r){const i=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&{sdk:t},...!!n&&r&&{dsn:Nc(r)},...i&&{trace:i}}}(e,i,r,t);return delete e.sdkProcessingMetadata,Yc(s,[[{type:o},e]])}(e,this.lt,this.et.Xe,this.et.tunnel);for(const e of t.attachments||[])n=Zc(n,Jc(e));this.sendEnvelope(n).then(t=>this.emit("afterSendEvent",e,t))}sendSession(e){const{release:t,environment:n=Lc}=this.et;if("aggregates"in e){const r=e.attrs||{};if(!r.release&&!t)return void(_a&&La(Md));r.release=r.release||t,r.environment=r.environment||n,e.attrs=r}else{if(!e.release&&!t)return void(_a&&La(Md));e.release=e.release||t,e.environment=e.environment||n}this.emit("beforeSendSession",e);const r=function(e,t,n,r){const i=ed(n);return Yc({sent_at:(new Date).toISOString(),...i&&{sdk:i},...!!r&&t&&{dsn:Nc(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this.lt,this.et.Xe,this.et.tunnel);this.sendEnvelope(r)}recordDroppedEvent(e,t,n=1){if(this.et.sendClientReports){const r=`${e}:${t}`;_a&&Aa(`Recording outcome: "${r}"${n>1?` (${n} times)`:""}`),this.it[r]=(this.it[r]||0)+n}}on(e,t){const n=this.ot[e]=this.ot[e]||new Set,r=(...e)=>t(...e);return n.add(r),()=>{n.delete(r)}}emit(e,...t){const n=this.ot[e];n&&n.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit("beforeEnvelope",e),this.yt()&&this.ct)try{return await this.ct.send(e)}catch(e){return _a&&Ba("Error while sending envelope:",e),{}}return _a&&Ba("Transport disabled"),{}}dispose(){}vt(){const{integrations:e}=this.et;this.nt=function(e,t){const n={};return t.forEach(t=>{t?.beforeSetup&&t.beforeSetup(e)}),t.forEach(t=>{t&&Sd(e,t,n)}),n}(this,e),Nd(this,e)}wt(e,t){let n="fatal"===t.level,r=!1;const i=t.exception?.values;if(i){r=!0,n=!1;for(const e of i)if(!1===e.mechanism?.handled){n=!0;break}}const o="ok"===e.status;(o&&0===e.errors||o&&n)&&(Vl(e,{...n&&{status:"crashed"},errors:e.errors||Number(r||n)}),this.captureSession(e))}async gt(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this.rt)return!0;t++}return!1}yt(){return!1!==this.getOptions().enabled&&void 0!==this.ct}bt(e,t,n,r){const i=this.getOptions(),o=Object.keys(this.nt);return!t.integrations&&o?.length&&(t.integrations=o),this.emit("preprocessEvent",e,t),e.type||r.setLastEventId(e.event_id||t.event_id),md(i,e,t,n,this,r).then(e=>{if(null===e)return e;this.emit("postprocessEvent",e,t),e.contexts={trace:{...e.contexts?.trace,...pc(n)},...e.contexts};const r=function(e,t){const n=t.getPropagationContext();return n.dsc||Bc(n.traceId,e)}(this,n);return e.sdkProcessingMetadata={dynamicSamplingContext:r,...e.sdkProcessingMetadata},e})}ft(e,t={},n=uc(),r=hc()){return _a&&Ud(e)&&Aa(`Captured error event \`${Dd(e)[0]||"<unknown>"}\``),this.xt(e,t,n,r).then(e=>e.event_id,e=>{_a&&(Bd(e)?Aa(e.message):Ld(e)?La(e.message):La(e))})}xt(e,t,n,r){const i=this.getOptions(),{sampleRate:o}=i,s=Yd(e),a=Ud(e),l=`before send for type \`${e.type||"error"}\``,c=void 0===o?void 0:function(e){if("boolean"==typeof e)return Number(e);const t="string"==typeof e?parseFloat(e):e;return"number"!=typeof t||isNaN(t)||t<0||t>1?void 0:t}(o);if(a&&"number"==typeof c&&Ml()>c)return this.recordDroppedEvent("sample_rate","error"),od(Ad(`Discarding event because it's not included in the random sample (sampling rate = ${o})`));const d=Hd(e.type);return this.bt(e,t,n,r).then(e=>{if(null===e)throw this.recordDroppedEvent("event_processor",d),Ad("An event processor returned `null`, will not send event.");if(!0===t.data?.Ke)return e;const n=function(e,t,n,r){const{beforeSend:i,beforeSendTransaction:o,ignoreSpans:s}=t,a=!((l=t.beforeSendSpan)&&"function"==typeof l&&"kt"in l&&l.kt)&&t.beforeSendSpan;var l;let c=n;if(Ud(c)&&i)return i(c,r);if(Yd(c)){if(a||s){const t=function(e){const{trace_id:t,parent_span_id:n,span_id:r,status:i,origin:o,data:s,op:a}=e.contexts?.trace??{};return{data:s??{},description:e.transaction,op:a,parent_span_id:n,span_id:r??"",start_timestamp:e.start_timestamp??0,status:i,timestamp:e.timestamp,trace_id:t??"",origin:o,profile_id:s?.[gc],exclusive_time:s?.[yc],measurements:e.measurements,is_segment:!0}}(c);if(s?.length&&jc(t,s))return null;if(a){const e=a(t);e?c=Ql(n,{type:"transaction",timestamp:(d=e).timestamp,start_timestamp:d.start_timestamp,transaction:d.description,contexts:{trace:{trace_id:d.trace_id,span_id:d.span_id,parent_span_id:d.parent_span_id,op:d.op,status:d.status,origin:d.origin,data:{...d.data,...d.profile_id&&{[gc]:d.profile_id},...d.exclusive_time&&{[yc]:d.exclusive_time}}}},measurements:d.measurements}):Mc()}if(c.spans){const t=[],n=c.spans;for(const e of n)if(s?.length&&jc(e,s))Wc(n,e);else if(a){const n=a(e);n?t.push(n):(Mc(),t.push(e))}else t.push(e);const r=c.spans.length-t.length;r&&e.recordDroppedEvent("before_send","span",r),c.spans=t}}if(o){if(c.spans){const e=c.spans.length;c.sdkProcessingMetadata={...n.sdkProcessingMetadata,spanCountBeforeProcessing:e}}return o(c,r)}}var d;return c}(this,i,e,t);return function(e,t){const n=`${t} must return \`null\` or a valid event.`;if(gl(e))return e.then(e=>{if(!fl(e)&&null!==e)throw Wd(n);return e},e=>{throw Wd(`${t} rejected with ${e}`)});if(!fl(e)&&null!==e)throw Wd(n);return e}(n,l)}).then(i=>{if(null===i){if(this.recordDroppedEvent("before_send",d),s){const t=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",t)}throw Ad(`${l} returned \`null\`, will not send event.`)}const o=n.getSession()||r.getSession();if(a&&o&&this.wt(o,i),s){const e=(i.sdkProcessingMetadata?.spanCountBeforeProcessing||0)-(i.spans?i.spans.length:0);e>0&&this.recordDroppedEvent("before_send","span",e)}const c=i.transaction_info;if(s&&c&&i.transaction!==e.transaction){const e="custom";i.transaction_info={...c,source:e}}return this.sendEvent(i,t),i}).then(null,e=>{if(Bd(e)||Ld(e))throw e;throw this.captureException(e,{mechanism:{handled:!1,type:"internal"},data:{Ke:!0},originalException:e}),Wd(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`)})}ht(e,t){this.rt++,this.st.add(e).then(e=>(this.rt--,e),e=>(this.rt--,e===Ed&&this.recordDroppedEvent("queue_overflow",t),e))}Nt(){const e=this.it;return this.it={},Object.entries(e).map(([e,t])=>{const[n,r]=e.split(":");return{reason:n,category:r,quantity:t}})}St(){_a&&Aa("Flushing outcomes...");const e=this.Nt();if(0===e.length)return void(_a&&Aa("No outcomes to send"));if(!this.lt)return void(_a&&Aa("No dsn provided, will not send outcomes"));_a&&Aa("Sending outcomes:",e);const t=(n=e,Yc((r=this.et.tunnel&&Nc(this.lt))?{dsn:r}:{},[[{type:"client_report"},{timestamp:Zl(),discarded_events:n}]]));var n,r;this.sendEnvelope(t)}}function Hd(e){return"replay_event"===e?"replay":e||"error"}function Ud(e){return void 0===e.type}function Yd(e){return"transaction"===e.type}function Zd(e){let t=0;return e.name&&(t+=2*e.name.length),t+=8,t+Vd(e.attributes)}function Gd(e){let t=0;return e.message&&(t+=2*e.message.length),t+Vd(e.attributes)}function Vd(e){if(!e)return 0;let t=0;return Object.values(e).forEach(e=>{Array.isArray(e)?t+=e.length*Qd(e[0]):ml(e)?t+=Qd(e):t+=100}),t}function Qd(e){return"string"==typeof e?2*e.length:"number"==typeof e?8:"boolean"==typeof e?4:0}function Jd(e){return function(e){return al(e)&&"Ct"in e&&"string"==typeof e.Ct}(e)?`${e.message} (${e.Ct})`:e.message}function Kd(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:n,hash:r,relative:t[5]+n+r}}function Xd(e){"aggregates"in e?void 0===e.attrs?.ip_address&&(e.attrs={...e.attrs,ip_address:"{{auto}}"}):void 0===e.ipAddress&&(e.ipAddress="{{auto}}")}const eu=100;function tu(e,t){const n=fc(),r=hc();if(!n)return;const{beforeBreadcrumb:i=null,maxBreadcrumbs:o=eu}=n.getOptions();if(o<=0)return;const s={timestamp:Zl(),...e},a=i?Ra(()=>i(s,t)):s;null!==a&&(n.emit&&n.emit("beforeAddBreadcrumb",a,t),r.addBreadcrumb(a,o))}let nu;const ru=new WeakMap,iu=()=>({name:"FunctionToString",setupOnce(){nu=function(){}.toString;try{Function.prototype.toString=function(...e){const t=$l(this),n=ru.has(fc())&&void 0!==t?t:this;return nu.apply(n,e)}}catch{}},setup(e){ru.set(e,!0)}}),ou=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],su=(e={})=>{let t;return{name:"EventFilters",setup(n){const r=n.getOptions();t=lu(e,r)},processEvent(n,r,i){if(!t){const n=i.getOptions();t=lu(e,n)}return function(e,t){if(e.type){if("transaction"===e.type&&function(e,t){if(!t?.length)return!1;const n=e.transaction;return!!n&&Ll(n,t)}(e,t.ignoreTransactions))return _a&&La(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${Fl(e)}`),!0}else{if(function(e,t){return!!t?.length&&Dd(e).some(e=>Ll(e,t))}(e,t.ignoreErrors))return _a&&La(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${Fl(e)}`),!0;if(function(e){return!!e.exception?.values?.length&&(!e.message&&!e.exception.values.some(e=>e.stacktrace||e.type&&"Error"!==e.type||e.value))}(e))return _a&&La(`Event dropped due to not having an error message, error type or stacktrace.\nEvent: ${Fl(e)}`),!0;if(function(e,t){if(!t?.length)return!1;const n=cu(e);return!!n&&Ll(n,t)}(e,t.denyUrls))return _a&&La(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${Fl(e)}.\nUrl: ${cu(e)}`),!0;if(!function(e,t){if(!t?.length)return!0;const n=cu(e);return!n||Ll(n,t)}(e,t.allowUrls))return _a&&La(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${Fl(e)}.\nUrl: ${cu(e)}`),!0}return!1}(n,t)?null:n}}},au=(e={})=>({...su(e),name:"InboundFilters"});function lu(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:ou],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[]]}}function cu(e){try{const t=[...e.exception?.values??[]].reverse().find(e=>void 0===e.mechanism?.parent_id&&e.stacktrace?.frames?.length),n=t?.stacktrace?.frames;return n?function(e=[]){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&"<anonymous>"!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null}(n):null}catch{return _a&&Ba(`Cannot extract url for event ${Fl(e)}`),null}}function du(e,t,n,r,i,o){if(!i.exception?.values||!o||!yl(o.originalException,Error))return;const s=i.exception.values.length>0?i.exception.values[i.exception.values.length-1]:void 0;s&&(i.exception.values=uu(e,t,r,o.originalException,n,i.exception.values,s,0))}function uu(e,t,n,r,i,o,s,a){if(o.length>=n+1)return o;let l=[...o];if(yl(r[i],Error)){mu(s,a,r);const o=e(t,r[i]),c=l.length;fu(o,i,c,a),l=uu(e,t,n,r[i],i,[o,...l],o,c)}return hu(r)&&r.errors.forEach((o,c)=>{if(yl(o,Error)){mu(s,a,r);const d=e(t,o),u=l.length;fu(d,`errors[${c}]`,u,a),l=uu(e,t,n,o,i,[d,...l],d,u)}}),l}function hu(e){return Array.isArray(e.errors)}function mu(e,t,n){e.mechanism={handled:!0,type:"auto.core.linked_errors",...hu(n)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function fu(e,t,n,r){e.mechanism={handled:!0,...e.mechanism,type:"chained",source:t,exception_id:n,parent_id:r}}function pu(){"console"in $a&&za.forEach(function(e){e in $a.console&&Sl($a.console,e,function(t){return Da[e]=t,function(...t){tl("console",{args:t,level:e});const n=Da[e];n?.apply($a.console,t)}})})}const gu=()=>{let e;return{name:"Dedupe",processEvent(t){if(t.type)return t;try{if(function(e,t){return!!t&&(!!function(e,t){const n=e.message,r=t.message;return!(!n&&!r)&&(!(n&&!r||!n&&r)&&(n===r&&(!!vu(e,t)&&!!yu(e,t))))}(e,t)||!!function(e,t){const n=wu(t),r=wu(e);return!(!n||!r)&&(n.type===r.type&&n.value===r.value&&(!!vu(e,t)&&!!yu(e,t)))}(e,t))}(t,e))return _a&&La("Event dropped due to being a duplicate of previously captured event."),null}catch{}return e=t}}};function yu(e,t){let n=Va(e),r=Va(t);if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;if(r.length!==n.length)return!1;for(let e=0;e<r.length;e++){const t=r[e],i=n[e];if(t.filename!==i.filename||t.lineno!==i.lineno||t.colno!==i.colno||t.function!==i.function)return!1}return!0}function vu(e,t){let n=e.fingerprint,r=t.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;try{return!(n.join("")!==r.join(""))}catch{return!1}}function wu(e){return e.exception?.values?.[0]}function bu(e){return void 0===e?void 0:e>=400&&e<500?"warning":e>=500?"error":void 0}const xu=$a;function ku(e){return e&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function Nu(e,t){const n="fetch";Xa(n,e),el(n,()=>function(e,t=!1){t&&!function(){if("string"==typeof EdgeRuntime)return!0;if(!function(){if(!("fetch"in xu))return!1;try{return new Headers,new Request("data:,"),new Response,!0}catch{return!1}}())return!1;if(ku(xu.fetch))return!0;let e=!1;const t=xu.document;if(t&&"function"==typeof t.createElement)try{const n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n),n.contentWindow?.fetch&&(e=ku(n.contentWindow.fetch)),t.head.removeChild(n)}catch(e){_a&&La("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return e}()||Sl($a,"fetch",function(e){return function(...t){const n=new Error,{method:r,url:i}=function(e){if(0===e.length)return{method:"GET",url:""};if(2===e.length){const[t,n]=e;return{url:Cu(t),method:Su(n,"method")?String(n.method).toUpperCase():wl(t)&&Su(t,"method")?String(t.method).toUpperCase():"GET"}}const t=e[0];return{url:Cu(t),method:Su(t,"method")?String(t.method).toUpperCase():"GET"}}(t),o={args:t,fetchData:{method:r,url:i},startTimestamp:1e3*Gl(),virtualError:n,headers:_u(t)};return tl("fetch",{...o}),e.apply($a,t).then(async e=>(tl("fetch",{...o,endTimestamp:1e3*Gl(),response:e}),e),e=>{tl("fetch",{...o,endTimestamp:1e3*Gl(),error:e}),al(e)&&void 0===e.stack&&(e.stack=n.stack,Cl(e,"framesToPop",1));const t=fc(),r=t?.getOptions().enhanceFetchErrorMessages??"always";if(!1!==r&&e instanceof TypeError&&("Failed to fetch"===e.message||"Load failed"===e.message||"NetworkError when attempting to fetch resource."===e.message))try{const t=new URL(o.fetchData.url).host;"always"===r?e.message=`${e.message} (${t})`:Cl(e,"__sentry_fetch_url_host__",t)}catch{}throw e})}})}(0,t))}function Su(e,t){return!!e&&"object"==typeof e&&!!e[t]}function Cu(e){return"string"==typeof e?e:e?Su(e,"url")?e.url:e.toString?e.toString():"":""}function _u(e){const[t,n]=e;try{if("object"==typeof n&&null!==n&&"headers"in n&&n.headers)return new Headers(n.headers);if(wl(t))return new Headers(t.headers)}catch{}}const $u=$a;let Iu=0;function Tu(){return Iu>0}function Eu(e,t={}){if(!function(e){return"function"==typeof e}(e))return e;try{const t=e._t;if(t)return"function"==typeof t?t:e;if($l(e))return e}catch{return e}const n=function(...n){try{const r=n.map(e=>Eu(e,t));return e.apply(this,r)}catch(e){throw Iu++,setTimeout(()=>{Iu--}),mc(r=>{r.addEventProcessor(e=>(t.mechanism&&(Hl(e,void 0),Ul(e,t.mechanism)),e.extra={...e.extra,arguments:n},e)),fd(e)}),e}};try{for(const t in e)({}).hasOwnProperty.call(e,t)&&(n[t]=e[t])}catch{}_l(n,e),Cl(e,"__sentry_wrapped__",n);try{Object.getOwnPropertyDescriptor(n,"name").configurable&&Object.defineProperty(n,"name",{get:()=>e.name})}catch{}return n}function Pu(e,t){const n=Du(e,t),r={type:Ou(t),value:ju(t)};return n.length&&(r.stacktrace={frames:n}),void 0===r.type&&""===r.value&&(r.value="Unrecoverable error caught"),r}function zu(e,t){return{exception:{values:[Pu(e,t)]}}}function Du(e,t){const n=t.stacktrace||t.stack||"",r=function(e){return e&&Ru.test(e.message)?1:0}(t),i=function(e){return"number"==typeof e.framesToPop?e.framesToPop:0}(t);try{return e(n,r,i)}catch{}return[]}const Ru=/Minified React error #\d+;/i;function Mu(e){return"undefined"!=typeof WebAssembly&&void 0!==WebAssembly.Exception&&e instanceof WebAssembly.Exception}function Ou(e){const t=e?.name;return!t&&Mu(e)?e.message&&Array.isArray(e.message)&&2==e.message.length?e.message[0]:"WebAssembly.Exception":t}function ju(e){const t=e?.message;return Mu(e)?Array.isArray(e.message)&&2==e.message.length?e.message[1]:"wasm exception":t?t.error&&"string"==typeof t.error.message?Jd(t.error):Jd(e):"No error message"}function Wu(e,t,n,r,i){let o;if(cl(t)&&t.error)return zu(e,t.error);if(dl(t)||ll(t,"DOMException")){const i=t;if("stack"in t)o=zu(e,t);else{const t=i.name||(dl(i)?"DOMError":"DOMException"),s=i.message?`${t}: ${i.message}`:t;o=Au(e,s,n,r),Hl(o,s)}return"code"in i&&(o.tags={...o.tags,"DOMException.code":`${i.code}`}),o}return al(t)?zu(e,t):fl(t)||pl(t)?(o=function(e,t,n,r){const i=fc(),o=i?.getOptions().normalizeDepth,s=(a=t,Object.values(a).find(e=>e instanceof Error));var a;const l={$t:Hc(t,o)};if(s)return{exception:{values:[Pu(e,s)]},extra:l};const c={exception:{values:[{type:pl(t)?t.constructor.name:r?"UnhandledRejection":"Error",value:Lu(t,{isUnhandledRejection:r})}]},extra:l};if(n){const t=Du(e,n);t.length&&(c.exception.values[0].stacktrace={frames:t})}return c}(e,t,n,i),Ul(o,{synthetic:!0}),o):(o=Au(e,t,n,r),Hl(o,`${t}`),Ul(o,{synthetic:!0}),o)}function Au(e,t,n,r){const i={};if(r&&n){const r=Du(e,n);r.length&&(i.exception={values:[{value:t,stacktrace:{frames:r}}]}),Ul(i,{synthetic:!0})}if(hl(t)){const{le:e,ce:n}=t;return i.logentry={message:e,params:n},i}return i.message=t,i}function Lu(e,{isUnhandledRejection:t}){const n=function(e){const t=Object.keys(Il(e));return t.sort(),t[0]?t.join(", "):"[object has no keys]"}(e),r=t?"promise rejection":"exception";return cl(e)?`Event \`ErrorEvent\` captured as ${r} with message \`${e.message}\``:pl(e)?`Event \`${function(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}(e)}\` (type=${e.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}class Bu extends Fd{constructor(e){const t=(n=e,{release:"string"==typeof __SENTRY_RELEASE__?__SENTRY_RELEASE__:$u.SENTRY_RELEASE?.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...n});var n;!function(e,t,n=[t],r="npm"){const i=(e.Xe=e.Xe||{}).sdk=e.Xe.sdk||{};i.name||(i.name=`sentry.javascript.${t}`,i.packages=n.map(e=>({name:`${r}:@sentry/${e}`,version:Ia})),i.version=Ia)}(t,"browser",["browser"],$u.SENTRY_SDK_SOURCE||"npm"),t.Xe?.sdk&&(t.Xe.sdk.settings={infer_ip:t.sendDefaultPii?"auto":"never",...t.Xe.sdk.settings}),super(t);const{sendDefaultPii:r,sendClientReports:i,enableLogs:o,ut:s,enableMetrics:a}=this.et,l=a??s?.enableMetrics??!0;$u.document&&(i||o||l)&&$u.document.addEventListener("visibilitychange",()=>{"hidden"===$u.document.visibilityState&&(i&&this.St(),o&&Cd(this),l&&$d(this))}),r&&this.on("beforeSendSession",Xd)}eventFromException(e,t){return function(e,t,n,r){const i=Wu(e,t,n?.syntheticException||void 0,r);return Ul(i),i.level="error",n?.event_id&&(i.event_id=n.event_id),id(i)}(this.et.stackParser,e,t,this.et.attachStacktrace)}eventFromMessage(e,t="info",n){return function(e,t,n="info",r,i){const o=Au(e,t,r?.syntheticException||void 0,i);return o.level=n,r?.event_id&&(o.event_id=r.event_id),id(o)}(this.et.stackParser,e,t,n,this.et.attachStacktrace)}bt(e,t,n,r){return e.platform=e.platform||"javascript",super.bt(e,t,n,r)}}const qu="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,Fu=$a;let Hu,Uu,Yu,Zu;function Gu(){if(!Fu.document)return;const e=tl.bind(null,"dom"),t=Vu(e,!0);Fu.document.addEventListener("click",t,!1),Fu.document.addEventListener("keypress",t,!1),["EventTarget","Node"].forEach(t=>{const n=Fu,r=n[t]?.prototype;r?.hasOwnProperty?.("addEventListener")&&(Sl(r,"addEventListener",function(t){return function(n,r,i){if("click"===n||"keypress"==n)try{const r=this.It=this.It||{},o=r[n]=r[n]||{refCount:0};if(!o.handler){const r=Vu(e);o.handler=r,t.call(this,n,r,i)}o.refCount++}catch{}return t.call(this,n,r,i)}}),Sl(r,"removeEventListener",function(e){return function(t,n,r){if("click"===t||"keypress"==t)try{const n=this.It||{},i=n[t];i&&(i.refCount--,i.refCount<=0&&(e.call(this,t,i.handler,r),i.handler=void 0,delete n[t]),0===Object.keys(n).length&&delete this.It)}catch{}return e.call(this,t,n,r)}}))})}function Vu(e,t=!1){return n=>{if(!n||n.Tt)return;const r=function(e){try{return e.target}catch{return null}}(n);if(function(e,t){return"keypress"===e&&(!t?.tagName||"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)}(n.type,r))return;Cl(n,"_sentryCaptured",!0),r&&!r.Et&&Cl(r,"_sentryId",Bl());const i="keypress"===n.type?"input":n.type;(function(e){if(e.type!==Uu)return!1;try{if(!e.target||e.target.Et!==Yu)return!1}catch{}return!0})(n)||(e({event:n,name:i,global:t}),Uu=n.type,Yu=r?r.Et:void 0),clearTimeout(Hu),Hu=Fu.setTimeout(()=>{Yu=void 0,Uu=void 0},1e3)}}function Qu(e){const t="history";Xa(t,e),el(t,Ju)}function Ju(){function e(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const r=Zu,i=function(e){try{return new URL(e,Fu.location.origin).toString()}catch{return e}}(String(n));if(Zu=i,r===i)return e.apply(this,t);tl("history",{from:r,to:i})}return e.apply(this,t)}}Fu.addEventListener("popstate",()=>{const e=Fu.location.href,t=Zu;Zu=e,t!==e&&tl("history",{from:t,to:e})}),"history"in xu&&xu.history&&(Sl(Fu.history,"pushState",e),Sl(Fu.history,"replaceState",e))}const Ku={},Xu="__sentry_xhr_v3__";function eh(){if(!Fu.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;e.open=new Proxy(e.open,{apply(e,t,n){const r=new Error,i=1e3*Gl(),o=ul(n[0])?n[0].toUpperCase():void 0,s=function(e){if(ul(e))return e;try{return e.toString()}catch{}}(n[1]);if(!o||!s)return e.apply(t,n);t[Xu]={method:o,url:s,request_headers:{}},"POST"===o&&s.match(/sentry_key/)&&(t.Pt=!0);const a=()=>{const e=t[Xu];if(e&&4===t.readyState){try{e.status_code=t.status}catch{}tl("xhr",{endTimestamp:1e3*Gl(),startTimestamp:i,xhr:t,virtualError:r})}};return"onreadystatechange"in t&&"function"==typeof t.onreadystatechange?t.onreadystatechange=new Proxy(t.onreadystatechange,{apply:(e,t,n)=>(a(),e.apply(t,n))}):t.addEventListener("readystatechange",a),t.setRequestHeader=new Proxy(t.setRequestHeader,{apply(e,t,n){const[r,i]=n,o=t[Xu];return o&&ul(r)&&ul(i)&&(o.request_headers[r.toLowerCase()]=i),e.apply(t,n)}}),e.apply(t,n)}}),e.send=new Proxy(e.send,{apply(e,t,n){const r=t[Xu];return r?(void 0!==n[0]&&(r.body=n[0]),tl("xhr",{startTimestamp:1e3*Gl(),xhr:t}),e.apply(t,n)):e.apply(t,n)}})}function th(e,t=function(e){const t=Ku[e];if(t)return t;let n=Fu[e];if(ku(n))return Ku[e]=n.bind(Fu);const r=Fu.document;if(r&&"function"==typeof r.createElement)try{const t=r.createElement("iframe");t.hidden=!0,r.head.appendChild(t);const i=t.contentWindow;i?.[e]&&(n=i[e]),r.head.removeChild(t)}catch(t){qu&&La(`Could not create sandbox iframe for ${e} check, bailing to window.${e}: `,t)}return n?Ku[e]=n.bind(Fu):n}("fetch")){let n=0,r=0;return zd(e,async function(i){const o=i.body.length;n+=o,r++;const s={body:i.body,method:"POST",referrerPolicy:"strict-origin",headers:e.headers,keepalive:n<=6e4&&r<15,...e.fetchOptions};try{const n=await t(e.url,s);return{statusCode:n.status,headers:{"x-sentry-rate-limits":n.headers.get("X-Sentry-Rate-Limits"),"retry-after":n.headers.get("Retry-After")}}}catch(e){throw Ku.fetch=void 0,e}finally{n-=o,r--}},Pd(e.bufferSize||40))}const nh="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function rh(e,t,n,r){const i={filename:e,function:"<anonymous>"===t?qa:t,in_app:!0};return void 0!==n&&(i.lineno=n),void 0!==r&&(i.colno=r),i}const ih=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,oh=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,sh=/\((\S*)(?::(\d+))(?::(\d+))\)/,ah=/at (.+?) ?\(data:(.+?),/,lh=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ch=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,dh=Ua([30,e=>{const t=e.match(ah);if(t)return{filename:`<data:${t[2]}>`,function:t[1]};const n=ih.exec(e);if(n){const[,e,t,r]=n;return rh(e,qa,+t,+r)}const r=oh.exec(e);if(r){if(0===r[2]?.indexOf("eval")){const e=sh.exec(r[2]);e&&(r[2]=e[1],r[3]=e[2],r[4]=e[3])}const[e,t]=uh(r[1]||qa,r[2]);return rh(t,e,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}}],[50,e=>{const t=lh.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const e=ch.exec(t[3]);e&&(t[1]=t[1]||"eval",t[3]=e[1],t[4]=e[2],t[5]="")}let e=t[3],n=t[1]||qa;return[n,e]=uh(n,e),rh(e,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]),uh=(e,t)=>{const n=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return n||r?[-1!==e.indexOf("@")?e.split("@")[0]:qa,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},hh=(e={})=>{const t={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e};return{name:"Breadcrumbs",setup(e){var n;t.console&&function(e){const t="console";Xa(t,e),el(t,pu)}(function(e){return function(t){if(fc()!==e)return;const n={category:"console",data:{arguments:t.args,logger:"console"},level:(r=t.level,"warn"===r?"warning":["fatal","error","warning","log","info","debug"].includes(r)?r:"log"),message:Wl(t.args," ")};var r;if("assert"===t.level){if(!1!==t.args[0])return;n.message=`Assertion failed: ${Wl(t.args.slice(1)," ")||"console.assert"}`,n.data.arguments=t.args.slice(1)}tu(n,{input:t.args,level:t.level})}}(e)),t.dom&&(n=function(e,t){return function(n){if(fc()!==e)return;let r,i,o="object"==typeof t?t.serializeAttribute:void 0,s="object"==typeof t&&"number"==typeof t.maxStringLength?t.maxStringLength:void 0;s&&s>1024&&(nh&&La(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${s} was configured. Sentry will use 1024 instead.`),s=1024),"string"==typeof o&&(o=[o]);try{const e=n.event,t=function(e){return!!e&&!!e.target}(e)?e.target:e;r=xl(t,{keyAttrs:o,maxStringLength:s}),i=function(e){if(!bl.HTMLElement)return null;let t=e;for(let e=0;e<5;e++){if(!t)return null;if(t instanceof HTMLElement){if(t.dataset.sentryComponent)return t.dataset.sentryComponent;if(t.dataset.sentryElement)return t.dataset.sentryElement}t=t.parentNode}return null}(t)}catch{r="<unknown>"}if(0===r.length)return;const a={category:`ui.${n.name}`,message:r};i&&(a.data={"ui.component_name":i}),tu(a,{event:n.event,name:n.name,global:n.global})}}(e,t.dom),Xa("dom",n),el("dom",Gu)),t.xhr&&function(e){Xa("xhr",e),el("xhr",eh)}(function(e){return function(t){if(fc()!==e)return;const{startTimestamp:n,endTimestamp:r}=t,i=t.xhr[Xu];if(!n||!r||!i)return;const{method:o,url:s,status_code:a,body:l}=i,c={method:o,url:s,status_code:a},d={xhr:t.xhr,input:l,startTimestamp:n,endTimestamp:r},u={category:"xhr",data:c,type:"http",level:bu(a)};e.emit("beforeOutgoingRequestBreadcrumb",u,d),tu(u,d)}}(e)),t.fetch&&Nu(function(e){return function(t){if(fc()!==e)return;const{startTimestamp:n,endTimestamp:r}=t;if(r&&(!t.fetchData.url.match(/sentry_key/)||"POST"!==t.fetchData.method))if(t.error){const i={data:t.error,input:t.args,startTimestamp:n,endTimestamp:r},o={category:"fetch",data:t.fetchData,level:"error",type:"http"};e.emit("beforeOutgoingRequestBreadcrumb",o,i),tu(o,i)}else{const i=t.response,o={...t.fetchData,status_code:i?.status},s={input:t.args,response:i,startTimestamp:n,endTimestamp:r},a={category:"fetch",data:o,type:"http",level:bu(o.status_code)};e.emit("beforeOutgoingRequestBreadcrumb",a,s),tu(a,s)}}}(e)),t.history&&Qu(function(e){return function(t){if(fc()!==e)return;let n=t.from,r=t.to;const i=Kd($u.location.href);let o=n?Kd(n):void 0;const s=Kd(r);o?.path||(o=i),i.protocol===s.protocol&&i.host===s.host&&(r=s.relative),i.protocol===o.protocol&&i.host===o.host&&(n=o.relative),tu({category:"navigation",data:{from:n,to:r}})}}(e)),t.sentry&&e.on("beforeSendEvent",function(e){return function(t){fc()===e&&tu({category:"sentry."+("transaction"===t.type?"transaction":"event"),event_id:t.event_id,level:t.level,message:Fl(t)},{event:t})}}(e))}}},mh="EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(","),fh=(e={})=>{const t={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...e};return{name:"BrowserApiErrors",setupOnce(){t.setTimeout&&Sl($u,"setTimeout",ph),t.setInterval&&Sl($u,"setInterval",ph),t.requestAnimationFrame&&Sl($u,"requestAnimationFrame",gh),t.XMLHttpRequest&&"XMLHttpRequest"in $u&&Sl(XMLHttpRequest.prototype,"send",yh);const e=t.eventTarget;e&&(Array.isArray(e)?e:mh).forEach(e=>function(e,t){const n=$u,r=n[e]?.prototype;r?.hasOwnProperty?.("addEventListener")&&(Sl(r,"addEventListener",function(n){return function(r,i,o){try{"function"==typeof i.handleEvent&&(i.handleEvent=Eu(i.handleEvent,{mechanism:{data:{handler:Ga(i),target:e},handled:!1,type:"auto.browser.browserapierrors.handleEvent"}}))}catch{}return t.unregisterOriginalCallbacks&&function(e,t,n){e&&"object"==typeof e&&"removeEventListener"in e&&"function"==typeof e.removeEventListener&&e.removeEventListener(t,n)}(this,r,i),n.apply(this,[r,Eu(i,{mechanism:{data:{handler:Ga(i),target:e},handled:!1,type:"auto.browser.browserapierrors.addEventListener"}}),o])}}),Sl(r,"removeEventListener",function(e){return function(t,n,r){try{const i=n._t;i&&e.call(this,t,i,r)}catch{}return e.call(this,t,n,r)}}))}(e,t))}}};function ph(e){return function(...t){const n=t[0];return t[0]=Eu(n,{mechanism:{handled:!1,type:`auto.browser.browserapierrors.${Ga(e)}`}}),e.apply(this,t)}}function gh(e){return function(t){return e.apply(this,[Eu(t,{mechanism:{data:{handler:Ga(e)},handled:!1,type:"auto.browser.browserapierrors.requestAnimationFrame"}})])}}function yh(e){return function(...t){const n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(e=>{e in n&&"function"==typeof n[e]&&Sl(n,e,function(t){const n={mechanism:{data:{handler:Ga(t)},handled:!1,type:`auto.browser.browserapierrors.xhr.${e}`}},r=$l(t);return r&&(n.mechanism.data.handler=Ga(r)),Eu(t,n)})}),e.apply(this,t)}}const vh=(e={})=>{const t=e.lifecycle??"route";return{name:"BrowserSession",setupOnce(){if(void 0===$u.document)return void(nh&&La("Using the `browserSessionIntegration` in non-browser environments is not supported."));yd({ignoreDuration:!0}),bd();const e=hc();let n=e.getUser();e.addScopeListener(e=>{const t=e.getUser();n?.id===t?.id&&n?.ip_address===t?.ip_address||(bd(),n=t)}),"route"===t&&Qu(({from:e,to:t})=>{e!==t&&(yd({ignoreDuration:!0}),bd())})}}},wh=(e={})=>{const t={onerror:!0,onunhandledrejection:!0,...e};return{name:"GlobalHandlers",setupOnce(){Error.stackTraceLimit=50},setup(e){t.onerror&&(function(e){!function(){const t="error";Xa(t,t=>{const{stackParser:n,attachStacktrace:r}=xh();if(fc()!==e||Tu())return;const{msg:i,url:o,line:s,column:a,error:l}=t,c=function(e,t,n,r){const i=e.exception=e.exception||{},o=i.values=i.values||[],s=o[0]=o[0]||{},a=s.stacktrace=s.stacktrace||{},l=a.frames=a.frames||[];return 0===l.length&&l.push({colno:r,lineno:n,filename:kh(t)??Nl(),function:qa,in_app:!0}),e}(Wu(n,l||i,void 0,r,!1),o,s,a);c.level="error",gd(c,{originalException:l,mechanism:{handled:!1,type:"auto.browser.global_handlers.onerror"}})}),el(t,rl)}()}(e),bh("onerror")),t.onunhandledrejection&&(function(e){!function(){const t="unhandledrejection";Xa(t,t=>{const{stackParser:n,attachStacktrace:r}=xh();if(fc()!==e||Tu())return;const i=function(e){if(ml(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}(t),o=ml(i)?{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`}]}}:Wu(n,i,void 0,r,!0);o.level="error",gd(o,{originalException:i,mechanism:{handled:!1,type:"auto.browser.global_handlers.onunhandledrejection"}})}),el(t,ol)}()}(e),bh("onunhandledrejection"))}}};function bh(e){nh&&Aa(`Global Handler attached: ${e}`)}function xh(){const e=fc();return e?.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}function kh(e){if(ul(e)&&0!==e.length)return e.startsWith("data:")?`<${function(e,t=!0){if(e.startsWith("data:")){const n=e.match(/^data:([^;,]+)/),r=n?n[1]:"text/plain",i=e.includes(";base64,"),o=e.indexOf(",");let s="";if(t&&-1!==o){const t=e.slice(o+1);s=t.length>10?`${t.slice(0,10)}... [truncated]`:t}return`data:${r}${i?",base64":""}${s?`,${s}`:""}`}return e}(e,!1)}>`:e}const Nh=(e={})=>{const t=e.limit||5,n=e.key||"cause";return{name:"LinkedErrors",preprocessEvent(e,r,i){du(Pu,i.getOptions().stackParser,n,t,e,r)}}};function Sh(e={}){const t=!e.skipBrowserExtensionCheck&&!!function(){if(void 0===$u.window)return!1;const e=$u;if(e.nw)return!1;const t=e.chrome||e.browser;if(!t?.runtime?.id)return!1;const n=Nl();return!($u===$u.top&&/^(?:chrome-extension|moz-extension|ms-browser-extension|safari-web-extension):\/\//.test(n))}()&&(nh&&Ra(()=>{}),!0);let n=null==e.defaultIntegrations?[au(),iu(),{name:"ConversationId",setup(e){e.on("spanStart",e=>{const t=uc().getScopeData(),n=hc().getScopeData(),r=t.conversationId||n.conversationId;r&&e.setAttribute("gen_ai.conversation.id",r)})}},fh(),hh(),wh(),Nh(),gu(),{name:"HttpContext",preprocessEvent(e){if(!$u.navigator&&!$u.location&&!$u.document)return;const t=function(){const e=Nl(),{referrer:t}=$u.document||{},{userAgent:n}=$u.navigator||{};return{url:e,headers:{...t&&{Referer:t},...n&&{"User-Agent":n}}}}(),n={...t.headers,...e.request?.headers};e.request={...t,...e.request,headers:n}}},{name:"CultureContext",preprocessEvent(e){const t=function(){try{const e=$u.Intl;if(!e)return;const t=e.DateTimeFormat().resolvedOptions();return{locale:t.locale,timezone:t.timeZone,calendar:t.calendar}}catch{return}}();t&&(e.contexts={...e.contexts,culture:{...t,...e.contexts?.culture}})}},vh()]:e.defaultIntegrations;const r={...e,enabled:!t&&e.enabled,stackParser:(i=e.stackParser||dh,Array.isArray(i)?Ua(...i):i),integrations:kd({integrations:e.integrations,defaultIntegrations:n}),transport:e.transport||th};var i;return function(e,t){!0===t.debug&&(_a?Wa():Ra(()=>{})),uc().update(t.initialScope);const n=new e(t);return function(e){uc().setClient(e)}(n),n.init(),n}(Bu,r)}let Ch=!1;function _h(t){if(Ch)e();else if(t.enabled&&t.dsn)try{const n=t.bundleUrlPatterns||[/cdn\.insure-os\.com/,/api\.os\.insure.*\/dist/,/localhost:\d+\/dist/,/index\.(esm|umd|cjs)\.js/];Sh({dsn:t.dsn,environment:t.environment||"production",release:t.release,beforeSend:t=>function(e,t){var n,r,i,o;const s=null===(o=null===(i=null===(r=null===(n=e.exception)||void 0===n?void 0:n.values)||void 0===r?void 0:r[0])||void 0===i?void 0:i.stacktrace)||void 0===o?void 0:o.frames;if(!s||0===s.length)return!0;return s.some(e=>!!e.filename&&t.some(t=>t.test(e.filename||"")))}(t,n)?(t.tags={...t.tags,source:"insureos-widget"},e(t.exception),t):(e(t.exception),null),allowUrls:n,sampleRate:t.sampleRate||1,tracesSampleRate:t.tracesSampleRate||.1,integrations:[hh({console:!0,dom:!0,fetch:!0,history:!1,xhr:!0}),gu()],ignoreErrors:["top.GLOBALS","originalCreateNotification","canvas.contentDocument","MyApp_RemoveAllHighlights","atomicFindClose","Can't find variable: ZiteReader","jigsaw is not defined","ComboSearch is not defined","ResizeObserver loop limit exceeded","ResizeObserver loop completed with undelivered notifications"]}),Ch=!0,e()}catch(e){}else e()}function $h(t,n){if(Ch)try{n?mc(e=>{Object.entries(n).forEach(([t,n])=>{e.setContext(t,n)}),fd(t)}):fd(t)}catch(t){e()}}function Ih(t,n="info",r){if(Ch)try{r?mc(e=>{Object.entries(r).forEach(([t,n])=>{e.setContext(t,n)}),pd(t,n)}):pd(t,n)}catch(t){e()}}function Th(t){if(Ch)try{!function(e){hc().setUser(e)}(t)}catch(t){e()}}function Eh(t){if(Ch)try{tu(t)}catch(t){e()}}function Ph(t,n){if(Ch)try{!function(e,t){hc().setTag(e,t)}(t,n)}catch(t){e()}}function zh(){return Ch}var Dh=Object.freeze({__proto__:null,addBreadcrumb:Eh,captureException:$h,captureMessage:Ih,initializeSentry:_h,isSentryInitialized:zh,setTag:Ph,setUser:Th});const Rh="https://a73b48791ca06287db6bc587f376f7b9@o490277.ingest.us.sentry.io/4510139918450688",Mh="production",Oh="insureos-scripts",jh=!0,Wh=1,Ah=.1;class Lh{constructor(e={}){var t,n,r,i;this.dataLayerAvailable=!1,this.config={enabled:null===(t=e.enabled)||void 0===t||t,customDataLayer:null!==(n=e.customDataLayer)&&void 0!==n?n:"dataLayer",includePersonalData:null!==(r=e.includePersonalData)&&void 0!==r&&r,debug:null!==(i=e.debug)&&void 0!==i&&i},"undefined"!=typeof window?this.initializeDataLayer():this.dataLayerAvailable=!1}initializeDataLayer(){try{const e=this.config.customDataLayer;window[e]||(window[e]=[],this.logDebug(`Created new ${e} array`)),Array.isArray(window[e])?(this.dataLayerAvailable=!0,this.logDebug(`✅ Data layer '${e}' is available and ready`)):(this.dataLayerAvailable=!1,this.logDebug(`⚠️ Data layer '${e}' exists but is not an array`))}catch(e){this.dataLayerAvailable=!1,this.logDebug("⚠️ Failed to initialize data layer:",e)}}isEnabled(){return this.config.enabled&&this.dataLayerAvailable}getDataLayer(){if(!this.isEnabled())return null;try{const e=window[this.config.customDataLayer];return Array.isArray(e)?e:null}catch(e){return this.logDebug("Failed to get data layer:",e),null}}push(e){if(!this.isEnabled())return void this.logDebug("📊 Analytics disabled or data layer not available, skipping event:",e.event);const t=this.getDataLayer();if(t)try{const n=this.config.includePersonalData?e:this.removePII(e);t.push(n),this.logDebug("📊 Pushed event to data layer:",n)}catch(e){this.logDebug("❌ Failed to push event to data layer:",e)}else this.logDebug("⚠️ Data layer not available, skipping event:",e.event)}removePII(e){const t={...e},n=["email","phone","name","address","client_name","client_email"];for(const e of n)e in t&&delete t[e];return t}logDebug(...t){this.config.debug&&e("[Analytics]",...t)}clear(){if(this.dataLayerAvailable)try{window[this.config.customDataLayer]=[],this.logDebug("🧹 Cleared data layer")}catch(e){this.logDebug("Failed to clear data layer:",e)}}getConfig(){return{...this.config}}updateConfig(e){this.config={...this.config,...e},(e.customDataLayer||void 0!==e.enabled)&&this.initializeDataLayer(),this.logDebug("Updated analytics configuration:",this.config)}}class Bh{constructor(){this.sentryInitialized=!1,this.analyticsManager=null,this.pendingPromoCodes=new Map}initializeSentryOnce(){if(!this.sentryInitialized)try{_h({dsn:Rh,environment:Mh,release:Oh,enabled:jh,sampleRate:Wh,tracesSampleRate:Ah}),this.sentryInitialized=!0,e()}catch(t){e()}}validateConfig(e){if(!e.orgId)throw new Error("orgId is required");if("payment"===e.mode&&!e.paymentLinkId)throw new Error("paymentLinkId is required when mode is 'payment'")}initializeAnalyticsOnce(t){var n,r,i,o,s;if(!this.analyticsManager)try{this.analyticsManager=new Lh({enabled:null===(n=t.analyticsConfig)||void 0===n?void 0:n.enabled,customDataLayer:null===(r=t.analyticsConfig)||void 0===r?void 0:r.customDataLayer,includePersonalData:null===(i=t.analyticsConfig)||void 0===i?void 0:i.includePersonalData,debug:null!==(s=null===(o=t.analyticsConfig)||void 0===o?void 0:o.debug)&&void 0!==s?s:t.debug}),ze(this.analyticsManager),e()}catch(t){e()}}async mount(e,r){r.debug&&(globalThis.insureOSDebug=!0),this.validateConfig(r),this.initializeSentryOnce(),this.initializeAnalyticsOnce(r),function(e,r){var i,o,s;r==document&&(r=document.documentElement),n.m&&n.m(e,r),i=r.i,o=[],s=[],A(r,e=r.i=N(C,null,[e]),i||y,y,r.namespaceURI,i?null:r.firstChild?t.call(r.childNodes):null,o,i?i.v:r.firstChild,!1,s),B(o,e,s)}(N(Ca,{config:r,initializeFormContext:this.initializeFormContext.bind(this)}),e)}createHttpClient(e){var t,n,r,i,o,s,a,l,c,d;if(!e.orgId)throw new Error("orgId is required");const u=e.apiBaseUrl||"https://api.os.insure";return new Q({orgId:e.orgId,apiBaseUrl:u,timeout:(null===(t=e.httpConfig)||void 0===t?void 0:t.timeout)||1e4,retryConfig:{maxRetries:(null===(r=null===(n=e.httpConfig)||void 0===n?void 0:n.retryConfig)||void 0===r?void 0:r.maxRetries)||3,baseDelay:(null===(o=null===(i=e.httpConfig)||void 0===i?void 0:i.retryConfig)||void 0===o?void 0:o.baseDelay)||1e3,maxDelay:(null===(a=null===(s=e.httpConfig)||void 0===s?void 0:s.retryConfig)||void 0===a?void 0:a.maxDelay)||1e4,retryableStatusCodes:(null===(c=null===(l=e.httpConfig)||void 0===l?void 0:l.retryConfig)||void 0===c?void 0:c.retryableStatusCodes)||[429,500,502,503,504],...null===(d=e.httpConfig)||void 0===d?void 0:d.retryConfig}})}createClient(e){const t=this.createHttpClient(e);return new Ue(t)}clearQuoteStateForOrg(e){try{if(window.localStorage){window.localStorage.removeItem("insure-os-selected-product"),window.localStorage.removeItem(`insure_os_quote_intent_${e}`),window.localStorage.removeItem(`insure-os-pending-promo-${e}`);for(let t=window.localStorage.length-1;t>=0;t--){const n=window.localStorage.key(t);n&&n.startsWith("insure_os_")&&n.endsWith(e)&&window.localStorage.removeItem(n)}}window.sessionStorage&&window.sessionStorage.removeItem(`insure_os_quote_intent_${e}`)}catch(e){}}async initializeFormContext(t){var n,r,i,o,s;const a=this.createHttpClient(t),l=new URLSearchParams(window.location.search),c=l.get("p")||l.get("pl_ref");if(c)return e(),this.clearQuoteStateForOrg(t.orgId),{httpClient:a,stateManager:null,quoteIntent:null,quoteIntentStore:null,formStateManager:null,paymentLinkConfig:{paymentLinkId:c,signedUrl:void 0}};const d=l.get("q")||l.get("qi");if(d){e();try{const t=await a.resumeQuoteIntent(d);if("redirect"===(null==t?void 0:t.mode)&&t.payment_link_short_code){const n=window.location.pathname+`?p=${encodeURIComponent(t.payment_link_short_code)}`;return e(),window.location.replace(n),new Promise(()=>{})}}catch(t){e(null==t||t.message)}t.quoteIntentUrl=`${t.apiBaseUrl}/quote-intents/${d}`,this.clearQuoteStateForOrg(t.orgId)}if("payment"===t.mode)return e(),{httpClient:a,stateManager:null,quoteIntent:null,quoteIntentStore:null,formStateManager:null,paymentLinkConfig:{paymentLinkId:t.paymentLinkId,signedUrl:t.signedUrl}};const u="sessionStorage"===t.storageType?new K:new J;u.isAvailable()?e(u.constructor.name):e();const h=new te(u),m=new ne(h),f=t.products,p=null==f?void 0:f.includes("*"),g=!f||0===f.length,y=g||p||f&&f.length>1,v=f&&1===f.length&&!p,w=localStorage.getItem("insure-os-selected-product"),b=new URLSearchParams(window.location.search),x=!!(b.get("transactionId")||b.get("transaction_id")||b.get("payment_id")),k=b.get("code");if("1"===b.get("clear")){e(),localStorage.clear(),b.delete("clear");const t=b.toString()?`${window.location.pathname}?${b.toString()}`:window.location.pathname;window.history.replaceState({},"",t),e()}const N=`insure-os-pending-promo-${t.orgId}`,S="skipPendingPromoCode"in t&&!0===t.skipPendingPromoCode;if(k&&!x&&!S){const n={code:k,ts:Date.now()};localStorage.setItem(N,JSON.stringify(n)),this.pendingPromoCodes.set(t.orgId,k),e(),b.delete("code");const r=b.toString()?`${window.location.pathname}?${b.toString()}`:window.location.pathname;window.history.replaceState({},"",r)}const C="promoCode"in t?t.promoCode:void 0;let _=null;if(!S)try{const e=localStorage.getItem(N);if(e){const t=JSON.parse(e);"object"==typeof t&&t.code&&Date.now()-t.ts<36e5?_=t.code:"string"==typeof t?_=t:localStorage.removeItem(N)}}catch(e){localStorage.removeItem(N)}const $=S?void 0:this.pendingPromoCodes.get(t.orgId),I=k||C||_||$||null;if(e(),I&&!x){const i=h.getQuoteIntent(t.orgId);if(null===(n=null==i?void 0:i.form_data)||void 0===n?void 0:n.page_data){const n=i.form_data.page_data,o=null===(r=Object.values(n).find(e=>e&&"object"==typeof e&&"promo_code"in e))||void 0===r?void 0:r.promo_code;o&&o!==I&&(e(),m.clearQuoteIntent(t.orgId))}}const T=async n=>{var r;e(n.id);const i=new Fe(n,a,m,{autoSave:!1,autoSaveInterval:n.form_definition.settings.autoSaveInterval});if("prefillFormData"in t&&t.prefillFormData){const o=(null===(r=n.form_definition)||void 0===r?void 0:r.pages.length)||0,s=Array.from({length:o},(e,t)=>t);i.restoreFormProgress({page_data:t.prefillFormData,current_page:o-1,completed_pages:s,last_updated:(new Date).toISOString()}),e()}else n.form_data&&i.restoreFormProgress(n.form_data);if(I){const t=i.getFormDefinition().pages.find(e=>e.fields.some(e=>"promo_code"===(e.code||e.id)));t?(i.updateFieldValue(t.id,"promo_code",I),e(t.id)):e()}if(n.cached_result&&(e(),i.restoreCalculationResult(n.cached_result)),n.organisation&&n.organisation.theme)try{await ma.loadTheme({slug:n.organisation.slug,theme_url:n.organisation.theme.css_url})}catch(t){e()}const o="skipAutoCalculation"in t&&!!t.skipAutoCalculation;return await this.handleAutoCalculationIfComplete(i,o),{httpClient:a,stateManager:h,quoteIntent:n,quoteIntentStore:m,formStateManager:i,urlPromoCode:I||void 0}};if(y&&!t.quoteIntentUrl&&!w){const n=x?null:h.getQuoteIntent(t.orgId);if(n)try{const r=await a.getQuoteIntent(n.url),l={id:r.quote_intent.id,url:r.url,calculate_url:r.calculate_url,delete_calculations_url:r.delete_calculations_url,expires_at:new Date(r.quote_intent.expires_at).getTime(),updated_at:new Date(r.quote_intent.updated_at).getTime(),created_at:new Date(r.quote_intent.created_at).getTime(),org_id:t.orgId,product_id:r.product.id,product_name:r.product.description||r.product.name,form_definition:r.product.form_definition,form_data:r.quote_intent.form_data,status:r.quote_intent.status,reference:r.quote_intent.reference,organisation:r.organisation,cached_result:r.cached_result};if(h.saveQuoteIntent(t.orgId,l),null===(o=null===(i=l.form_data)||void 0===i?void 0:i.completed_pages)||void 0===o?void 0:o.length){if(e(),null===(s=l.organisation)||void 0===s?void 0:s.theme)try{await ma.loadTheme({slug:l.organisation.slug,theme_url:l.organisation.theme.css_url})}catch(t){e()}const{firstName:n,lastUpdated:r}=(e=>{var t;const n=["client_first_name","first_name","firstName","fname","given_name"],r=null===(t=e.form_data)||void 0===t?void 0:t.page_data;let i=null;if(r)for(const e of Object.values(r)){if(!e||"object"!=typeof e)continue;const t=e;for(const e of n)if(t[e]){i=String(t[e]);break}if(i)break}return{firstName:i,lastUpdated:e.updated_at?new Date(e.updated_at).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"}):null}})(l);return{httpClient:a,stateManager:h,quoteIntent:null,quoteIntentStore:m,formStateManager:null,resumePrompt:{reference:l.reference||null,productName:l.product_name||null,firstName:n,lastUpdated:r,onContinue:async()=>T(l),onStartFresh:async()=>{m.clearQuoteIntent(t.orgId);const e=await a.fetchAvailableProducts(g?void 0:f);return{httpClient:a,stateManager:h,quoteIntent:null,quoteIntentStore:m,formStateManager:null,availableProducts:e.products,productCodes:f}}}}}}catch(n){e(),m.clearQuoteIntent(t.orgId)}e();const r=await a.fetchAvailableProducts(g?void 0:f);if(e(),r.organisation&&r.organisation.theme)try{const t=await Promise.resolve().then(function(){return fa}).then(e=>e.ThemeLoader);await t.loadTheme({slug:r.organisation.slug,theme_url:r.organisation.theme.css_url}),e()}catch(t){e()}return{httpClient:a,stateManager:h,quoteIntent:null,quoteIntentStore:m,formStateManager:null,availableProducts:r.products,productCodes:f}}let E;w?(e(),E=w,localStorage.removeItem("insure-os-selected-product")):v&&(E=f[0]);const P=async()=>{e();const n=t.quoteIntentUrl?await a.getQuoteIntent(t.quoteIntentUrl):await a.createQuoteIntent({code:E,...t.dealerOrganisationId&&{dealer_organisation_id:t.dealerOrganisationId}});return e(),{id:n.quote_intent.id,url:n.url,calculate_url:n.calculate_url,delete_calculations_url:n.delete_calculations_url,calculate_url_v2:n.calculate_url_v2,reprice_url_v2:n.reprice_url_v2,bind_url_v2:n.bind_url_v2,calculator_version:n.product.calculator_version,expires_at:new Date(n.quote_intent.expires_at).getTime(),updated_at:new Date(n.quote_intent.updated_at).getTime(),created_at:new Date(n.quote_intent.created_at).getTime(),org_id:t.orgId,product_id:n.product.id,product_name:n.product.description||n.product.name,form_definition:n.product.form_definition,form_data:n.quote_intent.form_data,status:n.quote_intent.status,reference:n.quote_intent.reference,organisation:n.organisation,cached_result:n.cached_result}},z=async e=>{var n;const r=new URLSearchParams(window.location.search),i=r.get("transaction_id")||r.get("payment_id")||r.get("transactionId"),o=await a.getQuoteIntent(e);let s;const l=r.get("status");if(i&&"processing"!==l){const e=null===(n=o.payment_transactions)||void 0===n?void 0:n.find(e=>e.id===i);if(e){let t="unknown";switch(e.status){case"completed":t="success";break;case"failed":t="declined";break;case"cancelled":t="cancelled";break;default:t="error"}s={paymentTransactionId:e.id,paymentStatus:t,transactionStatus:e}}else if(l){let e="error";switch(l.toLowerCase()){case"success":case"completed":e="success";break;case"failed":case"declined":e="declined";break;case"cancelled":case"canceled":e="cancelled";break;default:e="error"}s={paymentTransactionId:i,paymentStatus:e,transactionStatus:void 0}}}const c={id:o.quote_intent.id,url:o.url,calculate_url:o.calculate_url,delete_calculations_url:o.delete_calculations_url,calculate_url_v2:o.calculate_url_v2,reprice_url_v2:o.reprice_url_v2,bind_url_v2:o.bind_url_v2,calculator_version:o.product.calculator_version,expires_at:new Date(o.quote_intent.expires_at).getTime(),updated_at:new Date(o.quote_intent.updated_at).getTime(),created_at:new Date(o.quote_intent.created_at).getTime(),org_id:t.orgId,product_id:o.product.id,product_name:o.product.description||o.product.name,form_definition:o.product.form_definition,form_data:o.quote_intent.form_data,status:o.quote_intent.status,reference:o.quote_intent.reference,organisation:o.organisation,payment_return:s,payment_transactions:o.payment_transactions,cached_result:o.cached_result};return s&&h.saveQuoteIntent(t.orgId,c),c};return(async()=>{let e=null,n=!1;try{const r=h.getQuoteIntent(t.orgId),i=await m.getOrCreateQuoteIntent(t.orgId,P,z);i.payment_return&&h.saveQuoteIntent(t.orgId,i),e=i,n=!r}catch(r){if(!(r instanceof Z&&404===r.statusCode))throw r;m.clearQuoteIntent(t.orgId),e=await m.getOrCreateQuoteIntent(t.orgId,P,z),n=!0}if(n&&e&&Me(e),!e)throw new Error("Failed to initialize quote intent state");return T(e)})()}async handleAutoCalculationIfComplete(t,n=!1){try{if(n)return void e();const r=t.getQuoteIntent();if("paid"===r.status||"completed"===r.status)return void e();if(t.hasCalculationResponse())return void e();if(t.hasLastCalculationFailed())return void e();const i=t.getPageCompletionStatus(),{totalPages:o,completedPages:s}=i,a=s.length===o;e((s.length,t.getIsCalculating(),t.hasLastCalculationFailed())),a&&!t.getIsCalculating()&&(e(),await t.calculateQuote(),e())}catch(t){e()}}}const qh=new Bh;"undefined"!=typeof window&&(window.InsureOS=qh,function(){const e=document.querySelectorAll('script[src*="insureos"]'),t=e[e.length-1];if(t&&t.src){const e=new URL(t.src),n=e.searchParams.get("orgId"),r=e.searchParams.get("productCode"),i=e.searchParams.get("productCodes"),o=i?i.split(","):r?[r]:null;if(n&&o){const t=e.searchParams.get("container"),r=t?document.getElementById(t):document.body;if(r){const e={orgId:n,products:o};r.dataset.insureosConfig=JSON.stringify(e);const t=async()=>{try{await qh.mount(r,e)}catch(e){}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}}}}());class Fh{constructor(e={}){var t,n,r;this.detectionResults=null,this.config={fetch:null===(t=e.fetch)||void 0===t||t,promise:null===(n=e.promise)||void 0===n||n,url:null===(r=e.url)||void 0===r||r}}async loadPolyfills(){this.detectionResults=this.detectFeatures(),this.config.fetch&&this.detectionResults.fetch&&await this.loadFetchPolyfill(),this.config.promise&&this.detectionResults.promise&&await this.loadPromisePolyfill(),this.config.url&&this.detectionResults.url&&await this.loadUrlPolyfill()}getDetectionResults(){return this.detectionResults}detectFeatures(){return{fetch:this.needsFetchPolyfill(),promise:this.needsPromisePolyfill(),url:this.needsUrlPolyfill()}}needsFetchPolyfill(){if("undefined"==typeof fetch)return!0;if("undefined"==typeof Headers||"undefined"==typeof Request||"undefined"==typeof Response)return!0;try{return new Headers,new Request("http://example.com"),new Response,!1}catch(e){return!0}}needsPromisePolyfill(){if("undefined"==typeof Promise)return!0;if("function"!=typeof Promise.resolve||"function"!=typeof Promise.reject||"function"!=typeof Promise.all)return!0;try{const e=Promise.resolve(42);return"function"!=typeof e.then||"function"!=typeof e.catch}catch(e){return!0}}needsUrlPolyfill(){if("undefined"==typeof URL)return!0;try{const e=new URL("http://example.com/path?param=value#hash");if("string"!=typeof e.protocol||"string"!=typeof e.hostname||"string"!=typeof e.pathname||"string"!=typeof e.search||"string"!=typeof e.hash)return!0;if("undefined"==typeof URLSearchParams)return!0;const t=new URLSearchParams("param=value");return"function"!=typeof t.get||"function"!=typeof t.set}catch(e){return!0}}async loadFetchPolyfill(){if(this.needsFetchPolyfill())try{const{fetch:e,Headers:t,Request:n,Response:r}=await Promise.resolve().then(function(){return Gh});void 0===globalThis.fetch&&(globalThis.fetch=e),void 0===globalThis.Headers&&(globalThis.Headers=t),void 0===globalThis.Request&&(globalThis.Request=n),void 0===globalThis.Response&&(globalThis.Response=r)}catch(e){}}async loadPromisePolyfill(){if(this.needsPromisePolyfill())try{const{PromisePolyfill:e}=await Promise.resolve().then(function(){return Qh});void 0===globalThis.Promise&&(globalThis.Promise=e)}catch(e){}}async loadUrlPolyfill(){if(this.needsUrlPolyfill())try{const{URLPolyfill:e,URLSearchParamsPolyfill:t}=await Promise.resolve().then(function(){return Kh});void 0===globalThis.URL&&(globalThis.URL=e),void 0===globalThis.URLSearchParams&&(globalThis.URLSearchParams=t)}catch(e){}}}class Hh{constructor(){if(this.measurements=new Map,this.completedMeasurements=new Map,this.apiCallMetrics=[],this.initializationTime=0,Hh.instance)return Hh.instance;Hh.instance=this}startMeasurement(e){this.measurements.set(e,this.now())}endMeasurement(e){const t=this.measurements.get(e);if(void 0===t)throw new Error(`No measurement started for: ${e}`);const n=this.now()-t;return this.measurements.delete(e),this.completedMeasurements.has(e)||this.completedMeasurements.set(e,[]),this.completedMeasurements.get(e).push(n),"initialization"===e&&(this.initializationTime=n),n}async measureApiCall(e,t){const n=this.now();let r,i=!1;try{const e=await t();return i=!0,e}catch(e){throw i=!1,r=e instanceof Error?e.message:"Unknown error",e}finally{const t=this.now()-n;this.apiCallMetrics.push({operation:e,duration:t,timestamp:Date.now(),success:i,error:r})}}measureMemoryUsage(){return"undefined"!=typeof performance&&"memory"in performance&&performance.memory.usedJSHeapSize||0}getDetailedMemoryInfo(){if("undefined"!=typeof performance&&"memory"in performance){const e=performance.memory;return{usedJSHeapSize:e.usedJSHeapSize||0,totalJSHeapSize:e.totalJSHeapSize||0,jsHeapSizeLimit:e.jsHeapSizeLimit||0}}return null}getMetrics(){var e;const t=this.apiCallMetrics.filter(e=>e.success).map(e=>e.duration),n=t.length>0?t.reduce((e,t)=>e+t,0)/t.length:0,r={};return this.completedMeasurements.forEach((e,t)=>{r[t]=[...e]}),{bundleSize:{esm:0,umd:0,cjs:0,gzipped:{esm:0,umd:0,cjs:0}},runtime:{initializationTime:this.initializationTime,apiCallTime:t.length>0&&null!==(e=t[t.length-1])&&void 0!==e?e:0,memoryUsage:this.measureMemoryUsage(),averageApiCallTime:n,totalApiCalls:this.apiCallMetrics.length},measurements:r}}getApiCallMetrics(){return[...this.apiCallMetrics]}clearMetrics(){this.completedMeasurements.clear(),this.apiCallMetrics=[],this.initializationTime=0}generateReport(){const e=this.getMetrics(),t=this.getDetailedMemoryInfo();let n="=== Performance Report ===\n\n";if(n+="Runtime Performance:\n",n+=` Initialization Time: ${e.runtime.initializationTime.toFixed(2)}ms\n`,n+=` Total API Calls: ${e.runtime.totalApiCalls}\n`,n+=` Average API Call Time: ${e.runtime.averageApiCallTime.toFixed(2)}ms\n`,n+=` Current Memory Usage: ${(e.runtime.memoryUsage/1024/1024).toFixed(2)}MB\n\n`,t&&(n+="Memory Details:\n",n+=` Used Heap: ${(t.usedJSHeapSize/1024/1024).toFixed(2)}MB\n`,n+=` Total Heap: ${(t.totalJSHeapSize/1024/1024).toFixed(2)}MB\n`,n+=` Heap Limit: ${(t.jsHeapSizeLimit/1024/1024).toFixed(2)}MB\n\n`),this.apiCallMetrics.length>0){n+="API Call Breakdown:\n";const e=new Map;this.apiCallMetrics.forEach(t=>{e.has(t.operation)||e.set(t.operation,{count:0,totalTime:0,errors:0});const n=e.get(t.operation);n.count++,n.totalTime+=t.duration,t.success||n.errors++}),e.forEach((e,t)=>{const r=e.totalTime/e.count,i=(e.errors/e.count*100).toFixed(1);n+=` ${t}: ${e.count} calls, ${r.toFixed(2)}ms avg, ${i}% errors\n`})}return n}static async getBundleSizes(){return{esm:0,umd:0,cjs:0,gzipped:{esm:0,umd:0,cjs:0}}}now(){return"undefined"!=typeof performance&&performance.now?performance.now():Date.now()}static startMeasurement(e){(new Hh).startMeasurement(e)}static endMeasurement(e){return(new Hh).endMeasurement(e)}static measureMemoryUsage(){return(new Hh).measureMemoryUsage()}static async measureApiCall(e,t){return(new Hh).measureApiCall(e,t)}static getMetrics(){return(new Hh).getMetrics()}static generateReport(){return(new Hh).generateReport()}}let Uh=class e{constructor(t){this.headers=new Map,t&&(Array.isArray(t)?t.forEach(([e,t])=>this.set(e,t)):t instanceof e?t.forEach((e,t)=>this.set(t,e)):Object.entries(t).forEach(([e,t])=>this.set(e,t)))}append(e,t){const n=this.get(e);this.set(e,n?`${n}, ${t}`:t)}delete(e){this.headers.delete(e.toLowerCase())}get(e){return this.headers.get(e.toLowerCase())||null}has(e){return this.headers.has(e.toLowerCase())}set(e,t){this.headers.set(e.toLowerCase(),t)}forEach(e){this.headers.forEach(e)}},Yh=class{constructor(e,t={}){var n;"string"==typeof e?(this.url=e,this.method=t.method||"GET",this.headers=new Uh(t.headers),this.body=t.body||null,this.signal=t.signal||void 0):(this.url=e.url,this.method=t.method||e.method,this.headers=new Uh(t.headers||e.headers),this.body=void 0!==t.body?t.body:e.body,this.signal=void 0!==t.signal?null!==(n=t.signal)&&void 0!==n?n:void 0:e.signal)}},Zh=class{constructor(e="",t={}){this.status=t.status||200,this.statusText=t.statusText||"OK",this.headers=new Uh(t.headers),this.ok=this.status>=200&&this.status<300,this.zt=e}async text(){return this.zt}async json(){return JSON.parse(this.zt)}};var Gh=Object.freeze({__proto__:null,Headers:Uh,Request:Yh,Response:Zh,fetch:async function(e,t={}){return new Promise((n,r)=>{const i=new Yh(e,t),o=new XMLHttpRequest;i.signal&&i.signal.addEventListener("abort",()=>{o.abort(),r(new Error("Request aborted"))}),o.open(i.method,i.url),i.headers.forEach((e,t)=>{o.setRequestHeader(t,e)}),o.onload=()=>{const e=new Uh;o.getAllResponseHeaders().split("\r\n").forEach(t=>{const[n,r]=t.split(": ");n&&r&&e.set(n,r)});const t=new Zh(o.responseText,{status:o.status,statusText:o.statusText,headers:e});n(t)},o.onerror=()=>{r(new TypeError("Network request failed"))},o.ontimeout=()=>{r(new TypeError("Network request timed out"))},o.send(i.body)})}});class Vh{constructor(e){this.state="pending",this.onFulfilledCallbacks=[],this.onRejectedCallbacks=[];try{e(this.resolve.bind(this),this.reject.bind(this))}catch(e){this.reject(e)}}resolve(e){"pending"===this.state&&(this.state="fulfilled",this.value=e,this.onFulfilledCallbacks.forEach(t=>{setTimeout(()=>t(e),0)}))}reject(e){"pending"===this.state&&(this.state="rejected",this.reason=e,this.onRejectedCallbacks.forEach(t=>{setTimeout(()=>t(e),0)}))}then(e,t){return new Vh((n,r)=>{const i=t=>{try{if(e){const i=e(t);i instanceof Vh?i.then(n,r):n(i)}else n(t)}catch(e){r(e)}},o=e=>{try{if(t){const i=t(e);i instanceof Vh?i.then(n,r):n(i)}else r(e)}catch(e){r(e)}};"fulfilled"===this.state?setTimeout(()=>i(this.value),0):"rejected"===this.state?setTimeout(()=>o(this.reason),0):(this.onFulfilledCallbacks.push(i),this.onRejectedCallbacks.push(o))})}catch(e){return this.then(void 0,e)}static resolve(e){return new Vh(t=>t(e))}static reject(e){return new Vh((t,n)=>n(e))}static all(e){return new Vh((t,n)=>{if(0===e.length)return void t([]);const r=[];let i=0;e.forEach((o,s)=>{o.then(n=>{r[s]=n,i++,i===e.length&&t(r)},n)})})}}var Qh=Object.freeze({__proto__:null,PromisePolyfill:Vh});class Jh{constructor(e){this.params=new Map,"string"==typeof e?this.parseString(e):e&&"object"==typeof e&&"forEach"in e&&"function"==typeof e.forEach?e.forEach((e,t)=>this.append(t,e)):e&&"object"==typeof e&&Object.entries(e).forEach(([e,t])=>this.set(e,t))}parseString(e){const t=e.startsWith("?")?e.slice(1):e;t&&t.split("&").forEach(e=>{if(!e)return;const t=e.indexOf("=");let n,r;-1===t?(n=e,r=""):(n=e.substring(0,t),r=e.substring(t+1)),n&&this.append(decodeURIComponent(n),decodeURIComponent(r))})}append(e,t){const n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}delete(e){this.params.delete(e)}get(e){var t;const n=this.params.get(e);return n&&n.length>0&&null!==(t=n[0])&&void 0!==t?t:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}forEach(e){this.params.forEach((t,n)=>{t.forEach(t=>e(t,n))})}toString(){const e=[];return this.params.forEach((t,n)=>{t.forEach(t=>{e.push(`${encodeURIComponent(n)}=${encodeURIComponent(t)}`)})}),e.join("&")}}var Kh=Object.freeze({__proto__:null,URLPolyfill:class{constructor(e,t){const n=this.parseUrl(e,t);this.protocol=n.protocol,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.hash=n.hash,this.host=this.port?`${this.hostname}:${this.port}`:this.hostname,this.origin=`${this.protocol}//${this.host}`,this.href=this.toString(),this.searchParams=new Jh(this.search)}parseUrl(e,t){const n=document.createElement("a");if(t){const r=document.createElement("a");r.href=t,n.href=this.resolveUrl(e,r.href)}else n.href=e;return{protocol:n.protocol,hostname:n.hostname,port:n.port,pathname:n.pathname,search:n.search,hash:n.hash}}resolveUrl(e,t){if(e.includes("://"))return e;if(e.startsWith("/")){const n=document.createElement("a");return n.href=t,`${n.protocol}//${n.host}${e}`}return`${t.split("/").slice(0,-1).join("/")}/${e}`}toString(){return`${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`}},URLSearchParamsPolyfill:Jh});export{Lh as DataLayerManager,Q as EnhancedHttpClient,G as ErrorHandlingStrategy,g as ErrorType,Fe as FormStateManager,qh as InsureOS,Bh as InsureOSClient,Z as InsureOSError,te as LocalStateManager,J as LocalStorageAdapter,X as MemoryStorageAdapter,Hh as PerformanceMonitor,Fh as PolyfillManager,V as RetryStrategy,K as SessionStorageAdapter,ma as ThemeLoader,Eh as addBreadcrumb,$h as captureException,Ih as captureMessage,xe as createAppError,De as getAnalytics,Ee as getSupportMessage,ge as groupErrorsByField,ze as initializeAnalytics,_h as initializeSentry,zh as isSentryInitialized,pe as parseServerValidationErrors,Ph as setTag,Th as setUser,Ie as shouldShowErrorPage,Te as shouldShowMaintenancePage,Oe as trackFormProgress,Be as trackPaymentCompleted,qe as trackPaymentFailed,Le as trackPaymentInitiated,We as trackQuoteAtCheckout,je as trackQuoteCalculated,Ae as trackQuoteReferred,Me as trackQuoteStarted,me as validateField,fe as validatePage};
1
+ const e=()=>{globalThis.insureOSDebug};var t,n,r,i,o,s,a,l,c,d,u,h,m,f,p,g,y={},v=[],w=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,b=Array.isArray;function x(e,t){for(var n in t)e[n]=t[n];return e}function k(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function S(e,n,r){var i,o,s,a={};for(s in n)"key"==s?i=n[s]:"ref"==s?o=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?t.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===a[s]&&(a[s]=e.defaultProps[s]);return N(e,a,i,o,null)}function N(e,t,i,o,s){var a={type:e,props:t,key:i,ref:o,i:null,m:null,p:0,v:null,k:null,constructor:void 0,N:null==s?++r:s,_:-1,C:0};return null==s&&null!=n.vnode&&n.vnode(a),a}function _(e){return e.children}function C(e,t){this.props=e,this.context=t}function $(e,t){if(null==t)return e.m?$(e.m,e._+1):null;for(var n;t<e.i.length;t++)if(null!=(n=e.i[t])&&null!=n.v)return n.v;return"function"==typeof e.type?$(e):null}function I(e){if(e.I&&e.P){var t=e.N,r=t.v,i=[],o=[],s=x({},t);s.N=t.N+1,n.vnode&&n.vnode(s),A(e.I,s,t,e.R,e.I.namespaceURI,32&t.C?[r]:null,i,null==r?$(t):r,!!(32&t.C),o),s.N=t.N,s.m.i[s._]=s,B(i,s,o),t.v=t.m=null,s.v!=r&&T(s)}}function T(e){if(null!=(e=e.m)&&null!=e.k)return e.v=e.k.base=null,e.i.some(function(t){if(null!=t&&null!=t.v)return e.v=e.k.base=t.v}),T(e)}function E(e){(!e.P&&(e.P=!0)&&i.push(e)&&!P.O++||o!=n.debounceRendering)&&((o=n.debounceRendering)||s)(P)}function P(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(a),e=i.shift(),t=i.length,I(e)}finally{i.length=P.O=0}}function z(e,t,n,r,i,o,s,a,l,c,d){var u,h,m,f,p,g,w,b=r&&r.i||v,x=t.length;for(l=D(n,t,b,l,x),u=0;u<x;u++)null!=(m=n.i[u])&&(h=-1!=m._&&b[m._]||y,m._=u,g=A(e,m,h,i,o,s,a,l,c,d),f=m.v,m.ref&&h.ref!=m.ref&&(h.ref&&H(h.ref,null,m),d.push(m.ref,m.k||f,m)),null==p&&null!=f&&(p=f),(w=!!(4&m.C))||h.i===m.i?(l=R(m,l,e,w),w&&h.v&&(h.v=null)):"function"==typeof m.type&&void 0!==g?l=g:f&&(l=f.nextSibling),m.C&=-7);return n.v=p,l}function D(e,t,n,r,i){var o,s,a,l,c,d=n.length,u=d,h=0;for(e.i=new Array(i),o=0;o<i;o++)null!=(s=t[o])&&"boolean"!=typeof s&&"function"!=typeof s?("string"==typeof s||"number"==typeof s||"bigint"==typeof s||s.constructor==String?s=e.i[o]=N(null,s,null,null,null):b(s)?s=e.i[o]=N(_,{children:s},null,null,null):void 0===s.constructor&&s.p>0?s=e.i[o]=N(s.type,s.props,s.key,s.ref?s.ref:null,s.N):e.i[o]=s,l=o+h,s.m=e,s.p=e.p+1,a=null,-1!=(c=s._=M(s,n,l,u))&&(u--,(a=n[c])&&(a.C|=2)),null==a||null==a.N?(-1==c&&(i>d?h--:i<d&&h++),"function"!=typeof s.type&&(s.C|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,s.C|=4))):e.i[o]=null;if(u)for(o=0;o<d;o++)null!=(a=n[o])&&!(2&a.C)&&(a.v==r&&(r=$(a)),U(a,a));return r}function R(e,t,n,r){var i,o;if("function"==typeof e.type){for(i=e.i,o=0;i&&o<i.length;o++)i[o]&&(i[o].m=e,t=R(i[o],t,n,r));return t}e.v!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=$(e)),n.insertBefore(e.v,t||null)),t=e.v);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function M(e,t,n,r){var i,o,s,a=e.key,l=e.type,c=t[n],d=null!=c&&!(2&c.C);if(null===c&&null==a||d&&a==c.key&&l==c.type)return n;if(r>(d?1:0))for(i=n-1,o=n+1;i>=0||o<t.length;)if(null!=(c=t[s=i>=0?i--:o++])&&!(2&c.C)&&a==c.key&&l==c.type)return s;return-1}function O(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||w.test(t)?n:n+"px"}function j(e,t,n,r,i){var o,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||O(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||O(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(u,"$1")),s=t.toLowerCase(),t=s in e||"onFocusOut"==t||"onFocusIn"==t?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[d]=r[d]:(n[d]=h,e.addEventListener(t,o?f:m,o)):e.removeEventListener(t,o?f:m,o);else{if("http://www.w3.org/2000/svg"==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&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function W(e){return function(t){if(this.l){var r=this.l[t.type+e];if(null==t[c])t[c]=h++;else if(t[c]<r[d])return;return r(n.event?n.event(t):t)}}}function A(e,t,r,i,o,s,a,l,c,d){var u,h,m,f,p,g,y,w,S,N,$,I,T,E,P,D=t.type;if(void 0!==t.constructor)return null;128&r.C&&(c=!!(32&r.C),s=[l=t.v=r.v]),(u=n.p)&&u(t);e:if("function"==typeof D)try{if(w=t.props,S=D.prototype&&D.prototype.render,N=(u=D.contextType)&&i[u.k],$=u?N?N.props.value:u.m:i,r.k?y=(h=t.k=r.k).m=h.j:(S?t.k=h=new D(w,$):(t.k=h=new C(w,$),h.constructor=D,h.render=Y),N&&N.sub(h),h.state||(h.state={}),h.R=i,m=h.P=!0,h.W=[],h.A=[]),S&&null==h.L&&(h.L=h.state),S&&null!=D.getDerivedStateFromProps&&(h.L==h.state&&(h.L=x({},h.L)),x(h.L,D.getDerivedStateFromProps(w,h.L))),f=h.props,p=h.state,h.N=t,m)S&&null==D.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),S&&null!=h.componentDidMount&&h.W.push(h.componentDidMount);else{if(S&&null==D.getDerivedStateFromProps&&w!==f&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(w,$),t.N==r.N||!h.v&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(w,h.L,$)){t.N!=r.N&&(h.props=w,h.state=h.L,h.P=!1),t.v=r.v,t.i=r.i,t.i.some(function(e){e&&(e.m=t)}),v.push.apply(h.W,h.A),h.A=[],h.W.length&&a.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(w,h.L,$),S&&null!=h.componentDidUpdate&&h.W.push(function(){h.componentDidUpdate(f,p,g)})}if(h.context=$,h.props=w,h.I=e,h.v=!1,I=n.O,T=0,S)h.state=h.L,h.P=!1,I&&I(t),u=h.render(h.props,h.state,h.context),v.push.apply(h.W,h.A),h.A=[];else do{h.P=!1,I&&I(t),u=h.render(h.props,h.state,h.context),h.state=h.L}while(h.P&&++T<25);h.state=h.L,null!=h.getChildContext&&(i=x(x({},i),h.getChildContext())),S&&!m&&null!=h.getSnapshotBeforeUpdate&&(g=h.getSnapshotBeforeUpdate(f,p)),E=null!=u&&u.type===_&&null==u.key?q(u.props.children):u,l=z(e,b(E)?E:[E],t,r,i,o,s,a,l,c,d),h.base=t.v,t.C&=-161,h.W.length&&a.push(h),y&&(h.j=h.m=null)}catch(e){if(t.N=null,c||null!=s)if(e.then){for(t.C|=c?160:128;l&&8==l.nodeType&&l.nextSibling;)l=l.nextSibling;s[s.indexOf(l)]=null,t.v=l}else{for(P=s.length;P--;)k(s[P]);L(t)}else t.v=r.v,t.i=r.i,e.then||L(t);n.v(e,t,r)}else null==s&&t.N==r.N?(t.i=r.i,t.v=r.v):l=t.v=F(r.v,t,r,i,o,s,a,c,d);return(u=n.diffed)&&u(t),128&t.C?void 0:l}function L(e){e&&(e.k&&(e.k.v=!0),e.i&&e.i.some(L))}function B(e,t,r){for(var i=0;i<r.length;i++)H(r[i],r[++i],r[++i]);n.k&&n.k(t,e),e.some(function(t){try{e=t.W,t.W=[],e.some(function(e){e.call(t)})}catch(e){n.v(e,t.N)}})}function q(e){return"object"!=typeof e||null==e||e.p>0?e:b(e)?e.map(q):x({},e)}function F(e,r,i,o,s,a,l,c,d){var u,h,m,f,p,g,v,w=i.props||y,x=r.props,S=r.type;if("svg"==S?s="http://www.w3.org/2000/svg":"math"==S?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),null!=a)for(u=0;u<a.length;u++)if((p=a[u])&&"setAttribute"in p==!!S&&(S?p.localName==S:3==p.nodeType)){e=p,a[u]=null;break}if(null==e){if(null==S)return document.createTextNode(x);e=document.createElementNS(s,S,x.is&&x),c&&(n.B&&n.B(r,a),c=!1),a=null}if(null==S)w===x||c&&e.data==x||(e.data=x);else{if(a=a&&t.call(e.childNodes),!c&&null!=a)for(w={},u=0;u<e.attributes.length;u++)w[(p=e.attributes[u]).name]=p.value;for(u in w)p=w[u],"dangerouslySetInnerHTML"==u?m=p:"children"==u||u in x||"value"==u&&"defaultValue"in x||"checked"==u&&"defaultChecked"in x||j(e,u,null,p,s);for(u in x)p=x[u],"children"==u?f=p:"dangerouslySetInnerHTML"==u?h=p:"value"==u?g=p:"checked"==u?v=p:c&&"function"!=typeof p||w[u]===p||j(e,u,p,w[u],s);if(h)c||m&&(h.H==m.H||h.H==e.innerHTML)||(e.innerHTML=h.H),r.i=[];else if(m&&(e.innerHTML=""),z("template"==r.type?e.content:e,b(f)?f:[f],r,i,o,"foreignObject"==S?"http://www.w3.org/1999/xhtml":s,a,l,a?a[0]:i.i&&$(i,0),c,d),null!=a)for(u=a.length;u--;)k(a[u]);c||(u="value","progress"==S&&null==g?e.removeAttribute("value"):null!=g&&(g!==e[u]||"progress"==S&&!g||"option"==S&&g!=w[u])&&j(e,u,g,w[u],s),u="checked",null!=v&&v!=e[u]&&j(e,u,v,w[u],s))}return e}function H(e,t,r){try{if("function"==typeof e){var i="function"==typeof e.C;i&&e.C(),i&&null==t||(e.C=e(t))}else e.current=t}catch(e){n.v(e,r)}}function U(e,t,r){var i,o;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.v||H(i,null,t)),null!=(i=e.k)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.v(e,t)}i.base=i.I=null}if(i=e.i)for(o=0;o<i.length;o++)i[o]&&U(i[o],t,r||"function"!=typeof e.type);r||k(e.v),e.k=e.m=e.v=void 0}function Y(e,t,n){return this.constructor(e,n)}t=v.slice,n={v:function(e,t,n,r){for(var i,o,s;t=t.m;)if((i=t.k)&&!i.m)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(e)),s=i.P),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=i.P),s)return i.j=i}catch(t){e=t}throw e}},r=0,C.prototype.setState=function(e,t){var n;n=null!=this.L&&this.L!=this.state?this.L:this.L=x({},this.state),"function"==typeof e&&(e=e(x({},n),this.props)),e&&x(n,e),null!=e&&this.N&&(t&&this.A.push(t),E(this))},C.prototype.forceUpdate=function(e){this.N&&(this.v=!0,e&&this.W.push(e),E(this))},C.prototype.render=_,i=[],s="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,a=function(e,t){return e.N.p-t.N.p},P.O=0,l=Math.random().toString(8),c="__d"+l,d="__a"+l,u=/(PointerCapture)$|Capture$/i,h=0,m=W(!1),f=W(!0),p=0,function(e){e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.VALIDATION_ERROR="VALIDATION_ERROR",e.STORAGE_ERROR="STORAGE_ERROR",e.TIMEOUT_ERROR="TIMEOUT_ERROR",e.MAINTENANCE_ERROR="MAINTENANCE_ERROR"}(g||(g={}));class Z extends Error{constructor(e,t,n=!1,r,i,o,s){super(t),this.type=e,this.retryable=n,this.statusCode=r,this.retryAfter=i,this.validationErrors=o,this.organisation=s,this.name="InsureOSError"}}class G{handleNetworkError(e){return new Z(g.NETWORK_ERROR,"Network connection failed. Please check your internet connection.",!0)}handleApiError(e){if(503===e.status)return new Z(g.MAINTENANCE_ERROR,"We're performing scheduled maintenance. Please check back in a few minutes.",!1,e.status);const t=e.status>=500||429===e.status;return 429===e.status?new Z(g.API_ERROR,"Too many requests. Please wait a moment and try again.",!0,e.status):e.status>=400&&e.status<500?new Z(g.API_ERROR,"Invalid request. Please refresh the page and try again.",!1,e.status):e.status>=500?new Z(g.API_ERROR,"Service temporarily unavailable. Please try again in a moment.",!0,e.status):new Z(g.API_ERROR,`Request failed: ${e.statusText}`,t,e.status)}handleStorageError(e){return new Z(g.STORAGE_ERROR,"Unable to save progress. The quote will still work, but progress won't be saved.",!1)}shouldRetry(e){return e.retryable}getUserFriendlyMessage(e){switch(e.type){case g.NETWORK_ERROR:return"Connection failed. Please check your internet connection and try again.";case g.MAINTENANCE_ERROR:return"We're performing scheduled maintenance. Please check back in a few minutes.";case g.API_ERROR:return 429===e.statusCode?"Too many requests. Please wait a moment and try again.":e.statusCode&&e.statusCode>=400&&e.statusCode<500?"Invalid request. Please refresh the page and try again.":e.statusCode&&e.statusCode>=500?"Service temporarily unavailable. Please try again in a moment.":"Request failed. Please try again.";case g.STORAGE_ERROR:return"Unable to save progress. The quote will still work, but progress won't be saved.";case g.TIMEOUT_ERROR:return"Request timed out. Please try again.";case g.VALIDATION_ERROR:return e.validationErrors&&Object.keys(e.validationErrors).length>0?"There were validation errors in your form. Please check your inputs and try again.":"Invalid data provided. Please check your input and try again.";default:return"An unexpected error occurred. Please try again."}}}class V{constructor(e){this.config=e}shouldRetry(e,t){return!(t>=this.config.maxRetries)&&this.isRetryableError(e)}getDelay(e,t){if(t){const e=parseInt(t,10);if(!isNaN(e))return 1e3*e}const n=this.config.baseDelay*Math.pow(2,e);return Math.min(n,this.config.maxDelay)}isRetryableError(e){return e instanceof Z?e.retryable:!("TypeError"!==e.name||!e.message.includes("fetch"))||"AbortError"===e.name}}const Q=new Map;function J(e){return Q.get(e)}function K(e){if(e)for(const t of e)(null==t?void 0:t.code)&&Q.set(t.code,{name:t.name,content:t.content})}class X{constructor(e){this.config=e,this.retryStrategy=new V(e.retryConfig)}getBaseUrl(){return this.config.apiBaseUrl||"https://api.os.insure"}async makeRequest({url:e,method:t,body:n,skipOrgHeader:r=!1,timeoutMs:i,noRetry:o=!1}){return this.executeWithRetry(o,async()=>{const o=new AbortController,s=null!=i?i:this.config.timeout,a=setTimeout(()=>o.abort(),s);try{const i={"Content-Type":"application/json"},s=e.includes("signed=");r||s||(i["X-Organisation-ID"]=this.config.orgId);const l={method:t,headers:i,signal:o.signal};n&&(l.body=JSON.stringify(n));const c=await fetch(e,l);if(clearTimeout(a),!c.ok)throw await this.handleApiError(c);const d=await c.json();return d.data||d}catch(e){if(clearTimeout(a),e instanceof Z)throw e;if(e instanceof Error&&"AbortError"===e.name)throw new Z(g.TIMEOUT_ERROR,"Request timed out",!0);if(e instanceof TypeError&&e.message.includes("fetch"))throw new Z(g.NETWORK_ERROR,"Network connection failed. Please check your internet connection.",!0);throw e}})}async getQuoteIntent(e){const t=await this.makeRequest({url:e,method:"GET"});return K(null==t?void 0:t.documents),t}getDocument(e){const t=`${this.config.apiBaseUrl}/documents/${encodeURIComponent(e)}`;return this.makeRequest({url:t,method:"GET"})}async fetchAvailableProducts(t){var n;const r=null==t?void 0:t.includes("*"),i=!t||0===t.length,o=`${this.config.apiBaseUrl}/products`,s=await this.makeRequest({url:o,method:"GET"}),a=s.products||[],l=null===(n=s.organisation)||void 0===n?void 0:n.client_settings;let c=a;if(r)e(),c=a;else if(t&&t.length>0)c=a.filter(e=>t.includes(e.code));else if(i&&(null==l?void 0:l.products)&&l.products.length>0){const t=l.products.map(e=>e.code);c=t.map(e=>a.find(t=>t.code===e)).filter(e=>void 0!==e),e((a.length,c.length))}else i&&(e(),c=a);return{products:c,organisation:s.organisation}}async createQuoteIntent(e){const t=await this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents`,method:"POST",body:e});return K(null==t?void 0:t.documents),t}async updateQuoteIntent(e,t){const n=await this.makeRequest({url:e,method:"PUT",body:t});return K(null==n?void 0:n.documents),n}deleteQuoteIntent(e){return this.makeRequest({url:e,method:"DELETE"})}calculateQuoteIntent(e){return this.makeRequest({url:e,method:"POST"})}calculateQuoteIntentV2(e){return this.makeRequest({url:e,method:"POST"})}repriceQuoteIntentV2(e,t){return this.makeRequest({url:e,method:"POST",body:t})}bindQuoteIntentV2(e,t){return this.makeRequest({url:e,method:"POST",body:t})}deleteCalculations(e){return this.makeRequest({url:e,method:"DELETE"})}initiatePayment(e,t){const n="string"==typeof t?t:t.code;return this.makeRequest({url:`${this.config.apiBaseUrl}/payments/initiate`,method:"POST",body:{...e,gateway_code:n},timeoutMs:9e4,noRetry:!0})}getPaymentStatus(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/payments/status/${e}`,method:"GET"})}createQuotePaymentLink(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/payment-link`,method:"POST",body:t})}continueLater(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/continue-later`,method:"POST",body:{email:t}})}resumeQuoteIntent(e){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/resume`,method:"GET"})}getPaymentLinkDetails(e){return this.makeRequest({url:e,method:"GET",skipOrgHeader:!0})}getPaymentLinkById(e){return this.makeRequest({url:`${this.config.apiBaseUrl}/payment-links/${e}`,method:"GET"})}initiateFixedPayment(e,t,n,r){return this.makeRequest({url:`${this.config.apiBaseUrl}/payment-links/${e}/pay`,method:"POST",body:{gateway_code:t,client_name:n,...r?{gateway_method:r}:{}}})}validateCoverStartDate(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/payment-links/${e}/validate-cover-date`,method:"POST",body:{cover_start_date:t}})}validateQuoteCoverStartDate(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/validate-cover-date`,method:"POST",body:{cover_start_date:t}})}resolvePaymentTransaction(e){return this.makeRequest({url:`${this.config.apiBaseUrl}/payments/${e}/resolve`,method:"POST",body:{}})}validatePromoCode(e,t){return this.makeRequest({url:`${this.config.apiBaseUrl}/quote-intents/${e}/validate-promo-code`,method:"POST",body:{code:t}})}async executeWithRetry(t,n){let r;const i=t?0:this.config.retryConfig.maxRetries;for(let o=0;o<=i;o++)try{return e(),await n()}catch(n){r=n;const s=!t&&this.retryStrategy.shouldRetry(r,o);if(e(n instanceof Z&&(n.type,n.message)),e(),o===i||!s)throw e(),r;const a=n instanceof Z?n.retryAfter:void 0,l=this.retryStrategy.getDelay(o,a);e(),await new Promise(e=>setTimeout(e,l))}throw r}async handleApiError(t){var n,r;const i=t.headers.get("retry-after"),o=await t.json().catch(()=>({}));if(e(),this.captureApiErrorToSentry(t,o),503===t.status)return new Z(g.MAINTENANCE_ERROR,o.message||"We're performing scheduled maintenance. Please check back in a few minutes.",!1,t.status,void 0,void 0,null!==(n=o.organisation)&&void 0!==n?n:null);if(429===t.status)return new Z(g.API_ERROR,"Too many requests. Please wait a moment and try again.",!1,t.status,i||void 0);if(t.status>=500){const e=o.message||"Service temporarily unavailable. Please try again in a moment.";return new Z(g.API_ERROR,e,!1,t.status)}if(422===t.status)try{const e=o;return e.error&&e.error.details&&e.error.details.form_data?new Z(g.VALIDATION_ERROR,"Form validation failed. Please check your inputs.",!1,t.status,void 0,e.error.details):new Z(g.VALIDATION_ERROR,e.message||"Validation failed. Please check your inputs.",!1,t.status,void 0,null===(r=e.error)||void 0===r?void 0:r.details)}catch(e){return new Z(g.VALIDATION_ERROR,"Validation failed. Please check your inputs.",!1,t.status)}if(400===t.status)try{const e=o;return e.errors?new Z(g.VALIDATION_ERROR,e.message||"Form validation failed. Please check your inputs.",!1,t.status,void 0,e.errors):new Z(g.API_ERROR,e.message||"Invalid request. Please check your input and try again.",!1,t.status)}catch(e){return new Z(g.API_ERROR,"Invalid request. Please refresh the page and try again.",!1,t.status)}if(t.status>=400&&t.status<500){const e=o.message||"Invalid request. Please refresh the page and try again.";return new Z(g.API_ERROR,e,!1,t.status)}return new Z(g.API_ERROR,`Request failed: ${t.statusText}`,this.config.retryConfig.retryableStatusCodes.includes(t.status),t.status)}captureApiErrorToSentry(e,t){try{(e.status>=500||429===e.status)&&Promise.resolve().then(function(){return Zh}).then(({captureMessage:n,addBreadcrumb:r,isSentryInitialized:i})=>{i()&&(r({message:`API Error: ${e.status} ${e.statusText}`,category:"http",level:"error",data:{url:e.url,status:e.status,statusText:e.statusText}}),n(`API Error: ${e.status} - ${e.url}`,"error",{http:{status_code:e.status,url:e.url,method:"Unknown"},response:t}))}).catch(()=>{})}catch(e){}}}class ee{constructor(){this.available=this.checkAvailability()}get(e){if(!this.available)return null;try{return localStorage.getItem(e)}catch(e){return null}}set(e,t){if(this.available)try{localStorage.setItem(e,t)}catch(e){}}remove(e){if(this.available)try{localStorage.removeItem(e)}catch(e){}}clear(){if(this.available)try{localStorage.clear()}catch(e){}}isAvailable(){return this.available}checkAvailability(){try{if("undefined"==typeof window||!window.localStorage)return!1;const e="__insure_os_storage_test__";return localStorage.setItem(e,"test"),localStorage.removeItem(e),!0}catch(e){return!1}}}class te{constructor(){this.available=this.checkAvailability()}get(e){if(!this.available)return null;try{return sessionStorage.getItem(e)}catch(e){return null}}set(e,t){if(this.available)try{sessionStorage.setItem(e,t)}catch(e){}}remove(e){if(this.available)try{sessionStorage.removeItem(e)}catch(e){}}clear(){if(this.available)try{sessionStorage.clear()}catch(e){}}isAvailable(){return this.available}checkAvailability(){try{if("undefined"==typeof window||!window.sessionStorage)return!1;const e="__insure_os_storage_test__";return sessionStorage.setItem(e,"test"),sessionStorage.removeItem(e),!0}catch(e){return!1}}}class ne{constructor(){this.storage=new Map}get(e){return this.storage.get(e)||null}set(e,t){this.storage.set(e,t)}remove(e){this.storage.delete(e)}clear(){this.storage.clear()}isAvailable(){return!0}}class re{static generateKey(e,t,n){const r=[this.KEY_PREFIX+e,t];return n&&r.push(n),r.join(this.SEPARATOR)}static serialize(e){try{return JSON.stringify({data:e,timestamp:Date.now(),version:"1.0"})}catch(e){throw new Error(`Failed to serialize data: ${e}`)}}static deserialize(e){try{const t=JSON.parse(e);return t&&"object"==typeof t&&t.data?t.data:null}catch(e){return null}}static getTimestamp(e){try{return JSON.parse(e).timestamp||null}catch(e){return null}}static isExpired(e,t){const n=this.getTimestamp(e);return!n||Date.now()-n>t}}re.KEY_PREFIX="insure_os_",re.SEPARATOR="_";class ie{constructor(e,t={}){this.storageAdapter=e,this.config={defaultExpirationMs:t.defaultExpirationMs||ie.DEFAULT_EXPIRATION_MS,namespace:t.namespace||ie.DEFAULT_NAMESPACE}}saveQuoteIntent(e,t){if(this.storageAdapter.isAvailable())try{t.payment_transactions&&t.payment_transactions.length;const n=this.generateStorageKey(e),r=re.serialize(t);this.storageAdapter.set(n,r)}catch(e){}}getQuoteIntent(e){if(!this.storageAdapter.isAvailable())return null;try{const t=this.generateStorageKey(e),n=this.storageAdapter.get(t);if(!n)return null;const r=re.deserialize(n);return(null==r?void 0:r.payment_transactions)&&r.payment_transactions.length,r&&this.isQuoteIntentValid(r)?r:(this.removeQuoteIntent(e),null)}catch(e){return null}}removeQuoteIntent(e){if(this.storageAdapter.isAvailable())try{const t=this.generateStorageKey(e);this.storageAdapter.remove(t)}catch(e){}}isQuoteIntentValid(e){if(!e||"object"!=typeof e)return!1;if(!e.id||!e.url||!e.org_id)return!1;const t=Date.now();return!(e.expires_at&&t>e.expires_at||e.created_at&&t-e.created_at>this.config.defaultExpirationMs)}getAllQuoteIntents(){return{}}cleanupExpiredQuoteIntents(){}isStorageAvailable(){return this.storageAdapter.isAvailable()}generateStorageKey(e){return re.generateKey(this.config.namespace,e)}}ie.DEFAULT_EXPIRATION_MS=864e5,ie.DEFAULT_NAMESPACE="quote_intent";class oe{constructor(e){this.stateManager=e}async getOrCreateQuoteIntent(e,t,n){const r=this.stateManager.getQuoteIntent(e);if(r&&this.stateManager.isQuoteIntentValid(r)){const t=await n(r.url);return this.stateManager.saveQuoteIntent(e,t),t}try{const n=await t();return this.stateManager.saveQuoteIntent(e,n),n}catch(t){throw r&&this.stateManager.removeQuoteIntent(e),t}}updateQuoteIntent(e,t){const n=this.stateManager.getQuoteIntent(e);if(!n)return null;const r={...n,...t};return this.stateManager.saveQuoteIntent(e,r),r}clearQuoteIntent(e){this.stateManager.removeQuoteIntent(e)}clearExpiredQuoteIntents(){this.stateManager.cleanupExpiredQuoteIntents()}hasValidQuoteIntent(e){const t=this.stateManager.getQuoteIntent(e);return null!==t&&this.stateManager.isQuoteIntentValid(t)}getQuoteIntentUrl(e){const t=this.stateManager.getQuoteIntent(e);return(null==t?void 0:t.url)||null}isStorageAvailable(){return this.stateManager.isStorageAvailable()}}class se{constructor(e,t){this.saveCallback=t,this.isPaused=!1,this.consecutiveFailures=0,this.lastErrorTime=0,this.isUserTyping=!1,this.config=e}start(){this.intervalId&&this.stop(),this.isPaused=!1,this.consecutiveFailures=0,this.lastErrorTime=0,this.config.autoSave&&(this.intervalId=window.setInterval(()=>{this.isPaused||this.isUserTyping||!this.shouldAttemptSave()||this.saveCallback().catch(this.handleSaveError.bind(this))},this.config.autoSaveInterval))}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.typingTimeoutId&&(clearTimeout(this.typingTimeoutId),this.typingTimeoutId=void 0)}pause(){this.isPaused=!0,setTimeout(()=>this.resume(),6e4)}resume(){this.isPaused=!1,this.consecutiveFailures=0}shouldAttemptSave(){return!!this.config.autoSave&&(0===this.lastErrorTime||Date.now()-this.lastErrorTime>=this.config.retryDelay*Math.pow(2,this.consecutiveFailures-1))}handleSaveError(e){this.lastErrorTime=Date.now(),this.consecutiveFailures++,this.consecutiveFailures>=3&&(this.pause(),this.dispatchErrorEvent(e))}dispatchErrorEvent(e){if("undefined"!=typeof window){const t=new CustomEvent("form-autosave-error",{detail:{error:e,message:"Auto-save has been paused due to repeated failures."}});window.dispatchEvent(t)}}onSaveSuccess(){this.consecutiveFailures=0,this.lastErrorTime=0,this.isPaused&&this.resume()}startTyping(){this.isUserTyping=!0,this.typingTimeoutId&&clearTimeout(this.typingTimeoutId),this.typingTimeoutId=window.setTimeout(()=>{this.stopTyping()},500)}stopTyping(){this.isUserTyping=!1,this.typingTimeoutId&&(clearTimeout(this.typingTimeoutId),this.typingTimeoutId=void 0)}get status(){return{isPaused:this.isPaused,consecutiveFailures:this.consecutiveFailures,isActive:!!this.intervalId,isUserTyping:this.isUserTyping}}}function ae(e,t){const n=t.operator,r=t.value,i=null==r?"":String(r),o=null==e?"":String(e);switch(n){case"=":return o===i;case"!=":return o!==i;case"contains":return o.includes(i);case"not_contains":return!o.includes(i);case"starts_with":return o.startsWith(i);case"ends_with":return o.endsWith(i);case"is_empty":return void 0===e||null==e||""===e||""===e.trim();case"is_not_empty":return void 0!==e&&null!=e&&""!==e&&!(""===e.trim());default:throw new Error(`Unsupported text operator: ${n}`)}}function le(e,t){const n=t.operator,r=null==t.value?0:Number(t.value),i=null==e?0:Number(e.toString().replace(/,/g,"").trim());switch(n){case">":return i>r;case">=":return i>=r;case"<":return i<r;case"<=":return i<=r;case"=":return i===r;case"!=":return i!==r;case"is_empty":return void 0===e||null==e||""===e||""===e.toString().trim();case"is_not_empty":return void 0!==e&&null!=e&&""!==e&&!(""===e.toString().trim());default:throw new Error(`Unsupported numeric operator: ${n}`)}}function ce(e){if(!0===e||1===e)return!0;if("string"==typeof e){const t=e.toLowerCase();return"true"===t||"yes"===t}return!1}function de(e,t){const n=t.operator;switch(t.operator){case"true":case"=":return ce(e);case"false":return function(e){if(!1===e||0===e||void 0===e)return!0;if("string"==typeof e){const t=e.toLowerCase();return"false"===t||"no"===t}return!1}(e);case"!=":return!ce(e);default:throw new Error(`Unsupported boolean operator: ${n}`)}}function ue(e,t){const n=t.operator,r=t.value,i=null==r?0:Number(t.value);if(null==e||""===e.toString().trim())return"is_empty"===n;const o=e.toString().trim(),s=/^\d{4}$/.test(o)&&Number(o)>=1900&&Number(o)<=2100?new Date(Number(o),0,1).getTime():Date.parse(o),a=Math.floor((Date.now()-s)/315576e5),l=Math.floor((Date.now()-s)/864e5),c=new Date(s),d=new Date,u=12*(d.getFullYear()-c.getFullYear())+(d.getMonth()-c.getMonth());switch(n){case">":return s>Date.parse(r);case">=":return s>=Date.parse(r);case"<":return s<Date.parse(r);case"<=":return s<=Date.parse(r);case"age_less_than":return a<i;case"age_less_than_or_equal":return a<=i;case"age_greater_than":return a>i;case"age_greater_than_or_equal":return a>=i;case"age_days_less_than":return l<i;case"age_days_less_than_or_equal":return l<=i;case"age_days_greater_than":return l>i;case"age_days_greater_than_or_equal":return l>=i;case"age_months_less_than":return u<i;case"age_months_less_than_or_equal":return u<=i;case"age_months_greater_than":return u>i;case"age_months_greater_than_or_equal":return u>=i;default:throw new Error(`Unsupported date operator: ${n}`)}}class he{static create(e){switch(e){case"string":case"text":case"select":return ae;case"numeric":return le;case"boolean":return de;case"date":return ue;default:throw new Error(`Unsupported condition type: ${e}`)}}}function me(e,t){const n=t.condition_type||"and";if(!t.conditions||0===t.conditions.length)return{matched:!0,conditions:[]};const r={matched:!1,conditions:t.conditions.map(t=>{const n={...t,matched:fe(e,t),string:`${t.field} ${t.operator}`};return t.value&&(n.string+=` ${t.value}`),n})};return"none"===n&&(r.matched=!0),"and"===n&&(r.matched=r.conditions.every(e=>e.matched)),"or"===n&&(r.matched=r.conditions.some(e=>e.matched)),"not"===n&&(r.matched=r.conditions.every(e=>!e.matched)),r}function fe(e,t){if("expression"===t.type)throw new Error("Expression conditions should not be evaluated through matchesCondition");if(!t.field)throw new Error("Field is required for non-expression conditions");const n=e[t.field],r=he.create(t.type);if(!r)throw new Error(`Unsupported condition type: ${t.type}`);return r(n,t)}var pe=Object.freeze({__proto__:null,TypeConditionEvaluatorFactory:he,booleanMatchesCondition:de,checkSimpleConditions:me,dateMatchesCondition:ue,numericMatchesCondition:le,textMatchesCondition:ae});function ge(e,t){var n;const r=[];if("checkbox"===e.type&&e.required&&!0!==t&&"true"!==t)return r.push({field:e.code||e.id,message:`${e.label} must be accepted`}),r;"boolean"===e.type&&(null===(n=e.boolean_config)||void 0===n?void 0:n.enable_details_textbox)&&("yes"===e.boolean_config.show_details_on&&(!0===t||"true"===t)||e.boolean_config.show_details_on),"email"===e.type&&"string"==typeof t&&(t=t.trim());const i="boolean"===e.type?null==t:null==t||""===t;if(e.required&&i&&!0!==e.add_null_option)return r.push({field:e.code||e.id,message:`${e.label} is required`}),r;if(!e.required&&i)return r;const o=e.validation;if(!o)return r;const s=String(t),a="number"==typeof t?t:parseFloat(s);if(o.pattern&&("text"===e.type||"email"===e.type)){const t=new RegExp(o.pattern),n=s.trim();t.test(n)||r.push({field:e.code||e.id,message:`${e.label} format is invalid`})}if(o.minLength&&s.length<o.minLength&&r.push({field:e.code||e.id,message:`${e.label} must be at least ${o.minLength} characters`}),o.maxLength&&s.length>o.maxLength&&r.push({field:e.code||e.id,message:`${e.label} must be no more than ${o.maxLength} characters`}),"number"!==e.type||isNaN(a)||(void 0!==o.min&&a<o.min&&r.push({field:e.code||e.id,message:`${e.label} must be at least ${o.min}`}),void 0!==o.max&&a>o.max&&r.push({field:e.code||e.id,message:`${e.label} must be no more than ${o.max}`}),void 0!==o.step&&a%o.step!==0&&r.push({field:e.code||e.id,message:`${e.label} must be in increments of ${o.step}`})),("date"===e.type||"year"===e.type||"monthyear"===e.type)&&!1===o.canBeFuture){const t=new Date,n=t.getFullYear();let i=!1;if("year"===e.type){const e=parseInt(s,10);!isNaN(e)&&e>n&&(i=!0)}else if("date"===e.type){const e=new Date(s);if(!isNaN(e.getTime())){const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());new Date(e.getFullYear(),e.getMonth(),e.getDate())>n&&(i=!0)}}else if("monthyear"===e.type){const e=s.split("-");if(2===e.length){const n=parseInt(e[0],10),r=parseInt(e[1],10)-1;isNaN(n)||isNaN(r)||new Date(n,r,1)>new Date(t.getFullYear(),t.getMonth(),1)&&(i=!0)}}i&&r.push({field:e.code||e.id,message:`${e.label} cannot be in the future`})}return"date"===e.type&&o.softMaxDate&&s&&s>o.softMaxDate&&r.push({field:e.code||e.id,message:o.softMaxMessage||`${e.label} is too far in the future`}),r}function ye(e,t){var n,r;const i=[];for(const r of e.fields){const e=r.code||r.id;let o=!0;if(r.visibility){const e=me(t,{condition_type:r.visibility.condition_type,conditions:r.visibility.conditions});o="show"===r.visibility.action?e.matched:!e.matched}if(!o)continue;const s=t[e],a=ge(r,s);if(i.push(...a),"boolean"===r.type&&(null===(n=r.boolean_config)||void 0===n?void 0:n.enable_details_textbox)&&("yes"===r.boolean_config.show_details_on&&(!0===s||"true"===s)||"no"===r.boolean_config.show_details_on&&(!1===s||"false"===s))){const n=(t.U||{})[e];n&&""!==n.trim()||i.push({field:e,message:r.boolean_config.details_label||"Please provide details"})}}if(null===(r=e.validation)||void 0===r?void 0:r.required_fields)for(const n of e.validation.required_fields){const r=e.fields.find(e=>(e.code||e.id)===n),o=t[n];if(r){const e=r.code||r.id,n=i.find(t=>t.field===e);if(n)continue;let s=!0;if(r.visibility){const e=me(t,{condition_type:r.visibility.condition_type,conditions:r.visibility.conditions});s="show"===r.visibility.action?e.matched:!e.matched}if(!s)continue;if("checkbox"===r.type){!0!==o&&"true"!==o&&i.push({field:e,message:`${r.label} must be accepted`});continue}("boolean"===r.type?null==o:null==o||""===o)&&(!0===r.add_null_option||i.push({field:e,message:`${r.label} is required`}))}}return{isValid:0===i.length,errors:i}}function ve(e){const t=[];let n;if("object"==typeof e&&null!==e&&("validation_errors"in e&&e.validation_errors&&"object"==typeof e.validation_errors?n=e.validation_errors:"errors"in e&&e.errors&&"object"==typeof e.errors?n=e.errors:"message"in e||"validation_errors"in e||"errors"in e||(n=e)),n)for(const[e,r]of Object.entries(n))if(Array.isArray(r))for(const n of r)t.push({field:e,message:n});return t}function we(e){return e.reduce((e,t)=>(e[t.field]||(e[t.field]=[]),e[t.field].push(t),e),{})}class be{constructor(e,t,n){this.httpClient=e,this.definition=t,this.quoteIntentStore=n}async load(e,t){if(this.quoteIntentStore&&this.quoteIntentStore.getQuoteIntentUrl(e)){const e=await this.httpClient.getQuoteIntent(t);if(e.quote_intent.form_data)return e.quote_intent.form_data}return(await this.httpClient.getQuoteIntent(t)).quote_intent.form_data||this.createEmptyFormData()}async save(e,t,n,r){try{const e=this.prepareSavePayload(n,r);return await this.httpClient.updateQuoteIntent(t,e),{success:!0}}catch(e){if(e&&"object"==typeof e&&"validationErrors"in e){const t=e.validationErrors;if(t&&"object"==typeof t)return{success:!1,validationErrors:ve(t)}}throw e}}prepareSavePayload(e,t){const n=this.getCurrentPageId(e);return{current_page_index:e.current_page,current_page_id:n,page_data:e.page_data,save_type:t.saveType}}getCurrentPageId(e){const t=this.definition;if(!t||!e.page_data)return;const n=e.current_page;if(n<0||n>=t.pages.length)return;const r=t.pages[n];return r&&r.id?r.id:void 0}createEmptyFormData(){return{current_page:0,completed_pages:[],page_data:{},last_updated:(new Date).toISOString()}}}class xe{constructor(e,t,n,r){this.formDefinition=e,this.getFormData=t,this.updateFormData=n,this.saveCallback=r}canNavigateToPage(e){const t=this.getFormData().current_page;if(e<=t)return!0;if(this.hasActiveBlocker(t))return!1;if(this.isStagingEnvironment())return!0;const n=this.getFormData().completed_pages;for(let r=0;r<e;r++)if(r!==t&&!n.includes(r))return!1;return!0}async navigateToPage(e){if(e<0||e>=this.getTotalPages())return!1;if(!this.canNavigateToPage(e))return!1;const t=this.getFormData().current_page;if(e>t)try{await this.saveCallback(!0,"page")}catch(e){return e&&"object"==typeof e&&e.isValidationError,!1}return e>t&&this.markPageCompleted(t),this.updateFormData({current_page:e,last_updated:(new Date).toISOString()}),!0}navigateToNext(){const e=this.getFormData().current_page;return this.navigateToPage(e+1)}navigateToPrevious(){const e=this.getFormData().current_page;return this.navigateToPage(e-1)}markPageCompleted(e){const t=this.getFormData();if(!t.completed_pages.includes(e)){const n=[...t.completed_pages,e].sort((e,t)=>e-t);this.updateFormData({completed_pages:n})}}getTotalPages(){return this.formDefinition.pages.length}getCompletionStatus(){const e=this.getFormData(),t=this.getTotalPages(),n=[...e.completed_pages];return{totalPages:t,currentPage:e.current_page,completedPages:n,percentComplete:n.length/t*100}}hasActiveBlocker(e){var t;const n=this.formDefinition.pages[e];if(!n)return!1;const r=(null===(t=this.getFormData().page_data)||void 0===t?void 0:t[n.id])||{};for(const e of n.fields)if(e.blocker)if(e.blocker.conditions&&e.blocker.conditions.length>0){if(me(r,{condition_type:e.blocker.condition_type||"or",conditions:e.blocker.conditions}).matched)return!0}else if(void 0!==e.blocker.trigger_value){const t=r[e.code||e.id];if(void 0!==t&&String(t)===String(e.blocker.trigger_value))return!0}return!1}isStagingEnvironment(){const e=window.location.hostname;return"localhost"===e||e.endsWith(".test")||e.includes("staging")}}class ke{constructor(e){this.httpClient=e}async calculateQuote(t){const n=await this.httpClient.calculateQuoteIntent(t);return e(),n}}class Se{constructor(e){this.httpClient=e}async calculate(t){const n=await this.httpClient.calculateQuoteIntentV2(t);return e(),n}async reprice(t,n){const r={selection:n},i=await this.httpClient.repriceQuoteIntentV2(t,r);return e(),i}async bind(t,n){const r=await this.httpClient.bindQuoteIntentV2(t,n);return e(),r}}function Ne(e,t,n){var r,i,o,s,a,l,c,d,u;const h=Date.now(),m=`${Math.random().toString(36).slice(2,10)}-${e}-${h}`;if(function(e,t,n){try{Promise.resolve().then(function(){return Zh}).then(({captureException:r,addBreadcrumb:i,isSentryInitialized:o})=>{o()&&(i({message:`Error occurred: ${t}`,category:"error",level:"error",data:{errorType:t,customMessage:n}}),r(e,{errorType:t,customMessage:n}))}).catch(()=>{})}catch(e){}}(t,e,n),t&&"object"==typeof t){const f=null!==(o=null!==(r=t.organisation)&&void 0!==r?r:null===(i=t.data)||void 0===i?void 0:i.organisation)&&void 0!==o?o:null===(a=null===(s=t.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.organisation;if("statusCode"in t||"status"in t)return _e(m,e,t.statusCode||t.status||500,t.message||(null===(l=t.data)||void 0===l?void 0:l.message)||"Server error occurred",n,h,f);if("response"in t)return _e(m,e,(null===(c=t.response)||void 0===c?void 0:c.status)||500,(null===(u=null===(d=t.response)||void 0===d?void 0:d.data)||void 0===u?void 0:u.message)||t.message||"Network error occurred",n,h,f);if(t.message)return{id:m,type:e,severity:$e(e),title:Ce(e),message:n||Te(e),details:t.message,retryable:Ee(e,0),timestamp:h,trackingId:m}}const f="string"==typeof t?t:"An unexpected error occurred";return{id:m,type:e,severity:$e(e),title:Ce(e),message:n||f,retryable:Ee(e,0),timestamp:h,trackingId:m}}function _e(e,t,n,r,i,o,s){const a=n>=500?"critical":n>=400?"error":"warning",l=Ee(t,n);return{id:e,type:t,severity:a,statusCode:n,title:Ce(t,n),message:i||Ie(t,n,r),details:r,retryable:l,timestamp:o,organisation:null!=s?s:void 0}}function Ce(e,t){if(t){if(404===t)return"Not Found";if(503===t)return"Under Maintenance";if(t>=500)return"Something Went Wrong";if(t>=400)return"Invalid Request"}switch(e){case"initialization":default:return"Something Went Wrong";case"calculation":return"Calculation Error";case"network":return"Connection Problem";case"validation":return"Please Check Your Details";case"maintenance":return"Under Maintenance"}}function $e(e){switch(e){case"initialization":case"maintenance":return"critical";case"calculation":case"network":default:return"error";case"validation":return"warning"}}function Ie(e,t,n){return"calculation"===e&&(n.toLowerCase().includes("no matching values found")||n.toLowerCase().includes("rating table")||n.toLowerCase().includes("not supported"))?n:n.toLowerCase().includes("no matching values found")?"The entered value is not supported by our calculator. Please try a different amount.":n.toLowerCase().includes("rating table")?"Unable to calculate with the provided information. Please check your entries and try again.":404===t?"initialization"===e?"The requested form could not be found. Please check the URL or contact support.":"The requested resource was not found.":503===t?"We're performing scheduled maintenance. Please check back in a few minutes.":t>=500?"calculation"===e?"We're experiencing technical difficulties with the calculation. Please try again in a moment.":"We're experiencing technical difficulties. Please try again in a moment.":429===t?"Too many requests. Please wait a moment and try again.":t>=400?"There was an issue with your request. Please adjust your details and re-submit.":"An unexpected error occurred. Please try again."}function Te(e){switch(e){case"initialization":return"We're unable to load the application at this time. Please try again.";case"calculation":return"We couldn't complete the calculation. Please check your details and try again.";case"network":return"We're having trouble connecting. Please check your internet connection and try again.";case"validation":return"Please check your details and try again.";case"maintenance":return"We're performing scheduled maintenance. Please check back in a few minutes.";default:return"An unexpected error occurred. Please try again."}}function Ee(e,t){return"validation"!==e&&"maintenance"!==e&&404!==t&&503!==t&&!(t>=400&&t<500&&429!==t)&&("network"===e||"calculation"===e||t>=500&&503!==t||429===t)}function Pe(e){return"initialization"===e.type&&"critical"===e.severity}function ze(e){return"maintenance"===e.type||503===e.statusCode}function De(e){return e.trackingId?`If this problem persists, please contact support and reference error ID: ${e.trackingId.slice(0,8).toUpperCase()}`:"critical"===e.severity?"If this problem persists, please contact support with the error details.":"If you continue to experience issues, please contact support."}let Re=null;function Me(e){Re=e}function Oe(){return Re}function je(e,t){var n,r;return{event:t,quote_id:e.id,organisation_slug:null===(n=e.organisation)||void 0===n?void 0:n.slug,organisation_name:null===(r=e.organisation)||void 0===r?void 0:r.name,timestamp:(new Date).toISOString()}}function We(e){var t,n;if(!(null==Re?void 0:Re.isEnabled()))return;const r={...je(e,"quote_started"),quote_status:e.status,total_pages:null===(n=null===(t=e.form_definition)||void 0===t?void 0:t.pages)||void 0===n?void 0:n.length};Re.push(r)}function Ae(e,t,n,r){var i,o;if(!(null==Re?void 0:Re.isEnabled()))return;const s=(null===(o=null===(i=e.form_definition)||void 0===i?void 0:i.pages)||void 0===o?void 0:o.length)||0,a=s>0?Math.round(n.length/s*100):0,l={...je(e,"quote_form_progress"),current_page:t,total_pages:s,completed_pages:n.length,completion_percentage:a,page_title:r};Re.push(l)}function Le(e,t){if(!(null==Re?void 0:Re.isEnabled()))return;const n=t.calculations||[],r=t.payment_options||[],i=n.find(e=>e.id===t.default_excess_id),o=n.map(e=>e.premium_total),s=o.length>0?Math.min(...o):void 0,a=o.length>0?Math.max(...o):void 0,l=r.some(e=>"monthly"===e.amount.frequency),c={...je(e,"quote_calculated"),excess_id:null==i?void 0:i.id,excess_amount:null==i?void 0:i.excess_amount,premium_subtotal:null==i?void 0:i.premium_subtotal,premium_total:null==i?void 0:i.premium_total,excess_options_count:n.length,payment_options_count:r.length,has_installments:l,min_premium:s,max_premium:a};Re.push(c)}function Be(e,t,n,r,i){if(!(null==Re?void 0:Re.isEnabled()))return;const o={...je(e,"quote_at_checkout"),excess_id:t.id,excess_amount:t.excess_amount,premium_subtotal:t.premium_subtotal,premium_total:t.premium_total,payment_options_count:n,has_installments:r,form_completion:i,fees:t.fees};Re.push(o)}function qe(e,t){if(!(null==Re?void 0:Re.isEnabled()))return;const n=t.referrals||[],r={...je(e,"quote_referred"),referral_reason:t.referral_reason,referrals_count:n.length,referral_ids:n.map(e=>e.id)};Re.push(r)}function Fe(e,t,n,r){if(!(null==Re?void 0:Re.isEnabled()))return;const i={...je(e,"payment_initiated"),payment_amount:t.amount.dueToday,payment_gateway:t.gateway_id,payment_gateway_name:n,excess_amount:r||0,payment_frequency:t.amount.frequency,amount_due_today:t.amount.dueToday,installments_count:t.amount.numberOfInstallments};Re.push(i)}function He(e,t,n,r,i,o){if(!(null==Re?void 0:Re.isEnabled()))return;const s={...je(e,"payment_completed"),transaction_id:t,payment_amount:n,payment_gateway:r,premium_total:i||n,excess_amount:o||0};Re.push(s)}function Ue(e,t,n,r,i,o){if(!(null==Re?void 0:Re.isEnabled()))return;const s={...je(e,"payment_failed"),transaction_id:t,payment_amount:n,payment_gateway:r,payment_status:i,failure_reason:o};Re.push(s)}class Ye{constructor(e,t,n,r={}){this.quoteIntent=e,this.httpClient=t,this.subscribers=new Set,this.pendingChanges={},this.isCalculating=!1,this.isRepricing=!1,this.isSaving=!1,this.selectedExcessId=null,this.selectedPaymentOption=null,this.selectionV2=null,this.validationErrors=[],this.serverValidationErrors=[],this.generalErrors=[],this.lastCalculationFailed=!1,this.config={autoSaveInterval:r.autoSaveInterval||1e3,autoSave:!1!==r.autoSave,maxRetryAttempts:r.maxRetryAttempts||3,retryDelay:r.retryDelay||2e3},this.formData=this.createEmptyFormData(),this.quoteIntentStore=n,this.lastCalculationFailed=this.getPersistedCalculationFailureState();const i=e.form_definition;this.persistenceManager=new be(t,i,n),this.autoSaveManager=new se(this.config,this.saveFormData.bind(this)),this.navigationManager=new xe(i,this.getFormProgress.bind(this),this.updateFormDataInternal.bind(this),this.saveFormData.bind(this)),this.calculationManager=new ke(t),this.calculationManagerV2=new Se(t),this.config.autoSave&&this.autoSaveManager.start()}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}async loadFormProgress(){var e,t;return this.formData=await this.persistenceManager.load(this.quoteIntent.id,this.quoteIntent.url),this.lastCalculationFailed=!0===(null===(t=null===(e=this.formData.page_data)||void 0===e?void 0:e.Y)||void 0===t?void 0:t.lastCalculationFailed),this.config.autoSave=!1,this.autoSaveManager.stop(),this.notify(),this.formData}updatePageData(e,t){this.pendingChanges[e]={...this.pendingChanges[e],...t},this.formData.page_data={...this.formData.page_data,[e]:{...this.formData.page_data[e],...t}},this.formData.last_updated=(new Date).toISOString(),this.notify()}updateFieldValue(e,t,n){if(this.autoSaveManager.startTyping(),"string"==typeof n){const r=this.getFormDefinition().pages.find(t=>t.id===e),i=null==r?void 0:r.fields.find(e=>(e.code||e.id)===t);i&&"email"===i.type&&(n=n.trim())}this.pendingChanges[e]||(this.pendingChanges[e]={}),this.pendingChanges[e][t]=n,this.formData.page_data[e]||(this.formData.page_data[e]={}),this.formData.page_data[e][t]=n,this.formData.last_updated=(new Date).toISOString(),this.validateField(e,t,n),this.notify()}updateFieldAnswer(t,n,r,i){if(this.autoSaveManager.startTyping(),this.formData.page_data[t]||(this.formData.page_data[t]={}),this.formData.page_data[t].U||(this.formData.page_data[t].U={}),this.formData.page_data[t].U[n]=r,i){const n=this.getRatingFactorCodeById(i);n&&(this.formData.page_data[t][n]=r,e())}this.formData.last_updated=(new Date).toISOString(),this.notify()}restoreFormProgress(t){var n;if(this.isUserTyping())return;const r=t.completed_pages||[],i=(null===(n=this.quoteIntent.form_definition)||void 0===n?void 0:n.pages.length)||0;let o=0;for(let e=0;e<i;e++)if(!r.includes(e)){o=e;break}r.length===i&&i>0&&(o=i-1),e(t.current_page),this.formData={...t,current_page:o},this.notify()}restoreCalculationResult(t){e(),e(t.outcome_type),this.calculationResult=t,t.default_excess_id&&(this.selectedExcessId=t.default_excess_id),e(),this.notify(),e()}getRatingFactorCodeById(t){const n=this.getFormDefinition();for(const e of n.pages)for(const n of e.fields){if(n.rating_factor_id===t)return n.code||n.id;if(n.rating_factor_mappings)for(const e of n.rating_factor_mappings)if(e.rating_factor_id===t)return e.rating_factor_code||n.code||n.id}return e(),null}processRatingFactorMappings(e){const t=this.getFormDefinition(),n={};return t.pages.forEach(t=>{const r=e.page_data[t.id]||{};t.fields.forEach(e=>{const t=r[e.code||e.id];null!=t&&""!==t&&e.rating_factor_mappings&&e.rating_factor_mappings.length>0&&e.rating_factor_mappings.forEach(r=>{if("derived"===r.type&&r.derivation_rule){const i=this.applyDerivationRule(t,r.derivation_rule,r.metadata),o=r.rating_factor_code||`${e.code||e.id}_${r.derivation_rule}`;n[o]=i}})})}),n}applyDerivationRule(t,n,r){switch(e(JSON.stringify(r)),n){case"calculate_age":return this.calculateAge(t,r);case"invert_yes_no":return this.invertYesNo(t);default:return null}}invertYesNo(e){return"Yes"===e?"No":"Yes"}calculateAge(e,t){try{const n=new Date(e),r="current_date"===(null==t?void 0:t.reference_date)?new Date:new Date((null==t?void 0:t.reference_date)||Date.now());let i=r.getFullYear()-n.getFullYear();const o=r.getMonth()-n.getMonth();return(o<0||0===o&&r.getDate()<n.getDate())&&i--,i}catch(e){return null}}async saveFormData(t=!1,n="auto-save"){if(!t&&0===Object.keys(this.pendingChanges).length)return;this.isSaving=!0,this.notify();const r={...this.formData},i=this.processRatingFactorMappings(this.formData);e();const o={...this.formData,page_data:{...this.formData.page_data,V:i}};try{const e=await this.persistenceManager.save(this.quoteIntent.id,this.quoteIntent.url,o,{force:t,saveType:n});if(!e.success){if(e.validationErrors){this.setServerValidationErrors(e.validationErrors),this.notify();const t=new Error("Validation failed");throw t.isValidationError=!0,t}throw new Error("Failed to save form data")}{this.pendingChanges={},this.autoSaveManager.onSaveSuccess(),this.clearServerValidationErrors(),this.clearGeneralErrors();const e=this.formData;r.current_page===e.current_page?this.formData=o:this.formData={...o,current_page:e.current_page,completed_pages:e.completed_pages,last_updated:e.last_updated},this.notify()}}catch(e){if(e&&"object"==typeof e&&"type"in e&&"message"in e){const t=e;if(!t.validationErrors||0===Object.keys(t.validationErrors).length){const e=Ne("validation",t);this.addGeneralError(e),this.notify()}}throw e}finally{this.isSaving=!1,this.notify()}}canNavigateToPage(e){return this.navigationManager.canNavigateToPage(e)}navigateToPage(e){return this.navigationManager.navigateToPage(e)}async navigateToNextPage(){var e,t;const n=await this.navigationManager.navigateToNext();if(n){const n=this.formData.current_page,r=this.formData.completed_pages||[],i=null===(t=null===(e=this.quoteIntent.form_definition)||void 0===e?void 0:e.pages[n-1])||void 0===t?void 0:t.title;Ae(this.quoteIntent,n,r,i)}return n}navigateToPreviousPage(){return this.navigationManager.navigateToPrevious()}getPageCompletionStatus(){return this.navigationManager.getCompletionStatus()}getFormProgress(){return this.formData}getFormDefinition(){return this.quoteIntent.form_definition}getTotalPages(){return this.navigationManager.getTotalPages()}getCurrentPageIndex(){return this.formData.current_page}isAutoSavePaused(){return this.autoSaveManager.status.isPaused}isUserTyping(){return this.autoSaveManager.status.isUserTyping}getIsCalculating(){return this.isCalculating}getIsRepricing(){return this.isRepricing}getIsSaving(){return this.isSaving}hasCalculationResponse(){return Boolean(this.calculationResult)}getCalculationResult(){return this.calculationResult}getConsecutiveFailures(){return this.autoSaveManager.status.consecutiveFailures}getSelectedExcessId(){return this.selectedExcessId}setSelectedExcessId(e){this.selectedExcessId=e,this.selectedPaymentOption=null,this.notify()}getSelectedPaymentOption(){return this.selectedPaymentOption}setSelectedPaymentOption(e){this.selectedPaymentOption=e,this.notify()}hasPendingChanges(){return Object.keys(this.pendingChanges).length>0}validateCurrentPage(){const e=this.getCurrentPageIndex(),t=this.getFormDefinition().pages[e];if(!t)return[];const n=ye(t,this.getAllFormDataFlattened());return this.validationErrors=n.errors,this.notify(),n.errors}validateField(e,t,n){const r=this.getFormDefinition().pages.find(t=>t.id===e),i=null==r?void 0:r.fields.find(e=>(e.code||e.id)===t);if(!i)return[];const o=ge(i,n);return this.validationErrors=this.validationErrors.filter(e=>e.field!==t),this.validationErrors.push(...o),this.notify(),o}getValidationErrors(){return[...this.validationErrors,...this.serverValidationErrors]}getFieldErrors(e){return this.getValidationErrors().filter(t=>t.field===e)}hasErrors(){return this.validationErrors.length>0||this.serverValidationErrors.length>0}hasFieldErrors(e){return this.getFieldErrors(e).length>0}clearValidationErrors(){this.validationErrors=[],this.notify()}setServerValidationErrors(e){this.serverValidationErrors=e,this.notify()}clearServerValidationErrors(){this.serverValidationErrors=[],this.notify()}getGeneralErrors(){const e=this.generalErrors.filter(e=>!e.dismissed);return e.length>0?[e[e.length-1]]:[]}addGeneralError(e){this.generalErrors.push(e),this.notify()}dismissGeneralError(e){const t=this.generalErrors.find(t=>t.id===e);t&&(t.dismissed=!0,this.notify())}clearGeneralErrors(){this.generalErrors=[],this.notify()}hasGeneralErrors(){return this.getGeneralErrors().length>0}hasLastCalculationFailed(){return this.lastCalculationFailed}dispose(){this.autoSaveManager.stop(),Object.keys(this.pendingChanges).length>0&&!this.isAutoSavePaused()&&this.saveFormData(!0).catch(console.error),this.subscribers.clear()}async filterHiddenFieldsAndSave(){const e=this.getFormDefinition(),t={...this.formData},{checkSimpleConditions:n}=await Promise.resolve().then(function(){return pe}),r=this.getAllFormDataFlattened();e.pages.forEach(e=>{const i=this.formData.page_data[e.id]||{},o={};Object.keys(i).forEach(e=>{e.startsWith("__")&&e.endsWith("__")&&(o[e]=i[e])}),e.fields.forEach(e=>{const t=e.code||e.id,s=i[t];let a=!0;if(e.visibility){const t=n(r,{condition_type:e.visibility.condition_type,conditions:e.visibility.conditions});a="show"===e.visibility.action?t.matched:!t.matched}a&&void 0!==s&&(o[t]=s)}),t.page_data[e.id]=o});const i=this.processRatingFactorMappings(t),o={...t,page_data:{...t.page_data,V:i}};await this.persistenceManager.save(this.quoteIntent.id,this.quoteIntent.url,o,{force:!0,saveType:"full"})}async calculateQuote(){e();const t=this.getFormDefinition(),n=[],r=this.getAllFormDataFlattened();for(const i of t.pages){const t=ye(i,r);e(i.title,t.errors.length>0&&t.errors),n.push(...t.errors)}if(n.length>0)throw e(),this.validationErrors=n,this.notify(),new Error("Form validation failed");e(),await this.filterHiddenFieldsAndSave();try{if(this.isCalculating=!0,this.notify(),2===this.quoteIntent.calculator_version&&this.quoteIntent.calculate_url_v2){const e=await this.calculationManagerV2.calculate(this.quoteIntent.calculate_url_v2);if("referral"===e.outcome_type){this.calculationResultV2=void 0,this.selectionV2=null,this.selectedExcessId=null;const t=this.buildV1CompatResponseFromV2(e);return this.calculationResult=t,this.lastCalculationFailed=!1,this.persistCalculationFailureState(),qe(this.quoteIntent,t),t}this.calculationResultV2=e,this.selectionV2=e.selection;const t=this.buildV1CompatResponseFromV2(e);this.calculationResult=t,this.selectedExcessId=e.selection.excess_id,this.lastCalculationFailed=!1,this.persistCalculationFailureState();const n=this.generalErrors.filter(e=>"calculation"===e.type);return n.forEach(e=>this.dismissGeneralError(e.id)),"calculation"===t.outcome_type?Le(this.quoteIntent,t):"referral"===t.outcome_type&&qe(this.quoteIntent,t),t}const e=await this.calculationManager.calculateQuote(this.quoteIntent.calculate_url);this.calculationResult=e,this.selectedExcessId=e.default_excess_id||null,this.lastCalculationFailed=!1,this.persistCalculationFailureState();const t=this.generalErrors.filter(e=>"calculation"===e.type);return t.forEach(e=>this.dismissGeneralError(e.id)),"calculation"===e.outcome_type?Le(this.quoteIntent,e):"referral"===e.outcome_type&&qe(this.quoteIntent,e),e}catch(e){this.lastCalculationFailed=!0,this.persistCalculationFailureState();const t={outcome_type:"referral",referral_reason:"Your quote requires further review.",quote_intent:this.quoteIntent};return this.calculationResult=t,t}finally{this.isCalculating=!1,this.notify()}}async clearCalculationResults(){e();try{await this.httpClient.deleteCalculations(this.quoteIntent.delete_calculations_url),this.calculationResult=void 0,this.calculationResultV2=void 0,this.selectionV2=null,this.selectedExcessId=null,this.selectedPaymentOption=null,this.notify(),e()}catch(t){throw e(),t}}getCalculationResultV2(){return this.calculationResultV2}getSelectionV2(){return this.selectionV2}setV2Selection(e){var t,n,r,i;if(!this.calculationResultV2||!this.selectionV2)return;const o={cover_type_id:null!==(t=e.cover_type_id)&&void 0!==t?t:this.selectionV2.cover_type_id,excess_id:null!==(n=e.excess_id)&&void 0!==n?n:this.selectionV2.excess_id,coverage_option_ids:null!==(r=e.coverage_option_ids)&&void 0!==r?r:this.selectionV2.coverage_option_ids};if(e.cover_type_id&&e.cover_type_id!==this.selectionV2.cover_type_id){const e=this.calculationResultV2.variants.filter(e=>e.cover_type_id===o.cover_type_id),t=e.some(e=>e.excess_id===o.excess_id);if(!t){const t=null!==(i=e.find(e=>e.excess_id===this.calculationResultV2.default_excess_id))&&void 0!==i?i:e[0];t&&(o.excess_id=t.excess_id)}}this.selectionV2=o,this.selectedExcessId=o.excess_id,this.calculationResult=this.buildV1CompatResponseFromV2(this.calculationResultV2),this.notify()}async toggleV2CoverageOption(e){if(!this.calculationResultV2||!this.selectionV2||!this.quoteIntent.reprice_url_v2)return;const t=this.calculationResultV2.policy_coverage_options.find(t=>t.id===e);if(!t)return;const n=this.selectionV2.coverage_option_ids,r=n.includes(e)?n.filter(t=>t!==e):[...n,e],i={...this.selectionV2,coverage_option_ids:r};try{this.isRepricing=!0,this.notify();const e=await this.calculationManagerV2.reprice(this.quoteIntent.reprice_url_v2,i);this.calculationResultV2={...this.calculationResultV2,variants:e.variants,policy_coverage_options:e.policy_coverage_options},this.selectionV2=e.selection,this.calculationResult=this.buildV1CompatResponseFromV2(this.calculationResultV2)}catch(e){}finally{this.isRepricing=!1,this.notify()}}getV2DisplayedTotal(){if(!this.calculationResultV2||!this.selectionV2)return 0;const e=this.calculationResultV2.variants.find(e=>e.cover_type_id===this.selectionV2.cover_type_id&&e.excess_id===this.selectionV2.excess_id);return e?Math.round(100*e.pricing.total_payable)/100:0}async bindV2(e){if(!this.quoteIntent.bind_url_v2||!this.selectionV2)throw new Error("v2 bind unavailable — missing bind URL or selection");const t=this.getV2DisplayedTotal();return this.calculationManagerV2.bind(this.quoteIntent.bind_url_v2,{selection:this.selectionV2,client_claimed_total:t,email:e})}buildV1CompatResponseFromV2(e){var t;const n=null!==(t=this.selectionV2)&&void 0!==t?t:e.selection,r=e.variants.filter(e=>e.cover_type_id===n.cover_type_id),i=r.map(t=>{var n;const r=e.excess_options.find(e=>e.id===t.excess_id);return{id:t.excess_id,calculation_id:e.id,excess_amount:null!==(n=null==r?void 0:r.excess_amount)&&void 0!==n?n:0,excess_label:null==r?void 0:r.excess_label,description:void 0,premium_base:t.pricing.subtotal-t.pricing.fees,premium_subtotal:t.pricing.subtotal,premium_total:t.pricing.total_payable,fees:[]}});return{quote_intent:e.quote_intent,product_name:e.product_name,default_excess_id:e.default_excess_id,default_coverage_options:n.coverage_option_ids,outcome_type:e.outcome_type,referral_reason:e.referral_reason,calculations:i,referrals:e.referrals.map(e=>({id:e.id,reason:e.reason})),clauses:e.clauses,payment_options:[],payment_gateways:e.payment_gateways}}notify(){this.subscribers.forEach(e=>e(this))}getAllFormDataFlattened(){const e={};return Object.values(this.formData.page_data).forEach(t=>{const{U:n,...r}=t;Object.assign(e,r),n&&Object.keys(n).length>0&&(e.U||(e.U={}),Object.assign(e.U,n))}),e}updateFormDataInternal(e){if(this.isUserTyping()&&e.page_data){const t={...e};delete t.page_data,this.formData={...this.formData,...t}}else this.formData={...this.formData,...e};this.notify()}createEmptyFormData(){return{current_page:0,completed_pages:[],page_data:{},last_updated:(new Date).toISOString()}}getPersistedCalculationFailureState(){var e,t,n;return!!(null===(n=null===(t=null===(e=this.quoteIntent.form_data)||void 0===e?void 0:e.page_data)||void 0===t?void 0:t.Y)||void 0===n?void 0:n.lastCalculationFailed)&&!0===this.quoteIntent.form_data.page_data.Y.lastCalculationFailed}persistCalculationFailureState(){this.formData.page_data.Y||(this.formData.page_data.Y={}),this.formData.page_data.Y.lastCalculationFailed=this.lastCalculationFailed,this.formData.last_updated=(new Date).toISOString(),this.saveFormData(!0,"auto-save").catch(()=>{})}reset(){localStorage.clear();const e=new URL(window.location.href);e.searchParams.delete("url"),window.history.replaceState({},document.title,e.toString()),window.location.reload()}getQuoteIntent(){return this.quoteIntent}updateQuoteIntent(e){if(this.quoteIntentStore){const t=this.quoteIntentStore.updateQuoteIntent(this.quoteIntent.org_id,e);t&&(this.quoteIntent=t,this.notify())}}clearStoredQuoteIntent(){this.quoteIntentStore&&this.quoteIntentStore.clearQuoteIntent(this.quoteIntent.org_id)}async initiatePayment(t){var n,r,i;const o=((null===(n=this.calculationResult)||void 0===n?void 0:n.payment_gateways)||[]).find(e=>e.id===t.gatewayId);if(!o)throw new Error("Selected payment gateway not found in calculation response");e();const s=((null===(r=this.calculationResult)||void 0===r?void 0:r.payment_options)||[]).find(e=>e.gateway_id===t.gatewayId&&e.calculation_id===t.calculationId),a=((null===(i=this.calculationResult)||void 0===i?void 0:i.calculations)||[]).find(e=>e.id===t.calculationId);try{const e=await this.httpClient.initiatePayment(t,o);return s&&Fe(this.quoteIntent,s,o.name,null==a?void 0:a.excess_amount),this.notify(),e}catch(e){throw e}}async getPaymentStatus(e){var t;const n=this.getSelectedPaymentOption();if(!n)throw new Error("No payment option selected");const r=((null===(t=this.calculationResult)||void 0===t?void 0:t.payment_gateways)||[]).find(e=>e.id===n.gateway_id);if(!r)throw new Error("Selected payment gateway not found in calculation response");try{const t=await this.httpClient.getPaymentStatus(e,r);return this.notify(),t}catch(e){throw e}}startPaymentStatusPolling(e,t,n=30){let r=0,i=!1;const o=async()=>{if(!(i||r>=n))try{const s=await this.getPaymentStatus(e);t(s),"pending"!==s.status&&"initiated"!==s.status||(r++,r<n&&!i&&setTimeout(o,1e4))}catch(e){r++,r<n&&!i&&setTimeout(o,1e4)}};return o(),()=>{i=!0}}}class Ze{constructor(e,t){this.httpClient=e,this.response=t}async get(){return await this.httpClient.getQuoteIntent(this.response.url)}async update(e){var t;const n=this.response.product.form_definition,r={...this.response.quote_intent.form_data};r.page_data||(r.page_data={});for(const i of n.pages){const n=r.page_data[i.id]||{};for(const r of i.fields){const i=r.code||r.id;if(e.hasOwnProperty(i)?n[i]=e[i]:("text"===r.type&&(n[i]="sample"),"number"===r.type&&(n[i]=1),"checkbox"===r.type&&(n[i]=!0)),"boolean"===r.type&&(null===(t=r.boolean_config)||void 0===t?void 0:t.enable_details_textbox)){const e="yes"===r.boolean_config.show_details_on,t=n[i];(t===e||t===String(e))&&(n.U||(n.U={}),n.U[i]=`Sample details for: ${i}`)}}r.page_data[i.id]=n}const i={current_page_index:0,save_type:"full",page_data:{...r.page_data}};return await this.httpClient.updateQuoteIntent(this.response.url,i)}async replaceFormData(e,t){var n;return await this.httpClient.updateQuoteIntent(this.response.url,{current_page_index:0,save_type:null!==(n=null==t?void 0:t.saveType)&&void 0!==n?n:"full",page_data:e})}}class Ge{constructor(e){this.httpClient=e}async createQuoteIntent(e,t){const n=await this.httpClient.createQuoteIntent({code:e,...t});return new Ze(this.httpClient,n)}}var Ve=0;function Qe(e,t,r,i,o,s){t||(t={});var a,l,c=t;if("ref"in c)for(l in c={},t)"ref"==l?a=t[l]:c[l]=t[l];var d={type:e,props:c,key:r,ref:a,i:null,m:null,p:0,v:null,k:null,constructor:void 0,N:--Ve,_:-1,C:0,J:o,K:s};if("function"==typeof e&&(a=e.defaultProps))for(l in a)void 0===c[l]&&(c[l]=a[l]);return n.vnode&&n.vnode(d),d}var Je,Ke,Xe,et,tt=0,nt=[],rt=n,it=rt.p,ot=rt.O,st=rt.diffed,at=rt.k,lt=rt.unmount,ct=rt.m;function dt(e,t){rt.W&&rt.W(Ke,e,tt||t),tt=0;var n=Ke.X||(Ke.X={m:[],W:[]});return e>=n.m.length&&n.m.push({}),n.m[e]}function ut(e){return tt=1,function(e,t){var n=dt(Je++,2);if(n.t=e,!n.k&&(n.m=[kt(void 0,t),function(e){var t=n.ee?n.ee[0]:n.m[0],r=n.t(t,e);t!==r&&(n.ee=[r,n.m[1]],n.k.setState({}))}],n.k=Ke,!Ke.te)){var r=function(e,t,r){if(!n.k.X)return!0;var o=n.k.X.m.filter(function(e){return e.k});if(o.every(function(e){return!e.ee}))return!i||i.call(this,e,t,r);var s=n.k.props!==e;return o.some(function(e){if(e.ee){var t=e.m[0];e.m=e.ee,e.ee=void 0,t!==e.m[0]&&(s=!0)}}),i&&i.call(this,e,t,r)||s};Ke.te=!0;var i=Ke.shouldComponentUpdate,o=Ke.componentWillUpdate;Ke.componentWillUpdate=function(e,t,n){if(this.v){var s=i;i=void 0,r(e,t,n),i=s}o&&o.call(this,e,t,n)},Ke.shouldComponentUpdate=r}return n.ee||n.m}(kt,e)}function ht(e,t){var n=dt(Je++,3);!rt.L&&xt(n.X,t)&&(n.m=e,n.u=t,Ke.X.W.push(n))}function mt(e){return tt=5,ft(function(){return{current:e}},[])}function ft(e,t){var n=dt(Je++,7);return xt(n.X,t)&&(n.m=e(),n.X=t,n.W=e),n.m}function pt(e,t){return tt=8,ft(function(){return e},t)}function gt(){for(var e;e=nt.shift();){var t=e.X;if(e.I&&t)try{t.W.some(wt),t.W.some(bt),t.W=[]}catch(n){t.W=[],rt.v(n,e.N)}}}rt.p=function(e){Ke=null,it&&it(e)},rt.m=function(e,t){e&&t.i&&t.i.B&&(e.B=t.i.B),ct&&ct(e,t)},rt.O=function(e){ot&&ot(e),Je=0;var t=(Ke=e.k).X;t&&(Xe===Ke?(t.W=[],Ke.W=[],t.m.some(function(e){e.ee&&(e.m=e.ee),e.u=e.ee=void 0})):(t.W.some(wt),t.W.some(bt),t.W=[],Je=0)),Xe=Ke},rt.diffed=function(e){st&&st(e);var t=e.k;t&&t.X&&(t.X.W.length&&(1!==nt.push(t)&&et===rt.requestAnimationFrame||((et=rt.requestAnimationFrame)||vt)(gt)),t.X.m.some(function(e){e.u&&(e.X=e.u),e.u=void 0})),Xe=Ke=null},rt.k=function(e,t){t.some(function(e){try{e.W.some(wt),e.W=e.W.filter(function(e){return!e.m||bt(e)})}catch(n){t.some(function(e){e.W&&(e.W=[])}),t=[],rt.v(n,e.N)}}),at&&at(e,t)},rt.unmount=function(e){lt&&lt(e);var t,n=e.k;n&&n.X&&(n.X.m.some(function(e){try{wt(e)}catch(e){t=e}}),n.X=void 0,t&&rt.v(t,n.N))};var yt="function"==typeof requestAnimationFrame;function vt(e){var t,n=function(){clearTimeout(r),yt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);yt&&(t=requestAnimationFrame(n))}function wt(e){var t=Ke,n=e.k;"function"==typeof n&&(e.k=void 0,n()),Ke=t}function bt(e){var t=Ke;e.k=e.m(),Ke=t}function xt(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function kt(e,t){return"function"==typeof t?t(e):t}const St="insure-os";let Nt=!1;const _t=new Map,Ct={[`--${St}-radius`]:"0.75rem",[`--${St}-radius-sm`]:"0.5rem",[`--${St}-radius-lg`]:"1rem",[`--${St}-background`]:"oklch(0.955 0 0)",[`--${St}-foreground`]:"oklch(0.145 0 0)",[`--${St}-card`]:"oklch(1 0 0)",[`--${St}-card-foreground`]:"oklch(0.145 0 0)",[`--${St}-popover`]:"oklch(1 0 0)",[`--${St}-popover-foreground`]:"oklch(0.145 0 0)",[`--${St}-primary`]:"oklch(0.205 0 0)",[`--${St}-primary-foreground`]:"oklch(0.985 0 0)",[`--${St}-secondary`]:"oklch(0.97 0 0)",[`--${St}-secondary-foreground`]:"oklch(0.205 0 0)",[`--${St}-muted`]:"oklch(0.97 0 0)",[`--${St}-muted-foreground`]:"oklch(0.556 0 0)",[`--${St}-accent`]:"oklch(0.97 0 0)",[`--${St}-accent-foreground`]:"oklch(0.205 0 0)",[`--${St}-destructive`]:"oklch(0.577 0.245 27.325)",[`--${St}-border`]:"oklch(0.9 0 0)",[`--${St}-input`]:"oklch(0.9 0 0)",[`--${St}-ring`]:"oklch(0.708 0 0)",[`--${St}-font-family`]:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",[`--${St}-font-size-large`]:"18px",[`--${St}-font-size-small`]:"14px",[`--${St}-font-size`]:"16px",[`--${St}-border-width`]:"1px",[`--${St}-transition-duration`]:"200ms",[`--${St}-transition-timing-function`]:"cubic-bezier(0.4, 0, 0.2, 1)",[`--${St}-shadow-sm`]:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",[`--${St}-shadow`]:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",[`--${St}-shadow-md`]:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",[`--${St}-shadow-lg`]:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",[`--${St}-spacing-sm`]:"0.75rem",[`--${St}-spacing`]:"1rem",[`--${St}-spacing-md`]:"1.5rem",[`--${St}-spacing-lg`]:"2rem",[`--${St}-spacing-xl`]:"3rem"},$t={colors:{background:`var(--${St}-background)`,foreground:`var(--${St}-foreground)`,card:`var(--${St}-card)`,popover:`var(--${St}-popover)`,popoverForeground:`var(--${St}-popover-foreground)`,primary:`var(--${St}-primary)`,primaryForeground:`var(--${St}-primary-foreground)`,secondary:`var(--${St}-secondary)`,muted:`var(--${St}-muted)`,mutedForeground:`var(--${St}-muted-foreground)`,accent:`var(--${St}-accent)`,accentForeground:`var(--${St}-accent-foreground)`,destructive:`var(--${St}-destructive)`,border:`var(--${St}-border)`,input:`var(--${St}-input)`},fontSize:{small:`var(--${St}-font-size-small)`,default:`var(--${St}-font-size)`,large:`var(--${St}-font-size-large)`},radius:{small:`var(--${St}-radius-sm)`,default:`var(--${St}-radius)`,large:`var(--${St}-radius-lg)`},shadow:{sm:`var(--${St}-shadow-sm)`,md:`var(--${St}-shadow-md)`},spacing:{sm:`var(--${St}-spacing-sm)`,default:`var(--${St}-spacing)`,md:`var(--${St}-spacing-md)`,lg:`var(--${St}-spacing-lg)`,xl:`var(--${St}-spacing-xl)`},fontFamily:`var(--${St}-font-family)`,borderWidth:`var(--${St}-border-width)`,transition:`var(--${St}-transition-duration) var(--${St}-transition-timing-function)`},It=new Set;let Tt=!1;function Et(){Tt||(Pt(`\n/* InsureOS Style Isolation Reset */\n.${St}-root {\n all: revert;\n /* Re-apply our base styles after reset */\n font-family: var(--${St}-font-family);\n background-color: var(--${St}-background);\n color: var(--${St}-foreground);\n font-size: var(--${St}-font-size);\n line-height: 1.5;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.${St}-root *,\n.${St}-root *::before,\n.${St}-root *::after {\n box-sizing: border-box;\n}\n\n.${St}-root img,\n.${St}-root picture,\n.${St}-root video,\n.${St}-root canvas,\n.${St}-root svg {\n display: block;\n max-width: 100%;\n}\n\n.${St}-root button,\n.${St}-root input,\n.${St}-root select,\n.${St}-root textarea {\n font: inherit;\n color: inherit;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n}\n\n.${St}-root button {\n cursor: pointer;\n}\n\n.${St}-root a {\n color: inherit;\n text-decoration: inherit;\n}\n\n.${St}-root h1,\n.${St}-root h2,\n.${St}-root h3,\n.${St}-root h4,\n.${St}-root h5,\n.${St}-root h6 {\n font-size: inherit;\n font-weight: inherit;\n margin: 0;\n}\n\n.${St}-root p,\n.${St}-root ul,\n.${St}-root ol,\n.${St}-root blockquote,\n.${St}-root figure {\n margin: 0;\n padding: 0;\n}\n\n.${St}-root ul,\n.${St}-root ol {\n list-style: none;\n}\n\n.${St}-root table {\n border-collapse: collapse;\n border-spacing: 0;\n}\n\n.${St}-root hr {\n margin: 0;\n border: none;\n border-top: 1px solid var(--${St}-border);\n height: 0;\n}\n`),Tt=!0,e())}function Pt(e){if(!document.getElementById(`${St}-styles`)){const e=document.createElement("style");e.id=`${St}-styles`,document.head.appendChild(e)}document.getElementById(`${St}-styles`).textContent+=e+"\n"}function zt(e){return Object.entries(e).map(([e,t])=>{return`${n=e,n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}: ${t}`;var n}).join("; ")}function Dt(){Nt||(Pt(`:root {\n${Object.entries(Ct).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`),Nt=!0)}const Rt={name:e=>`${St}-${e}`,selector(e){return`.${this.name(e)}`},create(e,t,n){Dt();const r=zt(t),i=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t).toString(36)}(`${e}:${r}:${n?JSON.stringify(n):""}`),o=`${e}-${i}`,s=_t.get(o);if(s)return s.fullClassName;let a=e;const l=this.name(a);return It.has(a)||(Pt(`.${l} { ${r} }`),It.add(a)),_t.set(o,{contentHash:i,fullClassName:l}),n&&Object.entries(n).forEach(([e,t])=>{this.media(e,{[a]:t})}),l},keyframes(e,t){const n=`${St}-${e}`;return It.has(`keyframes-${e}`)||(Pt(`@keyframes ${n} {\n${Object.entries(t).map(([e,t])=>` ${e} { ${zt(t)} }`).join("\n")}\n}`),It.add(`keyframes-${e}`)),n},media(e,t){const n=`media-${e}`;Pt(`@media ${e} {\n${Object.entries(t).map(([e,t])=>` .${St}-${e} { ${zt(t)} }`).join("\n")}\n}`),It.add(n)},pseudoElement(e,t,n){const r=`${St}-${e}`,i=`${e}-${t}`;return It.has(i)||(Pt(`.${r}${t} { ${zt(n)} }`),It.add(i)),r}};var Mt=Object.freeze({__proto__:null,baseVariables:Ct,injectIsolationStyles:Et,styles:Rt,theme:$t,updateBaseVariables:function(t){e(),Object.assign(Ct,t);const n=document.getElementById(`${St}-styles`);if(n){const t=n.textContent||"",r=`:root {\n${Object.entries(Ct).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`,i=t.includes(":root {")?t.replace(/:root\s*\{[^}]*\}/g,r):r+"\n"+t;n.textContent=i,e()}else Dt()}});function Ot(e){return e&&e.ne&&{}.hasOwnProperty.call(e,"default")?e.default:e}var jt,Wt={exports:{}};function At(){return jt||(jt=1,e=Wt,function(){var t={}.hasOwnProperty;function n(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!=={}.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var r="";for(var o in e)t.call(e,o)&&e[o]&&(r=i(r,o));return r}function i(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):window.classNames=n}()),Wt.exports;var e}var Lt=Ot(At());function Bt({size:e="small"}){const t=Rt.create("spinner-small",{width:"16px",height:"16px"}),n=Rt.create("spinner-large",{width:"64px",height:"64px"}),r="small"===e?t:n;return Rt.keyframes("spin",{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Qe("div",{className:Rt.create("loading-spinner",{display:"flex",justifyContent:"center",alignItems:"center",animation:"insure-os-spin 1s linear infinite"}),children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:Lt(r),children:Qe("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})})}function qt({className:e,children:t,size:n="md"}){const r={sm:$t.spacing.sm,md:$t.spacing.md,lg:$t.spacing.lg,xl:$t.spacing.xl},i=Rt.create(`padding-${n}`,{padding:r[n]},{"(max-width: 950px)":{padding:"xl"===n?$t.spacing.lg:"lg"===n?$t.spacing.md:r[n]},"(max-width: 480px)":{padding:$t.spacing.sm}});return Qe("div",{className:Lt(i,e),children:t})}const Ft=function(){function e(t){var n,r;return this.getChildContext||(n=new Set,(r={})[e.k]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.v=!0,E(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),t.children}return e.k="__cC"+p++,e.m=null,e.Provider=e.re=(e.Consumer=function(e,t){return e.children(t)}).contextType=e,e}();function Ht({children:e,httpClient:t,stateManager:n,quoteIntentStore:r,formStateManager:i,paymentLinkConfig:o,availableProducts:s,productCodes:a,urlPromoCode:l}){return Qe(Ft.Provider,{value:{httpClient:t,stateManager:n,quoteIntentStore:r,formStateManager:i,paymentLinkConfig:o,availableProducts:s,productCodes:a,urlPromoCode:l,currentRetryAttempt:0,maxRetryAttempts:3},children:e})}function Ut(){const e=function(e){var t=Ke.context[e.k],n=dt(Je++,9);return n.c=e,t?(null==n.m&&(n.m=!0,t.sub(Ke)),t.props.value):e.m}(Ft);if(!e)throw new Error("useFormContext must be used within a FormContext provider");return e}function Yt(e){const t=Ut(),{formStateManager:n}=t;if(!n||"function"!=typeof n.subscribe)throw new Error("useQuoteForm can only be used in quote mode. If you're in payment link mode, use usePaymentLink instead.");const[r,i]=ut(()=>e(n));return ht(()=>n.subscribe(()=>{i(e(n))}),[n,e]),{...r,fsm:n}}class Zt extends Error{}class Gt extends Zt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Vt extends Zt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Qt extends Zt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class Jt extends Zt{}class Kt extends Zt{constructor(e){super(`Invalid unit ${e}`)}}class Xt extends Zt{}class en extends Zt{constructor(){super("Zone is an abstract class")}}const tn="numeric",nn="short",rn="long",on={year:tn,month:tn,day:tn},sn={year:tn,month:nn,day:tn},an={year:tn,month:nn,day:tn,weekday:nn},ln={year:tn,month:rn,day:tn},cn={year:tn,month:rn,day:tn,weekday:rn},dn={hour:tn,minute:tn},un={hour:tn,minute:tn,second:tn},hn={hour:tn,minute:tn,second:tn,timeZoneName:nn},mn={hour:tn,minute:tn,second:tn,timeZoneName:rn},fn={hour:tn,minute:tn,hourCycle:"h23"},pn={hour:tn,minute:tn,second:tn,hourCycle:"h23"},gn={hour:tn,minute:tn,second:tn,hourCycle:"h23",timeZoneName:nn},yn={hour:tn,minute:tn,second:tn,hourCycle:"h23",timeZoneName:rn},vn={year:tn,month:tn,day:tn,hour:tn,minute:tn},wn={year:tn,month:tn,day:tn,hour:tn,minute:tn,second:tn},bn={year:tn,month:nn,day:tn,hour:tn,minute:tn},xn={year:tn,month:nn,day:tn,hour:tn,minute:tn,second:tn},kn={year:tn,month:nn,day:tn,weekday:nn,hour:tn,minute:tn},Sn={year:tn,month:rn,day:tn,hour:tn,minute:tn,timeZoneName:nn},Nn={year:tn,month:rn,day:tn,hour:tn,minute:tn,second:tn,timeZoneName:nn},_n={year:tn,month:rn,day:tn,weekday:rn,hour:tn,minute:tn,timeZoneName:rn},Cn={year:tn,month:rn,day:tn,weekday:rn,hour:tn,minute:tn,second:tn,timeZoneName:rn};class $n{get type(){throw new en}get name(){throw new en}get ianaName(){return this.name}get isUniversal(){throw new en}offsetName(e,t){throw new en}formatOffset(e,t){throw new en}offset(e){throw new en}equals(e){throw new en}get isValid(){throw new en}}let In=null;class Tn extends $n{static get instance(){return null===In&&(In=new Tn),In}get type(){return"system"}get name(){return(new Intl.DateTimeFormat).resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Vr(e,t,n)}formatOffset(e,t){return Xr(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return"system"===e.type}get isValid(){return!0}}const En=new Map,Pn={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6},zn=new Map;class Dn extends $n{static create(e){let t=zn.get(e);return void 0===t&&zn.set(e,t=new Dn(e)),t}static resetCache(){zn.clear(),En.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch(e){return!1}}constructor(e){super(),this.zoneName=e,this.valid=Dn.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Vr(e,t,n,this.name)}formatOffset(e,t){return Xr(this.offset(e),t)}offset(e){if(!this.valid)return NaN;const t=new Date(e);if(isNaN(t))return NaN;const n=function(e){let t=En.get(e);return void 0===t&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),En.set(e,t)),t}(this.name);let[r,i,o,s,a,l,c]=n.formatToParts?function(e,t){const n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){const{type:t,value:i}=n[e],o=Pn[t];"era"===t?r[o]=i:Ir(o)||(r[o]=parseInt(i,10))}return r}(n,t):function(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,i,o,s,a,l,c,d]=r;return[s,i,o,a,l,c,d]}(n,t);"BC"===s&&(r=1-Math.abs(r));let d=+t;const u=d%1e3;return d-=u>=0?u:1e3+u,(Ur({year:r,month:i,day:o,hour:24===a?0:a,minute:l,second:c,millisecond:0})-d)/6e4}equals(e){return"iana"===e.type&&e.name===this.name}get isValid(){return this.valid}}let Rn={};const Mn=new Map;function On(e,t={}){const n=JSON.stringify([e,t]);let r=Mn.get(n);return void 0===r&&(r=new Intl.DateTimeFormat(e,t),Mn.set(n,r)),r}const jn=new Map,Wn=new Map;let An=null;const Ln=new Map;function Bn(e){let t=Ln.get(e);return void 0===t&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Ln.set(e,t)),t}const qn=new Map;function Fn(e,t,n,r){const i=e.listingMode();return"error"===i?null:"en"===i?n(t):r(t)}class Hn{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:i,...o}=n;if(!t||Object.keys(o).length>0){const t={useGrouping:!1,...n};n.padTo>0&&(t.minimumIntegerDigits=n.padTo),this.inf=function(e,t={}){const n=JSON.stringify([e,t]);let r=jn.get(n);return void 0===r&&(r=new Intl.NumberFormat(e,t),jn.set(n,r)),r}(e,t)}}format(e){if(this.inf){const t=this.floor?Math.floor(e):e;return this.inf.format(t)}return jr(this.floor?Math.floor(e):Br(e,3),this.padTo)}}class Un{constructor(e,t,n){let r;if(this.opts=n,this.originalZone=void 0,this.opts.timeZone)this.dt=e;else if("fixed"===e.zone.type){const t=e.offset/60*-1,n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;0!==e.offset&&Dn.create(n).valid?(r=n,this.dt=e):(r="UTC",this.dt=0===e.offset?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else"system"===e.zone.type?this.dt=e:"iana"===e.zone.type?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=On(t,i)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(e=>{if("timeZoneName"===e.type){const t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}return e}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class Yn{constructor(e,t,n){this.opts={style:"long",...n},!t&&Pr()&&(this.rtf=function(e,t={}){const{base:n,...r}=t,i=JSON.stringify([e,r]);let o=Wn.get(i);return void 0===o&&(o=new Intl.RelativeTimeFormat(e,t),Wn.set(i,o)),o}(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):function(e,t,n="always",r=!1){const i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},o=-1===["hours","minutes","seconds"].indexOf(e);if("auto"===n&&o){const n="days"===e;switch(t){case 1:return n?"tomorrow":`next ${i[e][0]}`;case-1:return n?"yesterday":`last ${i[e][0]}`;case 0:return n?"today":`this ${i[e][0]}`}}const s=Object.is(t,-0)||t<0,a=Math.abs(t),l=1===a,c=i[e],d=r?l?c[1]:c[2]||c[1]:l?i[e][0]:e;return s?`${a} ${d} ago`:`in ${a} ${d}`}(t,e,this.opts.numeric,"long"!==this.opts.style)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}}const Zn={firstDay:1,minimalDays:4,weekend:[6,7]};class Gn{static fromOpts(e){return Gn.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,t,n,r,i=!1){const o=e||hr.defaultLocale,s=o||(i?"en-US":An||(An=(new Intl.DateTimeFormat).resolvedOptions().locale,An)),a=t||hr.defaultNumberingSystem,l=n||hr.defaultOutputCalendar,c=Mr(r)||hr.defaultWeekSettings;return new Gn(s,a,l,c,o)}static resetCache(){An=null,Mn.clear(),jn.clear(),Wn.clear(),Ln.clear(),qn.clear()}static fromObject({locale:e,numberingSystem:t,outputCalendar:n,weekSettings:r}={}){return Gn.create(e,t,n,r)}constructor(e,t,n,r,i){const[o,s,a]=function(e){const t=e.indexOf("-x-");-1!==t&&(e=e.substring(0,t));const n=e.indexOf("-u-");if(-1===n)return[e];{let t,r;try{t=On(e).resolvedOptions(),r=e}catch(i){const o=e.substring(0,n);t=On(o).resolvedOptions(),r=o}const{numberingSystem:i,calendar:o}=t;return[r,i,o]}}(e);this.locale=o,this.numberingSystem=t||s||null,this.outputCalendar=n||a||null,this.weekSettings=r,this.intl=function(e,t,n){return n||t?(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){var e;return null==this.fastNumbersCached&&(this.fastNumbersCached=(!(e=this).numberingSystem||"latn"===e.numberingSystem)&&("latn"===e.numberingSystem||!e.locale||e.locale.startsWith("en")||"latn"===Bn(e.locale).numberingSystem)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),t=!(null!==this.numberingSystem&&"latn"!==this.numberingSystem||null!==this.outputCalendar&&"gregory"!==this.outputCalendar);return e&&t?"en":"intl"}clone(e){return e&&0!==Object.getOwnPropertyNames(e).length?Gn.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Mr(e.weekSettings)||this.weekSettings,e.defaultToEN||!1):this}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return Fn(this,e,ii,()=>{const n="ja"===this.intl||this.intl.startsWith("ja-"),r=(t&=!n)?{month:e,day:"numeric"}:{month:e},i=t?"format":"standalone";if(!this.monthsCache[i][e]){const t=n?e=>this.dtFormatter(e,r).format():e=>this.extract(e,r,"month");this.monthsCache[i][e]=function(e){const t=[];for(let n=1;n<=12;n++){const r=as.utc(2009,n,1);t.push(e(r))}return t}(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Fn(this,e,li,()=>{const n=t?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=t?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=function(e){const t=[];for(let n=1;n<=7;n++){const r=as.utc(2016,11,13+n);t.push(e(r))}return t}(e=>this.extract(e,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Fn(this,void 0,()=>ci,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[as.utc(2016,11,13,9),as.utc(2016,11,13,19)].map(t=>this.extract(t,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Fn(this,e,mi,()=>{const t={era:e};return this.eraCache[e]||(this.eraCache[e]=[as.utc(-40,1,1),as.utc(2017,1,1)].map(e=>this.extract(e,t,"era"))),this.eraCache[e]})}extract(e,t,n){const r=this.dtFormatter(e,t).formatToParts().find(e=>e.type.toLowerCase()===n);return r?r.value:null}numberFormatter(e={}){return new Hn(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new Un(e,this.intl,t)}relFormatter(e={}){return new Yn(this.intl,this.isEnglish(),e)}listFormatter(e={}){return function(e,t={}){const n=JSON.stringify([e,t]);let r=Rn[n];return r||(r=new Intl.ListFormat(e,t),Rn[n]=r),r}(this.intl,e)}isEnglish(){return"en"===this.locale||"en-us"===this.locale.toLowerCase()||Bn(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:zr()?function(e){let t=qn.get(e);if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...Zn,...t}),qn.set(e,t)}return t}(this.locale):Zn}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Vn=null;class Qn extends $n{static get utcInstance(){return null===Vn&&(Vn=new Qn(0)),Vn}static instance(e){return 0===e?Qn.utcInstance:new Qn(e)}static parseSpecifier(e){if(e){const t=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(t)return new Qn(Qr(t[1],t[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return 0===this.fixed?"UTC":`UTC${Xr(this.fixed,"narrow")}`}get ianaName(){return 0===this.fixed?"Etc/UTC":`Etc/GMT${Xr(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,t){return Xr(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return"fixed"===e.type&&e.fixed===this.fixed}get isValid(){return!0}}class Jn extends $n{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function Kn(e,t){if(Ir(e)||null===e)return t;if(e instanceof $n)return e;if(function(e){return"string"==typeof e}(e)){const n=e.toLowerCase();return"default"===n?t:"local"===n||"system"===n?Tn.instance:"utc"===n||"gmt"===n?Qn.utcInstance:Qn.parseSpecifier(n)||Dn.create(e)}return Tr(e)?Qn.instance(e):"object"==typeof e&&"offset"in e&&"function"==typeof e.offset?e:new Jn(e)}const Xn={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},er={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},tr=Xn.hanidec.replace(/[\[|\]]/g,"").split(""),nr=new Map;function rr({numberingSystem:e},t=""){const n=e||"latn";let r=nr.get(n);void 0===r&&(r=new Map,nr.set(n,r));let i=r.get(t);return void 0===i&&(i=new RegExp(`${Xn[n]}${t}`),r.set(t,i)),i}let ir,or=()=>Date.now(),sr="system",ar=null,lr=null,cr=null,dr=60,ur=null;class hr{static get now(){return or}static set now(e){or=e}static set defaultZone(e){sr=e}static get defaultZone(){return Kn(sr,Tn.instance)}static get defaultLocale(){return ar}static set defaultLocale(e){ar=e}static get defaultNumberingSystem(){return lr}static set defaultNumberingSystem(e){lr=e}static get defaultOutputCalendar(){return cr}static set defaultOutputCalendar(e){cr=e}static get defaultWeekSettings(){return ur}static set defaultWeekSettings(e){ur=Mr(e)}static get twoDigitCutoffYear(){return dr}static set twoDigitCutoffYear(e){dr=e%100}static get throwOnInvalid(){return ir}static set throwOnInvalid(e){ir=e}static resetCaches(){Gn.resetCache(),Dn.resetCache(),as.resetCache(),nr.clear()}}class mr{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const fr=[0,31,59,90,120,151,181,212,243,273,304,334],pr=[0,31,60,91,121,152,182,213,244,274,305,335];function gr(e,t){return new mr("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function yr(e,t,n){const r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const i=r.getUTCDay();return 0===i?7:i}function vr(e,t,n){return n+(qr(e)?pr:fr)[t-1]}function wr(e,t){const n=qr(e)?pr:fr,r=n.findIndex(e=>e<t);return{month:r+1,day:t-n[r]}}function br(e,t){return(e-t+7)%7+1}function xr(e,t=4,n=1){const{year:r,month:i,day:o}=e,s=vr(r,i,o),a=br(yr(r,i,o),n);let l,c=Math.floor((s-a+14-t)/7);return c<1?(l=r-1,c=Zr(l,t,n)):c>Zr(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:a,...ei(e)}}function kr(e,t=4,n=1){const{weekYear:r,weekNumber:i,weekday:o}=e,s=br(yr(r,1,t),n),a=Fr(r);let l,c=7*i+o-s-7+t;c<1?(l=r-1,c+=Fr(l)):c>a?(l=r+1,c-=Fr(r)):l=r;const{month:d,day:u}=wr(l,c);return{year:l,month:d,day:u,...ei(e)}}function Sr(e){const{year:t,month:n,day:r}=e;return{year:t,ordinal:vr(t,n,r),...ei(e)}}function Nr(e){const{year:t,ordinal:n}=e,{month:r,day:i}=wr(t,n);return{year:t,month:r,day:i,...ei(e)}}function _r(e,t){if(!Ir(e.localWeekday)||!Ir(e.localWeekNumber)||!Ir(e.localWeekYear)){if(!Ir(e.weekday)||!Ir(e.weekNumber)||!Ir(e.weekYear))throw new Jt("Cannot mix locale-based week fields with ISO-based week fields");return Ir(e.localWeekday)||(e.weekday=e.localWeekday),Ir(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),Ir(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}return{minDaysInFirstWeek:4,startOfWeek:1}}function Cr(e){const t=Er(e.year),n=Or(e.month,1,12),r=Or(e.day,1,Hr(e.year,e.month));return t?n?!r&&gr("day",e.day):gr("month",e.month):gr("year",e.year)}function $r(e){const{hour:t,minute:n,second:r,millisecond:i}=e,o=Or(t,0,23)||24===t&&0===n&&0===r&&0===i,s=Or(n,0,59),a=Or(r,0,59),l=Or(i,0,999);return o?s?a?!l&&gr("millisecond",i):gr("second",r):gr("minute",n):gr("hour",t)}function Ir(e){return void 0===e}function Tr(e){return"number"==typeof e}function Er(e){return"number"==typeof e&&e%1==0}function Pr(){try{return"undefined"!=typeof Intl&&!!Intl.RelativeTimeFormat}catch(e){return!1}}function zr(){try{return"undefined"!=typeof Intl&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch(e){return!1}}function Dr(e,t,n){if(0!==e.length)return e.reduce((e,r)=>{const i=[t(r),r];return e&&n(e[0],i[0])===e[0]?e:i},null)[1]}function Rr(e,t){return{}.hasOwnProperty.call(e,t)}function Mr(e){if(null==e)return null;if("object"!=typeof e)throw new Xt("Week settings must be an object");if(!Or(e.firstDay,1,7)||!Or(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!Or(e,1,7)))throw new Xt("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Or(e,t,n){return Er(e)&&e>=t&&e<=n}function jr(e,t=2){let n;return n=e<0?"-"+(""+-e).padStart(t,"0"):(""+e).padStart(t,"0"),n}function Wr(e){return Ir(e)||null===e||""===e?void 0:parseInt(e,10)}function Ar(e){return Ir(e)||null===e||""===e?void 0:parseFloat(e)}function Lr(e){if(!Ir(e)&&null!==e&&""!==e){const t=1e3*parseFloat("0."+e);return Math.floor(t)}}function Br(e,t,n="round"){const r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function qr(e){return e%4==0&&(e%100!=0||e%400==0)}function Fr(e){return qr(e)?366:365}function Hr(e,t){const n=(r=t-1)-12*Math.floor(r/12)+1;var r;return 2===n?qr(e+(t-n)/12)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Ur(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function Yr(e,t,n){return-br(yr(e,1,t),n)+t-1}function Zr(e,t=4,n=1){const r=Yr(e,t,n),i=Yr(e+1,t,n);return(Fr(e)-r+i)/7}function Gr(e){return e>99?e:e>hr.twoDigitCutoffYear?1900+e:2e3+e}function Vr(e,t,n,r=null){const i=new Date(e),o={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(o.timeZone=r);const s={timeZoneName:t,...o},a=new Intl.DateTimeFormat(n,s).formatToParts(i).find(e=>"timezonename"===e.type.toLowerCase());return a?a.value:null}function Qr(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);const r=parseInt(t,10)||0;return 60*n+(n<0||Object.is(n,-0)?-r:r)}function Jr(e){const t=Number(e);if("boolean"==typeof e||""===e||!Number.isFinite(t))throw new Xt(`Invalid unit value ${e}`);return t}function Kr(e,t){const n={};for(const r in e)if(Rr(e,r)){const i=e[r];if(null==i)continue;n[t(r)]=Jr(i)}return n}function Xr(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?"+":"-";switch(t){case"short":return`${i}${jr(n,2)}:${jr(r,2)}`;case"narrow":return`${i}${n}${r>0?`:${r}`:""}`;case"techie":return`${i}${jr(n,2)}${jr(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function ei(e){return function(e){return["hour","minute","second","millisecond"].reduce((t,n)=>(t[n]=e[n],t),{})}(e)}const ti=["January","February","March","April","May","June","July","August","September","October","November","December"],ni=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ri=["J","F","M","A","M","J","J","A","S","O","N","D"];function ii(e){switch(e){case"narrow":return[...ri];case"short":return[...ni];case"long":return[...ti];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const oi=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],si=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],ai=["M","T","W","T","F","S","S"];function li(e){switch(e){case"narrow":return[...ai];case"short":return[...si];case"long":return[...oi];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const ci=["AM","PM"],di=["Before Christ","Anno Domini"],ui=["BC","AD"],hi=["B","A"];function mi(e){switch(e){case"narrow":return[...hi];case"short":return[...ui];case"long":return[...di];default:return null}}function fi(e,t){let n="";for(const r of e)r.literal?n+=r.val:n+=t(r.val);return n}const pi={D:on,DD:sn,DDD:ln,DDDD:cn,t:dn,tt:un,ttt:hn,tttt:mn,T:fn,TT:pn,TTT:gn,TTTT:yn,f:vn,ff:bn,fff:Sn,ffff:_n,F:wn,FF:xn,FFF:Nn,FFFF:Cn};class gi{static create(e,t={}){return new gi(e,t)}static parseFormat(e){let t=null,n="",r=!1;const i=[];for(let o=0;o<e.length;o++){const s=e.charAt(o);"'"===s?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:""===n?"'":n}),t=null,n="",r=!r):r||s===t?n+=s:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=s,t=s)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return pi[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){return null===this.systemLoc&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0,n){if(this.opts.forceSimple)return jr(e,t);const r={...this.opts};return t>0&&(r.padTo=t),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,t){const n="en"===this.loc.listingMode(),r=this.loc.outputCalendar&&"gregory"!==this.loc.outputCalendar,i=(t,n)=>this.loc.extract(e,t,n),o=t=>e.isOffsetFixed&&0===e.offset&&t.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,t.format):"",s=(t,r)=>n?function(e,t){return ii(t)[e.month-1]}(e,t):i(r?{month:t}:{month:t,day:"numeric"},"month"),a=(t,r)=>n?function(e,t){return li(t)[e.weekday-1]}(e,t):i(r?{weekday:t}:{weekday:t,month:"long",day:"numeric"},"weekday"),l=t=>{const n=gi.macroTokenToFormatOpts(t);return n?this.formatWithSystemDefault(e,n):t},c=t=>n?function(e,t){return mi(t)[e.year<0?0:1]}(e,t):i({era:t},"era");return fi(gi.parseFormat(t),t=>{switch(t){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12==0?12:e.hour%12);case"hh":return this.num(e.hour%12==0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return n?function(e){return ci[e.hour<12?0:1]}(e):i({hour:"numeric",hourCycle:"h12"},"dayperiod");case"d":return r?i({day:"numeric"},"day"):this.num(e.day);case"dd":return r?i({day:"2-digit"},"day"):this.num(e.day,2);case"c":case"E":return this.num(e.weekday);case"ccc":return a("short",!0);case"cccc":return a("long",!0);case"ccccc":return a("narrow",!0);case"EEE":return a("short",!1);case"EEEE":return a("long",!1);case"EEEEE":return a("narrow",!1);case"L":return r?i({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?i({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return s("short",!0);case"LLLL":return s("long",!0);case"LLLLL":return s("narrow",!0);case"M":return r?i({month:"numeric"},"month"):this.num(e.month);case"MM":return r?i({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return s("short",!1);case"MMMM":return s("long",!1);case"MMMMM":return s("narrow",!1);case"y":return r?i({year:"numeric"},"year"):this.num(e.year);case"yy":return r?i({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?i({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?i({year:"numeric"},"year"):this.num(e.year,6);case"G":return c("short");case"GG":return c("long");case"GGGGG":return c("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return l(t)}})}formatDurationFromString(e,t){const n="negativeLargestOnly"===this.opts.signMode?-1:1,r=e=>{switch(e[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=gi.parseFormat(t),o=i.reduce((e,{literal:t,val:n})=>t?e:e.concat(n),[]),s=e.shiftTo(...o.map(r).filter(e=>e));return fi(i,((e,t)=>i=>{const o=r(i);if(o){const r=t.isNegativeDuration&&o!==t.largestUnit?n:1;let s;return s="negativeLargestOnly"===this.opts.signMode&&o!==t.largestUnit?"never":"all"===this.opts.signMode?"always":"auto",this.num(e.get(o)*r,i.length,s)}return i})(s,{isNegativeDuration:s<0,largestUnit:Object.keys(s.values)[0]}))}}const yi=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function vi(...e){const t=e.reduce((e,t)=>e+t.source,"");return RegExp(`^${t}$`)}function wi(...e){return t=>e.reduce(([e,n,r],i)=>{const[o,s,a]=i(t,r);return[{...e,...o},s||n,a]},[{},null,1]).slice(0,2)}function bi(e,...t){if(null==e)return[null,null];for(const[n,r]of t){const t=n.exec(e);if(t)return r(t)}return[null,null]}function xi(...e){return(t,n)=>{const r={};let i;for(i=0;i<e.length;i++)r[e[i]]=Wr(t[n+i]);return[r,null,n+i]}}const ki=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Si=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ni=RegExp(`${Si.source}(?:${ki.source}?(?:\\[(${yi.source})\\])?)?`),_i=RegExp(`(?:[Tt]${Ni.source})?`),Ci=xi("weekYear","weekNumber","weekDay"),$i=xi("year","ordinal"),Ii=RegExp(`${Si.source} ?(?:${ki.source}|(${yi.source}))?`),Ti=RegExp(`(?: ${Ii.source})?`);function Ei(e,t,n){const r=e[t];return Ir(r)?n:Wr(r)}function Pi(e,t){return[{hours:Ei(e,t,0),minutes:Ei(e,t+1,0),seconds:Ei(e,t+2,0),milliseconds:Lr(e[t+3])},null,t+4]}function zi(e,t){const n=!e[t]&&!e[t+1],r=Qr(e[t+1],e[t+2]);return[{},n?null:Qn.instance(r),t+3]}function Di(e,t){return[{},e[t]?Dn.create(e[t]):null,t+1]}const Ri=RegExp(`^T?${Si.source}$`),Mi=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Oi(e){const[t,n,r,i,o,s,a,l,c]=e,d="-"===t[0],u=l&&"-"===l[0],h=(e,t=!1)=>void 0!==e&&(t||e&&d)?-e:e;return[{years:h(Ar(n)),months:h(Ar(r)),weeks:h(Ar(i)),days:h(Ar(o)),hours:h(Ar(s)),minutes:h(Ar(a)),seconds:h(Ar(l),"-0"===l),milliseconds:h(Lr(c),u)}]}const ji={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Wi(e,t,n,r,i,o,s){const a={year:2===t.length?Gr(Wr(t)):Wr(t),month:ni.indexOf(n)+1,day:Wr(r),hour:Wr(i),minute:Wr(o)};return s&&(a.second=Wr(s)),e&&(a.weekday=e.length>3?oi.indexOf(e)+1:si.indexOf(e)+1),a}const Ai=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function Li(e){const[,t,n,r,i,o,s,a,l,c,d,u]=e,h=Wi(t,i,r,n,o,s,a);let m;return m=l?ji[l]:c?0:Qr(d,u),[h,new Qn(m)]}const Bi=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,qi=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Fi=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Hi(e){const[,t,n,r,i,o,s,a]=e;return[Wi(t,i,r,n,o,s,a),Qn.utcInstance]}function Ui(e){const[,t,n,r,i,o,s,a]=e;return[Wi(t,a,n,r,i,o,s),Qn.utcInstance]}const Yi=vi(/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,_i),Zi=vi(/(\d{4})-?W(\d\d)(?:-?(\d))?/,_i),Gi=vi(/(\d{4})-?(\d{3})/,_i),Vi=vi(Ni),Qi=wi(function(e,t){return[{year:Ei(e,t),month:Ei(e,t+1,1),day:Ei(e,t+2,1)},null,t+3]},Pi,zi,Di),Ji=wi(Ci,Pi,zi,Di),Ki=wi($i,Pi,zi,Di),Xi=wi(Pi,zi,Di),eo=wi(Pi),to=vi(/(\d{4})-(\d\d)-(\d\d)/,Ti),no=vi(Ii),ro=wi(Pi,zi,Di),io="Invalid Duration",oo={weeks:{days:7,hours:168,minutes:10080,seconds:604800,milliseconds:6048e5},days:{hours:24,minutes:1440,seconds:86400,milliseconds:864e5},hours:{minutes:60,seconds:3600,milliseconds:36e5},minutes:{seconds:60,milliseconds:6e4},seconds:{milliseconds:1e3}},so={years:{quarters:4,months:12,weeks:52,days:365,hours:8760,minutes:525600,seconds:31536e3,milliseconds:31536e6},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:131040,seconds:7862400,milliseconds:78624e5},months:{weeks:4,days:30,hours:720,minutes:43200,seconds:2592e3,milliseconds:2592e6},...oo},ao={years:{quarters:4,months:12,weeks:52.1775,days:365.2425,hours:8765.82,minutes:525949.2,seconds:525949.2*60,milliseconds:525949.2*60*1e3},quarters:{months:3,weeks:13.044375,days:91.310625,hours:2191.455,minutes:131487.3,seconds:525949.2*60/4,milliseconds:7889237999.999999},months:{weeks:4.3481250000000005,days:30.436875,hours:730.485,minutes:43829.1,seconds:2629746,milliseconds:2629746e3},...oo},lo=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],co=lo.slice(0).reverse();function uo(e,t,n=!1){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new po(r)}function ho(e,t){let n=t.milliseconds??0;for(const r of co.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function mo(e,t){const n=ho(e,t)<0?-1:1;lo.reduceRight((r,i)=>{if(Ir(t[i]))return r;if(r){const o=t[r]*n,s=e[i][r],a=Math.floor(o/s);t[i]+=a*n,t[r]-=a*s*n}return i},null),lo.reduce((n,r)=>{if(Ir(t[r]))return n;if(n){const i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function fo(e){const t={};for(const[n,r]of Object.entries(e))0!==r&&(t[n]=r);return t}class po{constructor(e){const t="longterm"===e.conversionAccuracy||!1;let n=t?ao:so;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||Gn.create(),this.conversionAccuracy=t?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,t){return po.fromObject({milliseconds:e},t)}static fromObject(e,t={}){if(null==e||"object"!=typeof e)throw new Xt("Duration.fromObject: argument expected to be an object, got "+(null===e?"null":typeof e));return new po({values:Kr(e,po.normalizeUnit),loc:Gn.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(Tr(e))return po.fromMillis(e);if(po.isDuration(e))return e;if("object"==typeof e)return po.fromObject(e);throw new Xt(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,t){const[n]=function(e){return bi(e,[Mi,Oi])}(e);return n?po.fromObject(n,t):po.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,t){const[n]=function(e){return bi(e,[Ri,eo])}(e);return n?po.fromObject(n,t):po.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,t=null){if(!e)throw new Xt("need to specify a reason the Duration is invalid");const n=e instanceof mr?e:new mr(e,t);if(hr.throwOnInvalid)throw new Qt(n);return new po({invalid:n})}static normalizeUnit(e){const t={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e?e.toLowerCase():e];if(!t)throw new Kt(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){const n={...t,floor:!1!==t.round&&!1!==t.floor};return this.isValid?gi.create(this.loc,n).formatDurationFromString(this,e):io}toHuman(e={}){if(!this.isValid)return io;const t=!1!==e.showZeros,n=lo.map(n=>{const r=this.values[n];return Ir(r)||0===r&&!t?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:n.slice(0,-1)}).format(r)}).filter(e=>e);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return 0!==this.years&&(e+=this.years+"Y"),0===this.months&&0===this.quarters||(e+=this.months+3*this.quarters+"M"),0!==this.weeks&&(e+=this.weeks+"W"),0!==this.days&&(e+=this.days+"D"),0===this.hours&&0===this.minutes&&0===this.seconds&&0===this.milliseconds||(e+="T"),0!==this.hours&&(e+=this.hours+"H"),0!==this.minutes&&(e+=this.minutes+"M"),0===this.seconds&&0===this.milliseconds||(e+=Br(this.seconds+this.milliseconds/1e3,3)+"S"),"P"===e&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const t=this.toMillis();return t<0||t>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},as.fromMillis(t,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?ho(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const t=po.fromDurationLike(e),n={};for(const e of lo)(Rr(t.values,e)||Rr(this.values,e))&&(n[e]=t.get(e)+this.get(e));return uo(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const t=po.fromDurationLike(e);return this.plus(t.negate())}mapUnits(e){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values))t[n]=Jr(e(this.values[n],n));return uo(this,{values:t},!0)}get(e){return this[po.normalizeUnit(e)]}set(e){return this.isValid?uo(this,{values:{...this.values,...Kr(e,po.normalizeUnit)}}):this}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){return uo(this,{loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:r,conversionAccuracy:n})}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return mo(this.matrix,e),uo(this,{values:e},!0)}rescale(){return this.isValid?uo(this,{values:fo(this.normalize().shiftToAll().toObject())},!0):this}shiftTo(...e){if(!this.isValid)return this;if(0===e.length)return this;e=e.map(e=>po.normalizeUnit(e));const t={},n={},r=this.toObject();let i;for(const o of lo)if(e.indexOf(o)>=0){i=o;let e=0;for(const t in n)e+=this.matrix[t][o]*n[t],n[t]=0;Tr(r[o])&&(e+=r[o]);const s=Math.trunc(e);t[o]=s,n[o]=(1e3*e-1e3*s)/1e3}else Tr(r[o])&&(n[o]=r[o]);for(const e in n)0!==n[e]&&(t[i]+=e===i?n[e]:n[e]/this.matrix[i][e]);return mo(this.matrix,t),uo(this,{values:t},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const t of Object.keys(this.values))e[t]=0===this.values[t]?0:-this.values[t];return uo(this,{values:e},!0)}removeZeros(){return this.isValid?uo(this,{values:fo(this.values)},!0):this}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return null===this.invalid}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid)return!1;if(!this.loc.equals(e.loc))return!1;function t(e,t){return void 0===e||0===e?void 0===t||0===t:e===t}for(const n of lo)if(!t(this.values[n],e.values[n]))return!1;return!0}}const go="Invalid Interval";class yo{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,t=null){if(!e)throw new Xt("need to specify a reason the Interval is invalid");const n=e instanceof mr?e:new mr(e,t);if(hr.throwOnInvalid)throw new Vt(n);return new yo({invalid:n})}static fromDateTimes(e,t){const n=ls(e),r=ls(t),i=function(e,t){return e&&e.isValid?t&&t.isValid?t<e?yo.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null:yo.invalid("missing or invalid end"):yo.invalid("missing or invalid start")}(n,r);return null==i?new yo({start:n,end:r}):i}static after(e,t){const n=po.fromDurationLike(t),r=ls(e);return yo.fromDateTimes(r,r.plus(n))}static before(e,t){const n=po.fromDurationLike(t),r=ls(e);return yo.fromDateTimes(r.minus(n),r)}static fromISO(e,t){const[n,r]=(e||"").split("/",2);if(n&&r){let e,i,o,s;try{e=as.fromISO(n,t),i=e.isValid}catch(r){i=!1}try{o=as.fromISO(r,t),s=o.isValid}catch(r){s=!1}if(i&&s)return yo.fromDateTimes(e,o);if(i){const n=po.fromISO(r,t);if(n.isValid)return yo.after(e,n)}else if(s){const e=po.fromISO(n,t);if(e.isValid)return yo.before(o,e)}}return yo.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return null===this.invalidReason}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",t){if(!this.isValid)return NaN;const n=this.start.startOf(e,t);let r;return r=t?.useLocaleWeeks?this.end.reconfigure({locale:n.locale}):this.end,r=r.startOf(e,t),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return!!this.isValid&&(this.isEmpty()||this.e.minus(1).hasSame(this.s,e))}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return!!this.isValid&&this.s>e}isBefore(e){return!!this.isValid&&this.e<=e}contains(e){return!!this.isValid&&this.s<=e&&this.e>e}set({start:e,end:t}={}){return this.isValid?yo.fromDateTimes(e||this.s,t||this.e):this}splitAt(...e){if(!this.isValid)return[];const t=e.map(ls).filter(e=>this.contains(e)).sort((e,t)=>e.toMillis()-t.toMillis()),n=[];let{s:r}=this,i=0;for(;r<this.e;){const e=t[i]||this.e,o=+e>+this.e?this.e:e;n.push(yo.fromDateTimes(r,o)),r=o,i+=1}return n}splitBy(e){const t=po.fromDurationLike(e);if(!this.isValid||!t.isValid||0===t.as("milliseconds"))return[];let n,{s:r}=this,i=1;const o=[];for(;r<this.e;){const e=this.start.plus(t.mapUnits(e=>e*i));n=+e>+this.e?this.e:e,o.push(yo.fromDateTimes(r,n)),r=n,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return!!this.isValid&&+this.e===+e.s}abutsEnd(e){return!!this.isValid&&+e.e===+this.s}engulfs(e){return!!this.isValid&&this.s<=e.s&&this.e>=e.e}equals(e){return!(!this.isValid||!e.isValid)&&this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const t=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return t>=n?null:yo.fromDateTimes(t,n)}union(e){if(!this.isValid)return this;const t=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return yo.fromDateTimes(t,n)}static merge(e){const[t,n]=e.sort((e,t)=>e.s-t.s).reduce(([e,t],n)=>t?t.overlaps(n)||t.abutsStart(n)?[e,t.union(n)]:[e.concat([t]),n]:[e,n],[[],null]);return n&&t.push(n),t}static xor(e){let t=null,n=0;const r=[],i=e.map(e=>[{time:e.s,type:"s"},{time:e.e,type:"e"}]),o=[].concat(...i).sort((e,t)=>e.time-t.time);for(const e of o)n+="s"===e.type?1:-1,1===n?t=e.time:(t&&+t!==+e.time&&r.push(yo.fromDateTimes(t,e.time)),t=null);return yo.merge(r)}difference(...e){return yo.xor([this].concat(e)).map(e=>this.intersection(e)).filter(e=>e&&!e.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:go}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=on,t={}){return this.isValid?gi.create(this.s.loc.clone(t),e).formatInterval(this):go}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:go}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:go}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:go}toFormat(e,{separator:t=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:go}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):po.invalid(this.invalidReason)}mapEndpoints(e){return yo.fromDateTimes(e(this.s),e(this.e))}}class vo{static hasDST(e=hr.defaultZone){const t=as.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return Dn.isValidZone(e)}static normalizeZone(e){return Kn(e,hr.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||Gn.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||Gn.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||Gn.create(e)).getWeekendDays().slice()}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Gn.create(t,n,i)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Gn.create(t,n,i)).months(e,!0)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Gn.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Gn.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return Gn.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return Gn.create(t,null,"gregory").eras(e)}static features(){return{relative:Pr(),localeWeek:zr()}}}function wo(e,t){const n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(po.fromMillis(r).as("days"))}function bo(e,t=e=>e){return{regex:e,deser:([e])=>t(function(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(-1!==e[n].search(Xn.hanidec))t+=tr.indexOf(e[n]);else for(const e in er){const[n,i]=er[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}return t}(e))}}const xo=`[ ${String.fromCharCode(160)}]`,ko=new RegExp(xo,"g");function So(e){return e.replace(/\./g,"\\.?").replace(ko,xo)}function No(e){return e.replace(/\./g,"").replace(ko," ").toLowerCase()}function _o(e,t){return null===e?null:{regex:RegExp(e.map(So).join("|")),deser:([n])=>e.findIndex(e=>No(n)===No(e))+t}}function Co(e,t){return{regex:e,deser:([,e,t])=>Qr(e,t),groups:t}}function $o(e){return{regex:e,deser:([e])=>e}}const Io={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};let To=null;function Eo(e,t){return[].concat(...e.map(e=>function(e,t){if(e.literal)return e;const n=Do(gi.macroTokenToFormatOpts(e.val),t);return null==n||n.includes(void 0)?e:n}(e,t)))}class Po{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=Eo(gi.parseFormat(t),e),this.units=this.tokens.map(t=>function(e,t){const n=rr(t),r=rr(t,"{2}"),i=rr(t,"{3}"),o=rr(t,"{4}"),s=rr(t,"{6}"),a=rr(t,"{1,2}"),l=rr(t,"{1,3}"),c=rr(t,"{1,6}"),d=rr(t,"{1,9}"),u=rr(t,"{2,4}"),h=rr(t,"{4,6}"),m=e=>{return{regex:RegExp((t=e.val,t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&"))),deser:([e])=>e,literal:!0};var t},f=(f=>{if(e.literal)return m(f);switch(f.val){case"G":return _o(t.eras("short"),0);case"GG":return _o(t.eras("long"),0);case"y":return bo(c);case"yy":case"kk":return bo(u,Gr);case"yyyy":case"kkkk":return bo(o);case"yyyyy":return bo(h);case"yyyyyy":return bo(s);case"M":case"L":case"d":case"H":case"h":case"m":case"q":case"s":case"W":return bo(a);case"MM":case"LL":case"dd":case"HH":case"hh":case"mm":case"qq":case"ss":case"WW":return bo(r);case"MMM":return _o(t.months("short",!0),1);case"MMMM":return _o(t.months("long",!0),1);case"LLL":return _o(t.months("short",!1),1);case"LLLL":return _o(t.months("long",!1),1);case"o":case"S":return bo(l);case"ooo":case"SSS":return bo(i);case"u":return $o(d);case"uu":return $o(a);case"uuu":case"E":case"c":return bo(n);case"a":return _o(t.meridiems(),0);case"EEE":return _o(t.weekdays("short",!1),1);case"EEEE":return _o(t.weekdays("long",!1),1);case"ccc":return _o(t.weekdays("short",!0),1);case"cccc":return _o(t.weekdays("long",!0),1);case"Z":case"ZZ":return Co(new RegExp(`([+-]${a.source})(?::(${r.source}))?`),2);case"ZZZ":return Co(new RegExp(`([+-]${a.source})(${r.source})?`),2);case"z":return $o(/[a-z_+-/]{1,256}?/i);case" ":return $o(/[^\S\n\r]/);default:return m(f)}})(e)||{invalidReason:"missing Intl.DateTimeFormat.formatToParts support"};return f.token=e,f}(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){const[e,t]=function(e){const t=e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,"");return[`^${t}$`,e]}(this.units);this.regex=RegExp(e,"i"),this.handlers=t}}explainFromTokens(e){if(this.isValid){const[t,n]=function(e,t,n){const r=e.match(t);if(r){const e={};let t=1;for(const i in n)if(Rr(n,i)){const o=n[i],s=o.groups?o.groups+1:1;!o.literal&&o.token&&(e[o.token.val[0]]=o.deser(r.slice(t,t+s))),t+=s}return[r,e]}return[r,{}]}(e,this.regex,this.handlers),[r,i,o]=n?function(e){let t,n=null;Ir(e.z)||(n=Dn.create(e.z)),Ir(e.Z)||(n||(n=new Qn(e.Z)),t=e.Z),Ir(e.q)||(e.M=3*(e.q-1)+1),Ir(e.h)||(e.h<12&&1===e.a?e.h+=12:12===e.h&&0===e.a&&(e.h=0)),0===e.G&&e.y&&(e.y=-e.y),Ir(e.u)||(e.S=Lr(e.u));const r=Object.keys(e).reduce((t,n)=>{const r=(e=>{switch(e){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}})(n);return r&&(t[r]=e[n]),t},{});return[r,n,t]}(n):[null,null,void 0];if(Rr(n,"a")&&Rr(n,"H"))throw new Jt("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:o}}return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function zo(e,t,n){return new Po(e,n).explainFromTokens(t)}function Do(e,t){if(!e)return null;const n=gi.create(t,e).dtFormatter((To||(To=as.fromMillis(1555555555555)),To)),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>function(e,t,n){const{type:r,value:i}=e;if("literal"===r){const e=/^\s+$/.test(i);return{literal:!e,val:e?" ":i}}const o=t[r];let s=r;"hour"===r&&(s=null!=t.hour12?t.hour12?"hour12":"hour24":null!=t.hourCycle?"h11"===t.hourCycle||"h12"===t.hourCycle?"hour12":"hour24":n.hour12?"hour12":"hour24");let a=Io[s];if("object"==typeof a&&(a=a[o]),a)return{literal:!1,val:a}}(t,e,i))}const Ro="Invalid DateTime",Mo=864e13;function Oo(e){return new mr("unsupported zone",`the zone "${e.name}" is not supported`)}function jo(e){return null===e.weekData&&(e.weekData=xr(e.c)),e.weekData}function Wo(e){return null===e.localWeekData&&(e.localWeekData=xr(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Ao(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new as({...n,...t,old:n})}function Lo(e,t,n){let r=e-60*t*1e3;const i=n.offset(r);if(t===i)return[r,t];r-=60*(i-t)*1e3;const o=n.offset(r);return i===o?[r,i]:[e-60*Math.min(i,o)*1e3,Math.max(i,o)]}function Bo(e,t){const n=new Date(e+=60*t*1e3);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function qo(e,t,n){return Lo(Ur(e),t,n)}function Fo(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+3*Math.trunc(t.quarters),o={...e.c,year:r,month:i,day:Math.min(e.c.day,Hr(r,i))+Math.trunc(t.days)+7*Math.trunc(t.weeks)},s=po.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),a=Ur(o);let[l,c]=Lo(a,n,e.zone);return 0!==s&&(l+=s,c=e.zone.offset(l)),{ts:l,o:c}}function Ho(e,t,n,r,i,o){const{setZone:s,zone:a}=n;if(e&&0!==Object.keys(e).length||t){const r=t||a,i=as.fromObject(e,{...n,zone:r,specificOffset:o});return s?i:i.setZone(a)}return as.invalid(new mr("unparsable",`the input "${i}" can't be parsed as ${r}`))}function Uo(e,t,n=!0){return e.isValid?gi.create(Gn.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function Yo(e,t,n){const r=e.c.year>9999||e.c.year<0;let i="";if(r&&e.c.year>=0&&(i+="+"),i+=jr(e.c.year,r?6:4),"year"===n)return i;if(t){if(i+="-",i+=jr(e.c.month),"month"===n)return i;i+="-"}else if(i+=jr(e.c.month),"month"===n)return i;return i+=jr(e.c.day),i}function Zo(e,t,n,r,i,o,s){let a=!n||0!==e.c.millisecond||0!==e.c.second,l="";switch(s){case"day":case"month":case"year":break;default:if(l+=jr(e.c.hour),"hour"===s)break;if(t){if(l+=":",l+=jr(e.c.minute),"minute"===s)break;a&&(l+=":",l+=jr(e.c.second))}else{if(l+=jr(e.c.minute),"minute"===s)break;a&&(l+=jr(e.c.second))}if("second"===s)break;!a||r&&0===e.c.millisecond||(l+=".",l+=jr(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&0===e.offset&&!o?l+="Z":e.o<0?(l+="-",l+=jr(Math.trunc(-e.o/60)),l+=":",l+=jr(Math.trunc(-e.o%60))):(l+="+",l+=jr(Math.trunc(e.o/60)),l+=":",l+=jr(Math.trunc(e.o%60)))),o&&(l+="["+e.zone.ianaName+"]"),l}const Go={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Vo={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Qo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Jo=["year","month","day","hour","minute","second","millisecond"],Ko=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Xo=["year","ordinal","hour","minute","second","millisecond"];function es(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new Kt(e);return t}function ts(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return es(e)}}function ns(e,t){const n=Kn(t.zone,hr.defaultZone);if(!n.isValid)return as.invalid(Oo(n));const r=Gn.fromObject(t);let i,o;if(Ir(e.year))i=hr.now();else{for(const t of Jo)Ir(e[t])&&(e[t]=Go[t]);const t=Cr(e)||$r(e);if(t)return as.invalid(t);const r=function(e){if(void 0===os&&(os=hr.now()),"iana"!==e.type)return e.offset(os);const t=e.name;let n=ss.get(t);return void 0===n&&(n=e.offset(os),ss.set(t,n)),n}(n);[i,o]=qo(e,r,n)}return new as({ts:i,zone:n,loc:r,o:o})}function rs(e,t,n){const r=!!Ir(n.round)||n.round,i=Ir(n.rounding)?"trunc":n.rounding,o=(e,o)=>(e=Br(e,r||n.calendary?0:2,n.calendary?"round":i),t.loc.clone(n).relFormatter(n).format(e,o)),s=r=>n.calendary?t.hasSame(e,r)?0:t.startOf(r).diff(e.startOf(r),r).get(r):t.diff(e,r).get(r);if(n.unit)return o(s(n.unit),n.unit);for(const e of n.units){const t=s(e);if(Math.abs(t)>=1)return o(t,e)}return o(e>t?-0:0,n.units[n.units.length-1])}function is(e){let t,n={};return e.length>0&&"object"==typeof e[e.length-1]?(n=e[e.length-1],t=Array.from(e).slice(0,e.length-1)):t=Array.from(e),[n,t]}let os;const ss=new Map;class as{constructor(e){const t=e.zone||hr.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new mr("invalid input"):null)||(t.isValid?null:Oo(t));this.ts=Ir(e.ts)?hr.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[r,i]=[e.old.c,e.old.o];else{const o=Tr(e.o)&&!e.old?e.o:t.offset(this.ts);r=Bo(this.ts,o),n=Number.isNaN(r.year)?new mr("invalid input"):null,r=n?null:r,i=n?null:o}this.ie=t,this.loc=e.loc||Gn.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new as({})}static local(){const[e,t]=is(arguments),[n,r,i,o,s,a,l]=t;return ns({year:n,month:r,day:i,hour:o,minute:s,second:a,millisecond:l},e)}static utc(){const[e,t]=is(arguments),[n,r,i,o,s,a,l]=t;return e.zone=Qn.utcInstance,ns({year:n,month:r,day:i,hour:o,minute:s,second:a,millisecond:l},e)}static fromJSDate(e,t={}){const n=function(e){return"[object Date]"==={}.toString.call(e)}(e)?e.valueOf():NaN;if(Number.isNaN(n))return as.invalid("invalid input");const r=Kn(t.zone,hr.defaultZone);return r.isValid?new as({ts:n,zone:r,loc:Gn.fromObject(t)}):as.invalid(Oo(r))}static fromMillis(e,t={}){if(Tr(e))return e<-Mo||e>Mo?as.invalid("Timestamp out of range"):new as({ts:e,zone:Kn(t.zone,hr.defaultZone),loc:Gn.fromObject(t)});throw new Xt(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,t={}){if(Tr(e))return new as({ts:1e3*e,zone:Kn(t.zone,hr.defaultZone),loc:Gn.fromObject(t)});throw new Xt("fromSeconds requires a numerical input")}static fromObject(e,t={}){e=e||{};const n=Kn(t.zone,hr.defaultZone);if(!n.isValid)return as.invalid(Oo(n));const r=Gn.fromObject(t),i=Kr(e,ts),{minDaysInFirstWeek:o,startOfWeek:s}=_r(i,r),a=hr.now(),l=Ir(t.specificOffset)?n.offset(a):t.specificOffset,c=!Ir(i.ordinal),d=!Ir(i.year),u=!Ir(i.month)||!Ir(i.day),h=d||u,m=i.weekYear||i.weekNumber;if((h||c)&&m)throw new Jt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(u&&c)throw new Jt("Can't mix ordinal dates with month/day");const f=m||i.weekday&&!h;let p,g,y=Bo(a,l);f?(p=Ko,g=Vo,y=xr(y,o,s)):c?(p=Xo,g=Qo,y=Sr(y)):(p=Jo,g=Go);let v=!1;for(const e of p)Ir(i[e])?i[e]=v?g[e]:y[e]:v=!0;const w=f?function(e,t=4,n=1){const r=Er(e.weekYear),i=Or(e.weekNumber,1,Zr(e.weekYear,t,n)),o=Or(e.weekday,1,7);return r?i?!o&&gr("weekday",e.weekday):gr("week",e.weekNumber):gr("weekYear",e.weekYear)}(i,o,s):c?function(e){const t=Er(e.year),n=Or(e.ordinal,1,Fr(e.year));return t?!n&&gr("ordinal",e.ordinal):gr("year",e.year)}(i):Cr(i),b=w||$r(i);if(b)return as.invalid(b);const x=f?kr(i,o,s):c?Nr(i):i,[k,S]=qo(x,l,n),N=new as({ts:k,zone:n,o:S,loc:r});return i.weekday&&h&&e.weekday!==N.weekday?as.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${N.toISO()}`):N.isValid?N:as.invalid(N.invalid)}static fromISO(e,t={}){const[n,r]=function(e){return bi(e,[Yi,Qi],[Zi,Ji],[Gi,Ki],[Vi,Xi])}(e);return Ho(n,r,t,"ISO 8601",e)}static fromRFC2822(e,t={}){const[n,r]=function(e){return bi(function(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}(e),[Ai,Li])}(e);return Ho(n,r,t,"RFC 2822",e)}static fromHTTP(e,t={}){const[n,r]=function(e){return bi(e,[Bi,Hi],[qi,Hi],[Fi,Ui])}(e);return Ho(n,r,t,"HTTP",t)}static fromFormat(e,t,n={}){if(Ir(e)||Ir(t))throw new Xt("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:i=null}=n,o=Gn.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),[s,a,l,c]=function(e,t,n){const{result:r,zone:i,specificOffset:o,invalidReason:s}=zo(e,t,n);return[r,i,o,s]}(o,e,t);return c?as.invalid(c):Ho(s,a,n,`format ${t}`,e,l)}static fromString(e,t,n={}){return as.fromFormat(e,t,n)}static fromSQL(e,t={}){const[n,r]=function(e){return bi(e,[to,Qi],[no,ro])}(e);return Ho(n,r,t,"SQL",e)}static invalid(e,t=null){if(!e)throw new Xt("need to specify a reason the DateTime is invalid");const n=e instanceof mr?e:new mr(e,t);if(hr.throwOnInvalid)throw new Gt(n);return new as({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){const n=Do(e,Gn.fromObject(t));return n?n.map(e=>e?e.val:null).join(""):null}static expandFormat(e,t={}){return Eo(gi.parseFormat(e),Gn.fromObject(t)).map(e=>e.val).join("")}static resetCache(){os=void 0,ss.clear()}get(e){return this[e]}get isValid(){return null===this.invalid}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this.ie}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?jo(this).weekYear:NaN}get weekNumber(){return this.isValid?jo(this).weekNumber:NaN}get weekday(){return this.isValid?jo(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Wo(this).weekday:NaN}get localWeekNumber(){return this.isValid?Wo(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Wo(this).weekYear:NaN}get ordinal(){return this.isValid?Sr(this.c).ordinal:NaN}get monthShort(){return this.isValid?vo.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?vo.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?vo.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?vo.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return!this.isOffsetFixed&&(this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset)}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,t=6e4,n=Ur(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),o=this.zone.offset(n-r*t),s=this.zone.offset(n-i*t);if(o===s)return[this];const a=n-o*t,l=n-s*t,c=Bo(a,o),d=Bo(l,s);return c.hour===d.hour&&c.minute===d.minute&&c.second===d.second&&c.millisecond===d.millisecond?[Ao(this,{ts:a}),Ao(this,{ts:l})]:[this]}get isInLeapYear(){return qr(this.year)}get daysInMonth(){return Hr(this.year,this.month)}get daysInYear(){return this.isValid?Fr(this.year):NaN}get weeksInWeekYear(){return this.isValid?Zr(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Zr(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:t,numberingSystem:n,calendar:r}=gi.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(Qn.instance(e),t)}toLocal(){return this.setZone(hr.defaultZone)}setZone(e,{keepLocalTime:t=!1,keepCalendarTime:n=!1}={}){if((e=Kn(e,hr.defaultZone)).equals(this.zone))return this;if(e.isValid){let r=this.ts;if(t||n){const t=e.offset(this.ts),n=this.toObject();[r]=qo(n,t,e)}return Ao(this,{ts:r,zone:e})}return as.invalid(Oo(e))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){return Ao(this,{loc:this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n})})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const t=Kr(e,ts),{minDaysInFirstWeek:n,startOfWeek:r}=_r(t,this.loc),i=!Ir(t.weekYear)||!Ir(t.weekNumber)||!Ir(t.weekday),o=!Ir(t.ordinal),s=!Ir(t.year),a=!Ir(t.month)||!Ir(t.day),l=s||a,c=t.weekYear||t.weekNumber;if((l||o)&&c)throw new Jt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(a&&o)throw new Jt("Can't mix ordinal dates with month/day");let d;i?d=kr({...xr(this.c,n,r),...t},n,r):Ir(t.ordinal)?(d={...this.toObject(),...t},Ir(t.day)&&(d.day=Math.min(Hr(d.year,d.month),d.day))):d=Nr({...Sr(this.c),...t});const[u,h]=qo(d,this.o,this.zone);return Ao(this,{ts:u,o:h})}plus(e){return this.isValid?Ao(this,Fo(this,po.fromDurationLike(e))):this}minus(e){return this.isValid?Ao(this,Fo(this,po.fromDurationLike(e).negate())):this}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;const n={},r=po.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0}if("weeks"===r)if(t){const e=this.loc.getStartOfWeek(),{weekday:t}=this;t<e&&(n.weekNumber=this.weekNumber-1),n.weekday=e}else n.weekday=1;if("quarters"===r){const e=Math.ceil(this.month/3);n.month=3*(e-1)+1}return this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?gi.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Ro}toLocaleString(e=on,t={}){return this.isValid?gi.create(this.loc.clone(t),e).formatDateTime(this):Ro}toLocaleParts(e={}){return this.isValid?gi.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;const s="extended"===e;let a=Yo(this,s,o=es(o));return Jo.indexOf(o)>=3&&(a+="T"),a+=Zo(this,s,t,n,r,i,o),a}toISODate({format:e="extended",precision:t="day"}={}){return this.isValid?Yo(this,"extended"===e,es(t)):null}toISOWeekDate(){return Uo(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:o="extended",precision:s="milliseconds"}={}){return this.isValid?(s=es(s),(r&&Jo.indexOf(s)>=3?"T":"")+Zo(this,"extended"===o,t,e,n,i,s)):null}toRFC2822(){return Uo(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Uo(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Yo(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(t||e)&&(n&&(r+=" "),t?r+="z":e&&(r+="ZZ")),Uo(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ro}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t="milliseconds",n={}){if(!this.isValid||!e.isValid)return po.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=(a=t,Array.isArray(a)?a:[a]).map(po.normalizeUnit),o=e.valueOf()>this.valueOf(),s=function(e,t,n,r){let[i,o,s,a]=function(e,t,n){const r=[["years",(e,t)=>t.year-e.year],["quarters",(e,t)=>t.quarter-e.quarter+4*(t.year-e.year)],["months",(e,t)=>t.month-e.month+12*(t.year-e.year)],["weeks",(e,t)=>{const n=wo(e,t);return(n-n%7)/7}],["days",wo]],i={},o=e;let s,a;for(const[l,c]of r)n.indexOf(l)>=0&&(s=l,i[l]=c(e,t),a=o.plus(i),a>t?(i[l]--,(e=o.plus(i))>t&&(a=e,i[l]--,e=o.plus(i))):e=a);return[e,i,a,s]}(e,t,n);const l=t-i,c=n.filter(e=>["hours","minutes","seconds","milliseconds"].indexOf(e)>=0);0===c.length&&(s<t&&(s=i.plus({[a]:1})),s!==i&&(o[a]=(o[a]||0)+l/(s-i)));const d=po.fromObject(o,r);return c.length>0?po.fromMillis(l,r).shiftTo(...c).plus(d):d}(o?this:e,o?e:this,i,r);var a;return o?s.negate():s}diffNow(e="milliseconds",t={}){return this.diff(as.now(),e,t)}until(e){return this.isValid?yo.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return!1;const r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const t=e.base||as.fromObject({},{zone:this.zone}),n=e.padding?this<t?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],i=e.unit;return Array.isArray(e.unit)&&(r=e.unit,i=void 0),rs(t,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){return this.isValid?rs(e.base||as.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(as.isDateTime))throw new Xt("min requires all arguments be DateTimes");return Dr(e,e=>e.valueOf(),Math.min)}static max(...e){if(!e.every(as.isDateTime))throw new Xt("max requires all arguments be DateTimes");return Dr(e,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){const{locale:r=null,numberingSystem:i=null}=n;return zo(Gn.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),e,t)}static fromStringExplain(e,t,n={}){return as.fromFormatExplain(e,t,n)}static buildFormatParser(e,t={}){const{locale:n=null,numberingSystem:r=null}=t,i=Gn.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Po(i,e)}static fromFormatParser(e,t,n={}){if(Ir(e)||Ir(t))throw new Xt("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:i=null}=n,o=Gn.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});if(!o.equals(t.locale))throw new Xt(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${t.locale}`);const{result:s,zone:a,specificOffset:l,invalidReason:c}=t.explainFromTokens(e);return c?as.invalid(c):Ho(s,a,n,`format ${t.format}`,e,l)}static get DATE_SHORT(){return on}static get DATE_MED(){return sn}static get DATE_MED_WITH_WEEKDAY(){return an}static get DATE_FULL(){return ln}static get DATE_HUGE(){return cn}static get TIME_SIMPLE(){return dn}static get TIME_WITH_SECONDS(){return un}static get TIME_WITH_SHORT_OFFSET(){return hn}static get TIME_WITH_LONG_OFFSET(){return mn}static get TIME_24_SIMPLE(){return fn}static get TIME_24_WITH_SECONDS(){return pn}static get TIME_24_WITH_SHORT_OFFSET(){return gn}static get TIME_24_WITH_LONG_OFFSET(){return yn}static get DATETIME_SHORT(){return vn}static get DATETIME_SHORT_WITH_SECONDS(){return wn}static get DATETIME_MED(){return bn}static get DATETIME_MED_WITH_SECONDS(){return xn}static get DATETIME_MED_WITH_WEEKDAY(){return kn}static get DATETIME_FULL(){return Sn}static get DATETIME_FULL_WITH_SECONDS(){return Nn}static get DATETIME_HUGE(){return _n}static get DATETIME_HUGE_WITH_SECONDS(){return Cn}}function ls(e){if(as.isDateTime(e))return e;if(e&&e.valueOf&&Tr(e.valueOf()))return as.fromJSDate(e);if(e&&"object"==typeof e)return as.fromObject(e);throw new Xt(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function cs({title:e,description:t,children:n,noSubscription:r,hideHeader:i}){return Qe("div",{className:Rt.create("page-container",{minHeight:"100vh",display:"flex",flexDirection:"column",backgroundColor:$t.colors.accent}),children:Qe("div",{className:Rt.create("page-content-container",{maxWidth:"1200px",margin:"0 auto",width:"100%",flex:"1",boxSizing:"border-box",overflowX:"hidden"}),children:[!i&&Qe("div",{className:Rt.create("page-heading-wrapper",{width:"100%",marginBottom:$t.spacing.lg}),children:Qe(qt,{children:Qe("div",{className:Rt.create("page-heading-container",{backgroundColor:$t.colors.primary,color:$t.colors.primaryForeground,borderRadius:$t.radius.large,padding:`${$t.spacing.lg} ${$t.spacing.xl}`,boxShadow:$t.shadow.md}),children:Qe("div",{className:Rt.create("page-heading-content",{display:"flex",alignItems:"center",justifyContent:"space-between",gap:$t.spacing.lg}),children:Qe("div",{className:Rt.create("page-heading-text",{flex:"1",minWidth:"0"}),children:[Qe("h1",{className:Rt.create("page-template-title",{margin:"0",fontSize:"1.5rem",fontWeight:"700",lineHeight:"1.3",color:$t.colors.primaryForeground,letterSpacing:"-0.025em"}),children:e}),t&&Qe("p",{className:Rt.create("page-template-description",{margin:"0",marginTop:$t.spacing.sm,fontSize:$t.fontSize.small,lineHeight:"1.5",color:$t.colors.primaryForeground,opacity:"0.85"}),children:t})]})})})})}),n]})})}function ds({title:e="Loading",message:t}){const n=Rt.create("loading-container",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:$t.spacing.md,minHeight:"500px"}),r=Rt.create("loading-title",{margin:"0",fontSize:"1.125rem",fontWeight:"600",color:$t.colors.foreground,letterSpacing:"-0.01em"}),i=Rt.create("loading-message",{margin:"0",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),o=Rt.create("loading-text-group",{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.25rem",textAlign:"center"});return Qe(cs,{title:"Loading",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe("div",{className:n,children:[Qe(Bt,{size:"large"}),Qe("div",{className:o,children:[Qe("p",{className:r,children:e}),t&&Qe("p",{className:i,children:t})]})]})})})}function us({variant:e="primary",type:t="button",onClick:n,disabled:r,loading:i=!1,children:o,className:s,...a}){const l={primary:{backgroundColor:$t.colors.primary,color:$t.colors.primaryForeground,boxShadow:$t.shadow.sm},outline:{border:`${$t.borderWidth} solid ${$t.colors.primary}`,backgroundColor:$t.colors.card,color:$t.colors.primary,boxShadow:$t.shadow.sm}},c=Rt.create("button",{height:"2.75rem",paddingLeft:"1.5rem",paddingRight:"1.5rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",border:"none",borderRadius:$t.radius.default,cursor:"pointer",fontSize:$t.fontSize.default,fontWeight:"500",transition:$t.transition,fontFamily:$t.fontFamily,display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem"},{"(max-width: 600px)":{fontSize:"14px",paddingLeft:"1.25rem",paddingRight:"1.25rem"}}),d=Rt.pseudoElement("button",":disabled",{opacity:"50%",cursor:"not-allowed"});Rt.pseudoElement(`button-${e}`,":hover:not(:disabled)",{transform:"translateY(-1px)",boxShadow:$t.shadow.md}),Rt.pseudoElement(`button-${e}`,":active:not(:disabled)",{transform:"translateY(0)",boxShadow:$t.shadow.sm});const u=Rt.create(`button-${e}`,{...l[e]});return Qe("button",{type:t,className:Lt(c,d,u,s),onClick:r||i?void 0:n,disabled:r||i,...a,children:[i&&Qe(Bt,{size:"small"}),o]})}function hs({className:e,children:t}){const n=Rt.create("center",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:"500px"});return Qe("div",{className:Lt(n,e),children:t})}function ms({source:e,className:t,inline:n=!1}){return e?n?Qe("span",{className:t,children:ps(e)}):Qe("div",{className:t,children:fs(e)}):null}function fs(e){const t=e.replace(/\r\n/g,"\n").split("\n"),n=[];let r=[],i=[];const o=()=>{if(0===r.length)return;const e=r.join(" ");n.push(Qe("p",{children:ps(e)},n.length)),r=[]},s=()=>{if(0===i.length)return;const e=i;n.push(Qe("ul",{children:e.map((e,t)=>Qe("li",{children:ps(e)},t))},n.length)),i=[]};for(const e of t){const t=e.trimEnd();if(""===t){o(),s();continue}const n=t.match(/^\s*[-*]\s+(.*)$/);n&&void 0!==n[1]?(o(),i.push(n[1])):(s(),r.push(t))}return o(),s(),n}function ps(e){var t,n;const r=/\[([^\]]+)\]\((https?:\/\/[^\s)]+|mailto:[^\s)]+)\)/g,i=[];let o,s=0,a=0;for(;null!==(o=r.exec(e));){o.index>s&&i.push(Qe(_,{children:gs(e.slice(s,o.index))},a++));const r=null!==(t=o[1])&&void 0!==t?t:"",l=null!==(n=o[2])&&void 0!==n?n:"";i.push(Qe("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:gs(r)},a++)),s=o.index+o[0].length}return s<e.length&&i.push(Qe(_,{children:gs(e.slice(s))},a++)),i}function gs(e){const t=e=>ys(e,"*",e=>Qe("em",{children:e}));return ys(e,"**",e=>Qe("strong",{children:t(e)}),t)}function ys(e,t,n,r=e=>e){const i=[];let o=0,s=0;for(;o<e.length;){const a=e.indexOf(t,o);if(-1===a){i.push(Qe(_,{children:r(e.slice(o))},s++));break}const l=e.indexOf(t,a+t.length);if(-1===l){i.push(Qe(_,{children:r(e.slice(o))},s++));break}a>o&&i.push(Qe(_,{children:r(e.slice(o,a))},s++)),i.push(Qe(_,{children:n(e.slice(a+t.length,l))},s++)),o=l+t.length}return i}function vs(e,t,n){var r,i,o,s;const a=null==e?void 0:e.status_pages;if(!a)return{};const l=n?null===(r=a.per_gateway)||void 0===r?void 0:r[n]:void 0,c=null==l?void 0:l[t],d=null===(i=a.default)||void 0===i?void 0:i[t],u=null!==(o=ws(null==c?void 0:c.title))&&void 0!==o?o:ws(null==d?void 0:d.title),h=null!==(s=ws(null==c?void 0:c.body))&&void 0!==s?s:ws(null==d?void 0:d.body);let m;if("referral"===t){const e=null==c?void 0:c.steps,t=null==d?void 0:d.steps,n=e&&e.length>0?e:t;n&&n.length>0&&(m=n)}return{title:u,body:h,steps:m}}function ws(e){return"string"==typeof e&&e.length>0?e:void 0}function bs({error:e}){var t,n,r,i,o;const s=null!=e?e:{title:"Something went wrong",message:"We weren't able to load this page. Please try again in a moment.",retryable:!0},a=null!==(t=s.organisation)&&void 0!==t?t:null,l=null!==(n=null==a?void 0:a.name)&&void 0!==n?n:null,c=null!==(r=null==a?void 0:a.admin_email)&&void 0!==r?r:null,d=null!==(i=null==a?void 0:a.phone)&&void 0!==i?i:null,u=Boolean(c||d),h=vs(null==a?void 0:a.client_settings,"maintenance"),m=null!==(o=h.title)&&void 0!==o?o:s.title,f=h.body,p=Rt.create("error-fallback-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:$t.spacing.lg},"(max-width: 480px)":{padding:$t.spacing.md}}),g=Rt.create("error-fallback-icon-container",{display:"flex",justifyContent:"center",marginBottom:$t.spacing.lg}),y=Rt.create("error-fallback-icon",{width:"4rem",height:"4rem",color:$t.colors.primary}),v=Rt.create("error-fallback-header",{textAlign:"center",marginBottom:$t.spacing.xl}),w=Rt.create("error-fallback-title",{fontSize:"2rem",fontWeight:"700",color:$t.colors.primary,marginBottom:$t.spacing.sm,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),b=Rt.create("error-fallback-subtitle",{fontSize:$t.fontSize.default,color:$t.colors.foreground,lineHeight:"1.6",opacity:"0.8"}),x=Rt.create("error-fallback-refresh-actions",{display:"flex",justifyContent:"center",marginBottom:u?"0":$t.spacing.sm}),k=Rt.create("error-fallback-contact-section",{borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.xl,marginTop:$t.spacing.xl,textAlign:"center"}),S=Rt.create("error-fallback-contact-text",{fontSize:$t.fontSize.default,color:$t.colors.foreground,marginBottom:$t.spacing.lg}),N=Rt.create("error-fallback-contact-actions",{display:"flex",gap:$t.spacing.md,flexWrap:"wrap",justifyContent:"center"});return Qe(cs,{title:m,noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe(hs,{children:Qe("div",{className:p,children:[Qe("div",{className:g,children:Qe(()=>Qe("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",className:y,children:[Qe("circle",{cx:"12",cy:"12",r:"10"}),Qe("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),Qe("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),{})}),Qe("div",{className:v,children:[Qe("h1",{className:w,children:m}),f?Qe(ms,{source:f,className:b}):Qe("p",{className:b,children:s.message})]}),s.retryable&&Qe("div",{className:x,children:Qe(us,{onClick:()=>{window.location.reload()},children:"Try Again"})}),u&&Qe("div",{className:k,children:[Qe("p",{className:S,children:l?`Need assistance? Contact ${l}`:"Need assistance? Contact us"}),Qe("div",{className:N,children:[d&&Qe(us,{variant:"outline",onClick:()=>window.open(`tel:${d}`),children:[Qe(()=>Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Qe("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),{}),"Call Us"]}),c&&Qe(us,{variant:"outline",onClick:()=>window.open(`mailto:${c}`),children:[Qe(()=>Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Qe("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Qe("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),{}),"Email Us"]})]})]})]})})})})}function xs({message:e,estimatedTime:t,organisation:n}){var r;const i=(null==n?void 0:n.name)||null,o=(null==n?void 0:n.admin_email)||null,s=(null==n?void 0:n.phone)||null,a=Boolean(o||s),l=Rt.create("maintenance-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:$t.spacing.lg},"(max-width: 480px)":{padding:$t.spacing.md}}),c=Rt.create("maintenance-icon-container",{display:"flex",justifyContent:"center",marginBottom:$t.spacing.lg}),d=Rt.create("maintenance-icon",{width:"4rem",height:"4rem",color:$t.colors.primary}),u=Rt.create("maintenance-header",{textAlign:"center",marginBottom:$t.spacing.xl}),h=Rt.create("maintenance-title",{fontSize:"2rem",fontWeight:"700",color:$t.colors.primary,marginBottom:$t.spacing.sm,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),m=Rt.create("maintenance-subtitle",{fontSize:$t.fontSize.default,color:$t.colors.foreground,lineHeight:"1.6",opacity:"0.8"}),f=Rt.create("maintenance-estimated-time",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginTop:$t.spacing.sm}),p=Rt.create("maintenance-refresh-actions",{display:"flex",justifyContent:"center",marginBottom:a?"0":$t.spacing.sm}),g=Rt.create("maintenance-contact-section",{borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.xl,marginTop:$t.spacing.xl,textAlign:"center"}),y=Rt.create("maintenance-contact-text",{fontSize:$t.fontSize.default,color:$t.colors.foreground,marginBottom:$t.spacing.lg}),v=Rt.create("maintenance-contact-actions",{display:"flex",gap:$t.spacing.md,flexWrap:"wrap",justifyContent:"center"}),w=vs(null==n?void 0:n.client_settings,"maintenance"),b=null!==(r=w.title)&&void 0!==r?r:"We'll be right back",x=w.body;return Qe(cs,{title:b,description:"Quotes are temporarily unavailable",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe(hs,{children:Qe("div",{className:l,children:[Qe("div",{className:c,children:Qe(()=>Qe("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",className:d,children:Qe("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),{})}),Qe("div",{className:u,children:[Qe("h1",{className:h,children:b}),x?Qe(ms,{source:x,className:m}):Qe("p",{className:m,children:e||"We're temporarily unable to issue new quotes. Please try again shortly."}),t&&Qe("p",{className:f,children:[Qe("strong",{children:"Estimated time:"})," ",t]})]}),Qe("div",{className:p,children:Qe(us,{onClick:()=>{window.location.reload()},children:"Refresh Page"})}),a&&Qe("div",{className:g,children:[Qe("p",{className:y,children:i?`Need assistance? Contact ${i}`:"Need assistance? Contact us"}),Qe("div",{className:v,children:[s&&Qe(us,{variant:"outline",onClick:()=>window.open(`tel:${s}`),children:[Qe(()=>Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Qe("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),{}),"Call Us"]}),o&&Qe(us,{variant:"outline",onClick:()=>window.open(`mailto:${o}`),children:[Qe(()=>Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Qe("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Qe("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),{}),"Email Us"]})]})]})]})})})})}function ks({size:e="default",style:t="normal",className:n,children:r}){const i=Rt.create("text",{marginTop:"0",marginBottom:"0"}),o=Rt.create("text-small",{fontSize:$t.fontSize.small}),s=Rt.create("text-default",{fontSize:$t.fontSize.default}),a=Rt.create("text-italic",{fontStyle:"italic"}),l=Rt.create("text-bold",{fontWeight:"bold"}),c=Rt.create("text-underline",{textDecoration:"underline"}),d=Lt({[a]:"italic"===t,[l]:"bold"===t,[c]:"underline"===t}),u=Lt({[o]:"small"===e,[s]:"default"===e});return Qe("p",{className:Lt(i,u,d,n),children:r})}function Ss({title:e,description:t}){return Qe("div",{className:Rt.create("section-header",{}),children:[Qe("h3",{className:Rt.create("section-title",{fontSize:$t.fontSize.large,fontWeight:"600",margin:"0",color:$t.colors.foreground}),children:e}),t&&Qe(ks,{className:Rt.create("section-description",{color:$t.colors.mutedForeground,margin:"0.25rem 0 0 0"}),children:"Choose your excess amount - the amount you'll pay if you need to make a claim"})]})}function Ns({selected:e}){return Qe("div",{className:Lt(Rt.create("selected-indicator",{height:"14px",width:"14px",borderRadius:"100%",border:`${$t.borderWidth} solid transparent`}),e?Rt.create("selected-indicator-selected",{backgroundColor:$t.colors.primary}):Rt.create("selected-indicator-unselected",{border:`${$t.borderWidth} solid ${$t.colors.border}`}))})}function _s({excessOptions:e,selectedExcessId:t,onExcessSelect:n}){const r=[...e].sort((e,t)=>e.excess_amount-t.excess_amount),i=e.find(e=>e.id===t);return Qe("div",{className:Rt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Qe(Ss,{title:1===e.length?"Excess":"Excess Options"}),Qe("div",{className:Rt.create("excess-options-grid",{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"1rem"}),children:r.map(e=>{const r=e.id===t;return Qe("div",{className:Lt(Rt.create("excess-option-card",{borderRadius:$t.radius.default,minWidth:"125px",padding:"0.5rem 1rem 0.5rem 0.5rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"center",gap:"1rem"}),r?Rt.create("excess-option-card-selected",{border:`2px solid ${$t.colors.primary}`,backgroundColor:$t.colors.accent}):Rt.create("excess-option-card-unselected",{border:`2px solid ${$t.colors.border}`,backgroundColor:$t.colors.card})),onClick:()=>n(e.id),children:[Qe(Ns,{selected:r}),Qe("div",{className:Rt.create("excess-amount",{color:$t.colors.foreground}),children:[e.excess_label||`$${Number(e.excess_amount).toFixed(0)}`,e.description?"*":""]})]},e.id)})}),(null==i?void 0:i.description)&&Qe("div",{className:Rt.create("excess-description",{padding:"0.75rem",backgroundColor:$t.colors.muted,borderRadius:$t.radius.default,border:`1px solid ${$t.colors.border}`}),children:Qe(ks,{className:Rt.create("excess-description-text",{fontSize:$t.fontSize.small,color:$t.colors.foreground,margin:"0"}),children:i.description})})]})}function Cs(e,t="NZD",n="en-NZ"){return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(e)}function $s(e,t){return"bank_transfer"===t?"Bank Transfer":"one-time"===e?"Online Payment":"monthly"===e?"Monthly Installments":`${e.charAt(0).toUpperCase()}${e.slice(1)} Installments`}function Is({paymentOptions:e,paymentGateways:t,selectedExcessId:n,selectedPaymentOption:r,onPaymentSelect:i}){const o=ft(()=>{if(!n)return[];const r=e.filter(e=>e.excess_id===n).map(e=>{const n=t.find(t=>t.id===e.gateway_id);if(!n)throw new Error(`Gateway not found for option: ${e.gateway_id}`);return{...e,gateway:n}});return r.sort((e,t)=>e.amount.success!==t.amount.success?e.amount.success?-1:1:0)},[e,t,n]);return n?Qe(Ts,{sortedOptions:o,selectedPaymentOption:r,onPaymentSelect:i}):Qe("div",{className:Rt.create("payment-section-disabled",{opacity:"0.5",pointerEvents:"none"}),children:Qe(Ts,{sortedOptions:[],selectedPaymentOption:null,onPaymentSelect:i})})}function Ts({sortedOptions:e,selectedPaymentOption:t,onPaymentSelect:n}){const r=e.length>0;return Qe("div",{className:Rt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"}),children:[Qe(Ss,{title:"Payment Options"}),Qe("div",r?{className:Rt.create("payment-options-container",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:e.map(e=>{var r;return Qe(Es,{option:e,selectedPaymentOption:t,onPaymentSelect:n},`${e.gateway_id}-${null!==(r=e.gateway_method)&&void 0!==r?r:"default"}-${e.excess_id}`)})}:{className:Rt.create("no-options-placeholder",{padding:"2rem",textAlign:"center",border:`1px dashed ${$t.colors.border}`,borderRadius:$t.radius.default,backgroundColor:$t.colors.muted}),children:Qe(ks,{className:Rt.create("placeholder-text",{color:$t.colors.mutedForeground,margin:"0"}),children:"Payment options will appear here after selecting an excess amount"})})]})}function Es({option:e,selectedPaymentOption:t,onPaymentSelect:n}){var r,i,o,s,a,l;const c=(null!==(r=null==t?void 0:t.gateway_method)&&void 0!==r?r:null)===(null!==(i=e.gateway_method)&&void 0!==i?i:null)&&(null==t?void 0:t.gateway_id)===e.gateway_id&&(null==t?void 0:t.excess_id)===e.excess_id,d=e.amount.success,u=null!==(s=null!==(o=e.display_title)&&void 0!==o?o:e.gateway.display_title)&&void 0!==s?s:null,h=null!==(l=null!==(a=e.description)&&void 0!==a?a:e.gateway.description)&&void 0!==l?l:null,m=()=>d?"one-time"===e.amount.frequency?Cs(e.amount.dueToday):`${Cs(e.amount.installmentAmount||0)} x ${e.amount.numberOfInstallments}`:"Currently Unavailable",f=()=>h||("bank_transfer"===e.gateway.code?"Manual":`via ${e.gateway.name}`);return Qe("div",{className:Lt(Rt.create("payment-option-row",{borderRadius:$t.radius.default,padding:"0.75rem 1rem",cursor:d?"pointer":"not-allowed",transition:"all 150ms ease",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",opacity:d?"1":"0.6"},{"(max-width: 950px)":{padding:"0.75rem",flexDirection:"column",alignItems:"stretch",gap:"0.25rem"}}),c?Rt.create("payment-option-row-selected",{border:`2px solid ${$t.colors.primary}`,backgroundColor:$t.colors.accent}):Rt.create("payment-option-row-unselected",{border:`2px solid ${$t.colors.border}`,backgroundColor:$t.colors.card})),onClick:()=>d&&n(e),children:[Qe("div",{className:Rt.create("payment-option-desktop-wrapper",{display:"flex",flexDirection:"column",flex:"1"},{"(max-width: 950px)":{display:"none"}}),children:[Qe("div",{className:Rt.create("frequency-title",{fontSize:$t.fontSize.default,fontWeight:"500",color:$t.colors.foreground}),children:u||$s(e.amount.frequency,e.gateway.code)}),Qe("div",{className:Rt.create("gateway-description",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:f()})]}),Qe("div",{className:Rt.create("payment-option-amount-desktop",{display:"flex",flexDirection:"column",alignItems:"flex-end"},{"(max-width: 950px)":{display:"none"}}),children:[Qe(ks,{className:d?Rt.create("amount-text",{textAlign:"right",color:$t.colors.foreground,fontStyle:"normal"}):Rt.create("amount-text-unavailable",{textAlign:"right",color:$t.colors.mutedForeground,fontStyle:"italic"}),children:m()}),d&&Qe(ks,{size:"small",className:Rt.create("gateway-fee-text",{textAlign:"right",color:$t.colors.mutedForeground}),children:"bank_transfer"!==e.gateway.code&&e.amount.gatewayFee>0?`${Cs(e.amount.gatewayFee)} fee`:"No fees"})]}),Qe("div",{className:Rt.create("payment-option-mobile-wrapper",{display:"none"},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:"0.125rem"}}),children:[Qe("div",{className:Rt.create("payment-option-title-mobile",{fontSize:$t.fontSize.default,fontWeight:"500",color:$t.colors.foreground}),children:u||$s(e.amount.frequency,e.gateway.code)}),Qe(ks,{className:d?Rt.create("amount-text-mobile",{fontWeight:"500",color:$t.colors.foreground,fontStyle:"normal"}):Rt.create("amount-text-mobile-unavailable",{fontWeight:"500",color:$t.colors.mutedForeground,fontStyle:"italic"}),children:[m(),d&&e.amount.gatewayFee>0&&Qe("span",{className:Rt.create("gateway-fee-inline",{fontWeight:"400",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginLeft:"0.375rem"}),children:["(",Cs(e.amount.gatewayFee)," fee)"]})]}),Qe("div",{className:Rt.create("gateway-description-mobile",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:f()})]})]})}const Ps={client_full_name:e=>{const t=[e.firstName,e.lastName].filter(Boolean).join(" ").trim();return t?{label:"Name",value:t}:null},client_email:e=>e.email?{label:"Email",value:e.email}:null,client_phone:e=>e.phone?{label:"Phone",value:e.phone}:null,client_dob:e=>e.dob?{label:"Date of Birth",value:Ds(e.dob)}:null,client_address:e=>e.address?{label:"Address",value:e.address}:null},zs=["client_full_name","client_email","client_phone","client_dob"],Ds=e=>{try{return new Date(e).toLocaleDateString("en-NZ",{year:"numeric",month:"long",day:"numeric"})}catch(t){return e}};function Rs({excessOptions:e,selectedExcessId:t,onEditQuote:n,isEditingQuote:r=!1,productName:i,quoteIntent:o,embedded:s=!1}){var a,l,c,d,u,h;const m=ft(()=>t?e.find(e=>e.id===t):null,[e,t]),{formProgress:f,checkoutConfig:p}=Yt(e=>{var t,n,r,i;return{formProgress:e.getFormProgress(),checkoutConfig:null!==(i=null===(r=null===(n=null===(t=e.getQuoteIntent())||void 0===t?void 0:t.organisation)||void 0===n?void 0:n.client_settings)||void 0===r?void 0:r.checkout)&&void 0!==i?i:null}}),g=null!=p?p:{},y=null!==(l=null===(a=null==g?void 0:g.insurance_details)||void 0===a?void 0:a.fields)&&void 0!==l?l:zs,v=null===(d=null===(c=null==g?void 0:g.insurance_details)||void 0===c?void 0:c.show_edit_button)||void 0===d||d,w=null!==(h=null===(u=null==g?void 0:g.line_items)||void 0===u?void 0:u.visibility)&&void 0!==h?h:{},b=((null==m?void 0:m.line_item_display)||[]).filter(e=>{var t;const n=null!==(t=null==e?void 0:e.code)&&void 0!==t?t:null==e?void 0:e.line_item_code;return!n||!1!==w[n]}),x=ft(()=>{var e;const t=(null==f?void 0:f.page_data)||(null===(e=null==o?void 0:o.form_data)||void 0===e?void 0:e.page_data);if(!t)return null;let n={};for(const e in t){const r=t[e];r&&"object"==typeof r&&(r.client_first_name&&(n.firstName=r.client_first_name),r.client_last_name&&(n.lastName=r.client_last_name),r.client_email&&(n.email=r.client_email),r.client_phone&&(n.phone=r.client_phone),r.client_dob&&(n.dob=r.client_dob),(r.client_address||r.client_address_line_1)&&(n.address=r.client_address||r.client_address_line_1))}return Object.keys(n).length>0?n:null},[f,o]),k=ft(()=>x?y.map(e=>{const t=Ps[e];if(!t)return null;const n=t(x);return n?{...n,code:e}:null}).filter(e=>Boolean(e)):[],[x,y]);return Qe("div",{className:Rt.create(s?"cart-summary-container-embedded":"cart-summary-container",s?{}:{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.lg,boxShadow:$t.shadow.sm},s?{}:{"(max-width: 768px)":{padding:$t.spacing.md}}),children:[Qe("h3",{className:Rt.create("cart-summary-title",{fontSize:$t.fontSize.large,fontWeight:"600",marginBottom:$t.spacing.md,color:$t.colors.foreground}),children:"Insurance Details"}),k.length>0&&Qe(_,{children:[Qe("div",{className:Rt.create("cart-client-details",{display:"flex",flexDirection:"column",gap:$t.spacing.sm,marginBottom:$t.spacing.md}),children:k.map(e=>Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:e.label}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:e.value})]},e.code))}),Qe("hr",{className:Rt.create("divider",{border:"none",borderTop:`1px solid ${$t.colors.border}`,margin:`${$t.spacing.md} 0`})})]}),Qe("div",{className:Rt.create("cart-product-section",{display:"flex",flexDirection:"column",gap:$t.spacing.sm,marginBottom:$t.spacing.lg}),children:b.map((e,t)=>Qe("div",{className:Rt.create("cart-item",{display:"flex",flexDirection:"column",gap:$t.spacing.sm}),children:[Qe("div",{className:Rt.create("cart-item-description",{fontSize:$t.fontSize.small,fontWeight:"500",color:$t.colors.foreground}),children:e.description}),e.show_sum_insured&&e.sum_insured&&Qe("div",{className:Rt.create("cart-item-sum-insured",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:["Sum Insured: ",Cs(e.sum_insured)]})]},t))}),v&&Qe(us,{onClick:n,disabled:r,variant:"outline",className:Rt.create("edit-quote-button",{width:"100%"}),children:r?"Clearing quote...":"Edit details"})]})}function Ms({clauses:e}){const[t,n]=ut(!0);return 0===e.length?null:Qe("div",{className:Rt.create("policy-clauses-section",{borderRadius:$t.radius.default,border:`1px solid ${$t.colors.border}`,overflow:"hidden"}),children:[Qe("button",{type:"button",onClick:()=>n(!t),className:Rt.create("policy-clauses-toggle",{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:`${$t.spacing.sm} ${$t.spacing.md}`,background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",textAlign:"left"}),children:[Qe("div",{className:Rt.create("policy-clauses-header",{display:"flex",alignItems:"center",gap:$t.spacing.sm}),children:[Qe("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:$t.colors.mutedForeground,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Qe("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),Qe("polyline",{points:"14 2 14 8 20 8"}),Qe("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),Qe("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),Qe("polyline",{points:"10 9 9 9 8 9"})]}),Qe("span",{className:Rt.create("policy-clauses-title",{fontSize:$t.fontSize.small,fontWeight:"500",color:$t.colors.foreground,opacity:"0.7"}),children:"Policy Clauses"})]}),Qe("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:$t.colors.mutedForeground,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{transition:"transform 0.2s ease",transform:t?"rotate(180deg)":"rotate(0deg)"},children:Qe("polyline",{points:"6 9 12 15 18 9"})})]}),t&&Qe("div",{className:Rt.create("policy-clauses-content",{padding:`0 ${$t.spacing.md} ${$t.spacing.md}`,borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.md}),children:Qe("ul",{className:Rt.create("policy-clauses-list",{margin:"0",padding:"0",listStyle:"none",display:"flex",flexDirection:"column",gap:$t.spacing.sm}),children:e.map((e,t)=>Qe("li",{className:Rt.create("policy-clause-item",{fontSize:$t.fontSize.small,color:$t.colors.foreground,opacity:"0.7",lineHeight:"1.5",paddingLeft:$t.spacing.md,position:"relative"}),children:[Qe("span",{className:Rt.create("policy-clause-bullet",{position:"absolute",left:"0",top:"0.6em",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:$t.colors.mutedForeground,opacity:"0.5"})}),e.note||e.reference||""]},t))})})]})}function Os({label:e,value:t,isTotal:n=!1,className:r}){return Qe("div",{className:Lt(Rt.create("summary-item",{display:"flex",justifyContent:"space-between",alignItems:"center"}),r),children:[Qe("span",{className:Rt.create("summary-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:e}),Qe("span",{className:Rt.create("summary-value",{fontWeight:n?"600":"500",color:$t.colors.foreground,fontSize:n?$t.fontSize.large:"inherit"}),children:t})]})}function js({excessOptions:e,paymentGateways:t,selectedExcessId:n,selectedPaymentOption:r,onPurchase:i,canPurchase:o,onContinueLater:s,continueLaterLoading:a=!1,showContinueLaterSuccess:l=!1}){ft(()=>n?e.find(e=>e.id===n):null,[e,n]);const c=ft(()=>r?t.find(e=>e.id===r.gateway_id):null,[t,r]);return Qe("div",{className:Rt.create("payment-summary",{display:"flex",flex:"1",flexDirection:"column",gap:"1rem"}),children:[r&&Qe("div",{className:Rt.create("summary-section",{paddingBottom:"1rem"}),children:Qe("div",{className:Rt.create("payment-breakdown",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:"one-time"===r.amount.frequency?Qe(_,{children:[r.amount.gatewayFee>0&&Qe(Os,{label:"windcave"===(null==c?void 0:c.code)?"Credit card surcharge:":"Provider Fee:",value:Cs(r.amount.gatewayFee)}),Qe(Os,{label:"Due Today:",value:Cs(Number(r.amount.dueToday)+Number(r.amount.gatewayFee)),isTotal:!0})]}):Qe(_,{children:[r.amount.gatewayFee>0&&Qe(Os,{label:"windcave"===(null==c?void 0:c.code)?"Credit card surcharge:":"Provider Fee:",value:Cs(r.amount.gatewayFee)}),r.amount.totalRepayable&&Qe(Os,{label:"Total Payable:",value:Cs(Number(r.amount.totalRepayable))}),Qe(Os,{label:"Due Today:",value:Cs(r.amount.dueToday)}),r.amount.installmentAmount&&r.amount.numberOfInstallments&&r.amount.numberOfInstallments>1&&Qe(Os,{label:"Remaining payments:",value:`${r.amount.numberOfInstallments-1} x ${Cs(r.amount.installmentAmount)}`})]})})}),s&&Qe(us,{onClick:s,disabled:a||l,variant:"outline",className:Rt.create("continue-later-button",{width:"100%",height:"2.75rem",fontSize:$t.fontSize.default,fontWeight:"500"},{"(max-width: 380px)":{fontSize:$t.fontSize.small,height:"2.5rem"}}),children:l?"Email sent":a?"Sending...":"Continue Later"}),Qe(us,{onClick:i,disabled:!o,className:Rt.create("purchase-button",{width:"100%",height:"3rem",fontSize:$t.fontSize.default,fontWeight:"600"},{"(max-width: 380px)":{fontSize:$t.fontSize.small,height:"2.75rem"}}),children:o?"Go to Payment":n?"Select Payment Option":"Select Excess"})]})}function Ws({details:e,onClose:t}){const n=(e,t)=>{navigator.clipboard.writeText(e).then(()=>{alert(`${t} copied to clipboard!`)}).catch(()=>{})};return Qe("div",{className:Rt.create("bank-transfer-container",{display:"flex",flexDirection:"column",gap:$t.spacing.lg}),children:[Qe("div",{className:Rt.create("success-message",{backgroundColor:$t.colors.accent,border:`2px solid ${$t.colors.primary}`,borderRadius:$t.radius.default,padding:$t.spacing.lg,textAlign:"center"}),children:[Qe("div",{className:Rt.create("success-icon",{fontSize:"3rem",marginBottom:$t.spacing.sm}),children:"✓"}),Qe("h3",{className:Rt.create("success-title",{margin:"0",marginBottom:$t.spacing.sm,color:$t.colors.primary,fontSize:$t.fontSize.large,fontWeight:"600"}),children:"Quote Reserved"}),Qe(ks,{className:Rt.create("success-description",{margin:"0",color:$t.colors.foreground,opacity:"0.9"}),children:"Your quote has been reserved. Please complete the bank transfer to finalize your coverage."})]}),Qe("div",{className:Rt.create("transfer-instructions",{backgroundColor:$t.colors.card,border:`1px solid ${$t.colors.border}`,borderRadius:$t.radius.default,padding:$t.spacing.lg}),children:[Qe("h4",{className:Rt.create("instructions-title",{margin:"0",marginBottom:$t.spacing.md,fontSize:$t.fontSize.default,fontWeight:"600",color:$t.colors.foreground}),children:"Bank Transfer Instructions"}),Qe("div",{className:Rt.create("instructions-grid",{display:"grid",gap:$t.spacing.md}),children:[Qe("div",{className:Rt.create("detail-row-highlighted",{backgroundColor:$t.colors.accent,border:`2px solid ${$t.colors.primary}`,borderRadius:$t.radius.default,padding:$t.spacing.md}),children:[Qe("div",{className:Rt.create("detail-label",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginBottom:"0.25rem",fontWeight:"500"}),children:"Reference Number (IMPORTANT)"}),Qe("div",{className:Rt.create("detail-value-wrapper",{display:"flex",alignItems:"center",gap:"0.5rem"}),children:[Qe("code",{className:Rt.create("detail-value-code",{fontFamily:"monospace",fontSize:$t.fontSize.large,fontWeight:"700",color:$t.colors.primary,letterSpacing:"0.05em"}),children:e.reference}),Qe("button",{onClick:()=>n(e.reference,"Reference"),className:Rt.create("copy-button",{background:"transparent",border:`1px solid ${$t.colors.primary}`,borderRadius:$t.radius.small,padding:"0.25rem 0.5rem",cursor:"pointer",fontSize:$t.fontSize.small,color:$t.colors.primary,transition:"all 150ms ease"}),children:"Copy"})]}),Qe(ks,{size:"small",className:Rt.create("reference-note",{marginTop:"0.5rem",marginBottom:"0",color:$t.colors.foreground,fontWeight:"500"}),children:"⚠️ Please include this reference in your transfer particulars"})]}),Qe("div",{className:Rt.create("detail-row",{}),children:[Qe("div",{className:Rt.create("detail-label",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginBottom:"0.25rem"}),children:"Amount"}),Qe("div",{className:Rt.create("detail-value",{fontSize:$t.fontSize.large,fontWeight:"600",color:$t.colors.foreground}),children:["$",e.amount.toFixed(2)," ",e.currency]})]}),Qe("div",{className:Rt.create("detail-row",{}),children:[Qe("div",{className:Rt.create("detail-label",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginBottom:"0.25rem"}),children:"Account Name"}),Qe("div",{className:Rt.create("detail-value-wrapper",{display:"flex",alignItems:"center",gap:"0.5rem"}),children:[Qe("span",{className:Rt.create("detail-value",{fontFamily:"monospace",fontSize:$t.fontSize.default,color:$t.colors.foreground}),children:e.bank_account_name}),Qe("button",{onClick:()=>n(e.bank_account_name,"Account name"),className:Rt.create("copy-button-small",{background:"transparent",border:`1px solid ${$t.colors.border}`,borderRadius:$t.radius.small,padding:"0.125rem 0.375rem",cursor:"pointer",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,transition:"all 150ms ease"}),children:"Copy"})]})]}),Qe("div",{className:Rt.create("detail-row",{}),children:[Qe("div",{className:Rt.create("detail-label",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginBottom:"0.25rem"}),children:"Account Number"}),Qe("div",{className:Rt.create("detail-value-wrapper",{display:"flex",alignItems:"center",gap:"0.5rem"}),children:[Qe("span",{className:Rt.create("detail-value",{fontFamily:"monospace",fontSize:$t.fontSize.default,color:$t.colors.foreground}),children:e.bank_account_number}),Qe("button",{onClick:()=>n(e.bank_account_number,"Account number"),className:Rt.create("copy-button-small",{background:"transparent",border:`1px solid ${$t.colors.border}`,borderRadius:$t.radius.small,padding:"0.125rem 0.375rem",cursor:"pointer",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,transition:"all 150ms ease"}),children:"Copy"})]})]})]}),e.instructions_html&&Qe("div",{className:Rt.create("additional-instructions",{marginTop:$t.spacing.md,paddingTop:$t.spacing.md,borderTop:`1px solid ${$t.colors.border}`}),children:Qe("div",{className:Rt.create("instructions-content",{fontSize:$t.fontSize.small,color:$t.colors.foreground,lineHeight:"1.6"}),dangerouslySetInnerHTML:{H:e.instructions_html}})})]}),Qe("div",{className:Rt.create("important-note",{backgroundColor:$t.colors.muted,border:`1px solid ${$t.colors.border}`,borderRadius:$t.radius.default,padding:$t.spacing.md}),children:Qe(ks,{size:"small",className:Rt.create("note-text",{margin:"0",color:$t.colors.foreground,lineHeight:"1.5"}),children:[Qe("strong",{children:"Important:"})," Your coverage will be activated once we verify receipt of your payment. This typically takes 1-2 business days. We'll send you a confirmation email once your payment is processed."]})}),Qe("div",{className:Rt.create("actions",{display:"flex",justifyContent:"center"}),children:Qe(us,{onClick:t,variant:"primary",children:"I've Made the Transfer"})})]})}function As({isOpen:e,onClose:t,onSuccess:n,paymentRequest:r}){const{fsm:i}=Yt(()=>({})),[o,s]=ut("initiating"),[a,l]=ut(null),[c,d]=ut(null),[u,h]=ut(null),[m,f]=ut(null);ht(()=>{e&&r&&p()},[e,r]);const p=async()=>{if(r)try{s("initiating"),l(null);const e={...r,returnUrl:window.location.href},t=await i.initiatePayment(e);if(h(t.transaction_id),t.bank_account_name&&t.reference){s("bank_transfer");const e=i.getQuoteIntent(),t=await i.httpClient.getQuoteIntent(e.url);i.updateQuoteIntent({status:t.quote_intent.status,payment_transactions:t.payment_transactions}),i.getQuoteIntent(),setTimeout(()=>{g()},500)}else{if(!t.gateway_acceptance_url)throw new Error("Invalid payment response");s("redirecting"),window.location.href=t.gateway_acceptance_url}}catch(e){l(e.message||"Failed to initiate payment"),s("failed")}},g=()=>{c&&!c.closed&&c.close(),s("initiating"),l(null),h(null),d(null),f(null),t()},y=()=>{g(),n()};return e?Qe("div","bank_transfer"===o&&m?{className:Rt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000",overflowY:"auto",padding:"1rem"}),onClick:e=>{e.target===e.currentTarget&&y()},children:Qe("div",{className:Rt.create("modal-content",{backgroundColor:$t.colors.background,borderRadius:$t.radius.large,padding:"2rem",maxWidth:"600px",width:"100%",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${$t.colors.border}`,margin:"auto"}),onClick:e=>e.stopPropagation(),children:Qe(Ws,{details:m,onClose:y})})}:{className:Rt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),children:[Qe("div",{className:Rt.create("modal-content",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:"2rem",minWidth:"400px",maxWidth:"500px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${$t.colors.border}`}),children:[Qe("div",{className:Rt.create("modal-header",{textAlign:"center",marginBottom:"1.5rem"}),children:[Qe("div",{className:Rt.create("status-icon",{fontSize:"3rem",marginBottom:"1rem"}),children:(()=>{switch(o){case"completed":return"✅";case"cancelled":return"❌";case"failed":return"⚠️";default:return"⏳"}})()}),Qe("h2",{className:Rt.create("modal-title",{margin:"0",color:$t.colors.foreground,fontSize:$t.fontSize.large}),children:"Payment Processing"})]}),Qe("div",{className:Rt.create("modal-body",{textAlign:"center",marginBottom:"2rem"}),children:[Qe(ks,{className:Rt.create("status-message",{fontSize:$t.fontSize.default,color:$t.colors.mutedForeground,marginBottom:"1rem"}),children:(()=>{switch(o){case"initiating":return"Setting up your payment...";case"redirecting":return"Redirecting to payment portal...";case"processing":default:return"Processing payment...";case"polling":return"Checking payment status...";case"completed":return"Payment completed successfully!";case"cancelled":return"Payment was cancelled";case"failed":return"Payment failed"}})()}),a&&Qe(ks,{className:Rt.create("error-message",{color:$t.colors.destructive,fontSize:$t.fontSize.small,padding:"0.75rem",backgroundColor:$t.colors.destructive+"10",borderRadius:$t.radius.default,border:`1px solid ${$t.colors.destructive}30`}),children:a}),("redirecting"===o||"initiating"===o)&&Qe("div",{className:Rt.create("loading-indicator",{display:"inline-block",width:"20px",height:"20px",marginTop:"1rem",border:`3px solid ${$t.colors.border}`,borderTop:`3px solid ${$t.colors.primary}`,borderRadius:"50%",animation:"spin 1s linear infinite"})})]}),Qe("div",{className:Rt.create("modal-actions",{display:"flex",gap:"1rem",justifyContent:"center"}),children:"failed"===o||"cancelled"===o?Qe(_,{children:[Qe(us,{onClick:g,variant:"outline",children:"Close"}),"cancelled"===o&&Qe(us,{onClick:()=>{s("initiating"),l(null),p()},children:"Try Again"})]}):Qe(us,"completed"===o?{onClick:g,children:"Continue"}:{onClick:g,variant:"outline",disabled:"initiating"===o,children:"Cancel"})})]}),Qe("style",{children:"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "})]}):null}const Ls={success:"payment_success",declined:"payment_declined",cancelled:"payment_cancelled",error:"payment_error"};function Bs({type:e,transactionId:t,isOpen:n,onClose:r,clientSettings:i,gatewayCode:o}){var s;if(!n)return null;const a=vs(i,Ls[e],null!=o?o:void 0),l=(()=>{switch(e){case"success":return{title:"Payment Successful!",message:"Your payment has been processed successfully and your policy is now active.",icon:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:$t.colors.primary||"#10b981"},children:Qe("path",{d:"M20 6 9 17l-5-5"})}),buttonText:"Close"};case"declined":return{title:"Payment Declined",message:"Your payment was declined by the payment processor. Please try a different payment method or contact your bank.",icon:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:$t.colors.destructive},children:[Qe("circle",{cx:"12",cy:"12",r:"10"}),Qe("path",{d:"m15 9-6 6"}),Qe("path",{d:"m9 9 6 6"})]}),buttonText:"Close"};case"cancelled":return{title:"Payment Cancelled",message:"You cancelled the payment process. You can try again when you're ready.",icon:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:$t.colors.secondary},children:[Qe("circle",{cx:"12",cy:"12",r:"10"}),Qe("path",{d:"m15 9-6 6"}),Qe("path",{d:"m9 9 6 6"})]}),buttonText:"Continue"};default:return{title:"Payment Error",message:"There was an issue processing your payment. Please try again or contact support if the problem persists.",icon:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{color:$t.colors.destructive},children:[Qe("circle",{cx:"12",cy:"12",r:"10"}),Qe("path",{d:"M12 8v4"}),Qe("path",{d:"m12 16 .01 0"})]}),buttonText:"Try Again"}}})(),c=Rt.create("modal-overlay",{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000",padding:"1rem"}),d=Rt.create("modal-content",{backgroundColor:$t.colors.background,borderRadius:$t.radius.default,padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",border:`${$t.borderWidth} solid ${$t.colors.border}`}),u=Rt.create("modal-body",{display:"flex",flexDirection:"column",alignItems:"center",gap:"1.5rem",textAlign:"center"}),h=Rt.create("modal-title",{fontSize:"1.25rem",fontWeight:"600",color:$t.colors.foreground,margin:"0"}),m=Rt.create("modal-message",{color:$t.colors.foreground,lineHeight:"1.5",margin:"0"});Rt.create("transaction-info",{backgroundColor:$t.colors.muted||"#f8f9fa",padding:"0.75rem",borderRadius:$t.radius.small,border:`${$t.borderWidth} solid ${$t.colors.border}`,fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,wordBreak:"break-all"});const f=Rt.create("modal-button",{backgroundColor:$t.colors.primary,color:$t.colors.primaryForeground,border:"none",borderRadius:$t.radius.default,padding:"0.75rem 1.5rem",fontSize:$t.fontSize.default,fontWeight:"500",cursor:"pointer",minWidth:"120px",transition:"background-color 0.2s"}),p=Rt.create("message-container",{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem",marginTop:"0.5rem"});return Qe("div",{className:c,onClick:r,children:Qe("div",{className:d,onClick:e=>e.stopPropagation(),children:Qe("div",{className:u,children:[l.icon,Qe("div",{className:p,children:[Qe("h2",{className:h,children:null!==(s=a.title)&&void 0!==s?s:l.title}),a.body?Qe(ms,{source:a.body,className:m}):Qe("p",{className:m,children:l.message})]}),Qe("button",{className:f,onClick:r,children:l.buttonText})]})})})}function qs({httpClient:e,transactionId:t,onResolved:n,onError:r}){const[i,o]=ut(!1),s=mt(!1);return ht(()=>{if(s.current)return;s.current=!0;let i=!1;return(async()=>{var s;try{const r=await e.resolvePaymentTransaction(t);if(i)return;n(r.status,r.recovery,r.fallback)}catch(e){if(i)return;r(null!==(s=null==e?void 0:e.message)&&void 0!==s?s:"Failed to confirm payment status"),o(!0)}})(),()=>{i=!0}},[e,t]),Qe("div",{role:"status","aria-live":"polite",className:Rt.create("payment-processing-overlay",{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:"1000",display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"}),children:Qe("div",{className:Rt.create("payment-processing-card",{backgroundColor:$t.colors.background,borderRadius:$t.radius.default,border:`${$t.borderWidth} solid ${$t.colors.border}`,boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",padding:"2rem",maxWidth:"400px",width:"100%",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:$t.spacing.md}),children:[Qe(Fs,{}),Qe("h2",{className:Rt.create("payment-processing-title",{margin:"0",fontSize:$t.fontSize.large,fontWeight:"600",color:$t.colors.foreground}),children:"Payment Processing"}),Qe(ks,{children:i?"Just a moment, we're still finishing up. Hang tight, this page will update automatically.":"Hang tight, we're finalising your payment. This page will update automatically in a few seconds."})]})})}function Fs(){return Rt.keyframes("payment-processing-spin",{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Qe("span",{"aria-hidden":"true",className:Rt.create("payment-processing-spinner",{width:"2.5rem",height:"2.5rem",borderRadius:"50%",border:`3px solid ${$t.colors.border}`,borderTopColor:$t.colors.primary,animation:"insure-os-payment-processing-spin 0.9s linear infinite",display:"block"})})}function Hs({isOpen:e,onClose:t,title:n,description:r,children:i,footer:o,width:s="440px"}){if(ht(()=>{if(e)return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n);function n(e){"Escape"===e.key&&t()}},[e,t]),!e)return null;const a=Rt.create("modal-overlay",{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000",padding:"1rem"}),l=Rt.create("modal-content-card",{backgroundColor:$t.colors.background,borderRadius:$t.radius.large,boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",border:`${$t.borderWidth} solid ${$t.colors.border}`,width:"100%",maxWidth:s,maxHeight:"calc(100vh - 2rem)",display:"flex",flexDirection:"column",padding:$t.spacing.lg,gap:$t.spacing.md,overflow:"hidden"});Rt.media("(max-width: 640px)",{"modal-overlay":{padding:"0.5rem"},"modal-content-card":{padding:$t.spacing.md,gap:$t.spacing.sm,maxHeight:"calc(100vh - 1rem)"}});const c=Rt.create("modal-card-header-row",{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:$t.spacing.md,flexShrink:"0"}),d=Rt.create("modal-card-title",{margin:"0",fontSize:"1.125rem",fontWeight:"600",color:$t.colors.foreground}),u=Rt.create("modal-card-description",{margin:"0",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,lineHeight:"1.5"}),h=Rt.create("modal-card-body",{display:"flex",flexDirection:"column",gap:$t.spacing.sm,flex:"1 1 auto",minHeight:"0",overflowY:"auto"}),m=Rt.create("modal-card-footer",{display:"flex",gap:$t.spacing.sm,marginTop:$t.spacing.sm,flexWrap:"wrap",justifyContent:"flex-end",flexShrink:"0"}),f=Rt.create("modal-card-close",{background:"none",border:"none",padding:"0.25rem",margin:"-0.25rem -0.25rem 0 0",color:$t.colors.mutedForeground,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:$t.radius.default,lineHeight:"0"});Rt.pseudoElement("modal-card-close",":hover",{color:$t.colors.foreground,backgroundColor:$t.colors.muted});const p=Rt.create("modal-card-footer-close",{background:$t.colors.background,border:`${$t.borderWidth} solid ${$t.colors.border}`,borderRadius:$t.radius.default,padding:"0.5rem 1rem",fontSize:$t.fontSize.small,fontWeight:"500",color:$t.colors.foreground,cursor:"pointer"});return Rt.pseudoElement("modal-card-footer-close",":hover",{backgroundColor:$t.colors.muted}),Qe("div",{className:a,onClick:t,children:Qe("div",{className:l,onClick:e=>e.stopPropagation(),children:[Qe("div",{className:c,children:[Qe("h2",{className:d,children:n}),Qe("button",{type:"button",onClick:t,"aria-label":"Close",className:f,children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Qe("path",{d:"M18 6 6 18"}),Qe("path",{d:"m6 6 12 12"})]})})]}),Qe("div",{className:h,children:[r&&Qe("p",{className:u,children:r}),i]}),Qe("div",o?{className:m,children:o}:{className:m,children:Qe("button",{type:"button",onClick:t,className:p,children:"Close"})})]})})}function Us({isOpen:e,onClose:t,status:n,onSendEmail:r,onCopyLink:i,email:o}){const s="sending"===n.kind,a="sent"===n.kind,l=s||a,c=Rt.create("continue-later-status",{margin:"0",fontSize:$t.fontSize.small,color:$t.colors.primary}),d=Rt.create("continue-later-status-error",{margin:"0",fontSize:$t.fontSize.small,color:$t.colors.destructive});let u=null;return"sent"===n.kind?u=Qe("p",{className:c,children:o?`A link will be sent to ${o} shortly.`:"A link will be sent to your email shortly."}):"copied"===n.kind?u=Qe("p",{className:c,children:"Link copied to your clipboard."}):"error"===n.kind&&(u=Qe("p",{className:d,children:n.message})),Qe(Hs,{isOpen:e,onClose:t,title:"Save and continue later",description:"We'll save your progress and give you a link to come back to. Your details stay safe and only the people you share the link with can resume.",footer:Qe(_,{children:[Qe(us,{variant:"outline",onClick:i,disabled:s,children:"Copy link"}),Qe(us,{onClick:r,disabled:l,loading:s,children:a?"Email sent":o?"Email me a link":"Send email"})]}),children:u})}function Ys(e=0){const t=new Date;return t.setDate(t.getDate()+e),`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Zs({results:e}){var t,n;const{fsm:r,selectedExcessId:i,selectedPaymentOption:o,quoteIntent:s,httpClient:a}=Yt(e=>({selectedExcessId:e.getSelectedExcessId(),selectedPaymentOption:e.getSelectedPaymentOption(),quoteIntent:e.getQuoteIntent(),httpClient:e.httpClient})),[l,c]=ut(!1),[d,u]=ut(null),[h,m]=ut(!1),[f,p]=ut({kind:"idle"}),[g,y]=ut(!1),v=ft(()=>{var e,t;const n=null!==(t=null===(e=null==s?void 0:s.form_data)||void 0===e?void 0:e.page_data)&&void 0!==t?t:{};for(const e of Object.values(n))if(e&&"object"==typeof e&&e.cover_start_date)return String(e.cover_start_date);return null},[null==s?void 0:s.form_data]),w=ft(()=>{if(!v)return!1;const e=new Date(v);if(Number.isNaN(e.getTime()))return!1;e.setHours(0,0,0,0);const t=new Date;return t.setHours(0,0,0,0),e<t},[v]),b=Ys(),[x,k]=ut(()=>w?b:null!=v?v:b),[S,N]=ut(null),[_,C]=ut(null),[$,I]=ut(!1),[T,E]=ut(!w),P=new URLSearchParams(window.location.search),z=P.get("status"),D=P.get("transactionId")||P.get("transaction_id"),[R,M]=ut(null),[O,j]=ut(null),W="processing"===z&&!!D&&!R&&!O,A=null!=R?R:z,[L,B]=ut(!(!z||"failed"!==z&&"declined"!==z&&"cancelled"!==z)),q=e.calculations,F=e.payment_options,H=e.payment_gateways;ht(()=>{const e=q.find(e=>e.id===i);if(e&&s){const t=F.some(e=>"monthly"===e.amount.frequency),n=r.getPageCompletionStatus(),i=Math.round(n.completedPages.length/n.totalPages*100);Be(s,e,F.length,t,i)}},[]),ht(()=>{if(!o||!i)return;const e=q.find(e=>e.id===i);if(!e)return;if(o.calculation_id===e.calculation_id)return;const t=F.find(t=>t.gateway_id===o.gateway_id&&t.calculation_id===e.calculation_id&&t.amount.frequency===o.amount.frequency);t?r.setSelectedPaymentOption(t):r.setSelectedPaymentOption(null)},[i,o,q,F,r]);const U=async e=>{var t,n,r;if(a&&(null==s?void 0:s.id)){I(!0),N(null),C(null);try{const r=await a.validateQuoteCoverStartDate(s.id,e);r.valid?E(!0):(E(!1),N(null!==(t=r.message)&&void 0!==t?t:"Cover start date is invalid"),C(null!==(n=r.quote_page_url)&&void 0!==n?n:null))}catch(e){E(!1),N(null!==(r=null==e?void 0:e.message)&&void 0!==r?r:"Failed to validate cover start date")}finally{I(!1)}}},Y=e=>{k(e),E(!1),N(null),C(null),e&&U(e)};ht(()=>{w&&x&&!T&&!$&&U(x)},[w,null==s?void 0:s.id]);const Z=()=>{if(!i||!o)return void alert("Please select both an excess amount and payment option");if(w&&!T)return void alert("Please choose and validate a new cover start date before continuing.");const t={quoteIntentId:e.quote_intent.id,excessId:i,gatewayId:o.gateway_id,calculationId:o.calculation_id,clientDetails:{legalName:"Test"},...o.gateway_method?{gateway_method:o.gateway_method}:{},...w&&x?{coverStartDate:x}:{}};u(t),c(!0)},G=async()=>{try{y(!0),await r.clearCalculationResults()}catch(e){alert("Failed to edit quote. Please try again.")}finally{y(!1)}},V=()=>{const e=null==s?void 0:s.form_data;if(!(null==e?void 0:e.page_data))return null;for(const t in e.page_data){const n=e.page_data[t];if(n&&"object"==typeof n&&n.client_email)return n.client_email}return null},Q=()=>{p(e=>"sent"===e.kind?e:{kind:"idle"}),m(!0)},J=Boolean(i&&o&&(!w||T)),K=null==s?void 0:s.payment_return,X=K&&("declined"===K.paymentStatus||"cancelled"===K.paymentStatus||"error"===K.paymentStatus)||L,ee=(null==K?void 0:K.paymentStatus)||("failed"===A?"declined":"cancelled"===A?"cancelled":"error"),te=(null==K?void 0:K.paymentTransactionId)||D||void 0,ne=null===(t=null==K?void 0:K.transactionStatus)||void 0===t?void 0:t.gateway_code;return Qe(cs,{title:"Complete Your Purchase",description:"Choose your coverage and payment options",hideHeader:!0,children:[W&&a&&D&&Qe(qs,{httpClient:a,transactionId:D,onResolved:async e=>{const t="completed"===e?"approved":"cancelled"===e?"cancelled":"failed"===e?"declined":"error",n=new URL(window.location.href);if(n.searchParams.set("status",t),D&&n.searchParams.set("transactionId",D),window.history.replaceState({},"",n.toString()),"completed"===e&&a&&(null==s?void 0:s.url))try{const e=await a.getQuoteIntent(s.url);r.updateQuoteIntent({status:e.quote_intent.status,payment_transactions:e.payment_transactions})}catch(e){}M(t),"declined"!==t&&"cancelled"!==t&&"error"!==t||B(!0)},onError:e=>{j(e),B(!0)}}),Qe(qt,{children:[Qe("div",{className:Rt.create("checkout-layout",{display:"grid",gridTemplateColumns:"1fr 380px",gap:$t.spacing.lg},{"(max-width: 950px)":{display:"none"}}),children:[Qe("div",{className:Rt.create("checkout-main-wrapper",{minWidth:"0",backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,display:"flex",flexDirection:"column",alignSelf:"start"}),children:[Qe("div",{className:Rt.create("checkout-header",{paddingInline:$t.spacing.xl,paddingTop:$t.spacing.xl,paddingBottom:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingTop:$t.spacing.md}}),children:[Qe("h2",{className:Rt.create("checkout-title",{margin:"0",marginBottom:$t.spacing.md,fontSize:"1.75rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.25rem"}}),children:"Complete Your Purchase"}),Qe("p",{className:Rt.create("checkout-description",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:q.length>1?"Choose your excess amount and payment option to secure your coverage.":"Choose your payment method to secure your coverage."}),(null==s?void 0:s.reference)&&Qe("p",{className:Rt.create("checkout-quote-reference",{margin:"0",marginTop:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:["Quote reference: ",Qe("strong",{style:{color:$t.colors.foreground,fontWeight:600},children:s.reference})]}),Qe("hr",{className:Rt.create("checkout-header-border",{marginTop:$t.spacing.lg,border:"0",borderTop:`1px solid ${$t.colors.border}`,height:"0"})})]}),Qe("div",{className:Rt.create("checkout-sections",{paddingInline:$t.spacing.xl,paddingBottom:$t.spacing.xl,display:"flex",flexDirection:"column",gap:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingBottom:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingBottom:$t.spacing.md}}),children:[e.clauses&&e.clauses.length>0&&Qe(Ms,{clauses:e.clauses}),w&&Qe(Gs,{value:x,onChange:Y,validating:$,validated:T,error:S,quotePageUrl:_}),Qe(_s,{excessOptions:q,selectedExcessId:i,onExcessSelect:e=>r.setSelectedExcessId(e)}),Qe(Is,{paymentOptions:F,paymentGateways:H,selectedExcessId:i,selectedPaymentOption:o,onPaymentSelect:e=>r.setSelectedPaymentOption(e)})]})]}),Qe("div",{className:Rt.create("checkout-sidebar",{display:"flex",flexDirection:"column"},{"(max-width: 950px)":{display:"block"}}),children:Qe("div",{className:Rt.create("checkout-sidebar-sticky",{}),children:[Qe(Rs,{excessOptions:q,selectedExcessId:i,onEditQuote:G,isEditingQuote:g,productName:e.product_name,quoteIntent:s}),Qe("div",{className:Rt.create("checkout-sidebar-spacer",{height:$t.spacing.lg},{"(max-width: 950px)":{height:$t.spacing.md}})}),Qe("div",{className:Rt.create("checkout-sidebar-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,boxShadow:$t.shadow.sm,padding:$t.spacing.lg},{"(max-width: 768px)":{padding:$t.spacing.md}}),children:Qe(js,{excessOptions:q,paymentGateways:H,selectedExcessId:i,selectedPaymentOption:o,onPurchase:Z,canPurchase:J,onContinueLater:Q,continueLaterLoading:"sending"===f.kind,showContinueLaterSuccess:"sent"===f.kind})})]})})]}),Qe("div",{className:Rt.create("checkout-mobile-layout",{display:"none"},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:$t.spacing.md}}),children:[Qe("div",{className:Rt.create("mobile-card-summary",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md}),children:[Qe("h2",{className:Rt.create("mobile-checkout-title",{margin:"0",marginBottom:$t.spacing.md,fontSize:"1.5rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:"Complete Your Purchase"}),Qe("p",{className:Rt.create("mobile-checkout-description",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:q.length>1?"Choose your excess amount and payment option to secure your coverage.":"Choose your payment method to secure your coverage."}),Qe("hr",{className:Rt.create("mobile-summary-divider",{marginTop:$t.spacing.md,marginBottom:$t.spacing.md,borderColor:$t.colors.border})}),Qe(Rs,{excessOptions:q,selectedExcessId:i,onEditQuote:G,isEditingQuote:g,productName:e.product_name,quoteIntent:s,embedded:!0})]}),e.clauses&&e.clauses.length>0&&Qe("div",{className:Rt.create("mobile-card-clauses",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md}),children:Qe(Ms,{clauses:e.clauses})}),Qe("div",{className:Rt.create("mobile-card-options",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md}),children:[w&&Qe(Gs,{value:x,onChange:Y,validating:$,validated:T,error:S,quotePageUrl:_}),Qe(_s,{excessOptions:q,selectedExcessId:i,onExcessSelect:e=>r.setSelectedExcessId(e)})]}),Qe("div",{className:Rt.create("mobile-card-payment",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md}),children:[Qe(Is,{paymentOptions:F,paymentGateways:H,selectedExcessId:i,selectedPaymentOption:o,onPaymentSelect:e=>r.setSelectedPaymentOption(e)}),Qe("hr",{className:Rt.create("mobile-payment-divider",{border:"none",borderTop:`1px solid ${$t.colors.border}`,margin:`${$t.spacing.md} 0`})}),Qe(js,{excessOptions:q,paymentGateways:H,selectedExcessId:i,selectedPaymentOption:o,onPurchase:Z,canPurchase:J,onContinueLater:Q,continueLaterLoading:"sending"===f.kind,showContinueLaterSuccess:"sent"===f.kind})]})]}),X&&Qe(Bs,{type:ee,transactionId:te,clientSettings:null===(n=null==s?void 0:s.organisation)||void 0===n?void 0:n.client_settings,gatewayCode:ne,isOpen:!0,onClose:()=>{r.updateQuoteIntent({payment_return:void 0}),B(!1);const e=new URL(window.location.href);e.searchParams.delete("status"),e.searchParams.delete("transactionId"),e.searchParams.delete("transaction_id"),window.history.replaceState({},"",e.toString())}}),Qe(As,{isOpen:l,onClose:()=>{c(!1),u(null)},onSuccess:()=>{c(!1),u(null),alert("Payment completed successfully!")},onError:e=>{alert("Payment failed: "+e)},paymentRequest:d}),Qe(Us,{isOpen:h,onClose:()=>m(!1),status:f,onSendEmail:async()=>{const t=V();if(!t)return void p({kind:"error",message:"Email address not found. Please fill in your email first."});const n=e.quote_intent.id;try{p({kind:"sending"}),await a.continueLater(n,t),p({kind:"sent"})}catch(e){p({kind:"error",message:"Failed to send link. Please try again."})}},onCopyLink:async()=>{var t;const n=(e=>{var t;const n=null===(t=null==s?void 0:s.organisation)||void 0===t?void 0:t.quote_page_url;if(n){const t=n.replace(/\/+$/,""),r=t.includes("?")?"&":"?";return`${t}${r}q=${e}`}return`${window.location.origin}${window.location.pathname}?q=${e}`})(e.quote_intent.id);try{if(null===(t=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===t?void 0:t.writeText)await navigator.clipboard.writeText(n);else{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}p({kind:"copied"})}catch(e){p({kind:"error",message:"Could not copy link. Please copy manually."})}},email:V()})]})]})}function Gs({value:e,onChange:t,validating:n,validated:r,error:i,quotePageUrl:o}){const s=Ys();return Qe("div",{className:Rt.create("cover-date-field",{}),children:[Qe(Ss,{title:"Cover Start Date"}),Qe("div",{className:Rt.create("cover-date-row",{display:"flex",alignItems:"center",gap:$t.spacing.sm,marginTop:$t.spacing.sm}),children:[Qe("input",{type:"date",value:e,min:s,onChange:e=>t(e.target.value),className:Rt.create("cover-date-input",{padding:"0.5rem 1rem",border:`1px solid ${i?"#dc2626":$t.colors.border}`,borderRadius:$t.radius.large,fontSize:$t.fontSize.default,backgroundColor:$t.colors.card,color:$t.colors.foreground,boxSizing:"border-box",width:"auto",maxWidth:"16rem"})}),!n&&r&&!i&&Qe("span",{"aria-label":"Date confirmed",className:Rt.create("cover-date-tick",{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.75rem",height:"1.75rem",borderRadius:"9999px",backgroundColor:$t.colors.primary,color:$t.colors.card,flexShrink:"0"}),children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("polyline",{points:"20 6 9 17 4 12"})})})]}),!n&&i&&Qe("div",{className:Rt.create("cover-date-error",{marginTop:$t.spacing.sm}),children:[Qe("p",{className:Rt.create("cover-date-error-text",{margin:"0",fontSize:$t.fontSize.small,color:"#dc2626",lineHeight:"1.5"}),children:i}),o&&Qe("a",{href:o,className:Rt.create("cover-date-new-quote",{display:"inline-block",marginTop:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.primary,textDecoration:"underline"}),children:"Start a new quote"})]})]})}function Vs({coverTypes:e,selectedCoverTypeId:t,onCoverTypeSelect:n}){const r=[...e].sort((e,t)=>e.sort_order-t.sort_order),i=e.find(e=>e.id===t);return Qe("div",{className:Rt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Qe(Ss,{title:"Cover Type"}),Qe("div",{className:Rt.create("cover-type-options-grid",{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"1rem"}),children:r.map(e=>{const r=e.id===t;return Qe("div",{className:Lt(Rt.create("cover-type-card",{borderRadius:$t.radius.default,minWidth:"180px",padding:"0.5rem 1rem 0.5rem 0.5rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"center",gap:"1rem"}),r?Rt.create("cover-type-card-selected",{border:`2px solid ${$t.colors.primary}`,backgroundColor:$t.colors.accent}):Rt.create("cover-type-card-unselected",{border:`2px solid ${$t.colors.border}`,backgroundColor:$t.colors.card})),onClick:()=>n(e.id),children:[Qe(Ns,{selected:r}),Qe("div",{className:Rt.create("cover-type-label",{color:$t.colors.foreground}),children:[e.label,e.description?"*":""]})]},e.id)})}),(null==i?void 0:i.description)&&Qe("div",{className:Rt.create("cover-type-description",{padding:"0.75rem",backgroundColor:$t.colors.muted,borderRadius:$t.radius.default,border:`1px solid ${$t.colors.border}`}),children:Qe(ks,{className:Rt.create("cover-type-description-text",{fontSize:$t.fontSize.small,color:$t.colors.foreground,margin:"0"}),children:i.description})})]})}function Qs({offers:e,selectedIds:t,onToggle:n,isCalculating:r}){if(0===e.length)return null;const i=[...e].sort((e,t)=>e.sort_order-t.sort_order);return Qe("div",{className:Rt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Qe(Ss,{title:"Add-ons"}),Qe("div",{className:Rt.create("coverage-options-grid",{display:"flex",flexDirection:"column",gap:"0.75rem"}),children:i.map(e=>{const i=t.includes(e.id),o=null!=e.delta_total;return Qe("div",{onClick:()=>!r&&n(e.id),className:Lt(Rt.create("coverage-option-card",{borderRadius:$t.radius.default,padding:"0.75rem 1rem",cursor:r?"wait":"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"flex-start",gap:"1rem",opacity:r?"0.6":"1"}),i?Rt.create("coverage-option-card-selected",{border:`2px solid ${$t.colors.primary}`,backgroundColor:$t.colors.accent}):Rt.create("coverage-option-card-unselected",{border:`2px solid ${$t.colors.border}`,backgroundColor:$t.colors.card})),children:[Qe("div",{className:Rt.create("coverage-option-indicator",{marginTop:"0.125rem"}),children:Qe(Ns,{selected:i})}),Qe("div",{className:Rt.create("coverage-option-body",{flex:"1",display:"flex",flexDirection:"column",gap:"0.25rem",minWidth:"0"}),children:[Qe("div",{className:Rt.create("coverage-option-label",{fontWeight:"600",color:$t.colors.foreground}),children:e.label}),e.description&&Qe(ks,{className:Rt.create("coverage-option-description",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,margin:"0"}),children:e.description}),!o&&Qe(ks,{className:Rt.create("coverage-option-roundtrip",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,fontStyle:"italic",margin:"0"}),children:"Price updates when you toggle this option."})]}),Qe("div",{className:Rt.create("coverage-option-price",{fontWeight:"600",whiteSpace:"nowrap",color:$t.colors.foreground}),children:o?`+${Cs(e.delta_total)}`:"See total"})]},e.id)})})]})}function Js({value:e,className:t,durationMs:n=500}){const[r,i]=ut(e),o=mt(e),s=mt(null);return ht(()=>{if(null!==s.current&&(cancelAnimationFrame(s.current),s.current=null),"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||o.current===e)return o.current=e,void i(e);const t=o.current,r=e,a=performance.now(),l=e=>{const c=e-a,d=Math.min(1,c/n);i(t+(r-t)*(1-(1-d)*(1-d))),d<1?s.current=requestAnimationFrame(l):(o.current=r,s.current=null)};return s.current=requestAnimationFrame(l),()=>{null!==s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[e,n]),Qe("span",{className:t,children:Cs(r)})}function Ks(){var e,t,n,r,i,o,s,a,l,c,d,u,h,m;const{fsm:f,v2Result:p,selection:g,isCalculating:y,isRepricing:v,selectedExcessId:w,quoteIntent:b,calculationResult:x}=Yt(e=>({v2Result:e.getCalculationResultV2(),selection:e.getSelectionV2(),isCalculating:e.getIsCalculating(),isRepricing:e.getIsRepricing(),selectedExcessId:e.getSelectedExcessId(),quoteIntent:e.getQuoteIntent(),calculationResult:e.getCalculationResult()})),[k,S]=ut(null),[N,_]=ut(!1),[C,$]=ut(!1),I=ft(()=>{var e;return null!==(e=null==x?void 0:x.calculations)&&void 0!==e?e:[]},[x]),T=null===(t=null===(e=null==b?void 0:b.organisation)||void 0===e?void 0:e.client_settings)||void 0===t?void 0:t.checkout,E=(null===(n=null==T?void 0:T.headings)||void 0===n?void 0:n.new_business)||"Complete Your Purchase",P=null===(r=null==T?void 0:T.descriptions)||void 0===r?void 0:r.new_business;if(ht(()=>{S(null)},[null==g?void 0:g.cover_type_id,null==g?void 0:g.excess_id,null==g?void 0:g.coverage_option_ids.join(",")]),!p||!g)return Qe(cs,{title:E,description:"Choose your coverage and payment options",hideHeader:!0,children:Qe(qt,{children:Qe("p",{style:{color:$t.colors.mutedForeground},children:"Loading calculation…"})})});const z=null!==(o=null!==(i=p.product_name)&&void 0!==i?i:null==b?void 0:b.product_name)&&void 0!==o?o:"Insurance",D=p.cover_types.length>1,R=I.length>1,M=(null!==(a=null===(s=null==x?void 0:x.clauses)||void 0===s?void 0:s.length)&&void 0!==a?a:0)>0||D||R||(null!==(c=null===(l=p.policy_coverage_options)||void 0===l?void 0:l.length)&&void 0!==c?c:0)>0,O=!(!g.cover_type_id||!g.excess_id||y||v),j=async()=>{_(!0);try{const e=await f.bindV2();S(e)}catch(e){}finally{_(!1)}},W=async()=>{try{$(!0),await f.clearCalculationResults()}catch(e){}finally{$(!1)}};return Qe(cs,{title:E,description:"Choose your coverage and payment options",hideHeader:!0,children:Qe(qt,{children:[Qe("div",{className:Rt.create("checkout-layout",{display:"grid",gridTemplateColumns:"1fr 380px",gap:$t.spacing.lg},{"(max-width: 950px)":{display:"none"}}),children:[Qe("div",{className:Rt.create("checkout-main-wrapper",{minWidth:"0",backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,display:"flex",flexDirection:"column",alignSelf:"start"}),children:[Qe(Xs,{showCoverType:D,showExcess:R,checkoutHeading:E,descriptionOverride:P}),Qe("div",{className:Rt.create("checkout-sections",{paddingInline:$t.spacing.xl,paddingBottom:$t.spacing.xl,display:"flex",flexDirection:"column",gap:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingBottom:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingBottom:$t.spacing.md}}),children:[(null==x?void 0:x.clauses)&&x.clauses.length>0&&Qe(Ms,{clauses:x.clauses}),D&&Qe(Vs,{coverTypes:p.cover_types,selectedCoverTypeId:g.cover_type_id,onCoverTypeSelect:e=>f.setV2Selection({cover_type_id:e})}),R&&Qe(_s,{excessOptions:I,selectedExcessId:w,onExcessSelect:e=>f.setV2Selection({excess_id:e})}),Qe(Qs,{offers:p.policy_coverage_options,selectedIds:g.coverage_option_ids,onToggle:e=>f.toggleV2CoverageOption(e),isCalculating:v}),!M&&Qe(ta,{adminEmail:null===(d=null==b?void 0:b.organisation)||void 0===d?void 0:d.admin_email,phone:null===(u=null==b?void 0:b.organisation)||void 0===u?void 0:u.phone})]})]}),Qe("div",{className:Rt.create("checkout-sidebar",{display:"flex",flexDirection:"column"}),children:Qe("div",{className:Rt.create("checkout-sidebar-sticky",{position:"sticky",top:$t.spacing.lg}),children:[Qe(Rs,{excessOptions:I,selectedExcessId:w,onEditQuote:W,isEditingQuote:C,productName:z,quoteIntent:b}),Qe("div",{className:Rt.create("checkout-sidebar-spacer",{height:$t.spacing.lg})}),Qe("div",{className:Rt.create("checkout-sidebar-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,boxShadow:$t.shadow.sm,padding:$t.spacing.lg},{"(max-width: 768px)":{padding:$t.spacing.md}}),children:Qe(ea,{fsm:f,onBind:j,binding:N,canContinue:O,bindOutcome:k,isRepricing:v})})]})})]}),Qe("div",{className:Rt.create("checkout-mobile-layout",{display:"none"},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:$t.spacing.md}}),children:[Qe("div",{className:Rt.create("mobile-card-summary",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md}),children:[Qe("h2",{className:Rt.create("mobile-checkout-title",{margin:"0",marginBottom:$t.spacing.md,fontSize:"1.5rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:E}),Qe("p",{className:Rt.create("mobile-checkout-description",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:D||R?"Choose your cover and add-ons to secure your policy.":"Review your cover and add-ons to secure your policy."}),Qe("hr",{className:Rt.create("mobile-summary-divider",{marginTop:$t.spacing.md,marginBottom:$t.spacing.md,borderColor:$t.colors.border})}),Qe(Rs,{excessOptions:I,selectedExcessId:w,onEditQuote:W,isEditingQuote:C,productName:z,quoteIntent:b,embedded:!0})]}),(null==x?void 0:x.clauses)&&x.clauses.length>0&&Qe("div",{className:Rt.create("mobile-card-clauses",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md}),children:Qe(Ms,{clauses:x.clauses})}),Qe("div",{className:Rt.create("mobile-card-options",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md,display:"flex",flexDirection:"column",gap:$t.spacing.lg}),children:[D&&Qe(Vs,{coverTypes:p.cover_types,selectedCoverTypeId:g.cover_type_id,onCoverTypeSelect:e=>f.setV2Selection({cover_type_id:e})}),R&&Qe(_s,{excessOptions:I,selectedExcessId:w,onExcessSelect:e=>f.setV2Selection({excess_id:e})}),Qe(Qs,{offers:p.policy_coverage_options,selectedIds:g.coverage_option_ids,onToggle:e=>f.toggleV2CoverageOption(e),isCalculating:y}),!M&&Qe(ta,{adminEmail:null===(h=null==b?void 0:b.organisation)||void 0===h?void 0:h.admin_email,phone:null===(m=null==b?void 0:b.organisation)||void 0===m?void 0:m.phone})]}),Qe("div",{className:Rt.create("mobile-card-payment",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,padding:$t.spacing.md}),children:Qe(ea,{fsm:f,onBind:j,binding:N,canContinue:O,bindOutcome:k,isRepricing:v})})]})]})})}function Xs({showCoverType:e,showExcess:t,checkoutHeading:n,descriptionOverride:r}){let i="Review your cover and add-ons to secure your policy.";return e&&t?i="Choose your cover type, excess amount, and add-ons to secure your policy.":e?i="Choose your cover type and add-ons to secure your policy.":t&&(i="Choose your excess amount and add-ons to secure your policy."),r&&""!==r.trim()&&(i=r),Qe("div",{className:Rt.create("checkout-header",{paddingInline:$t.spacing.xl,paddingTop:$t.spacing.xl,paddingBottom:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingTop:$t.spacing.md}}),children:[Qe("h2",{className:Rt.create("checkout-title",{margin:"0",marginBottom:$t.spacing.sm,fontSize:"1.75rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.125rem"}}),children:n}),Qe("p",{className:Rt.create("checkout-description",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:i}),Qe("hr",{className:Rt.create("checkout-header-border",{marginTop:$t.spacing.lg,borderColor:$t.colors.border})})]})}function ea({fsm:e,onBind:t,binding:n,canContinue:r,bindOutcome:i,isRepricing:o}){const s=e.getV2DisplayedTotal();return Qe("div",{className:Rt.create("payment-summary",{display:"flex",flex:"1",flexDirection:"column",gap:"1rem"}),children:[Qe(Ss,{title:"Payment"}),Qe("div",{className:Rt.create("summary-item",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("summary-label",{display:"flex",alignItems:"center",gap:"0.5rem",color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:["Total payable",Qe("span",{className:Rt.create("summary-label-spinner",{display:"inline-flex",color:$t.colors.mutedForeground,opacity:o?"1":"0",transition:"opacity 200ms ease"}),"aria-hidden":!o,children:Qe(Bt,{size:"small"})})]}),Qe(Js,{value:s,className:Rt.create("summary-value-total",{fontWeight:"600",fontSize:$t.fontSize.large,color:$t.colors.foreground,fontVariantNumeric:"tabular-nums"})})]}),"verified"===(null==i?void 0:i.status)&&Qe("div",{className:Rt.create("verified-banner",{padding:"0.75rem 1rem",border:`1px solid ${$t.colors.primary}`,borderRadius:$t.radius.default,backgroundColor:$t.colors.accent,fontSize:$t.fontSize.small}),children:["Verified at ",Cs(i.server_total),". Payment gateway integration for v2 is pending, quote is ready."]}),"mismatch"===(null==i?void 0:i.status)&&Qe("div",{className:Rt.create("mismatch-banner",{padding:"0.75rem 1rem",border:`1px solid ${$t.colors.destructive}`,borderRadius:$t.radius.default,color:$t.colors.destructive,fontSize:$t.fontSize.small}),children:[Qe("strong",{children:"Price updated."})," The server calculated ",Cs(i.server_total),". Please review and try again."]}),Qe(us,{onClick:t,disabled:!r||n,children:n?"Verifying…":"verified"===(null==i?void 0:i.status)?"Continue to payment":"Verify & continue"}),Qe(ks,{className:Rt.create("payment-footer-note",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,margin:"0"}),children:'Payment gateway integration for v2 products is scoped for a later phase. The "verify" step confirms your selection against the server.'})]})}function ta({adminEmail:e,phone:t}){const n=!!e||!!t;return Qe("div",{className:Rt.create("v2-no-options",{padding:$t.spacing.lg,textAlign:"center",color:$t.colors.foreground,border:`1px dashed ${$t.colors.border}`,borderRadius:$t.radius.default,display:"flex",flexDirection:"column",alignItems:"center",gap:$t.spacing.md}),children:[Qe("p",{className:Rt.create("v2-no-options-title",{margin:"0",fontSize:$t.fontSize.default,fontWeight:"600"}),children:"Sorry, there are no payment options available at this time."}),n?Qe(_,{children:[Qe("p",{className:Rt.create("v2-no-options-body",{margin:"0",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,lineHeight:"1.6"}),children:"Please get in touch and we'll help you complete your purchase."}),Qe("div",{className:Rt.create("v2-no-options-actions",{display:"flex",flexWrap:"wrap",gap:$t.spacing.sm,justifyContent:"center"}),children:[t&&Qe(us,{variant:"outline",onClick:()=>window.open(`tel:${t}`),children:"Call Us"}),e&&Qe(us,{variant:"outline",onClick:()=>window.open(`mailto:${e}`),children:"Email Us"})]})]}):Qe("p",{className:Rt.create("v2-no-options-body-no-contact",{margin:"0",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,lineHeight:"1.6"}),children:"Please get in touch with the provider directly to complete your purchase."})]})}function na({results:e}){var t,n,r,i,o,s;const{quoteIntent:a,fsm:l}=Yt(e=>({quoteIntent:null==e?void 0:e.getQuoteIntent()})),c=null===(t=null==a?void 0:a.organisation)||void 0===t?void 0:t.admin_email,d=null===(n=null==a?void 0:a.organisation)||void 0===n?void 0:n.phone,u=c||d,h=vs(null===(r=null==a?void 0:a.organisation)||void 0===r?void 0:r.client_settings,"referral"),m=null!==(i=h.steps)&&void 0!==i?i:["Our team will review your application within 1-2 business days","We'll contact you with either approval or additional requirements","If approved, we'll provide you with payment options to complete your purchase"],f=Rt.create("referral-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:$t.spacing.lg},"(max-width: 480px)":{padding:$t.spacing.md}}),p=Rt.create("referral-icon-container",{display:"flex",justifyContent:"center",marginBottom:$t.spacing.lg}),g=Rt.create("referral-icon",{width:"4rem",height:"4rem",color:$t.colors.primary}),y=Rt.create("referral-header",{textAlign:"center",marginBottom:$t.spacing.xl}),v=Rt.create("referral-title",{fontSize:"2rem",fontWeight:"700",color:$t.colors.primary,marginBottom:$t.spacing.sm,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),w=Rt.create("referral-subtitle",{fontSize:$t.fontSize.default,color:$t.colors.foreground,lineHeight:"1.6",opacity:"0.8"}),b=Rt.create("referral-process-box",{backgroundColor:$t.colors.accent,borderRadius:$t.radius.default,padding:$t.spacing.lg,marginBottom:$t.spacing.xl}),x=Rt.create("referral-process-title",{fontSize:"1.125rem",fontWeight:"600",color:$t.colors.accentForeground,marginBottom:$t.spacing.md,marginTop:"0"}),k=Rt.create("referral-process-list",{listStyle:"none",padding:"0",margin:"0",display:"flex",flexDirection:"column",gap:$t.spacing.sm}),S=Rt.create("referral-process-item",{display:"flex",alignItems:"flex-start",fontSize:$t.fontSize.small,color:$t.colors.accentForeground,lineHeight:"1.6"}),N=Rt.create("referral-bullet",{width:"1.5rem",height:"1.5rem",backgroundColor:$t.colors.primary,color:$t.colors.primaryForeground,borderRadius:"50%",marginRight:$t.spacing.sm,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.75rem",fontWeight:"600"}),_=Rt.create("referral-contact-section",{borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.xl,marginTop:$t.spacing.xl,textAlign:"center"}),C=Rt.create("referral-contact-text",{fontSize:$t.fontSize.default,color:$t.colors.foreground,marginBottom:$t.spacing.lg}),$=Rt.create("referral-actions",{display:"flex",gap:$t.spacing.md,flexWrap:"wrap",justifyContent:"center",marginBottom:$t.spacing.lg}),I=Rt.create("referral-reference",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginTop:$t.spacing.md}),T=Rt.create("referral-new-request",{textAlign:"center",marginTop:$t.spacing.md}),E=Rt.create("referral-new-request-link",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,textDecoration:"underline",cursor:"pointer",background:"none",border:"none",padding:"0",fontFamily:"inherit"});return Qe(cs,{title:"Quote Under Review",description:"We'll get back to you",hideHeader:!0,children:Qe(qt,{children:Qe(hs,{children:Qe("div",{className:f,children:[Qe("div",{className:p,children:Qe(()=>Qe("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",className:g,children:[Qe("path",{d:"M7 10v12"}),Qe("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]}),{})}),Qe("div",{className:y,children:[Qe("h1",{className:v,children:null!==(o=h.title)&&void 0!==o?o:"Thanks for your quote request!"}),h.body?Qe(ms,{source:h.body,className:w}):Qe("p",{className:w,children:"Our team is reviewing your details and will come back to you with a personalised quote."})]}),Qe("div",{className:b,children:[Qe("h3",{className:x,children:"What happens next?"}),Qe("ul",{className:k,children:m.map((e,t)=>Qe("li",{className:S,children:[Qe("span",{className:N,children:t+1}),Qe("span",{children:e})]},t))})]}),u&&Qe("div",{className:_,children:[Qe("p",{className:C,children:"Need to speak with someone about your quote?"}),Qe("div",{className:$,children:[d&&Qe(us,{variant:"outline",onClick:()=>window.open(`tel:${d}`),children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Qe("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),"Call Us"]}),c&&Qe(us,{variant:"outline",onClick:()=>window.open(`mailto:${c}`),children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Qe("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Qe("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Email Us"]})]}),(null===(s=e.quote_intent)||void 0===s?void 0:s.reference)&&Qe("div",{className:I,children:["Quote Reference: ",Qe("strong",{children:e.quote_intent.reference})]})]}),Qe("div",{className:T,children:Qe("button",{type:"button",className:E,onClick:()=>null==l?void 0:l.reset(),children:"Start a new quote"})})]})})})})}function ra({results:e}){const{calculationResultV2:t}=Yt(e=>({calculationResultV2:e.getCalculationResultV2()}));return"referral"===e.outcome_type?Qe(na,{results:e}):t?Qe(Ks,{}):Qe(Zs,{results:e})}function ia(e,t){return n=e?.use_custom_options?t||e?.options||[]:e?.options||t||[],r=e?.options_sort,r&&"default"!==r?[...n].sort((e,t)=>e.label.localeCompare(t.label,void 0,"numerical"===r?{numeric:!0}:void 0)):[...n];var n,r}function oa({value:e,onChange:t,name:n,id:r,placeholder:i,required:o,disabled:s,className:a,hasError:l,prefix:c="$"}){const d=mt(null),[u,h]=ut("");function m(e){if(!e)return"";const t=e.replace(/[^\d.]/g,"");if(!t)return"";const n=t.split(".");let r=n[0];const i=n[1];r=r.replace(/^0+/,"")||"0";const o=r.replace(/\B(?=(\d{3})+(?!\d))/g,",");return void 0!==i?o+"."+i:o}ht(()=>{h(null!=e&&""!==e?m(e):"")},[e]);const f=Rt.create("money-input-wrapper",{position:"relative",display:"flex",alignItems:"center"}),p=Rt.create("money-input-prefix",{position:"absolute",left:"1rem",color:$t.colors.mutedForeground,pointerEvents:"none",fontSize:"14px",userSelect:"none"}),g=Rt.create("money-input-with-prefix",{paddingLeft:c?"2rem":"1rem"});return Qe("div",{className:f,children:[c&&Qe("span",{className:p,children:c}),Qe("input",{ref:d,type:"text",inputMode:"decimal",name:n,id:r,value:u,onInput:function(e){const n=e.currentTarget,r=n.selectionStart||0,i=u,o=n.value.replace(/[^\d.]/g,""),s=m(o);h(s),t(o),requestAnimationFrame(()=>{if(d.current){const e=function(e,t,n){let r=n+(t.length-e.length);return r=Math.max(0,Math.min(r,t.length)),r}(i,s,r);d.current.setSelectionRange(e,e)}})},onBlur:function(){u&&u.includes(".")},placeholder:i,required:o,disabled:s,className:Lt(a,c&&g)})]})}function sa(e){var t,n;const r=Rt.create("input",{width:"100%",maxWidth:"100%",minWidth:"0",boxSizing:"border-box",height:"2.75rem",paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",border:`${$t.borderWidth} solid ${$t.colors.input}`,borderRadius:$t.radius.default,fontSize:$t.fontSize.default,backgroundColor:$t.colors.card,color:$t.colors.foreground,transition:$t.transition,outline:"none",boxShadow:"none"},{"(max-width: 480px)":{paddingLeft:"0.75rem",paddingRight:"0.75rem"}}),i=Rt.create("input-error",{border:`${$t.borderWidth} solid ${$t.colors.destructive}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${$t.colors.destructive} 20%, transparent)`}),o=e.hasError?`${r} ${i}`:r,s=Rt.name("input");Rt.pseudoElement("input",":focus",{border:`${$t.borderWidth} solid ${$t.colors.primary}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${$t.colors.primary} 20%, transparent)`,borderRadius:$t.radius.default});const a=Rt.create("select",{width:"100%",minWidth:"0",boxSizing:"border-box",height:`calc(2.75rem - (${$t.borderWidth} * 2))`,paddingLeft:"1.25rem",paddingRight:"2.5rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",border:"none",fontSize:$t.fontSize.default,backgroundColor:"transparent",color:$t.colors.foreground,outline:"none",WebkitAppearance:"none",appearance:"none",textOverflow:"ellipsis"},{"(max-width: 480px)":{paddingLeft:"0.75rem",paddingRight:"2rem"}}),l=Rt.create("select-wrapper",{position:"relative",minWidth:"0",border:`${$t.borderWidth} solid ${$t.colors.input}`,borderRadius:$t.radius.default,backgroundColor:$t.colors.card,transition:$t.transition,outline:"none",boxShadow:"none"}),c=Rt.create("select-wrapper-error",{border:`${$t.borderWidth} solid ${$t.colors.destructive}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${$t.colors.destructive} 20%, transparent)`}),d=e.hasError?`${l} ${c}`:l,u=Rt.name("select-wrapper");Rt.pseudoElement("select-wrapper",":focus-within",{border:`${$t.borderWidth} solid ${$t.colors.primary}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${$t.colors.primary} 20%, transparent)`,borderRadius:$t.radius.default});const{onChange:h,onBlur:m,onKeyDown:f,className:p,validation:g,errors:y,suffix:v,...w}=e;function b(e){h(e.currentTarget.value)}function x(e){h(e.currentTarget.value)}function k(e){m&&m(e.currentTarget.value)}if("select"===e.type){const S=e.null_option_label||"N/A",N=ia(e.validation,e.options),_=!w.value&&!e.add_null_option,C=Rt.create("select-placeholder",{color:$t.colors.mutedForeground}),$=Rt.create("select-chevron",{position:"absolute",right:"0.75rem",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:$t.colors.mutedForeground});return Qe("div",{className:Lt(d,u),children:[Qe("select",{...w,onChange:b,className:Lt(a,_&&C),children:[_&&Qe("option",{value:"",disabled:!0,selected:!0,children:"Select..."}),e.add_null_option&&Qe("option",{value:"",children:S}),N.map(e=>Qe("option",{value:e.value,children:e.label},e.value))]}),Qe("svg",{className:$,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M6 9l6 6 6-6"})})]})}if("radio"===e.type){const I=e.null_option_label||"N/A",T=ia(e.validation,e.options),E=Rt.create(e.inline?"radio-container-inline":"radio-container",{display:"flex",flexDirection:e.inline?"row":"column",gap:e.inline?"1rem":"0.5rem",flexWrap:e.inline?"wrap":"nowrap"}),P=Rt.create("radio-label",{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer",fontSize:$t.fontSize.default,color:$t.colors.foreground}),z=Rt.create("radio-input",{accentColor:$t.colors.primary,width:"1.25rem",height:"1.25rem",cursor:"pointer",marginRight:"0.25rem"}),D=Rt.name("radio-input");return Rt.pseudoElement("radio-input",":focus",{outline:`3px solid color-mix(in srgb, ${$t.colors.primary} 30%, transparent)`,outlineOffset:"2px"}),Qe("div",{className:E,children:[e.add_null_option&&Qe("label",{className:P,children:[Qe("input",{type:"radio",name:e.name,value:"",checked:""===e.value,onChange:()=>h(""),className:Lt(z,D)}),Qe("span",{children:I})]}),T.map(t=>Qe("label",{className:P,children:[Qe("input",{type:"radio",name:e.name,value:t.value,checked:e.value===t.value,onChange:()=>h(t.value),className:Lt(z,D)}),Qe("span",{children:t.label})]},t.value))]})}if("date"===e.type){const R=Rt.create("input-date",{height:"2.75rem",minHeight:"2.75rem",maxHeight:"2.75rem",WebkitAppearance:"none",appearance:"none"});return Qe("input",{...w,type:"date",min:null===(t=e.validation)||void 0===t?void 0:t.minDate,max:null===(n=e.validation)||void 0===n?void 0:n.maxDate,onInput:x,onChange:b,className:Lt(o,s,R,p)})}if("monthyear"===e.type)return Qe(la,{id:e.id,name:e.name,value:e.value,required:e.required,disabled:e.disabled,hasError:e.hasError,onChange:h,selectWrapperBaseClass:l,selectWrapperErrorClass:c,selectWrapperBaseClassName:u,selectBaseClassName:a});if("year"===e.type){const M=(new Date).getFullYear();return Qe("input",{...w,type:"number",min:M-100,max:M,placeholder:"YYYY",onInput:x,onChange:b,className:Lt(o,s,p)})}if("money"===e.type)return Qe(oa,{value:e.value,onChange:h,name:e.name,id:e.id,placeholder:e.placeholder,required:e.required,disabled:e.disabled,className:Lt(o,s,p),hasError:e.hasError});if("checkbox"===e.type){const O=!0===e.value||"true"===e.value||"true"===e.value,j=Rt.create("checkbox-wrapper",{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.25rem",height:"1.25rem",flexShrink:"0"}),W=Rt.create("checkbox-"+(O?"checked":"unchecked"),{appearance:"none",width:"1.25rem",height:"1.25rem",border:`2px solid ${O?$t.colors.primary:e.hasError?$t.colors.destructive:$t.colors.input}`,borderRadius:"0.375rem",cursor:"pointer",backgroundColor:O?$t.colors.primary:$t.colors.card,transition:$t.transition,position:"absolute"}),A=Rt.name("checkbox-"+(O?"checked":"unchecked"));function L(e){e.preventDefault(),h(O?"false":"true")}return Rt.pseudoElement("checkbox-"+(O?"checked":"unchecked"),":focus",{outline:"none",boxShadow:`0 0 0 3px color-mix(in srgb, ${$t.colors.primary} 20%, transparent)`,borderRadius:"0.375rem"}),Qe("div",{className:j,children:[Qe("input",{type:"checkbox",id:e.id,name:e.name,checked:O,onClick:L,className:Lt(W,A,p),required:e.required,readOnly:!0}),O&&Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:$t.colors.primaryForeground,"stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",style:{pointerEvents:"none",position:"relative",zIndex:1},children:Qe("path",{d:"M20 6 9 17l-5-5"})})]})}if("boolean"===e.type){const B=Rt.create("boolean-container",{display:"flex",flexDirection:"column",gap:"1rem"}),q=Rt.create("boolean-radio-group",{display:"flex",gap:"1rem"}),F=Rt.create("boolean-radio-label",{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"}),H=Rt.create("boolean-radio",{accentColor:$t.colors.primary,width:"1.25rem",height:"1.25rem",cursor:"pointer",marginRight:"0.25rem"}),U=Rt.name("boolean-radio");Rt.pseudoElement("boolean-radio",":focus",{outline:`3px solid color-mix(in srgb, ${$t.colors.primary} 30%, transparent)`,outlineOffset:"2px"});const Y=Rt.create("boolean-textarea",{width:"100%",boxSizing:"border-box",minHeight:"5rem",padding:"1rem",border:`${$t.borderWidth} solid ${$t.colors.input}`,borderRadius:$t.radius.default,fontSize:$t.fontSize.default,backgroundColor:$t.colors.card,color:$t.colors.foreground,transition:$t.transition,outline:"none",boxShadow:"none",resize:"vertical",fontFamily:$t.fontFamily}),Z=Rt.create("boolean-textarea-error",{border:`${$t.borderWidth} solid ${$t.colors.destructive}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${$t.colors.destructive} 20%, transparent)`}),G=e.hasError?`${Y} ${Z}`:Y,V=Rt.name("boolean-textarea");Rt.pseudoElement("boolean-textarea",":focus",{border:`${$t.borderWidth} solid ${$t.colors.primary}`,boxShadow:`0 0 0 3px color-mix(in srgb, ${$t.colors.primary} 20%, transparent)`,borderRadius:$t.radius.default});const Q=!0===e.value||"true"===e.value,J=!1===e.value||"false"===e.value,K=e.answer||"",X=e.booleanConfig,ee=(null==X?void 0:X.enable_details_textbox)&&("yes"===X.show_details_on&&Q||"no"===X.show_details_on&&J);function te(t){h(t),(!(null==X?void 0:X.enable_details_textbox)||!("yes"===X.show_details_on&&"true"===t||"no"===X.show_details_on&&"false"===t))&&e.onAnswerChange&&K&&e.onAnswerChange("")}return Qe("div",{className:Lt(B,p),children:[Qe("div",{className:q,children:[Qe("label",{className:F,children:[Qe("input",{type:"radio",name:e.name,checked:Q,onChange:()=>te("true"),className:Lt(H,U)}),Qe("span",{children:"Yes"})]}),Qe("label",{className:F,children:[Qe("input",{type:"radio",name:e.name,checked:J,onChange:()=>te("false"),className:Lt(H,U)}),Qe("span",{children:"No"})]})]}),ee&&Qe("textarea",{placeholder:(null==X?void 0:X.details_placeholder)||"Please provide details",value:K,required:!0,onInput:t=>{return n=t.target.value,void(e.onAnswerChange&&e.onAnswerChange(n));var n},className:Lt(G,V)})]})}return v?Qe("div",{className:Rt.create("input-with-suffix",{display:"flex",alignItems:"center",gap:$t.spacing.sm,minWidth:"0",maxWidth:"100%"}),children:[Qe("input",{...w,onInput:x,onChange:b,onBlur:k,onKeyDown:f,className:Lt(o,s,p),style:{flex:1,minWidth:0}}),v]}):Qe("input",{...w,onInput:x,onChange:b,onBlur:k,onKeyDown:f,className:Lt(o,s,p)})}const aa=[{value:"01",label:"January"},{value:"02",label:"February"},{value:"03",label:"March"},{value:"04",label:"April"},{value:"05",label:"May"},{value:"06",label:"June"},{value:"07",label:"July"},{value:"08",label:"August"},{value:"09",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}];function la(e){const t=e.value||"",n=t.length>=7?t.substring(5,7):"",r=t.length>=4?t.substring(0,4):"",[i,o]=ut(n),[s,a]=ut(r),[l,c]=ut(!1),[d,u]=ut(!1),[h,m]=ut(!(!n||!r));ht(()=>{o(n),a(r),m(!(!n||!r))},[e.value]);const f=(new Date).getFullYear(),p=[];for(let e=f;e>=f-100;e--)p.push(e);function g(t,n){if(t&&n)return m(!0),void e.onChange(`${n}-${t}-01`);h&&e.onChange("")}const y=!!i!=!!s&&l&&d&&!e.required,v=!i&&l&&(e.hasError||y),w=!s&&d&&(e.hasError||y),b=v?`${e.selectWrapperBaseClass} ${e.selectWrapperErrorClass}`:e.selectWrapperBaseClass,x=w?`${e.selectWrapperBaseClass} ${e.selectWrapperErrorClass}`:e.selectWrapperBaseClass,k=Rt.create("monthyear-row",{display:"flex",gap:$t.spacing.sm,minWidth:"0"}),S=Rt.create("monthyear-item",{flex:"1 1 0",minWidth:"0"}),N=Rt.create("monthyear-placeholder",{color:$t.colors.mutedForeground}),_=Rt.create("monthyear-chevron",{position:"absolute",right:"0.75rem",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:$t.colors.mutedForeground}),C=Rt.create("monthyear-partial-error",{marginTop:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.destructive}),$=Qe("svg",{className:_,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M6 9l6 6 6-6"})}),I=!i,T=!s,E=!e.required;return Qe("div",{children:[Qe("div",{className:k,children:[Qe("div",{className:Lt(b,e.selectWrapperBaseClassName,S),children:[Qe("select",{id:e.id,name:e.name,required:e.required,disabled:e.disabled,value:i,onChange:function(e){const t=e.currentTarget.value;o(t),c(!0),g(t,s)},onBlur:function(){c(!0)},className:Lt(e.selectBaseClassName,I&&N),children:[I?Qe("option",{value:"",disabled:!0,selected:!0,children:"Month"}):E&&Qe("option",{value:"",children:"— None —"}),aa.map(e=>Qe("option",{value:e.value,children:e.label},e.value))]}),$]}),Qe("div",{className:Lt(x,e.selectWrapperBaseClassName,S),children:[Qe("select",{id:`${e.id}__year`,required:e.required,disabled:e.disabled,value:s,onChange:function(e){const t=e.currentTarget.value;a(t),u(!0),g(i,t)},onBlur:function(){u(!0)},className:Lt(e.selectBaseClassName,T&&N),children:[T?Qe("option",{value:"",disabled:!0,selected:!0,children:"Year"}):E&&Qe("option",{value:"",children:"— None —"}),p.map(e=>Qe("option",{value:String(e),children:e},e))]}),$]})]}),y&&Qe("div",{className:C,children:"Please select both month and year, or clear both."})]})}function ca(e,t){const{fsm:n,lastUpdated:r}=Yt(e=>{var t,n;return{lastUpdated:null!==(n=null===(t=e.getFormProgress())||void 0===t?void 0:t.last_updated)&&void 0!==n?n:null}}),[i,o]=ut({kind:"idle"}),s=ft(()=>{var t;for(let n=0;n<e.length;n++)if((null!==(t=e[n].fields)&&void 0!==t?t:[]).some(e=>"client_email"===e.code))return n;return-1},[e]);return{showContinueLater:s>=0&&t.includes(s),lastUpdated:r,continueLaterStatus:i,sendContinueLaterEmail:async function(){var e,t;const r=function(){const e=null==n?void 0:n.getFormProgress(),t=null==e?void 0:e.page_data;if(!t)return null;for(const e in t){const n=t[e];if(null==n?void 0:n.client_email)return n.client_email}return null}();if(!r)return void o({kind:"error",message:"Email address not found. Please fill in your email first."});const i=null===(e=null==n?void 0:n.getQuoteIntent())||void 0===e?void 0:e.id;if(i)try{o({kind:"sending"}),await(null===(t=null==n?void 0:n.httpClient)||void 0===t?void 0:t.continueLater(i,r)),o({kind:"sent"})}catch(e){o({kind:"error",message:"Failed to send link. Please try again."})}},copyContinueLaterLink:async function(){var e,t;const r=null===(e=null==n?void 0:n.getQuoteIntent())||void 0===e?void 0:e.id;if(!r)return;const i=function(e){var t,r;const i=null===(r=null===(t=null==n?void 0:n.getQuoteIntent())||void 0===t?void 0:t.organisation)||void 0===r?void 0:r.quote_page_url;if(i){const t=i.replace(/\/+$/,""),n=t.includes("?")?"&":"?";return`${t}${n}q=${e}`}return`${window.location.origin}${window.location.pathname}?q=${e}`}(r);try{if(null===(t=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===t?void 0:t.writeText)await navigator.clipboard.writeText(i);else{const e=document.createElement("textarea");e.value=i,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}o({kind:"copied"})}catch(e){o({kind:"error",message:"Could not copy link. Please copy manually."})}},resetContinueLaterStatus:function(){o({kind:"idle"})},clearTransientStatus:function(){o(e=>"sent"===e.kind?e:{kind:"idle"})},confirmReset:function(){null==n||n.reset()}}}function da({isOpen:e,onClose:t,onConfirm:n}){return Qe(Hs,{isOpen:e,onClose:t,title:"Reset your progress?",description:"This will clear everything you've entered so far and start the form over. This cannot be undone.",footer:Qe(_,{children:[Qe(us,{variant:"outline",onClick:t,children:"Cancel"}),Qe(us,{onClick:function(){n(),t()},children:"Reset progress"})]})})}function ua({pages:t,currentPageIndex:n,completedPages:r}){const{fsm:i,isSaving:o}=Yt(e=>({isSaving:e.getIsSaving()})),{showContinueLater:s,lastUpdated:a,continueLaterStatus:l,sendContinueLaterEmail:c,copyContinueLaterLink:d,clearTransientStatus:u,confirmReset:h}=ca(t,r),[m,f]=ut(!1),[p,g]=ut(!1),y=mt(null),v=mt(null);e(t.length),e(t.map((e,t)=>({index:t,id:e.id,title:e.title})));const w=(()=>{var e;const t=null===(e=null==i?void 0:i.getFormProgress())||void 0===e?void 0:e.page_data;if(!t)return null;for(const e in t){const n=t[e];if(null==n?void 0:n.client_email)return n.client_email}return null})();ht(()=>{if(y.current&&v.current){const e=v.current,t=y.current,n=e.getBoundingClientRect(),r=t.getBoundingClientRect();(r.top<n.top||r.bottom>n.bottom)&&t.scrollIntoView({behavior:"smooth",block:"nearest"})}},[n]);const b=Math.round((n+1)/t.length*100),x=Rt.create("sidebar-nav-item-base",{display:"flex",alignItems:"flex-start",gap:$t.spacing.sm,padding:`${$t.spacing.sm} ${$t.spacing.sm}`,borderRadius:$t.radius.default,border:"none",backgroundColor:"transparent",color:$t.colors.foreground,cursor:"pointer",transition:$t.transition,textAlign:"left",width:"100%",fontFamily:$t.fontFamily,fontSize:$t.fontSize.small,opacity:"1"}),k=Rt.create("sidebar-nav-item-active",{backgroundColor:$t.colors.accent,color:$t.colors.accentForeground}),S=Rt.create("sidebar-nav-item-disabled",{cursor:"not-allowed",opacity:"0.5"});Rt.pseudoElement("sidebar-nav-item-base",":hover",{backgroundColor:$t.colors.muted}),Rt.pseudoElement("sidebar-nav-item-active",":hover",{backgroundColor:$t.colors.accent});const N=Rt.create("sidebar-indicator-base",{width:"1.25rem",height:"1.25rem",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:"0",marginTop:"0.125rem",backgroundColor:$t.colors.muted,color:$t.colors.mutedForeground,fontSize:"0.75rem",fontWeight:"600"}),_=Rt.create("sidebar-indicator-active",{backgroundColor:$t.colors.accentForeground,color:$t.colors.accent}),C=Rt.create("sidebar-indicator-completed",{backgroundColor:$t.colors.primary,color:$t.colors.primaryForeground}),$=Rt.create("sidebar-page-title-base",{fontWeight:"500",fontSize:"0.875rem",lineHeight:"1.7",wordWrap:"break-word",overflowWrap:"break-word"}),I=Rt.create("sidebar-page-title-active",{fontWeight:"600"});return Qe("div",{className:Rt.create("sidebar-navigation",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.lg,boxShadow:$t.shadow.sm,alignSelf:"flex-start",display:"flex",flexDirection:"column",gap:$t.spacing.lg}),children:[Qe("div",{className:Rt.create("sidebar-progress-container",{display:"flex",flexDirection:"column",gap:$t.spacing.sm}),children:[Qe("span",{className:Rt.create("sidebar-progress-text",{fontSize:$t.fontSize.small,fontWeight:"600",color:$t.colors.foreground}),children:["Step ",n+1," of ",t.length]}),Qe("div",{className:Rt.create("sidebar-progress-bg",{width:"100%",height:"0.5rem",backgroundColor:$t.colors.muted,borderRadius:$t.radius.small,overflow:"hidden"}),children:Qe("div",{className:Rt.create("sidebar-progress-fill",{height:"100%",backgroundColor:$t.colors.primary,borderRadius:$t.radius.small,transition:$t.transition}),style:{width:`${b}%`}})})]}),Qe("hr",{className:Rt.create("sidebar-divider",{borderColor:$t.colors.border})}),Qe("nav",{ref:v,className:Rt.create("sidebar-nav",{display:"flex",flexDirection:"column",gap:$t.spacing.sm,maxHeight:"calc(100vh - 400px)",overflowY:"auto",overflowX:"hidden",paddingRight:$t.spacing.sm}),children:t.map((t,s)=>{const a=s===n,l=r.includes(s),c=i.canNavigateToPage(s);s===n&&e(t.title);const d=[x];a&&d.push(k),c&&!o||d.push(S);const u=d.join(" "),h=[N];l?h.push(C):a&&h.push(_);const m=h.join(" ");return Qe("button",{ref:a?y:null,onClick:()=>{return e=s,void((null==i?void 0:i.canNavigateToPage(e))&&i.navigateToPage(e));var e},disabled:!c||o,className:u,children:[Qe("div",{className:m,children:l?Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M20 6 9 17l-5-5"})}):s+1}),Qe("div",{className:Rt.create("sidebar-nav-text",{display:"flex",flexDirection:"column",gap:"0.125rem",flex:"1",minWidth:"0"}),children:Qe("span",{className:a?`${$} ${I}`:$,children:t.title})})]},t.id)})}),a&&Qe("div",{className:Rt.create("sidebar-footer",{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"}),children:[Qe("div",{className:Rt.create("sidebar-last-saved",{fontSize:"0.6875rem",color:$t.colors.mutedForeground,textAlign:"center",opacity:"0.6",fontStyle:"italic"}),children:["Last saved: ",as.fromJSDate(new Date(a)).toFormat("T")]}),Qe("button",{onClick:()=>g(!0),className:Rt.create("sidebar-reset-link",{background:"none",border:"none",padding:"0",fontSize:"0.6875rem",color:$t.colors.mutedForeground,opacity:"0.5",cursor:"pointer",textDecoration:"underline",fontFamily:$t.fontFamily}),children:"Reset progress"})]}),s&&Qe("button",{onClick:()=>{u(),f(!0)},className:Rt.create("sidebar-continue-later-button",{padding:`${$t.spacing.sm} ${$t.spacing.md}`,border:`${$t.borderWidth} solid ${$t.colors.border}`,borderRadius:$t.radius.default,backgroundColor:"transparent",color:$t.colors.mutedForeground,fontSize:$t.fontSize.small,fontFamily:$t.fontFamily,cursor:"pointer",transition:$t.transition,textAlign:"center",width:"100%"}),children:"Continue Later"}),Qe(Us,{isOpen:m,onClose:()=>f(!1),status:l,onSendEmail:c,onCopyLink:d,email:w}),Qe(da,{isOpen:p,onClose:()=>g(!1),onConfirm:h})]})}function ha({pages:e,currentPageIndex:t,completedPages:n}){const{fsm:r,isSaving:i}=Yt(e=>({fsm:e,isSaving:null==e?void 0:e.getIsSaving()})),[o,s]=ut(!1),a=Math.round((t+1)/e.length*100),l=Rt.create("mobile-sidebar-item-base",{display:"flex",alignItems:"center",gap:$t.spacing.sm,padding:$t.spacing.sm,border:"none",borderRadius:$t.radius.default,backgroundColor:"transparent",color:$t.colors.foreground,cursor:"pointer",opacity:"1",transition:$t.transition,width:"100%",textAlign:"left",fontFamily:$t.fontFamily}),c=Rt.create("mobile-sidebar-item-active",{backgroundColor:$t.colors.accent,color:$t.colors.accentForeground}),d=Rt.create("mobile-sidebar-item-disabled",{cursor:"not-allowed",opacity:"0.5"}),u=Rt.create("mobile-sidebar-indicator-base",{width:"1.25rem",height:"1.25rem",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:"0",backgroundColor:$t.colors.muted,color:$t.colors.mutedForeground,fontSize:"0.75rem",fontWeight:"600"}),h=Rt.create("mobile-sidebar-indicator-active",{backgroundColor:$t.colors.accentForeground,color:$t.colors.accent}),m=Rt.create("mobile-sidebar-indicator-completed",{backgroundColor:$t.colors.primary,color:$t.colors.primaryForeground}),f=Rt.create("mobile-sidebar-page-title-base",{fontSize:$t.fontSize.small,fontWeight:"500"}),p=Rt.create("mobile-sidebar-page-title-active",{fontWeight:"600"});return Qe("div",{className:Rt.create("mobile-sidebar",{overflow:"hidden"}),children:[Qe("button",{onClick:()=>s(!o),className:Rt.create("mobile-sidebar-header",{width:"100%",padding:$t.spacing.md,border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",flexDirection:"column",gap:$t.spacing.sm}),children:[Qe("div",{className:Rt.create("mobile-sidebar-header-row",{display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[Qe("span",{className:Rt.create("mobile-sidebar-step-text",{fontSize:$t.fontSize.small,fontWeight:"600",color:$t.colors.foreground}),children:["Step ",t+1," of ",e.length]}),Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:Rt.create("mobile-sidebar-chevron",{transition:$t.transition,transform:o?"rotate(180deg)":"rotate(0deg)",color:$t.colors.mutedForeground}),children:Qe("path",{d:"m6 9 6 6 6-6"})})]}),Qe("div",{className:Rt.create("mobile-sidebar-progress-bg",{width:"100%",height:"0.5rem",backgroundColor:$t.colors.muted,borderRadius:$t.radius.small,overflow:"hidden"}),children:Qe("div",{className:Rt.create("mobile-sidebar-progress-fill",{height:"100%",backgroundColor:$t.colors.primary,borderRadius:$t.radius.small,transition:$t.transition}),style:{width:`${a}%`}})})]}),Qe("hr",{className:Rt.create("mobile-sidebar-border",{borderColor:$t.colors.border})}),o&&Qe("div",{className:Rt.create("mobile-sidebar-content",{padding:$t.spacing.sm,display:"flex",flexDirection:"column",gap:"0.25rem",maxHeight:"300px",overflowY:"auto"}),children:e.map((e,o)=>{const a=o===t,g=n.includes(o),y=r.canNavigateToPage(o),v=[l];a&&v.push(c),y&&!i||v.push(d);const w=v.join(" "),b=[u];g?b.push(m):a&&b.push(h);const x=b.join(" ");return Qe("button",{onClick:()=>{return e=o,void((null==r?void 0:r.canNavigateToPage(e))&&(r.navigateToPage(e),s(!1)));var e},disabled:!y||i,className:w,children:[Qe("div",{className:x,children:g?Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M20 6 9 17l-5-5"})}):o+1}),Qe("span",{className:a?`${f} ${p}`:f,children:e.title})]},e.id)})})]})}function ma({pages:e,completedPages:t}){const{fsm:n}=Yt(()=>({})),{showContinueLater:r,lastUpdated:i,continueLaterStatus:o,sendContinueLaterEmail:s,copyContinueLaterLink:a,clearTransientStatus:l,confirmReset:c}=ca(e,t),[d,u]=ut(!1),[h,m]=ut(!1);if(!i&&!r)return null;const f=(()=>{var e;const t=null===(e=null==n?void 0:n.getFormProgress())||void 0===e?void 0:e.page_data;if(!t)return null;for(const e in t){const n=t[e];if(null==n?void 0:n.client_email)return n.client_email}return null})(),p=Rt.create("mobile-form-actions-container",{display:"flex",justifyContent:"center",alignItems:"center",gap:$t.spacing.lg,paddingTop:$t.spacing.sm,paddingBottom:$t.spacing.sm}),g=Rt.create("mobile-form-actions-link",{background:"none",border:"none",padding:"0",fontSize:"0.75rem",color:$t.colors.mutedForeground,opacity:"0.6",cursor:"pointer",textDecoration:"underline",fontFamily:$t.fontFamily});return Qe("div",{className:p,children:[i&&Qe("button",{type:"button",onClick:()=>m(!0),className:g,children:"Reset progress"}),r&&Qe("button",{type:"button",onClick:()=>{l(),u(!0)},className:g,children:"Continue later"}),Qe(Us,{isOpen:d,onClose:()=>u(!1),status:o,onSendEmail:s,onCopyLink:a,email:f}),Qe(da,{isOpen:h,onClose:()=>m(!1),onConfirm:c})]})}function fa({organisation:e}){return Qe("div",{className:Rt.create("welcome-card",{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},{"(max-width: 950px)":{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingTop:$t.spacing.md}}),children:[Qe("h2",{className:Rt.create("welcome-title",{margin:"0",marginBottom:$t.spacing.md,fontSize:"1.75rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 950px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.25rem",marginBottom:$t.spacing.sm}}),children:["Thank you for choosing ",e.name,"."]}),Qe("p",{className:Rt.create("welcome-text",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:"Getting a quote online is quick and easy. Simply complete the form below with your details, and we'll provide you with a personalied quote. Our secure platform ensures your information is protected every step of the way."}),Qe("hr",{className:Rt.create("welcome-border",{marginTop:$t.spacing.lg,borderColor:$t.colors.border})})]})}function pa({title:e,description:t}){return Qe(cs,{title:e,description:t,children:Qe(qt,{children:Qe(hs,{className:Rt.name("error-container"),children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:"lucide lucide-ban-icon lucide-ban",children:[Qe("path",{d:"M4.929 4.929 19.07 19.071"}),Qe("circle",{cx:"12",cy:"12",r:"10"})]})})})})}function ga({errors:e,className:t}){return e&&0!==e.length?Qe("div",{className:Rt.create("field-error",{color:$t.colors.destructive,fontSize:$t.fontSize.small,marginTop:"0.25rem",display:"flex",flexDirection:"column",gap:"0.125rem"}),children:e.map((e,t)=>Qe("span",{className:Rt.create("field-error-message",{lineHeight:"1.4"}),children:e.message},t))}):null}function ya({htmlFor:e,label:t,children:n,required:r,tooltip:i,...o}){const[s,a]=ut({visible:!1,top:0,left:0,flipped:!1}),l=mt(null),c=pt(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect(),n=!(t.top>68),r=n?t.bottom+8:t.top-8,i=t.left+t.width/2;a({visible:!0,top:r,left:i,flipped:n})},[]),d=pt(()=>{a(e=>({...e,visible:!1}))},[]);return Qe("label",{for:e,className:Rt.create("label",{display:"flex",flexDirection:"column",minWidth:"0"}),...o,children:[Qe("span",{className:Rt.create("label-text",{marginBottom:$t.spacing.sm,fontSize:$t.fontSize.default,fontWeight:"600",display:"flex",alignItems:"center",gap:$t.spacing.sm,color:$t.colors.foreground}),children:[Qe("span",{children:r?Qe(_,{children:[t.includes(" ")?t.substring(0,t.lastIndexOf(" ")+1):"",Qe("span",{style:{whiteSpace:"nowrap"},children:[t.includes(" ")?t.substring(t.lastIndexOf(" ")+1):t,Qe("span",{className:Rt.create("label-required-indicator",{color:$t.colors.destructive}),children:"*"})]})]}):t}),i&&Qe("span",{ref:l,className:Rt.create("tooltip-container",{position:"relative",display:"inline-flex"}),onMouseEnter:c,onMouseLeave:d,children:[Qe("svg",{className:Rt.create("tooltip-icon",{width:"1rem",height:"1rem",color:$t.colors.mutedForeground,cursor:"help"}),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[Qe("circle",{cx:"12",cy:"12",r:"10",strokeWidth:"2"}),Qe("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Qe("circle",{cx:"12",cy:"17",r:"0.5",fill:"currentColor",strokeWidth:"0"})]}),s.visible&&Qe("span",{style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,transform:s.flipped?"translateX(-50%)":"translateX(-50%) translateY(-100%)",padding:"0.5rem 0.75rem",backgroundColor:$t.colors.popover,color:$t.colors.popoverForeground,fontSize:"0.875rem",borderRadius:$t.radius.default,whiteSpace:"normal",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",zIndex:1e4,minWidth:"200px",maxWidth:"300px",pointerEvents:"none"},children:[i,Qe("span",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",width:"0",height:"0",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...s.flipped?{bottom:"100%",borderBottom:`6px solid ${$t.colors.popover}`}:{top:"100%",borderTop:`6px solid ${$t.colors.popover}`}}})]})]})]}),n]})}function va(e){const t={"(max-width: 600px)":{gridColumn:"span 12 / span 12"}};switch(null!=e?e:100){case 25:return Rt.create("field-wrapper-25",{gridColumn:"span 3 / span 3"},t);case 33:return Rt.create("field-wrapper-33",{gridColumn:"span 4 / span 4"},t);case 50:return Rt.create("field-wrapper-50",{gridColumn:"span 6 / span 6"},t);case 66:return Rt.create("field-wrapper-66",{gridColumn:"span 8 / span 8"},t);case 75:return Rt.create("field-wrapper-75",{gridColumn:"span 9 / span 9"},t);default:return Rt.create("field-wrapper-100",{gridColumn:"span 12 / span 12"})}}function wa(e){return e?e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=n.trim();return r.match(/^(https?:\/\/|mailto:)/i)?`<a href="${r}" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:text-blue-800 underline">${t}</a>`:e}):""}function ba({code:e,isOpen:t,onClose:n}){var r,i;const{httpClient:o}=Yt(e=>({httpClient:e.httpClient})),[s,a]=ut(null!==(r=J(e))&&void 0!==r?r:null),[l,c]=ut(null),[d,u]=ut(!1);ht(()=>{if(!t)return;const n=J(e);n?a(n):(u(!0),c(null),o.getDocument(e).then(t=>{var n;const r=null!==(n=null==t?void 0:t.data)&&void 0!==n?n:t,i={name:r.name,content:r.content};!function(e,t){Q.set(e,t)}(e,i),a(i),u(!1)}).catch(e=>{c(e instanceof Error?e.message:"Unable to load document."),u(!1)}))},[t,e,o]);const h=Rt.create("document-modal-body",{fontSize:$t.fontSize.small,lineHeight:"1.55",color:$t.colors.foreground});return Rt.pseudoElement("document-modal-body"," p",{margin:"0 0 0.85em"}),Rt.pseudoElement("document-modal-body"," p:last-child",{marginBottom:"0"}),Rt.pseudoElement("document-modal-body"," ul",{margin:"0 0 0.85em",paddingLeft:"1.25em"}),Rt.pseudoElement("document-modal-body"," li",{marginBottom:"0.25em"}),Qe(Hs,{isOpen:t,onClose:n,title:null!==(i=null==s?void 0:s.name)&&void 0!==i?i:"Loading...",width:"720px",children:[d&&Qe("p",{style:{margin:0,color:"#6b7280"},children:"Loading…"}),l&&Qe("p",{style:{margin:0,color:"#b91c1c"},children:l}),!d&&!l&&s&&Qe("div",{className:h,children:Qe(ms,{source:s.content})})]})}function xa({field:e,errors:t,children:n,className:r}){const i=e.code||e.id,o=(null==t?void 0:t.filter(e=>e.field===i))||[],[s,a]=ut(!1),l=Rt.create("validated-field",{display:"flex",flexDirection:"column",gap:$t.spacing.sm,minWidth:"0"});if("notice"===e.type){const t=Rt.create("notice-field",{display:"flex",gap:$t.spacing.sm,padding:$t.spacing.md,backgroundColor:$t.colors.accent,borderRadius:$t.radius.default,border:`1px solid ${$t.colors.border}`}),n=Rt.create("notice-icon",{flexShrink:"0",fontSize:$t.fontSize.default,lineHeight:"1.6"}),r=Rt.create("notice-text",{fontSize:$t.fontSize.small,color:$t.colors.foreground,lineHeight:"1.6"});return Qe("div",{className:Lt(va(e.width)),children:Qe("div",{className:t,children:[Qe("span",{className:n,children:"ⓘ"}),Qe("div",{className:r,children:[e.label&&Qe("strong",{children:e.label}),e.label&&e.description&&Qe("br",{}),e.description&&Qe("span",{children:e.description})]})]})})}if("section"===e.type){const t=Rt.create("section-separator",{display:"flex",alignItems:"center",gap:$t.spacing.md}),n=Rt.create("section-line",{flex:"1",height:"1px",backgroundColor:$t.colors.border}),r=Rt.create("section-title",{fontSize:$t.fontSize.small,fontWeight:"600",color:$t.colors.mutedForeground,whiteSpace:"nowrap"});return Qe("div",{className:Lt(va(e.width)),children:Qe("div",{className:t,children:e.label?Qe(_,{children:[Qe("div",{className:n}),Qe("span",{className:r,children:e.label}),Qe("div",{className:n})]}):Qe("div",{className:n})})})}if("checkbox"===e.type){const t=Rt.create("checkbox-field-container",{display:"flex",flexDirection:"column",gap:$t.spacing.sm}),c=Rt.create("checkbox-field-row",{display:"flex",alignItems:"flex-start",gap:"0.75rem",cursor:"pointer"}),d=Rt.create("checkbox-field-control",{display:"flex",cursor:"pointer",paddingTop:"0.125rem"}),u=Rt.create("checkbox-field-label",{display:"flex",flexDirection:"column",gap:"0.25rem",flex:"1"}),h=Rt.create("checkbox-label-text",{fontSize:$t.fontSize.default,fontWeight:"600",color:$t.colors.foreground,lineHeight:"1.4"});return Qe("div",{className:Lt(l,va(e.width),r),children:[Qe("div",{className:t,children:Qe("div",{className:c,children:[Qe("label",{htmlFor:i,className:d,children:n}),Qe("label",{htmlFor:i,className:u,children:[Qe("span",{className:h,children:[e.label,e.required&&Qe(_,{children:[" ",Qe("span",{className:Rt.create("checkbox-required-indicator",{color:$t.colors.destructive}),children:"*"})]})]}),e.description&&Qe("div",{className:Rt.create("checkbox-field-description",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,lineHeight:"1.6"}),dangerouslySetInnerHTML:{H:wa(e.description)}}),e.document_code&&Qe("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),a(!0)},className:Rt.create("checkbox-field-doc-link",{alignSelf:"flex-start",background:"none",border:"none",padding:0,margin:0,cursor:"pointer",fontSize:$t.fontSize.small,color:$t.colors.primary,textDecoration:"underline"}),children:"View document"})]})]})}),Qe(ga,{errors:o}),e.document_code&&Qe(ba,{code:e.document_code,isOpen:s,onClose:()=>a(!1)})]})}return Qe("div",{className:Lt(l,va(e.width),r),children:[Qe(ya,{htmlFor:i,label:e.label,required:e.required,tooltip:e.tooltip,children:[e.description&&Qe("div",{className:Rt.create("field-description",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginBottom:$t.spacing.sm,lineHeight:"1.6"}),dangerouslySetInnerHTML:{H:wa(e.description)}}),n]}),Qe(ga,{errors:o})]})}function ka({error:e,onDismiss:t,className:n}){const r=globalThis.insureOSDebug,i={warning:{backgroundColor:$t.colors.muted,borderColor:$t.colors.border,accentColor:$t.colors.mutedForeground,titleColor:$t.colors.foreground},error:{backgroundColor:$t.colors.destructive+"0A",borderColor:$t.colors.destructive+"30",accentColor:$t.colors.destructive,titleColor:$t.colors.foreground},critical:{backgroundColor:$t.colors.destructive+"0A",borderColor:$t.colors.destructive+"40",accentColor:$t.colors.destructive,titleColor:$t.colors.foreground}}[e.severity],o=Rt.create("error-card",{padding:`${$t.spacing.sm} ${$t.spacing.md}`,borderRadius:$t.radius.default,border:`1px solid ${i.borderColor}`,backgroundColor:i.backgroundColor,marginInline:$t.spacing.lg,marginBlock:$t.spacing.md}),s=Rt.create("error-card-header",{display:"flex",alignItems:"flex-start",gap:$t.spacing.sm}),a=Rt.create("error-card-icon",{width:"1rem",height:"1rem",color:i.accentColor,flexShrink:"0",marginTop:"0.15rem"}),l=Rt.create("error-card-content-wrapper",{flex:"1",minWidth:"0",display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"0.75rem"}),c=Rt.create("error-card-content",{flex:"1",minWidth:"0",display:"flex",flexDirection:"column",gap:"0.5rem"}),d=Rt.create("error-card-title",{fontSize:$t.fontSize.default,fontWeight:"600",color:i.titleColor,lineHeight:"1.4"}),u=Rt.create("error-card-message",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,lineHeight:"1.5"}),h=Rt.create("error-card-details",{fontSize:"0.8125rem",color:$t.colors.mutedForeground,fontFamily:"monospace",backgroundColor:$t.colors.muted,padding:"0.625rem",borderRadius:$t.radius.small,wordBreak:"break-word",lineHeight:"1.4"}),m=Rt.create("error-card-support",{fontSize:"0.8125rem",color:$t.colors.mutedForeground,lineHeight:"1.4"}),f=Rt.create("error-card-dismiss",{padding:"0.125rem",border:"none",backgroundColor:"transparent",color:$t.colors.mutedForeground,cursor:"pointer",borderRadius:$t.radius.small,lineHeight:"1",display:"flex",alignItems:"center",justifyContent:"center",width:"1.5rem",height:"1.5rem",flexShrink:"0",marginTop:"-0.125rem",transition:$t.transition});return Rt.pseudoElement("error-card-dismiss",":hover",{backgroundColor:$t.colors.muted,color:$t.colors.foreground}),Qe("div",{className:Lt(o,n),children:Qe("div",{className:s,children:[Qe(()=>"warning"===e.severity?Qe("svg",{className:a,fill:"currentColor",viewBox:"0 0 20 20",children:Qe("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}):Qe("svg",{className:a,fill:"currentColor",viewBox:"0 0 20 20",children:Qe("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),{}),Qe("div",{className:l,children:[Qe("div",{className:c,children:[Qe("div",{className:d,children:e.title}),Qe("div",{className:u,children:e.message}),r&&e.details&&Qe("div",{className:h,children:e.details}),Qe("div",{className:m,children:De(e)})]}),t&&Qe("button",{className:f,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":"Dismiss error",title:"Dismiss",type:"button",children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{pointerEvents:"none"},children:[Qe("path",{d:"M18 6 6 18"}),Qe("path",{d:"m6 6 12 12"})]})})]})]})})}function Sa(){var t,n;const{definition:r,currentPageIndex:i,totalPages:o,validationErrors:s,generalErrors:a,quoteIntent:l,isSaving:c,fsm:d}=Yt(e=>({definition:e.getFormDefinition(),currentPageIndex:e.getCurrentPageIndex(),totalPages:e.getTotalPages(),results:e.getCalculationResult(),validationErrors:e.getValidationErrors(),generalErrors:e.getGeneralErrors(),quoteIntent:e.getQuoteIntent(),isSaving:e.getIsSaving()})),{httpClient:u,urlPromoCode:h}=Ut(),[m,f]=ut({status:"idle"}),[p,g]=ut(""),y=pt(async t=>{const n=null!=t?t:p;if(n&&n.trim()){if((null==l?void 0:l.id)&&u){f({status:"validating"});try{const e=await u.validatePromoCode(l.id,n.trim());e.valid?f({status:"valid",name:e.name||n}):f({status:"invalid",message:e.message})}catch(t){e(),f({status:"invalid",message:"Unable to validate promo code"})}}}else f({status:"idle"})},[null==l?void 0:l.id,u,p]),v=pt(e=>{"Enter"===e.key&&(e.preventDefault(),y())},[y]),w=mt(!1);ht(()=>{h&&!w.current&&(null==l?void 0:l.id)&&u&&(w.current=!0,g(h),(async()=>{try{const e=await u.validatePromoCode(l.id,h.trim());if(e.valid){f({status:"valid",name:e.name||h});const t=d.getFormDefinition().pages.find(e=>e.fields.some(e=>"promo_code"===(e.code||e.id)));t&&d.updateFieldValue(t.id,"promo_code",h)}else{g("");const e=d.getFormDefinition().pages.find(e=>e.fields.some(e=>"promo_code"===(e.code||e.id)));e&&d.updateFieldValue(e.id,"promo_code","")}}catch(e){g("")}})())},[h,null==l?void 0:l.id,u]);const b=r.pages[i];if(!b)return Qe(pa,{title:"Unexpected Error",description:"No page available"});const x=mt(new Map),k=(e,t)=>{var n;const r=d.getFormProgress().page_data[b.id],i=null==r?void 0:r[e];if(null!=i&&""!==i)return i;if(t&&("date"===t.type||"monthyear"===t.type)&&(null===(n=t.validation)||void 0===n?void 0:n.defaultDate)){const n=S(t.validation.defaultDate,"monthyear"===t.type);if(n)return d.updateFieldValue(b.id,e,n),n}return""},S=(e,t)=>{var n;const r=(null===(n=null==l?void 0:l.organisation)||void 0===n?void 0:n.timezone)||"Pacific/Auckland",i=(new Date).toLocaleString("en-US",{timeZone:r}),o=new Date(i);let s=new Date(i);switch(e){case"today":s=o;break;case"+1week":s.setDate(o.getDate()+7);break;case"+1month":s.setMonth(o.getMonth()+1);break;case"+1year":s.setFullYear(o.getFullYear()+1);break;default:return""}const a=s.getFullYear(),c=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return t?`${a}-${c}-01`:`${a}-${c}-${d}`},N=e=>{const t=d.getFormProgress().page_data[b.id];return((null==t?void 0:t.U)||{})[e]||""},_=d.getFormProgress(),C={};Object.values(_.page_data).forEach(e=>{const{U:t,...n}=e;Object.assign(C,n),t&&Object.keys(t).length>0&&(C.U||(C.U={}),Object.assign(C.U,t))});const $=t=>{if(!t.visibility)return!0;const n=t.visibility.conditions.map(e=>"field"in e?e.field:null).filter(Boolean);n.length>0&&(e((t.label,t.code)),e(Object.keys(C)),n.forEach(t=>{t&&e((C[t],C[t]))}));const r=me(C,{condition_type:t.visibility.condition_type,conditions:t.visibility.conditions}),i="show"===t.visibility.action?r.matched:!r.matched;return x.current.get(t.id)!==i&&(e((t.label,t.code)),e(),x.current.set(t.id,i)),i},I=(()=>{for(const e of b.fields)if(e.blocker&&$(e))if(e.blocker.conditions&&e.blocker.conditions.length>0){if(me(C,{condition_type:e.blocker.condition_type||"or",conditions:e.blocker.conditions}).matched)return{field:e,config:e.blocker}}else if(void 0!==e.blocker.trigger_value){const t=e.code||e.id,n=k(t,e);if(String(n)===String(e.blocker.trigger_value))return{field:e,config:e.blocker}}return null})(),T=null==l?void 0:l.payment_return,E=T&&("declined"===T.paymentStatus||"cancelled"===T.paymentStatus||"error"===T.paymentStatus),P=d.getFormProgress().completed_pages||[];return Qe(cs,{title:b.title,description:b.description,hideHeader:!0,children:Qe("div",{children:[E&&Qe(Bs,{type:T.paymentStatus,transactionId:T.paymentTransactionId||void 0,clientSettings:null===(t=null==l?void 0:l.organisation)||void 0===t?void 0:t.client_settings,gatewayCode:null===(n=T.transactionStatus)||void 0===n?void 0:n.gateway_code,isOpen:!0,onClose:()=>{d.updateQuoteIntent({payment_return:void 0})}}),Qe(qt,{children:[Qe("div",{className:Rt.create("form-layout",{display:"grid",gridTemplateColumns:"1fr 320px",gap:$t.spacing.lg},{"(max-width: 950px)":{display:"flex",flexDirection:"column",gap:$t.spacing.sm}}),children:[Qe("div",{className:Rt.create("form-content-wrapper",{minWidth:"0",backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,display:"flex",flexDirection:"column",minHeight:"100%"},{"(max-width: 950px)":{minHeight:"auto"}}),children:[Qe("div",{className:Rt.create("mobile-sidebar-container",{display:"none"},{"(max-width: 950px)":{display:"block"}}),children:Qe(ha,{pages:r.pages,currentPageIndex:i,completedPages:P})}),i>0&&Qe("div",{className:Rt.create("page-heading-container",{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},{"(max-width: 950px)":{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingTop:$t.spacing.md}}),children:[Qe("div",{className:Rt.create("page-heading-content",{display:"flex",alignItems:"center",justifyContent:"space-between",gap:$t.spacing.lg}),children:Qe("div",{className:Rt.create("page-heading-text",{flex:"1",minWidth:"0"}),children:[Qe("h1",{className:Rt.create("page-template-title",{margin:"0",fontSize:"1.5rem",fontWeight:"700",lineHeight:"1.3",color:$t.colors.primary,letterSpacing:"-0.025em"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:b.title}),b.description&&Qe("p",{className:Rt.create("page-template-description",{margin:"0",marginTop:$t.spacing.sm,fontSize:$t.fontSize.small,lineHeight:"1.5",color:$t.colors.foreground,opacity:"0.7"}),children:b.description})]})}),Qe("hr",{className:Rt.create("page-heading-border",{marginTop:$t.spacing.lg,border:"0",borderTop:`1px solid ${$t.colors.border}`,height:"0"})})]}),0===i&&(null==l?void 0:l.organisation)&&Qe(fa,{organisation:l.organisation}),a.length>0&&a.map(e=>Qe(ka,{error:e,onDismiss:()=>d.dismissGeneralError(e.id)},e.id)),Qe("div",{className:Rt.create("form-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.lg,boxShadow:$t.shadow.sm,display:"flex",flexDirection:"column",gap:$t.spacing.xl,flex:"1",minWidth:"0",overflow:"hidden"},{"(max-width: 950px)":{padding:$t.spacing.md,gap:$t.spacing.lg,flex:"initial"},"(max-width: 480px)":{padding:$t.spacing.md,gap:$t.spacing.md}}),children:[Qe("form",{onSubmit:e=>e.preventDefault(),className:Rt.create("form-fields-container",{flex:"1"},{"(max-width: 950px)":{flex:"initial"}}),children:Qe("div",{className:Rt.create("form-content-page",{display:"grid",gap:$t.spacing.md,rowGap:$t.spacing.lg,gridTemplateColumns:"repeat(12, minmax(0, 1fr))",minWidth:"0"},{"(max-width: 600px)":{display:"flex",flexDirection:"column"}}),children:b.fields.map(e=>{const t=e.code||e.id,n="promo_code"===t;if(!$(e))return null;if("section"===e.type)return Qe(xa,{field:e,errors:[],children:Qe("span",{})},e.id);if("notice"===e.type)return Qe(xa,{field:e,errors:[],children:Qe("span",{})},e.id);const r="validating"===m.status,i=n?Qe("button",{type:"button",onClick:()=>y(),disabled:!p.trim()||r,style:{height:"2.75rem",minWidth:"5rem",padding:"0 1rem",fontSize:$t.fontSize.small,backgroundColor:$t.colors.primary,color:$t.colors.primaryForeground,border:"none",borderRadius:$t.radius.default,cursor:p.trim()&&!r?"pointer":"not-allowed",opacity:p.trim()&&!r?1:.5,whiteSpace:"nowrap"},children:r?Qe(Bt,{size:"small"}):"Apply"}):void 0,o=!n||"valid"!==m.status&&"invalid"!==m.status?null:Qe("div",{style:{marginTop:"0.5rem"},children:["valid"===m.status&&Qe("span",{style:{color:"#22c55e",fontSize:$t.fontSize.small,display:"flex",alignItems:"center",gap:"0.25rem"},children:[Qe("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:Qe("path",{d:"M20 6 9 17l-5-5"})}),'Promo code "',m.name,'" applied']}),"invalid"===m.status&&Qe("span",{style:{color:$t.colors.destructive,fontSize:$t.fontSize.small,display:"flex",alignItems:"center",gap:"0.25rem"},children:[Qe("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Qe("circle",{cx:"12",cy:"12",r:"10"}),Qe("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),Qe("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m.message]})]});return Qe(xa,{field:e,errors:s,children:[Qe(sa,{value:k(t,e).toString(),onChange:r=>{let i=r;"boolean"!==e.type&&"checkbox"!==e.type||(i="true"===r),d.updateFieldValue(b.id,t,i),n&&(g(r),f({status:"idle"}))},onKeyDown:n?v:void 0,answer:N(t),onAnswerChange:n=>{var r;d.updateFieldAnswer(b.id,t,n,null===(r=e.boolean_config)||void 0===r?void 0:r.details_rating_factor_id)},id:t,name:t,type:e.type,placeholder:e.placeholder,required:e.required,options:e.options,validation:e.validation,booleanConfig:e.boolean_config,add_null_option:e.add_null_option,null_option_label:e.null_option_label,inline:e.inline,hasError:d.hasFieldErrors(t),errors:d.getFieldErrors(t),suffix:i}),o]},e.id)})})}),I&&Qe("div",{className:Rt.create("form-blocker",{backgroundColor:$t.colors.accent,borderRadius:$t.radius.default,padding:$t.spacing.lg}),children:[Qe("h3",{className:Rt.create("form-blocker-title",{margin:"0",marginBottom:$t.spacing.sm,fontSize:"1.125rem",fontWeight:"600",color:$t.colors.accentForeground}),children:I.config.title}),Qe("p",{className:Rt.create("form-blocker-message",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.accentForeground,opacity:"0.9"}),children:I.config.message}),I.config.link&&Qe("a",{href:I.config.link.url,target:"_blank",rel:"noopener noreferrer",className:Rt.create("form-blocker-link",{display:"inline-flex",alignItems:"center",gap:"0.375rem",marginTop:$t.spacing.md,fontSize:$t.fontSize.default,fontWeight:"600",color:$t.colors.primary,textDecoration:"none"}),children:[I.config.link.label,Qe("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Qe("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),Qe("polyline",{points:"15 3 21 3 21 9"}),Qe("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})]}),Qe("hr",{className:Rt.create("form-navigation-border",{border:"0",borderTop:`1px solid ${$t.colors.border}`,height:"0"})}),Qe("div",{className:0===i?Rt.create("form-navigation-inline-first",{paddingTop:$t.spacing.lg,display:"flex",alignItems:"center",justifyContent:"flex-end"}):Rt.create("form-navigation-inline",{paddingTop:$t.spacing.lg,display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[i>0&&Qe(us,{onClick:()=>null==d?void 0:d.navigateToPreviousPage(),variant:"outline",children:"Back"}),!I&&Qe(us,{onClick:async function(){d.validateCurrentPage().length>0||(i===o-1?await(null==d?void 0:d.calculateQuote()):await(null==d?void 0:d.navigateToNextPage()))},disabled:c,loading:c,children:i===o-1?"Get Quote":"Continue"})]})]})]}),Qe("div",{className:Rt.create("form-sidebar",{display:"block"},{"(max-width: 950px)":{display:"none"}}),children:Qe(ua,{pages:r.pages,currentPageIndex:i,completedPages:P})}),Qe("div",{className:Rt.create("form-mobile-actions",{display:"none"},{"(max-width: 950px)":{display:"block"}}),children:Qe(ma,{pages:r.pages,completedPages:P})})]}),(null==l?void 0:l.reference)&&Qe("p",{className:Rt.create("form-quote-reference",{margin:"0",marginTop:$t.spacing.md,textAlign:"center",fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:["Quote reference: ",Qe("strong",{style:{color:$t.colors.foreground,fontWeight:600},children:l.reference})]})]})]})})}function Na(){var e,t,n,r,i,o,s;const{quoteIntent:a,fsm:l}=Yt(e=>({quoteIntent:e.getQuoteIntent(),fsm:e})),c=null==a?void 0:a.payment_return,d=null==c?void 0:c.paymentTransactionId,u=null==c?void 0:c.transactionStatus,h=null===(e=null==a?void 0:a.organisation)||void 0===e?void 0:e.name,m=null===(t=null==a?void 0:a.organisation)||void 0===t?void 0:t.admin_email,f=null===(n=null==a?void 0:a.organisation)||void 0===n?void 0:n.phone,p=m||f,g=null===(r=null==a?void 0:a.payment_transactions)||void 0===r?void 0:r.find(e=>"completed"===e.status),y=null!==(i=null==u?void 0:u.gateway_code)&&void 0!==i?i:null==g?void 0:g.gateway_code,v=vs(null===(o=null==a?void 0:a.organisation)||void 0===o?void 0:o.client_settings,"payment_success",y);ht(()=>{if(d&&a){const e=null==c?void 0:c.paymentStatus,t=null==u?void 0:u.amount;"success"===e&&u?He(a,d,t||0,u.gateway_code,t,void 0):e&&["declined","cancelled","error"].includes(e)&&Ue(a,d,t,null==u?void 0:u.gateway_code,e,null==u?void 0:u.status)}const e=setTimeout(()=>{null==l||l.clearStoredQuoteIntent()},2e3);return()=>clearTimeout(e)},[l,d,c,a]);const w=Rt.create("success-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:$t.spacing.lg},"(max-width: 480px)":{padding:$t.spacing.md}}),b=Rt.create("success-icon-container",{display:"flex",justifyContent:"center",marginBottom:$t.spacing.lg}),x=Rt.create("success-icon",{width:"5rem",height:"5rem",borderRadius:"50%",backgroundColor:"#10b981",color:"white",display:"flex",alignItems:"center",justifyContent:"center"}),k=Rt.create("success-header",{textAlign:"center",marginBottom:$t.spacing.xl}),S=Rt.create("success-title",{margin:"0",marginBottom:$t.spacing.sm,fontSize:"2rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),N=Rt.create("success-message",{fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9",margin:"0 auto",maxWidth:"450px",paddingLeft:$t.spacing.md,paddingRight:$t.spacing.md}),_=Rt.create("success-contact-section",{borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.xl,marginTop:$t.spacing.xl}),C=Rt.create("success-contact-title",{fontSize:"1.125rem",fontWeight:"600",color:$t.colors.foreground,marginBottom:$t.spacing.md,textAlign:"center"}),$=Rt.create("success-contact-details",{backgroundColor:$t.colors.accent,borderRadius:$t.radius.default,padding:$t.spacing.md,display:"flex",flexDirection:"column",gap:$t.spacing.sm,marginBottom:$t.spacing.lg}),I=Rt.create("success-contact-item",{display:"flex",alignItems:"center",gap:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.accentForeground}),T=Rt.create("success-actions",{display:"flex",gap:$t.spacing.md,flexWrap:"wrap",justifyContent:"center"}),E=Rt.create("success-reference",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,textAlign:"center",marginTop:$t.spacing.md});return Qe(cs,{title:"Payment Successful",description:"Your payment has been processed successfully",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe(hs,{children:Qe("div",{className:w,children:[Qe("div",{className:b,children:Qe("div",{className:x,children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M20 6 9 17l-5-5"})})})}),Qe("div",{className:k,children:[Qe("h1",{className:S,children:null!==(s=v.title)&&void 0!==s?s:"Payment Complete!"}),v.body?Qe(ms,{source:v.body,className:N}):Qe("p",{className:N,children:["Your payment has been processed successfully and your policy is being set up. You will receive your policy documentation by email."," ","For now, you can relax knowing you're ",h?`covered by ${h}`:"covered","."]})]}),p&&Qe("div",{className:_,children:[Qe("h3",{className:C,children:"Need assistance?"}),Qe("div",{className:$,children:[m&&Qe("div",{className:I,children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Qe("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Qe("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Qe("span",{children:m})]}),f&&Qe("div",{className:I,children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),Qe("span",{children:f})]})]}),Qe("div",{className:T,children:[f&&Qe(us,{variant:"outline",onClick:()=>window.open(`tel:${f}`),children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Qe("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),"Call Us"]}),m&&Qe(us,{variant:"outline",onClick:()=>window.open(`mailto:${m}`),children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Qe("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Qe("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Email Us"]})]})]}),a.reference&&Qe("div",{className:E,children:["Quote Reference: ",Qe("strong",{children:a.reference})]})]})})})})}function _a({isOpen:e,onClose:t,onSuccess:n,paymentRequest:r,httpClient:i}){const[o,s]=ut("initiating"),[a,l]=ut(null),[c,d]=ut(null),[u,h]=ut(null);ht(()=>{e&&r&&m()},[e,r]);const m=async()=>{var e;if(r)try{s("initiating"),l(null);const t={...r,returnUrl:window.location.href},n=null===(e=r.metadata)||void 0===e?void 0:e.gateway;if(!n)throw new Error("Payment gateway not found");const o=await i.initiatePayment(t,n);h(o.transaction_id),s("redirecting"),window.location.href=o.gateway_acceptance_url}catch(e){l(e.message||"Failed to initiate payment"),s("failed")}},f=()=>{c&&!c.closed&&c.close(),s("initiating"),l(null),h(null),d(null),t()};return e?Qe("div",{className:Rt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),children:[Qe("div",{className:Rt.create("modal-content",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:"2rem",minWidth:"400px",maxWidth:"500px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${$t.colors.border}`}),children:[Qe("div",{className:Rt.create("modal-header",{textAlign:"center",marginBottom:"1.5rem"}),children:[Qe("div",{className:Rt.create("status-icon",{fontSize:"3rem",marginBottom:"1rem"}),children:(()=>{switch(o){case"completed":return"✅";case"cancelled":return"❌";case"failed":return"⚠️";default:return"⏳"}})()}),Qe("h2",{className:Rt.create("modal-title",{margin:"0",color:$t.colors.foreground,fontSize:$t.fontSize.large}),children:"Payment Processing"})]}),Qe("div",{className:Rt.create("modal-body",{textAlign:"center",marginBottom:"2rem"}),children:[Qe(ks,{className:Rt.create("status-message",{fontSize:$t.fontSize.default,color:$t.colors.mutedForeground,marginBottom:"1rem"}),children:(()=>{switch(o){case"initiating":return"Setting up your payment...";case"redirecting":return"Redirecting to payment portal...";case"processing":default:return"Processing payment...";case"polling":return"Checking payment status...";case"completed":return"Payment completed successfully!";case"cancelled":return"Payment was cancelled";case"failed":return"Payment failed"}})()}),a&&Qe(ks,{className:Rt.create("error-message",{color:$t.colors.destructive,fontSize:$t.fontSize.small,padding:"0.75rem",backgroundColor:$t.colors.destructive+"10",borderRadius:$t.radius.default,border:`1px solid ${$t.colors.destructive}30`}),children:a}),("redirecting"===o||"initiating"===o)&&Qe("div",{className:Rt.create("loading-indicator",{display:"inline-block",width:"20px",height:"20px",marginTop:"1rem",border:`3px solid ${$t.colors.border}`,borderTop:`3px solid ${$t.colors.primary}`,borderRadius:"50%",animation:"spin 1s linear infinite"})})]}),Qe("div",{className:Rt.create("modal-actions",{display:"flex",gap:"1rem",justifyContent:"center"}),children:"failed"===o||"cancelled"===o?Qe(_,{children:[Qe(us,{onClick:f,variant:"outline",children:"Close"}),"cancelled"===o&&Qe(us,{onClick:()=>{s("initiating"),l(null),m()},children:"Try Again"})]}):Qe(us,"completed"===o?{onClick:f,children:"Continue"}:{onClick:f,variant:"outline",disabled:"initiating"===o,children:"Cancel"})})]}),Qe("style",{children:"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "})]}):null}function Ca({transactionId:e,organisationId:t,allowCancel:n=!0,clientSettings:r=null}){var i,o,s,a,l,c;const{httpClient:d,formStateManager:u}=Ut(),h=null!==(o=null===(i=null==u?void 0:u.getQuoteIntent)||void 0===i?void 0:i.call(u))&&void 0!==o?o:null,m=null!==(a=null!=r?r:null===(s=null==h?void 0:h.organisation)||void 0===s?void 0:s.client_settings)&&void 0!==a?a:null,f=vs(m,"bank_transfer","bank_transfer"),p=(()=>{var e,t,n,r,i,o;const s=null===(n=null===(t=null===(e=null==m?void 0:m.status_pages)||void 0===e?void 0:e.per_gateway)||void 0===t?void 0:t.bank_transfer)||void 0===n?void 0:n.bank_transfer,a=null===(i=null===(r=null==m?void 0:m.status_pages)||void 0===r?void 0:r.default)||void 0===i?void 0:i.bank_transfer;return null!==(o=null!=s?s:a)&&void 0!==o?o:{}})(),g={title:null==p?void 0:p.instructions_title,body:null==p?void 0:p.instructions_body},[y,v]=ut(!0),[w,b]=ut(null),[x,k]=ut(null),[S,N]=ut(!1),[C,$]=ut(!1),[I,T]=ut(!1);ht(()=>{E()},[e]);const E=async()=>{try{if(v(!0),b(null),!d)throw new Error("HTTP client not available");const n=d.getBaseUrl(),r=await fetch(`${n}/payments/bank-transfer/${e}?orgId=${t}`);if(!r.ok)throw new Error(`Failed to load bank transfer details: ${r.statusText}`);const i=await r.json(),o=i.data||i;k({bank_account_name:o.bank_account_name,bank_account_number:o.bank_account_number,instructions_html:o.instructions_html,reference:o.reference,amount:Number(o.amount),currency:o.currency})}catch(e){b(e.message||"Failed to load bank transfer details")}finally{v(!1)}};return y?Qe(ds,{message:"Loading payment details..."}):w?Qe(cs,{title:"Error",description:"Failed to load bank transfer details",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe(hs,{children:Qe("div",{className:Rt.create("error-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto",textAlign:"center"},{"(max-width: 480px)":{padding:$t.spacing.lg}}),children:[Qe("div",{className:Rt.create("error-icon",{fontSize:"3rem",marginBottom:$t.spacing.md,color:$t.colors.destructive}),children:"⚠️"}),Qe("h2",{className:Rt.create("error-title",{margin:"0",marginBottom:$t.spacing.sm,color:$t.colors.foreground}),children:"Error Loading Payment Details"}),Qe("p",{className:Rt.create("error-message",{color:$t.colors.mutedForeground}),children:w})]})})})}):x?Qe(cs,{title:"Bank Transfer Payment",description:"Complete your payment via bank transfer",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:[Qe(hs,{children:Qe("div",{className:Rt.create("bank-transfer-container",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,maxWidth:"42rem",margin:"0 auto",overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.1)"}),children:[Qe("div",{style:{backgroundColor:$t.colors.primary},className:Rt.create("bank-transfer-header",{color:"white",padding:"2.5rem 2rem",textAlign:"center"},{"(max-width: 480px)":{padding:"1.5rem 1rem"}}),children:[Qe("h1",{className:Rt.create("header-title",{fontSize:"1.75rem",fontWeight:"700",margin:"0",marginBottom:"0.5rem"},{"(max-width: 480px)":{fontSize:"1.25rem",marginBottom:"0.25rem"}}),children:null!==(l=f.title)&&void 0!==l?l:"Bank Transfer Payment"}),f.body?Qe(ms,{source:f.body,className:Rt.create("header-subtitle",{fontSize:"1rem",margin:"0",opacity:"0.9"},{"(max-width: 480px)":{fontSize:$t.fontSize.small}})}):Qe("p",{className:Rt.create("header-subtitle",{fontSize:"1rem",margin:"0",opacity:"0.9"},{"(max-width: 480px)":{fontSize:$t.fontSize.small}}),children:"Complete your payment using the details below"})]}),Qe("div",{className:Rt.create("bank-transfer-content",{padding:"2rem"},{"(max-width: 480px)":{padding:"1rem"}}),children:[Qe("div",{className:Rt.create("payment-details-card",{backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:$t.radius.default,padding:"1.5rem",marginBottom:"1.5rem"},{"(max-width: 480px)":{padding:"1rem",marginBottom:"1rem"}}),children:[Qe("div",{className:Rt.create("detail-row-amount",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0",borderBottom:"1px solid #e5e7eb"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.5rem"}}),children:[Qe("span",{className:Rt.create("detail-label",{color:"#6b7280",fontSize:$t.fontSize.default}),children:"Amount to Transfer"}),Qe("span",{className:Rt.create("detail-value-amount",{color:$t.colors.primary,fontSize:"1.5rem",fontWeight:"700"},{"(max-width: 480px)":{fontSize:"1.25rem"}}),children:["$",x.amount.toFixed(2)," ",x.currency]})]}),Qe("div",{className:Rt.create("detail-row-name",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0",borderBottom:"1px solid #e5e7eb"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.25rem"}}),children:[Qe("span",{className:Rt.create("detail-label-name",{color:"#6b7280",fontSize:$t.fontSize.default}),children:"Account Name"}),Qe("span",{className:Rt.create("detail-value-name",{color:$t.colors.foreground,fontSize:$t.fontSize.default,fontWeight:"600"}),children:x.bank_account_name})]}),Qe("div",{className:Rt.create("detail-row-number",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0",borderBottom:"1px solid #e5e7eb"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.25rem"}}),children:[Qe("span",{className:Rt.create("detail-label-number",{color:"#6b7280",fontSize:$t.fontSize.default}),children:"Account Number"}),Qe("span",{className:Rt.create("detail-value-number",{color:$t.colors.foreground,fontSize:$t.fontSize.default,fontWeight:"600"}),children:x.bank_account_number})]}),Qe("div",{className:Rt.create("detail-row-ref",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 0"},{"(max-width: 480px)":{flexDirection:"column",alignItems:"flex-start",gap:"0.25rem"}}),children:[Qe("span",{className:Rt.create("detail-label-ref",{color:"#6b7280",fontSize:$t.fontSize.default}),children:"Payment Reference"}),Qe("span",{className:Rt.create("detail-value-ref",{color:$t.colors.foreground,fontSize:$t.fontSize.default,fontWeight:"600"}),children:x.reference})]})]}),Qe("div",{className:Rt.create("instructions-card",{backgroundColor:$t.colors.muted,border:`1px solid ${$t.colors.border}`,borderRadius:$t.radius.default,padding:"1.25rem",marginBottom:"1.5rem"},{"(max-width: 480px)":{padding:"1rem",marginBottom:"1rem"}}),children:[Qe("h3",{className:Rt.create("instructions-title",{margin:"0 0 0.75rem 0",fontSize:$t.fontSize.default,fontWeight:"600",color:$t.colors.foreground}),children:null!==(c=g.title)&&void 0!==c?c:"Payment Instructions"}),g.body?Qe(ms,{source:g.body,className:Rt.create("instructions-text",{margin:"0",fontSize:$t.fontSize.small,lineHeight:"1.6",color:$t.colors.foreground})}):Qe(_,{children:[Qe("p",{className:Rt.create("instructions-text",{margin:"0 0 0.75rem 0",fontSize:$t.fontSize.small,lineHeight:"1.6",color:$t.colors.foreground}),children:[Qe("strong",{children:"Important:"})," Please include the payment reference when making your transfer to ensure your payment is processed correctly."]}),Qe("p",{className:Rt.create("instructions-text",{margin:"0",fontSize:$t.fontSize.small,lineHeight:"1.6",color:$t.colors.foreground}),children:"Once we receive your payment, we will process your quote and send you a confirmation email."})]})]}),Qe("div",{className:Rt.create("button-wrapper",{textAlign:"center",marginBottom:"1.5rem",display:"flex",gap:"1rem",justifyContent:"center",flexWrap:"wrap"},{"(max-width: 480px)":{flexDirection:"column",gap:"0.75rem",marginBottom:"1rem"}}),children:[Qe("button",{onClick:()=>{N(!0)},style:{backgroundColor:$t.colors.primary},className:Rt.create("confirm-button",{color:"white",border:"none",borderRadius:$t.radius.default,padding:"0.75rem 2rem",fontSize:$t.fontSize.default,fontWeight:"600",cursor:"pointer",transition:"opacity 150ms ease"},{"(max-width: 480px)":{width:"100%",padding:"0.625rem 1.5rem"}}),children:"I've Made the Transfer"}),n&&Qe("button",{onClick:()=>{$(!0)},className:Rt.create("cancel-button",{color:"#6b7280",backgroundColor:"white",border:"2px solid #e5e7eb",borderRadius:$t.radius.default,padding:"0.75rem 2rem",fontSize:$t.fontSize.default,fontWeight:"600",cursor:"pointer",transition:"all 150ms ease"},{"(max-width: 480px)":{width:"100%",padding:"0.625rem 1.5rem"}}),children:"Cancel"})]}),Qe("p",{className:Rt.create("footer-text",{textAlign:"center",color:"#6b7280",fontSize:$t.fontSize.small,margin:"0"}),children:"Your quote has been saved. We'll process it once payment is received."})]})]})}),C&&Qe("div",{className:Rt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),onClick:()=>!I&&$(!1),children:Qe("div",{className:Rt.create("modal-content",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,maxWidth:"400px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${$t.colors.border}`,textAlign:"center"},{"(max-width: 480px)":{padding:$t.spacing.lg,margin:"0 1rem"}}),onClick:e=>e.stopPropagation(),children:[Qe("div",{className:Rt.create("warning-icon",{fontSize:"4rem",marginBottom:$t.spacing.md}),children:"⚠️"}),Qe("h3",{className:Rt.create("modal-title",{margin:"0",marginBottom:$t.spacing.sm,color:$t.colors.foreground,fontSize:$t.fontSize.large,fontWeight:"600"}),children:"Are you sure?"}),Qe("p",{className:Rt.create("modal-message",{margin:"0",marginBottom:$t.spacing.lg,color:$t.colors.foreground,lineHeight:"1.6"}),children:"This will take you back to the checkout page."}),Qe("div",{className:Rt.create("modal-buttons",{display:"flex",flexDirection:"column-reverse",gap:"0.75rem",justifyContent:"center"}),children:[Qe("button",{onClick:()=>$(!1),disabled:I,className:Rt.create("no-button",{backgroundColor:"#f3f4f6",color:$t.colors.foreground,border:"none",borderRadius:$t.radius.default,padding:`${$t.spacing.sm} ${$t.spacing.lg}`,fontSize:$t.fontSize.default,fontWeight:"500",cursor:I?"not-allowed":"pointer",transition:"opacity 150ms ease",opacity:I?"0.5":"1",width:"100%"}),children:"No, Go Back"}),Qe("button",{onClick:async()=>{if(d)try{T(!0);const n=d.getBaseUrl();if(!(await fetch(`${n}/payments/${e}/cancel-bank-transfer?orgId=${t}`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to cancel payment");window.location.reload()}catch(e){b("Failed to cancel payment. Please try again."),$(!1),T(!1)}},disabled:I,className:Rt.create("yes-button",{backgroundColor:"#ef4444",color:"white",border:"none",borderRadius:$t.radius.default,padding:`${$t.spacing.sm} ${$t.spacing.lg}`,fontSize:$t.fontSize.default,fontWeight:"500",cursor:I?"not-allowed":"pointer",transition:"opacity 150ms ease",opacity:I?"0.5":"1",width:"100%"}),children:I?"Cancelling...":"Yes, Cancel Payment"})]})]})}),S&&Qe("div",{className:Rt.create("modal-overlay",{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"}),onClick:()=>N(!1),children:Qe("div",{className:Rt.create("modal-content",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,maxWidth:"400px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)",border:`1px solid ${$t.colors.border}`,textAlign:"center"},{"(max-width: 480px)":{padding:$t.spacing.lg,margin:"0 1rem"}}),onClick:e=>e.stopPropagation(),children:[Qe("div",{className:Rt.create("success-icon",{fontSize:"4rem",marginBottom:$t.spacing.md}),children:"✓"}),Qe("h3",{className:Rt.create("modal-title",{margin:"0",marginBottom:$t.spacing.sm,color:$t.colors.primary,fontSize:$t.fontSize.large,fontWeight:"600"}),children:"Thank You!"}),Qe("p",{className:Rt.create("modal-message",{margin:"0",marginBottom:$t.spacing.lg,color:$t.colors.foreground,lineHeight:"1.6"}),children:"We'll process your payment as soon as we receive it. You'll receive a confirmation email once your coverage is activated."}),Qe("button",{onClick:()=>N(!1),className:Rt.create("close-button",{backgroundColor:$t.colors.primary,color:"white",border:"none",borderRadius:$t.radius.default,padding:`${$t.spacing.sm} ${$t.spacing.lg}`,fontSize:$t.fontSize.default,fontWeight:"500",cursor:"pointer",transition:"opacity 150ms ease"}),children:"Close"})]})})]})}):null}Rt.pseudoElement("sidebar-continue-later-button",":hover",{backgroundColor:$t.colors.muted,borderColor:$t.colors.primary,color:$t.colors.primary});class $a{static async loadTheme(t){try{if(e(t.slug),e(t.theme_url),this.loadedThemes.has(t.slug))return void e(t.slug);const n=await fetch(t.theme_url,{method:"GET",headers:{Accept:"text/css"}});if(!n.ok)throw new Error(`Failed to load theme: ${n.status} ${n.statusText}`);const r=await n.text();e(r.substring(0,200));const i=this.parseCSSContent(r);e(i.mappedVariables),e(i.classRules.length),this.applyParsedTheme(t.slug,i),this.loadedThemes.add(t.slug),e(t.slug)}catch(n){throw e(t.slug),n}}static parseCSSContent(t){e();const n={},r={};let i="";const o=t.match(/:root\s*\{([^}]+)\}/);if(o){const t=o[1];e(null==t||t.substring(0,100));const i=/--([\w-]+):\s*([^;]+);/g;let s;for(;null!==(s=i.exec(t));){const t=`--${s[1]}`,i=s[2].trim();n[t]=i;const o=this.variableMapping[t];o?(r[o]=i,e()):e()}}else e();return i=t.replace(/:root\s*\{[^}]+\}/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim(),i&&e(i.substring(0,100)),{variables:n,classRules:i,mappedVariables:r}}static applyParsedTheme(t,n){e(),Promise.resolve().then(function(){return Mt}).then(({updateBaseVariables:t})=>{Object.keys(n.mappedVariables).length>0&&(e(n.mappedVariables),t(n.mappedVariables))}).catch(()=>{e()}),n.classRules&&this.applyClassRules(t,n.classRules),this.injectOriginalCSS(t,n)}static applyClassRules(t,n){const r=document.getElementById(`insure-os-theme-classes-${t}`);if(r&&r.remove(),n.trim()){const r=document.createElement("style");r.id=`insure-os-theme-classes-${t}`,r.type="text/css",r.textContent=n,document.head.appendChild(r),e()}}static injectOriginalCSS(t,n){const r=document.getElementById(`insure-os-theme-original-${t}`);r&&r.remove();const i={};for(const[e,t]of Object.entries(n.variables))this.variableMapping[e]||(i[e]=t);if(Object.keys(i).length>0){const n=`:root {\n${Object.entries(i).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`,r=document.createElement("style");r.id=`insure-os-theme-original-${t}`,r.type="text/css",r.textContent=n,document.head.appendChild(r),e()}}static removeTheme(t){let n=!1;[`insure-os-theme-classes-${t}`,`insure-os-theme-original-${t}`].forEach(e=>{const t=document.getElementById(e);t&&(t.remove(),n=!0)}),n&&(this.loadedThemes.delete(t),e())}static isThemeLoaded(e){return this.loadedThemes.has(e)}static getLoadedThemes(){return Array.from(this.loadedThemes)}}$a.loadedThemes=new Set,$a.variableMapping={"--color-primary":"--insure-os-primary","--color-primary-foreground":"--insure-os-primary-foreground","--color-secondary":"--insure-os-secondary","--color-secondary-foreground":"--insure-os-secondary-foreground","--color-accent":"--insure-os-accent","--color-accent-foreground":"--insure-os-accent-foreground","--color-background":"--insure-os-background","--color-foreground":"--insure-os-foreground","--color-card":"--insure-os-card","--color-card-foreground":"--insure-os-card-foreground","--color-popover":"--insure-os-popover","--color-popover-foreground":"--insure-os-popover-foreground","--color-muted":"--insure-os-muted","--color-muted-foreground":"--insure-os-muted-foreground","--color-destructive":"--insure-os-destructive","--color-border":"--insure-os-border","--color-input":"--insure-os-input","--color-ring":"--insure-os-ring","--font-sans":"--insure-os-font-family","--radius":"--insure-os-radius","--radius-sm":"--insure-os-radius-sm","--radius-lg":"--insure-os-radius-lg"};var Ia=Object.freeze({__proto__:null,ThemeLoader:$a});function Ta(e,t){return"windcave"!==e?"Provider Fee:":"account2account"===t?"Account2Account surcharge:":"Credit card surcharge:"}function Ea(e){var t;return(null===(t=e.metadata)||void 0===t?void 0:t.gateway_method)?`${e.gateway_code}:${e.metadata.gateway_method}`:e.gateway_code}function Pa({paymentLinkId:t,signedUrl:n}){var r,i,o,s,a,l,c,d,u,h,m,f,p,g,y,v,w,b,x,k,S,N,C,$,I,T,E;const P=Ut().httpClient,[z,D]=ut(null),[R,M]=ut(!0),[O,j]=ut(null),[W,A]=ut(!1),[L,B]=ut(null),[q,F]=ut(null),[H,U]=ut(null),[Y,Z]=ut(!1),[G,V]=ut(null),[Q,J]=ut(null),[K,X]=ut(!0),ee="undefined"!=typeof window?new URLSearchParams(window.location.search):new URLSearchParams,[te,ne]=ut("processing"===ee.get("status")?ee.get("transactionId"):null),[re,ie]=ut(()=>Ys()),[oe,se]=ut(null),[ae,le]=ut(!1),[ce,de]=ut(null),[ue,he]=ut(null),[me,fe]=ut(null);ht(()=>{pe()},[t]);const pe=async()=>{var r,i,o;try{M(!0);const s=new URLSearchParams(window.location.search),a=s.get("transactionId"),l=s.get("status"),c=s.get("gateway_code"),d=s.get("method"),u=s.get("excess_id");a&&l&&(Z(!0),V(l),J(a)),c&&U(d?`${c}:${d}`:c);const h=n?await P.getPaymentLinkDetails(n):await P.getPaymentLinkById(t);if(h.organisation&&h.organisation.theme)try{await $a.loadTheme({slug:h.organisation.slug,theme_url:h.organisation.theme.css_url})}catch(t){e()}if("paid"===h.status&&!Y&&(!a||"completed"!==l&&"success"!==l))return D(h),void j("This payment link has already been used.");if("superseded"===h.status)return D(h),void j("This payment link has been replaced by a newer one. Please use the latest link you received.");if("confirmed"===h.status)return D(h),void he({message:"Your renewal is confirmed. Your premium funding will continue automatically on the policy start date.",effectiveDate:null===(r=h.metadata)||void 0===r?void 0:r.effective_date});if("expired"===h.status)return D(h),void j("This payment link has expired.");if("cancelled"===h.status)return D(h),void j("This payment link has been cancelled.");if("outdated"===h.status)return D(h),void j("This payment link is no longer valid because the quote has been updated. Please request a new payment link.");const m=Array.isArray(h.payment_options)&&h.payment_options.some(e=>{var t,n;return Number(null!==(n=null===(t=e.amount)||void 0===t?void 0:t.total)&&void 0!==n?n:0)>0}),f=Array.isArray(h.calculations)&&h.calculations.some(e=>{var t;return Number(null!==(t=e.premium_payable)&&void 0!==t?t:0)>0});if(!m&&!f)return D(h),void j("This payment link is not available. Please contact support.");if("awaiting_payment"===h.status&&h.pending_bank_transfer){const t=h.pending_bank_transfer;return e(),void fe({transactionId:t.transaction_id,organisationId:(null===(i=h.organisation)||void 0===i?void 0:i.id)||""})}if(u){const e=h.calculations.find(e=>e.excess_id===u);e?F(e.id):1===h.calculations.length&&h.calculations[0]&&F(h.calculations[0].id)}else 1===h.calculations.length&&h.calculations[0]&&F(h.calculations[0].id);!c&&1===h.payment_options.length&&h.payment_options[0]&&U(Ea(h.payment_options[0])),D(h),(null===(o=h.organisation)||void 0===o?void 0:o.quote_page_url)&&de(h.organisation.quote_page_url)}catch(e){j("Failed to load payment details. Please check your link.")}finally{M(!1)}},ge=ft(()=>z&&q?z.calculations.find(e=>e.id===q):null,[z,q]),ye=ft(()=>z&&H?z.payment_options.find(e=>Ea(e)===H):null,[z,H]);if(me)return Qe(Ca,{transactionId:me.transactionId,organisationId:me.organisationId,allowCancel:!0,clientSettings:null!==(i=null===(r=null==z?void 0:z.organisation)||void 0===r?void 0:r.client_settings)&&void 0!==i?i:null});if(ue){const e=null==z?void 0:z.organisation,t=null==e?void 0:e.admin_email,n=null==e?void 0:e.phone,r=t||n;return Qe(cs,{title:"Renewal Confirmed",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe("div",{className:Rt.create("auto-renew-success-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto"}),children:[Qe("div",{className:Rt.create("success-icon-container",{display:"flex",justifyContent:"center",marginBottom:$t.spacing.lg}),children:Qe("div",{className:Rt.create("success-icon",{width:"5rem",height:"5rem",borderRadius:"50%",backgroundColor:"#10b981",color:"white",display:"flex",alignItems:"center",justifyContent:"center"}),children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M20 6 9 17l-5-5"})})})}),Qe("div",{className:Rt.create("success-header",{textAlign:"center",marginBottom:$t.spacing.xl}),children:[Qe("h1",{className:Rt.create("success-title",{margin:"0",marginBottom:$t.spacing.sm,fontSize:"2rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.2",letterSpacing:"-0.025em"}),children:"Renewal Confirmed"}),Qe("p",{className:Rt.create("success-message",{fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9",margin:"0"}),children:ue.message})]}),ue.effectiveDate&&Qe("div",{className:Rt.create("payment-date-box",{backgroundColor:$t.colors.accent,borderRadius:$t.radius.default,padding:$t.spacing.lg,marginBottom:$t.spacing.lg,textAlign:"center"}),children:[Qe("p",{className:Rt.create("payment-date-label",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,margin:"0",marginBottom:$t.spacing.sm}),children:"Your first payment will be on"}),Qe("p",{className:Rt.create("payment-date-value",{fontSize:"1.25rem",fontWeight:"600",color:$t.colors.foreground,margin:"0"}),children:new Date(ue.effectiveDate).toLocaleDateString("en-NZ",{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),Qe("div",{className:Rt.create("info-box",{backgroundColor:$t.colors.muted,borderRadius:$t.radius.default,padding:$t.spacing.md,marginBottom:$t.spacing.lg}),children:Qe("p",{className:Rt.create("info-text",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,margin:"0",textAlign:"center"}),children:"No further action is required. Your monthly payments will continue as normal."})}),r&&Qe("div",{className:Rt.create("contact-section",{borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.xl,marginTop:$t.spacing.xl}),children:[Qe("h3",{className:Rt.create("contact-title",{fontSize:"1.125rem",fontWeight:"600",color:$t.colors.foreground,marginBottom:$t.spacing.md,textAlign:"center"}),children:"Need assistance?"}),Qe("div",{className:Rt.create("contact-details",{backgroundColor:$t.colors.accent,borderRadius:$t.radius.default,padding:$t.spacing.md,display:"flex",flexDirection:"column",gap:$t.spacing.sm}),children:[t&&Qe("div",{className:Rt.create("contact-item",{display:"flex",alignItems:"center",gap:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.accentForeground}),children:Qe("span",{children:["Email: ",t]})}),n&&Qe("div",{className:Rt.create("contact-item",{display:"flex",alignItems:"center",gap:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.accentForeground}),children:Qe("span",{children:["Phone: ",n]})})]})]})]})})})}if(te&&P)return Qe(cs,{title:"Payment Processing",noSubscription:!0,hideHeader:!0,children:Qe(qs,{httpClient:P,transactionId:te,onResolved:async e=>{const t="completed"===e?"success":"cancelled"===e?"cancelled":"failed"===e?"declined":"error",n=new URL(window.location.href);n.searchParams.set("status",t),te&&n.searchParams.set("transactionId",te),window.history.replaceState({},"",n.toString()),ne(null),await pe()},onError:async()=>{const e=new URL(window.location.href);e.searchParams.set("status","error"),window.history.replaceState({},"",e.toString()),ne(null),await pe()}})});if(R)return Qe(ds,{message:"Loading payment details..."});if(O){const e=null==z?void 0:z.organisation,t=null==e?void 0:e.quote_page_url,n=null==e?void 0:e.name,r=null==e?void 0:e.admin_email,i=null==e?void 0:e.phone,o=r||i,s="paid"===(null==z?void 0:z.status),a=s?"Payment Completed":"Payment Link Unavailable",l=s?"Thank you, your payment was received.":O,c=Rt.create("pl-error-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto"},{"(max-width: 768px)":{padding:$t.spacing.lg},"(max-width: 480px)":{padding:$t.spacing.md}}),d=Rt.create("pl-error-icon-container",{display:"flex",justifyContent:"center",marginBottom:$t.spacing.lg}),u=Rt.create("pl-error-icon",{width:"4rem",height:"4rem",color:$t.colors.primary}),h=Rt.create("pl-error-header",{textAlign:"center",marginBottom:$t.spacing.xl}),m=Rt.create("pl-error-title",{fontSize:"2rem",fontWeight:"700",color:$t.colors.primary,marginBottom:$t.spacing.sm,lineHeight:"1.2",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.75rem"},"(max-width: 480px)":{fontSize:"1.5rem"}}),f=Rt.create("pl-error-subtitle",{fontSize:$t.fontSize.default,color:$t.colors.foreground,lineHeight:"1.6",opacity:"0.8"}),p=Rt.create("pl-error-contact-section",{borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.xl,marginTop:$t.spacing.xl,textAlign:"center"}),g=Rt.create("pl-error-contact-text",{fontSize:$t.fontSize.default,color:$t.colors.foreground,marginBottom:$t.spacing.lg}),y=Rt.create("pl-error-actions",{display:"flex",gap:$t.spacing.md,flexWrap:"wrap",justifyContent:"center",marginBottom:$t.spacing.lg}),v=()=>Qe("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",className:u,children:[Qe("circle",{cx:"12",cy:"12",r:"10"}),Qe("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),Qe("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),w=()=>Qe("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",className:u,children:[Qe("circle",{cx:"12",cy:"12",r:"10"}),Qe("polyline",{points:"8 12.5 11 15.5 16 9.5"})]});return Qe(cs,{title:"Payment Link",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe(hs,{children:Qe("div",{className:c,children:[Qe("div",{className:d,children:Qe(s?w:v,{})}),Qe("div",{className:h,children:[Qe("h1",{className:m,children:a}),Qe("p",{className:f,children:l})]}),t&&Qe("div",{className:Rt.create("pl-error-quote-action",{display:"flex",justifyContent:"center",marginBottom:o?"0":$t.spacing.sm}),children:Qe(us,{variant:"primary",onClick:()=>{window.location.href=t},children:"Start a New Quote"})}),o&&Qe("div",{className:p,children:[Qe("p",{className:g,children:n?`Need assistance? Contact ${n}`:"Need assistance? Contact us"}),Qe("div",{className:y,children:[i&&Qe(us,{variant:"outline",onClick:()=>window.open(`tel:${i}`),children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:Qe("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),"Call Us"]}),r&&Qe(us,{variant:"outline",onClick:()=>window.open(`mailto:${r}`),children:[Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{marginRight:"0.5rem"},children:[Qe("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),Qe("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Email Us"]})]})]})]})})})})}if(!z)return null;const ve=new URLSearchParams(window.location.search),we=ve.get("transactionId"),be=ve.get("status"),xe=we&&be;if("paid"===z.status&&("completed"===be||"success"===be||xe||Y||"completed"===G)){const e=null===(o=z.organisation)||void 0===o?void 0:o.admin_email,t=null===(s=z.organisation)||void 0===s?void 0:s.phone,n=e||t,r=null!==(l=null!==(a=ve.get("gateway_code"))&&void 0!==a?a:null==ye?void 0:ye.gateway_code)&&void 0!==l?l:null,i=vs(null!==(d=null===(c=z.organisation)||void 0===c?void 0:c.client_settings)&&void 0!==d?d:null,"payment_success",r),m=null!==(u=i.title)&&void 0!==u?u:"Payment Complete!",f=i.body;return Qe(cs,{title:"Payment Successful",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe("div",{className:Rt.create("payment-success-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.xl,boxShadow:$t.shadow.sm,maxWidth:"42rem",margin:"0 auto"}),children:[Qe("div",{className:Rt.create("success-icon-container",{display:"flex",justifyContent:"center",marginBottom:$t.spacing.lg}),children:Qe("div",{className:Rt.create("success-icon",{width:"5rem",height:"5rem",borderRadius:"50%",backgroundColor:"#10b981",color:"white",display:"flex",alignItems:"center",justifyContent:"center"}),children:Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:Qe("path",{d:"M20 6 9 17l-5-5"})})})}),Qe("div",{className:Rt.create("success-header",{textAlign:"center",marginBottom:$t.spacing.xl}),children:[Qe("h1",{className:Rt.create("success-title",{margin:"0",marginBottom:$t.spacing.sm,fontSize:"2rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.2",letterSpacing:"-0.025em"}),children:m}),f?Qe(ms,{source:f,className:Rt.create("success-message",{fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9",margin:"0"})}):Qe("p",{className:Rt.create("success-message",{fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9",margin:"0"}),children:"Your payment has been processed successfully! You will receive your documentation by email."})]}),n&&Qe("div",{className:Rt.create("contact-section",{borderTop:`1px solid ${$t.colors.border}`,paddingTop:$t.spacing.xl,marginTop:$t.spacing.xl}),children:[Qe("h3",{className:Rt.create("contact-title",{fontSize:"1.125rem",fontWeight:"600",color:$t.colors.foreground,marginBottom:$t.spacing.md,textAlign:"center"}),children:"Need assistance?"}),Qe("div",{className:Rt.create("contact-details",{backgroundColor:$t.colors.accent,borderRadius:$t.radius.default,padding:$t.spacing.md,display:"flex",flexDirection:"column",gap:$t.spacing.sm,marginBottom:$t.spacing.lg}),children:[e&&Qe("div",{className:Rt.create("contact-item",{display:"flex",alignItems:"center",gap:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.accentForeground}),children:Qe("span",{children:["Email: ",e]})}),t&&Qe("div",{className:Rt.create("contact-item",{display:"flex",alignItems:"center",gap:$t.spacing.sm,fontSize:$t.fontSize.small,color:$t.colors.accentForeground}),children:Qe("span",{children:["Phone: ",t]})})]}),(Q||we)&&Qe("div",{className:Rt.create("reference",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,textAlign:"center",marginTop:$t.spacing.md}),children:["Transaction ID: ",Qe("strong",{children:null===(h=Q||we)||void 0===h?void 0:h.slice(0,8).toUpperCase()})]})]})]})})})}const ke=K&&xe&&("failed"===be||"declined"===be||"cancelled"===be||"failed"===G||"declined"===G||"cancelled"===G),Se="cancelled"===be||"cancelled"===G?"cancelled":"failed"===be||"declined"===be||"failed"===G||"declined"===G?"declined":"error",Ne=z.calculations,_e=Ne.length>1,Ce=Ne.length>0,$e=Ce,Ie=(null===(m=z.metadata)||void 0===m?void 0:m.product_name)||(null===(f=z.policy_details)||void 0===f?void 0:f.product_name)||"Payment",Te=Boolean(null===(p=null==z?void 0:z.metadata)||void 0===p?void 0:p.quote_intent_id),Ee=Boolean((!Ce||q)&&H&&!oe&&!ae),Pe=ft(()=>{var e,t;const n=null===(e=null==z?void 0:z.metadata)||void 0===e?void 0:e.client_details;if(n)return{firstName:n.first_name,lastName:n.last_name,email:n.email,phone:n.phone};const r=null===(t=null==z?void 0:z.policy_details)||void 0===t?void 0:t.client_name;if(r){const e=r.trim().split(/\s+/);return{firstName:e[0]||r,lastName:e.slice(1).join(" ")||"",email:void 0,phone:void 0}}return null},[z]),ze=ft(()=>{var e;const t=null==z?void 0:z.policy_details;if(!t)return null;const n=e=>{if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString()},r=n(t.insured_from),i=n(t.insured_to),o=r&&i?`${r} – ${i}`:r||i||null,s=null!=t.sum_insured&&t.sum_insured>0?t.sum_insured:null,a=null!=t.excess&&t.excess>=0?t.excess:null;return t.external_policy_number||o||null!=s||null!=a?{externalPolicyNumber:null!==(e=t.external_policy_number)&&void 0!==e?e:null,insurancePeriod:o,sumInsured:s,excess:a}:null},[z]),De=ft(()=>ge&&ge.line_item_display||null,[ge]),Re=null===(g=null==z?void 0:z.metadata)||void 0===g?void 0:g.type,Me=null!==(b=null===(w=null===(v=null===(y=null==z?void 0:z.organisation)||void 0===y?void 0:y.client_settings)||void 0===v?void 0:v.checkout)||void 0===w?void 0:w.headings)&&void 0!==b?b:{},Oe="renewal"===Re?"Complete Your Renewal":"endorsement"===Re?"Complete Your Payment":"Complete Your Purchase",je="renewal"===Re?"renewal":"endorsement"===Re?"endorsement":"payment_link",We=Me[je]&&String(Me[je]).trim()||Oe;return Qe(cs,{title:We,noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:[Qe("div",{className:Rt.create("checkout-layout",{display:"grid",gridTemplateColumns:"1fr 380px",gap:$t.spacing.lg},{"(max-width: 950px)":{display:"flex",flexDirection:"column"},"(max-width: 480px)":{gap:$t.spacing.md}}),children:[Qe("div",{className:Rt.create("checkout-main-wrapper",{minWidth:"0",backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,display:"flex",flexDirection:"column"}),children:[Qe("div",{className:Rt.create("checkout-header",{paddingInline:$t.spacing.xl,paddingTop:$t.spacing.xl,paddingBottom:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingTop:$t.spacing.md}}),children:[Qe("h2",{className:Rt.create("checkout-title",{margin:"0",marginBottom:$t.spacing.md,fontSize:"1.75rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.25rem"}}),children:We}),Qe("p",{className:Rt.create("checkout-description",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:Ce?_e?"Choose your excess amount and payment option to secure your coverage.":"Choose your payment method to secure your coverage.":"Choose your payment option to complete your purchase."}),Qe("hr",{className:Rt.create("checkout-header-border",{marginTop:$t.spacing.lg,border:"0",borderTop:`1px solid ${$t.colors.border}`,height:"0"})})]}),Qe("div",{className:Rt.create("checkout-sections",{paddingInline:$t.spacing.xl,paddingBottom:$t.spacing.xl,display:"flex",flexDirection:"column",gap:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingBottom:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingBottom:$t.spacing.md}}),children:[Te&&Qe("div",{className:Rt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Qe(Ss,{title:"Cover Start Date"}),Qe("div",{className:Rt.create("cover-date-container",{display:"flex",flexDirection:"column",gap:"0.75rem"}),children:[Qe("input",{type:"date",value:re,onChange:e=>{return t=e.target.value,ie(t),void(async e=>{var t;if(z&&P&&(null===(t=z.metadata)||void 0===t?void 0:t.quote_intent_id)){le(!0),se(null);try{const t=await P.validateCoverStartDate(z.payment_link_id,e);t.valid?se(null):(se(t.message||"This cover start date is not valid."),t.quote_page_url&&de(t.quote_page_url))}catch(e){se("Failed to validate cover date. Please try again.")}finally{le(!1)}}})(t);var t},min:Ys(),disabled:ae,className:Rt.create("cover-date-input",{padding:"0.75rem 1rem",fontSize:$t.fontSize.default,border:`2px solid ${oe?$t.colors.destructive:$t.colors.border}`,borderRadius:$t.radius.default,backgroundColor:$t.colors.background,color:$t.colors.foreground,width:"auto",maxWidth:"200px",cursor:ae?"wait":"pointer"})}),ae&&Qe("p",{className:Rt.create("validating-text",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,margin:"0"}),children:"Validating..."}),oe&&Qe("div",{className:Rt.create("cover-date-error",{backgroundColor:`${$t.colors.destructive}10`,border:`1px solid ${$t.colors.destructive}`,borderRadius:$t.radius.default,padding:"1rem"}),children:[Qe("p",{className:Rt.create("error-message",{color:$t.colors.destructive,fontSize:$t.fontSize.small,margin:"0",marginBottom:ce?$t.spacing.md:"0"}),children:oe}),ce&&Qe("a",{href:ce,className:Rt.create("new-quote-link",{display:"inline-flex",alignItems:"center",gap:"0.5rem",color:$t.colors.primary,fontSize:$t.fontSize.small,fontWeight:"500",textDecoration:"none"}),children:["Start New Quote",Qe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Qe("path",{d:"M5 12h14"}),Qe("path",{d:"m12 5 7 7-7 7"})]})]})]})]})]}),$e&&Ce&&Qe("div",{className:Rt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem"}),children:[Qe(Ss,{title:1===Ne.length?"Excess":"Excess Options"}),Qe("div",{className:Rt.create("excess-options-grid",{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"1rem"}),children:[...Ne].sort((e,t)=>e.excess_amount-t.excess_amount).map(e=>{const t=e.id===q;return Qe("div",{className:Lt(Rt.create("excess-option-card",{borderRadius:$t.radius.default,minWidth:"125px",padding:"0.5rem 1rem 0.5rem 0.5rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",flexDirection:"row",alignItems:"center",gap:"1rem"}),t?Rt.create("excess-option-card-selected",{border:`2px solid ${$t.colors.primary}`,backgroundColor:$t.colors.accent}):Rt.create("excess-option-card-unselected",{border:`2px solid ${$t.colors.border}`,backgroundColor:$t.colors.card})),onClick:()=>F(e.id),children:[Qe(Ns,{selected:t}),Qe("div",{className:Rt.create("excess-amount",{color:$t.colors.foreground}),children:[e.excess_label||`$${Number(e.excess_amount).toFixed(0)}`,e.description?"*":""]})]},e.id)})}),(null==ge?void 0:ge.description)&&Qe("div",{className:Rt.create("excess-description",{padding:"0.75rem",backgroundColor:$t.colors.muted,borderRadius:$t.radius.default,border:`1px solid ${$t.colors.border}`}),children:Qe(ks,{className:Rt.create("excess-description-text",{fontSize:$t.fontSize.small,color:$t.colors.foreground,margin:"0"}),children:ge.description})})]}),z.payment_options.length>0&&Qe("div",{className:Rt.create("checkout-section",{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"}),children:[Qe(Ss,{title:"Payment Options"}),Qe("div",{className:Rt.create("payment-options-container",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:z.payment_options.map(e=>{var t,n;const r=Ea(e),i=H===r,o="monthly"===e.payment_frequency,s=!!((null===(t=e.metadata)||void 0===t?void 0:t.gateway_fee)&&parseFloat(e.metadata.gateway_fee)>0),a=!0===(null===(n=e.metadata)||void 0===n?void 0:n.unavailable),l=()=>{var t;return a?"Currently Unavailable":o&&e.amount.monthly?`${Cs(parseFloat(e.amount.monthly))} x ${(null===(t=e.metadata)||void 0===t?void 0:t.number_of_instalments)||12}`:Cs(parseFloat(e.amount.due_today))},c=()=>e.description?e.description:"bank_transfer"===e.gateway_code?"Manual":`via ${e.gateway_name}`;return Qe("div",{title:a?"Currently Unavailable":void 0,className:Lt(Rt.create("payment-option-row",{borderRadius:$t.radius.default,padding:"0.75rem 1rem",cursor:a?"not-allowed":"pointer",opacity:a?"0.55":"1",transition:"all 150ms ease",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem"},{"(max-width: 480px)":{padding:"0.625rem 0.75rem",gap:"0.25rem",flexWrap:"wrap",alignItems:"flex-start"}}),i?Rt.create("payment-option-row-selected",{border:`2px solid ${$t.colors.primary}`,backgroundColor:$t.colors.accent}):Rt.create("payment-option-row-unselected",{border:`2px solid ${$t.colors.border}`,backgroundColor:$t.colors.card})),onClick:()=>{a||U(r)},children:[Qe("div",{className:Rt.create("payment-option-desktop-wrapper",{display:"flex",alignItems:"center",gap:"1rem",flex:"1"},{"(max-width: 480px)":{display:"none"}}),children:[Qe(Ns,{selected:i}),Qe("div",{className:Rt.create("payment-option-info-desktop",{display:"flex",flexDirection:"column",flex:"1"}),children:[Qe("div",{className:Rt.create("frequency-title",{fontSize:$t.fontSize.default,fontWeight:"500",color:$t.colors.foreground}),children:e.display_title||$s(o?"monthly":"one-time",e.gateway_code)}),Qe("div",{className:Rt.create("gateway-description",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:c()})]})]}),Qe("div",{className:Rt.create("payment-option-amount-desktop",{display:"flex",flexDirection:"column",alignItems:"flex-end"},{"(max-width: 480px)":{display:"none"}}),children:[Qe(ks,{className:Rt.create("amount-text",{textAlign:"right",color:$t.colors.foreground}),children:l()}),!a&&Qe(ks,{size:"small",className:Rt.create("gateway-fee-text",{textAlign:"right",color:$t.colors.mutedForeground}),children:s?`${(()=>{var t;return"bank_transfer"===e.gateway_code?null:(null===(t=e.metadata)||void 0===t?void 0:t.gateway_fee)?Cs(parseFloat(e.metadata.gateway_fee)):Cs(0)})()} fee`:"No fees"})]}),Qe("div",{className:Rt.create("payment-option-title-mobile-wrapper",{display:"none"},{"(max-width: 480px)":{display:"flex",alignItems:"center",gap:"0.5rem",flex:"1 1 100%"}}),children:[Qe(Ns,{selected:i}),Qe("div",{className:Rt.create("payment-option-title-mobile",{fontSize:$t.fontSize.default,fontWeight:"500",color:$t.colors.foreground}),children:e.display_title||$s(o?"monthly":"one-time",e.gateway_code)})]}),Qe("div",{className:Rt.create("payment-option-bottom-mobile",{display:"none"},{"(max-width: 480px)":{display:"flex",flex:"1 1 100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"1.5rem"}}),children:[Qe("div",{className:Rt.create("gateway-description-mobile",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:c()}),Qe(ks,{className:Rt.create("amount-text-mobile",{fontWeight:"500",color:$t.colors.foreground}),children:l()})]})]},r)})})]})]})]}),Qe("div",{className:Rt.create("checkout-sidebar",{display:"flex",flexDirection:"column"},{"(max-width: 950px)":{display:"block"}}),children:Qe("div",{className:Rt.create("checkout-sidebar-sticky",{}),children:[(Pe||ze||De&&De.length>0)&&Qe("div",{className:Rt.create("insurance-details-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,padding:$t.spacing.lg,boxShadow:$t.shadow.sm},{"(max-width: 768px)":{padding:$t.spacing.md}}),children:[Qe("h3",{className:Rt.create("cart-summary-title",{fontSize:$t.fontSize.large,fontWeight:"600",marginBottom:$t.spacing.md,color:$t.colors.foreground}),children:"Insurance Details"}),(Pe||ze||"Payment"!==Ie)&&Qe(_,{children:[Qe("div",{className:Rt.create("client-details",{display:"flex",flexDirection:"column",gap:$t.spacing.sm}),children:[(null==Pe?void 0:Pe.firstName)&&(null==Pe?void 0:Pe.lastName)&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Name"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:[null==Pe?void 0:Pe.firstName," ",null==Pe?void 0:Pe.lastName]})]}),(null==Pe?void 0:Pe.email)&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Email"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:null==Pe?void 0:Pe.email})]}),(null==Pe?void 0:Pe.phone)&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Phone"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:null==Pe?void 0:Pe.phone})]}),"Payment"!==Ie&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Product"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:Ie})]}),(null==ze?void 0:ze.externalPolicyNumber)&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Policy Number"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:ze.externalPolicyNumber})]}),(null==z?void 0:z.quote_reference)&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Quote Reference"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:z.quote_reference})]}),null!=(null==ze?void 0:ze.sumInsured)&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Sum Insured"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:Cs(ze.sumInsured)})]}),null!=(null==ze?void 0:ze.excess)&&Qe("div",{className:Rt.create("detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("detail-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:"Excess"}),Qe("span",{className:Rt.create("detail-value",{fontWeight:"500",color:$t.colors.foreground,fontSize:$t.fontSize.small}),children:Cs(ze.excess)})]})]}),De&&De.length>0&&Qe("hr",{className:Rt.create("divider",{border:"none",borderTop:`1px solid ${$t.colors.border}`,margin:`${$t.spacing.md} 0`})})]}),De&&De.length>0&&Qe("div",{className:Rt.create("line-items-section",{display:"flex",flexDirection:"column",gap:$t.spacing.md}),children:De.map((e,t)=>Qe("div",{className:Rt.create("line-item",{}),children:[Qe("div",{className:Rt.create("line-item-description",{fontSize:$t.fontSize.small,fontWeight:"500",color:$t.colors.foreground}),children:e.description}),e.show_sum_insured&&null!=e.sum_insured&&e.sum_insured>0&&Qe("div",{className:Rt.create("line-item-sum-insured",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground,marginTop:$t.spacing.sm}),children:["Sum Insured: ",Cs(e.sum_insured)]})]},t))})]}),(Pe||ze||De&&De.length>0)&&Qe("div",{className:Rt.create("checkout-sidebar-spacer",{height:$t.spacing.lg},{"(max-width: 950px)":{height:$t.spacing.md}})}),Qe("div",{className:Rt.create("checkout-sidebar-card",{backgroundColor:$t.colors.card,borderRadius:$t.radius.large,boxShadow:$t.shadow.sm,padding:$t.spacing.lg},{"(max-width: 768px)":{padding:$t.spacing.md}}),children:Qe("div",{className:Rt.create("payment-summary",{display:"flex",flex:"1",flexDirection:"column",gap:"1rem"}),children:[Qe("h3",{className:Rt.create("cart-summary-title",{fontSize:$t.fontSize.large,fontWeight:"600",marginBottom:$t.spacing.sm,color:$t.colors.foreground}),children:"Payment Details"}),ye&&Qe("div",{className:Rt.create("summary-section",{paddingBottom:"1rem"}),children:Qe("div",{className:Rt.create("payment-breakdown",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:"monthly"!==ye.payment_frequency?Qe(_,{children:[(null===(x=ye.metadata)||void 0===x?void 0:x.gateway_fee)&&parseFloat(ye.metadata.gateway_fee)>0&&Qe(za,{label:Ta(ye.gateway_code,null===(k=ye.metadata)||void 0===k?void 0:k.gateway_method),value:Cs(parseFloat(ye.metadata.gateway_fee))}),Qe(za,{label:"Total Due Today:",value:Cs(parseFloat(ye.amount.due_today)),isTotal:!0})]}):Qe(_,{children:[(null===(S=ye.metadata)||void 0===S?void 0:S.gateway_fee)&&parseFloat(ye.metadata.gateway_fee)>0&&Qe(za,{label:Ta(ye.gateway_code,null===(N=ye.metadata)||void 0===N?void 0:N.gateway_method),value:Cs(parseFloat(ye.metadata.gateway_fee))}),ye.amount.total&&Qe(za,{label:"Total Payable:",value:Cs(parseFloat(ye.amount.total))}),Qe(za,{label:"Due Today:",value:Cs(parseFloat(ye.amount.due_today))}),ye.amount.monthly&&(null===(C=ye.metadata)||void 0===C?void 0:C.number_of_instalments)&&ye.metadata.number_of_instalments>1&&Qe(za,{label:"Remaining payments:",value:`${ye.metadata.number_of_instalments-1} x ${Cs(parseFloat(ye.amount.monthly))}`})]})})}),Qe(us,{onClick:async()=>{var e,t,n,r,i,o;if(!z)return;const s=z.calculations.length>0,a=!s;if(s&&!q)return void alert("Please select an excess amount before proceeding.");if(!H)return void alert("Please select a payment method before proceeding.");const l=s?z.calculations.find(e=>e.id===q):null;if(s&&!l)return void alert("Payment configuration error. Please try again.");const c=z.payment_options.find(e=>Ea(e)===H);if(!c)return void alert("Payment method not available. Please try again.");const d=c.gateway_code,u=null===(e=c.metadata)||void 0===e?void 0:e.gateway_method;let h="Customer";if(null===(t=z.metadata)||void 0===t?void 0:t.client_name)h=z.metadata.client_name;else if(null===(n=z.metadata)||void 0===n?void 0:n.client_details){const e=z.metadata.client_details;e.first_name&&(h=`${e.first_name} ${e.last_name||""}`.trim())}if(a){if(!P)return void alert("Payment service not available. Please try again.");try{M(!0);const e=await P.initiateFixedPayment(z.payment_link_id,d,h,u);if("auto_renew_confirmed"===e.status)return void he({message:e.message||"Your renewal is confirmed. Your premium funding will continue automatically on the policy start date.",effectiveDate:e.effective_date});if("bank_transfer"===d&&e.transaction_id)return void fe({transactionId:e.transaction_id,organisationId:(null===(r=z.organisation)||void 0===r?void 0:r.id)||""});e.gateway_acceptance_url?window.location.href=e.gateway_acceptance_url:alert("Payment initiated successfully")}catch(e){alert(e.message||"Failed to initiate payment")}finally{M(!1)}return}const m=null===(i=z.metadata)||void 0===i?void 0:i.quote_intent_id,f={...m?{quoteIntentId:m}:{paymentLinkId:z.payment_link_id},paymentLinkId:z.payment_link_id,excessId:(null==l?void 0:l.excess_id)||"",gatewayId:d,calculationId:q||"",clientDetails:{legalName:h},metadata:{payment_link_id:z.payment_link_id,payment_type:m?"quote":"rate",gateway_code:d,gateway:d,...u?{gateway_method:u}:{}},...Te&&re?{coverStartDate:re}:{}};if("bank_transfer"!==d)B(f),A(!0);else{if(!P)return void alert("Payment service not available. Please try again.");try{M(!0);const e={...f,returnUrl:window.location.href},t=await P.initiatePayment(e,d);if(!(t.bank_account_name&&t.reference&&t.transaction_id))throw new Error("Invalid bank transfer response");fe({transactionId:t.transaction_id,organisationId:(null===(o=z.organisation)||void 0===o?void 0:o.id)||""})}catch(e){alert(e.message||"Failed to initiate bank transfer")}finally{M(!1)}}},disabled:!Ee,className:Rt.create("purchase-button",{width:"100%",height:"3rem",fontSize:$t.fontSize.default,fontWeight:"600"}),children:Ee?"Go to Payment":"Select Options to Continue"})]})})]})})]}),W&&L&&P&&Qe(_a,{isOpen:W,onClose:()=>{A(!1),B(null)},onSuccess:()=>{A(!1),B(null),alert("Payment completed successfully!")},paymentRequest:L,httpClient:P}),ke&&Qe(Bs,{type:Se,transactionId:we||Q||void 0,clientSettings:null!==(I=null===($=null==z?void 0:z.organisation)||void 0===$?void 0:$.client_settings)&&void 0!==I?I:null,gatewayCode:null!==(E=null!==(T=ve.get("gateway_code"))&&void 0!==T?T:null==ye?void 0:ye.gateway_code)&&void 0!==E?E:void 0,isOpen:!0,onClose:()=>{X(!1);const e=new URL(window.location.href);e.searchParams.delete("status"),e.searchParams.delete("transactionId"),e.searchParams.delete("transaction_id"),window.history.replaceState({},"",e.toString())}})]})})}function za({label:e,value:t,isTotal:n=!1,className:r}){return Qe("div",{className:Lt(Rt.create("summary-item",{display:"flex",justifyContent:"space-between",alignItems:"center"}),r),children:[Qe("span",{className:Rt.create("summary-label",{color:$t.colors.mutedForeground,fontSize:$t.fontSize.small}),children:e}),Qe("span",{className:Rt.create("summary-value",{fontWeight:n?"600":"500",color:$t.colors.foreground,fontSize:n?$t.fontSize.large:"inherit"}),children:t})]})}function Da({products:e,onSelectProduct:t}){const[n,r]=ut(null),i=(e,t)=>{t&&(t.preventDefault(),t.stopPropagation()),r(e)};return Qe(cs,{title:"Select cover",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe("div",{className:Rt.create("product-selection-layout",{display:"flex",justifyContent:"center",width:"100%"}),children:Qe("div",{className:Rt.create("product-selection-card",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,display:"flex",flexDirection:"column",width:"100%",maxWidth:"600px"}),children:[Qe("div",{className:Rt.create("product-selection-header",{paddingInline:$t.spacing.xl,paddingTop:$t.spacing.xl,paddingBottom:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingTop:$t.spacing.md}}),children:[Qe("h2",{className:Rt.create("product-selection-title",{margin:"0",marginBottom:$t.spacing.sm,fontSize:"1.75rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.125rem"}}),children:"Select Your Cover"}),Qe("p",{className:Rt.create("product-selection-description",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:"What type of vessel are you insuring?"}),Qe("hr",{className:Rt.create("product-selection-header-border",{marginTop:$t.spacing.lg,borderColor:$t.colors.border})})]}),Qe("div",{className:Rt.create("product-selection-content",{paddingInline:$t.spacing.xl,paddingBottom:$t.spacing.xl},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingBottom:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingBottom:$t.spacing.md}}),children:[0===e.length?Qe("div",{className:Rt.create("no-products-placeholder",{padding:"2rem",textAlign:"center",border:`1px dashed ${$t.colors.border}`,borderRadius:$t.radius.default,backgroundColor:$t.colors.muted}),children:[Qe("div",{style:{marginBottom:$t.spacing.default},children:Qe("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",style:{margin:"0 auto",opacity:.5},children:[Qe("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),Qe("polyline",{points:"14 2 14 8 20 8"})]})}),Qe("p",{className:Rt.create("placeholder-text",{color:$t.colors.mutedForeground,margin:"0"}),children:"No products available for quoting."})]}):Qe("div",{className:Rt.create("product-options-container",{display:"flex",flexDirection:"column",gap:"0.5rem"}),children:e.map(e=>Qe(Ra,{product:e,isSelected:(null==n?void 0:n.id)===e.id,onSelect:i},e.id))}),e.length>0&&Qe("div",{className:Rt.create("product-selection-actions",{marginTop:$t.spacing.lg}),children:Qe(us,{onClick:()=>{n&&t(n)},disabled:!n,className:Rt.create("product-selection-continue-button",{width:"100%"}),children:"Continue"})})]})]})})})})}function Ra({product:e,isSelected:t,onSelect:n}){return Qe("div",{className:Lt(Rt.create("product-option-row",{borderRadius:$t.radius.default,padding:"0.75rem 1rem",cursor:"pointer",transition:"all 150ms ease",display:"flex",alignItems:"center",gap:"1rem"},{"(max-width: 480px)":{padding:"0.625rem 0.75rem"}}),t?Rt.create("product-option-row-selected",{border:`2px solid ${$t.colors.primary}`,backgroundColor:$t.colors.accent}):Rt.create("product-option-row-unselected",{border:`2px solid ${$t.colors.border}`,backgroundColor:$t.colors.card})),onClick:t=>n(e,t),role:"button",tabIndex:0,onKeyPress:t=>{"Enter"!==t.key&&" "!==t.key||n(e,t)},children:[Qe(Ns,{selected:t}),Qe("div",{className:Rt.create("product-option-content",{display:"flex",alignItems:"center",justifyContent:"space-between",flex:"1",gap:"1rem"}),children:[Qe("div",{className:Rt.create("product-option-info",{display:"flex",flexDirection:"column"}),children:[e.description&&Qe("div",{className:Rt.create("product-option-description",{fontSize:$t.fontSize.default,fontWeight:"500",color:$t.colors.foreground}),children:e.description}),Qe("div",{className:Rt.create("product-option-name",{fontSize:$t.fontSize.small,color:$t.colors.mutedForeground}),children:e.name})]}),e.icon_svg&&Qe("div",{className:Rt.create("product-option-icon",{width:"2.5rem",height:"2.5rem",flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center",color:t?$t.colors.primary:$t.colors.mutedForeground,transition:"color 150ms ease"}),dangerouslySetInnerHTML:{H:e.icon_svg.replace(/^<svg(?![^>]*\bwidth\b)/,'<svg width="100%" height="100%"')}})]})]})}function Ma(){var e,t;const n=Ut(),{paymentLinkConfig:r,availableProducts:i,formStateManager:o}=n;if(i&&!o)return Qe(Da,{products:i,onSelectProduct:()=>{}});if(r)return Qe(Pa,{paymentLinkId:r.paymentLinkId,signedUrl:r.signedUrl});const s=new URLSearchParams(window.location.search),a=s.get("p")||s.get("pl_ref");if(a&&!o)return Qe(Pa,{paymentLinkId:a});const l=window.location.pathname,c=l.match(/\/pay\/([a-f0-9-]+)/);if(c&&c[1])return Qe(Pa,{paymentLinkId:c[1],signedUrl:window.location.href});const d=l.match(/\/payments\/bank-transfer\/([a-f0-9-]+)/),u=s.get("orgId");if(d&&d[1]&&u)return Qe(Ca,{transactionId:d[1],organisationId:u});const{isCalculating:h,results:m,quoteIntent:f}=Yt(e=>({isCalculating:null==e?void 0:e.getIsCalculating(),results:null==e?void 0:e.getCalculationResult(),quoteIntent:null==e?void 0:e.getQuoteIntent(),fsm:e})),p="hold"===(null==f?void 0:f.status),g=null===(e=null==f?void 0:f.payment_transactions)||void 0===e?void 0:e.find(e=>"bank_transfer"===e.gateway_code&&"pending"===e.status),y="paid"===(null==f?void 0:f.status)||"completed"===(null==f?void 0:f.status);return h?Qe(ds,{title:"Calculating premium",message:"Crunching the numbers now"}):p&&g&&(null===(t=null==f?void 0:f.organisation)||void 0===t?void 0:t.id)?Qe(Ca,{transactionId:g.id,organisationId:f.organisation.id,allowCancel:!0}):y?Qe(Na,{}):m?Qe(ra,{results:m}):Qe(Sa,{})}function Oa(e){return Qe(Ht,{...e,children:Qe(Ma,{})})}function ja({reference:e,productName:t,firstName:n,lastUpdated:r,onContinue:i,onStartFresh:o}){const[s,a]=ut(null);return Qe(cs,{title:"Resume Quote",noSubscription:!0,hideHeader:!0,children:Qe(qt,{children:Qe("div",{className:Rt.create("resume-prompt-layout",{display:"flex",justifyContent:"center",width:"100%"}),children:Qe("div",{className:Rt.create("resume-prompt-card",{backgroundColor:$t.colors.card,boxShadow:$t.shadow.sm,borderRadius:$t.radius.large,display:"flex",flexDirection:"column",width:"100%",maxWidth:"600px"}),children:[Qe("div",{className:Rt.create("resume-prompt-header",{paddingInline:$t.spacing.xl,paddingTop:$t.spacing.xl,paddingBottom:$t.spacing.lg},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingTop:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingTop:$t.spacing.md}}),children:[Qe("h2",{className:Rt.create("resume-prompt-title",{margin:"0",marginBottom:$t.spacing.sm,fontSize:"1.75rem",fontWeight:"700",color:$t.colors.primary,lineHeight:"1.1",letterSpacing:"-0.025em"},{"(max-width: 768px)":{fontSize:"1.5rem"},"(max-width: 480px)":{fontSize:"1.125rem"}}),children:"Existing Quote Found"}),Qe("p",{className:Rt.create("resume-prompt-description",{margin:"0",fontSize:$t.fontSize.default,lineHeight:"1.6",color:$t.colors.foreground,opacity:"0.9"}),children:"There is a quote in progress. Would you like to continue where you left off or start a new quote?"}),(e||t||n||r)&&Qe("div",{className:Rt.create("resume-prompt-details",{marginTop:$t.spacing.md,padding:$t.spacing.md,backgroundColor:$t.colors.background,borderRadius:$t.radius.default,display:"flex",flexDirection:"column",gap:$t.spacing.sm}),children:[t&&Qe("div",{className:Rt.create("resume-prompt-detail-row",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("resume-prompt-detail-label",{fontSize:$t.fontSize.small,color:$t.colors.foreground,opacity:"0.6"}),children:"Product"}),Qe("span",{className:Rt.create("resume-prompt-detail-value",{fontSize:$t.fontSize.small,fontWeight:"600",color:$t.colors.foreground}),children:t})]}),n&&Qe("div",{className:Rt.create("resume-prompt-detail-row-name",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("resume-prompt-detail-label-name",{fontSize:$t.fontSize.small,color:$t.colors.foreground,opacity:"0.6"}),children:"Client"}),Qe("span",{className:Rt.create("resume-prompt-detail-value-name",{fontSize:$t.fontSize.small,fontWeight:"600",color:$t.colors.foreground}),children:n})]}),e&&Qe("div",{className:Rt.create("resume-prompt-detail-row-ref",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("resume-prompt-detail-label-ref",{fontSize:$t.fontSize.small,color:$t.colors.foreground,opacity:"0.6"}),children:"Reference"}),Qe("span",{className:Rt.create("resume-prompt-detail-value-ref",{fontSize:$t.fontSize.small,fontWeight:"600",color:$t.colors.foreground}),children:e})]}),r&&Qe("div",{className:Rt.create("resume-prompt-detail-row-date",{display:"flex",justifyContent:"space-between",alignItems:"center"}),children:[Qe("span",{className:Rt.create("resume-prompt-detail-label-date",{fontSize:$t.fontSize.small,color:$t.colors.foreground,opacity:"0.6"}),children:"Last updated"}),Qe("span",{className:Rt.create("resume-prompt-detail-value-date",{fontSize:$t.fontSize.small,fontWeight:"600",color:$t.colors.foreground}),children:r})]})]}),Qe("hr",{className:Rt.create("resume-prompt-header-border",{marginTop:$t.spacing.lg,borderColor:$t.colors.border})})]}),Qe("div",{className:Rt.create("resume-prompt-content",{paddingInline:$t.spacing.xl,paddingBottom:$t.spacing.xl,display:"flex",flexDirection:"column",gap:$t.spacing.md},{"(max-width: 768px)":{paddingInline:$t.spacing.lg,paddingBottom:$t.spacing.lg},"(max-width: 480px)":{paddingInline:$t.spacing.md,paddingBottom:$t.spacing.md}}),children:[Qe(us,{onClick:()=>{a("continue"),i()},loading:"continue"===s,disabled:null!==s,className:Rt.create("resume-prompt-continue-btn",{width:"100%"}),children:"Continue where I left off"}),Qe(us,{variant:"outline",onClick:()=>{a("fresh"),o()},loading:"fresh"===s,disabled:null!==s,className:Rt.create("resume-prompt-fresh-btn",{width:"100%"}),children:"Start a new quote"})]})]})})})})}class Wa extends C{constructor(e){super(e),this.state={hasError:!1}}componentDidCatch(t,n){e();try{Promise.resolve().then(function(){return Zh}).then(({captureException:e,addBreadcrumb:r,isSentryInitialized:i})=>{i()&&(r({message:"Component error",category:"ui",level:"error",data:{componentStack:n.componentStack}}),e(t,{componentStack:n.componentStack}))}).catch(()=>{})}catch(e){}const r=Ne("initialization",t,"A component error occurred");this.setState({hasError:!0,error:r})}render(){if(this.state.hasError){const e=this.state.error;return ze(e)?Qe(xs,{message:e.message,organisation:e.organisation}):Qe(bs,{error:e})}return this.props.children}}function Aa({config:t,initializeFormContext:n}){const[r,i]=ut({type:"loading",message:"Loading application..."}),o=n=>{if(n.resumePrompt)return e(),void i({type:"resume_prompt",resumeData:n.resumePrompt});const r=n.availableProducts&&n.availableProducts.length>0;if(r&&!n.formStateManager)return e(),void i({type:"product_selection",products:n.availableProducts});if(!("payment"===t.mode||n.paymentLinkConfig||r||n.formStateManager&&"function"==typeof n.formStateManager.getFormProgress))throw new Error("FormStateManager was not properly initialized");e(),i({type:"success",formContextProps:n})},s=async(r="Loading application...")=>{i({type:"loading",message:r});try{e();const r=await n(t);o(r)}catch(t){let n;e(),n=t&&"object"==typeof t&&"type"in t&&"MAINTENANCE_ERROR"===t.type||t&&"object"==typeof t&&"statusCode"in t&&503===t.statusCode||t&&"object"==typeof t&&"status"in t&&503===t.status?Ne("maintenance",t):Ne("initialization",t),e((n.type,n.severity,n.statusCode)),i({type:"error",error:n})}};ht(()=>{t.isolateStyles&&Et(),s()},[t,n]);const a=async t=>{if("resume_prompt"!==r.type)return;const{onContinue:n,onStartFresh:s}=r.resumeData;i({type:"loading",message:"continue"===t?"Loading your quote...":"Starting a new quote..."});try{const e="continue"===t?await n():await s();o(e)}catch(t){e();const n=Ne("initialization",t);i({type:"error",error:n})}},l=async t=>{e(t.code),localStorage.setItem("insure-os-selected-product",t.code),await s("Loading...")};return Qe(Wa,{children:Qe("div",{className:Rt.create("root",{fontFamily:$t.fontFamily,backgroundColor:$t.colors.background,minHeight:"100vh",color:$t.colors.foreground,maxWidth:"100vw",overflowX:"hidden",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"}),children:function(){switch(r.type){case"loading":return Qe(ds,{message:r.message});case"error":return ze(r.error)?Qe(xs,{message:r.error.message,organisation:r.error.organisation}):Qe(bs,{error:r.error});case"product_selection":return Qe(Da,{products:r.products,onSelectProduct:l});case"resume_prompt":return Qe(ja,{reference:r.resumeData.reference,productName:r.resumeData.productName,firstName:r.resumeData.firstName,lastUpdated:r.resumeData.lastUpdated,onContinue:()=>a("continue"),onStartFresh:()=>a("fresh")});case"success":return Qe(Oa,{...r.formContextProps});default:return Qe(bs,{})}}()})})}const La="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,Ba=globalThis,qa="10.48.0";function Fa(){return Ha(Ba),Ba}function Ha(e){const t=e.oe=e.oe||{};return t.version=t.version||qa,t[qa]=t[qa]||{}}function Ua(e,t,n=Ba){const r=n.oe=n.oe||{},i=r[qa]=r[qa]||{};return i[e]||(i[e]=t())}const Ya=["debug","info","warn","error","log","assert","trace"],Za={};function Ga(e){if(!("console"in Ba))return e();const t=Ba.console,n={},r=Object.keys(Za);r.forEach(e=>{const r=Za[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function Va(){return Ja().enabled}function Qa(e,...t){La&&Va()&&Ga(()=>{Ba.console[e](`Sentry Logger [${e}]:`,...t)})}function Ja(){return La?Ua("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Ka=function(){Ja().enabled=!0},Xa=function(...e){Qa("log",...e)},el=function(...e){Qa("warn",...e)},tl=function(...e){Qa("error",...e)},nl="?",rl=/\(error: (.*)\)/,il=/captureMessage|captureException/;function ol(...e){const t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{const i=[],o=e.split("\n");for(let e=n;e<o.length;e++){let n=o[e];n.length>1024&&(n=n.slice(0,1024));const s=rl.test(n)?n.replace(rl,"$1"):n;if(!s.includes("Error: ")){for(const e of t){const t=e(s);if(t){i.push(t);break}}if(i.length>=50+r)break}}return function(e){if(!e.length)return[];const t=Array.from(e);return/sentryWrapped/.test(sl(t).function||"")&&t.pop(),t.reverse(),il.test(sl(t).function||"")&&(t.pop(),il.test(sl(t).function||"")&&t.pop()),t.slice(0,50).map(e=>({...e,filename:e.filename||sl(t).filename,function:e.function||nl}))}(i.slice(r))}}function sl(e){return e[e.length-1]||{}}const al="<anonymous>";function ll(e){try{return e&&"function"==typeof e&&e.name||al}catch{return al}}function cl(e){const t=e.exception;if(t){const e=[];try{return t.values.forEach(t=>{t.stacktrace.frames&&e.push(...t.stacktrace.frames)}),e}catch{return}}}function dl(e){return"se"in e&&e.se?"[VueVNode]":"[VueViewModel]"}const ul={},hl={};function ml(e,t){ul[e]=ul[e]||[],ul[e].push(t)}function fl(e,t){if(!hl[e]){hl[e]=!0;try{t()}catch(t){La&&tl(`Error while instrumenting ${e}`,t)}}}function pl(e,t){const n=e&&ul[e];if(n)for(const r of n)try{r(t)}catch(t){La&&tl(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${ll(r)}\nError:`,t)}}let gl=null;function yl(){gl=Ba.onerror,Ba.onerror=function(e,t,n,r,i){return pl("error",{column:r,error:i,line:n,msg:e,url:t}),!!gl&&gl.apply(this,arguments)},Ba.onerror.ae=!0}let vl=null;function wl(){vl=Ba.onunhandledrejection,Ba.onunhandledrejection=function(e){return pl("unhandledrejection",e),!vl||vl.apply(this,arguments)},Ba.onunhandledrejection.ae=!0}const bl={}.toString;function xl(e){switch(bl.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return Pl(e,Error)}}function kl(e,t){return bl.call(e)===`[object ${t}]`}function Sl(e){return kl(e,"ErrorEvent")}function Nl(e){return kl(e,"DOMError")}function _l(e){return kl(e,"String")}function Cl(e){return"object"==typeof e&&null!==e&&"le"in e&&"ce"in e}function $l(e){return null===e||Cl(e)||"object"!=typeof e&&"function"!=typeof e}function Il(e){return kl(e,"Object")}function Tl(e){return"undefined"!=typeof Event&&Pl(e,Event)}function El(e){return Boolean(e?.then&&"function"==typeof e.then)}function Pl(e,t){try{return e instanceof t}catch{return!1}}function zl(e){return!("object"!=typeof e||null===e||!(e.de||e.ue||e.se))}function Dl(e){return"undefined"!=typeof Request&&Pl(e,Request)}const Rl=Ba;function Ml(e,t={}){if(!e)return"<unknown>";try{let n=e;const r=5,i=[];let o=0,s=0;const a=" > ",l=a.length;let c;const d=Array.isArray(t)?t:t.keyAttrs,u=!Array.isArray(t)&&t.maxStringLength||80;for(;n&&o++<r&&(c=Ol(n,d),!("html"===c||o>1&&s+i.length*l+c.length>=u));)i.push(c),s+=c.length,n=n.parentNode;return i.reverse().join(a)}catch{return"<unknown>"}}function Ol(e,t){const n=e,r=[];if(!n?.tagName)return"";if(Rl.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());const i=t?.length?t.filter(e=>n.getAttribute(e)).map(e=>[e,n.getAttribute(e)]):null;if(i?.length)i.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else{n.id&&r.push(`#${n.id}`);const e=n.className;if(e&&_l(e)){const t=e.split(/\s+/);for(const e of t)r.push(`.${e}`)}}for(const e of["aria-label","type","name","title","alt"]){const t=n.getAttribute(e);t&&r.push(`[${e}="${t}"]`)}return r.join("")}function jl(){try{return Rl.document.location.href}catch{return""}}function Wl(e,t,n){if(!(t in e))return;const r=e[t];if("function"!=typeof r)return;const i=n(r);"function"==typeof i&&Ll(i,r);try{e[t]=i}catch{La&&Xa(`Failed to replace method "${t}" in object`,e)}}function Al(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{La&&Xa(`Failed to add non-enumerable property "${t}" to object`,e)}}function Ll(e,t){try{const n=t.prototype||{};e.prototype=t.prototype=n,Al(e,"__sentry_original__",t)}catch{}}function Bl(e){return e.he}function ql(e){if(xl(e))return{message:e.message,name:e.name,stack:e.stack,...Hl(e)};if(Tl(e)){const t={type:e.type,target:Fl(e.target),currentTarget:Fl(e.currentTarget),...Hl(e)};return"undefined"!=typeof CustomEvent&&Pl(e,CustomEvent)&&(t.detail=e.detail),t}return e}function Fl(e){try{return"undefined"!=typeof Element&&Pl(e,Element)?Ml(e):{}.toString.call(e)}catch{return"<unknown>"}}function Hl(e){return"object"==typeof e&&null!==e?Object.fromEntries(Object.entries(e)):{}}let Ul,Yl,Zl;function Gl(e){if(void 0!==Ul)return Ul?Ul(e):e();const t=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=Ba;return t in n&&"function"==typeof n[t]?(Ul=n[t],Ul(e)):(Ul=null,e())}function Vl(){return Gl(()=>Math.random())}function Ql(){return Gl(()=>Date.now())}function Jl(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function Kl(e,t){if(!Array.isArray(e))return"";const n=[];for(let t=0;t<e.length;t++){const r=e[t];try{zl(r)?n.push(dl(r)):n.push(String(r))}catch{n.push("[value cannot be serialized]")}}return n.join(t)}function Xl(e,t,n=!1){return!!_l(e)&&(kl(t,"RegExp")?t.test(e):_l(t)?n?e===t:e.includes(t):"function"==typeof t&&t(e))}function ec(e,t=[],n=!1){return t.some(t=>Xl(e,t,n))}function tc(e=function(){const e=Ba;return e.crypto||e.msCrypto}()){try{if(e?.randomUUID)return Gl(()=>e.randomUUID()).replace(/-/g,"")}catch{}return Yl||(Yl=[1e7]+1e3+4e3+8e3+1e11),Yl.replace(/[018]/g,e=>(e^(16*Vl()&15)>>e/4).toString(16))}function nc(e){return e.exception?.values?.[0]}function rc(e){const{message:t,event_id:n}=e;if(t)return t;const r=nc(e);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function ic(e,t){const n=e.exception=e.exception||{},r=n.values=n.values||[],i=r[0]=r[0]||{};i.value||(i.value=t||""),i.type||(i.type="Error")}function oc(e,t){const n=nc(e);if(!n)return;const r=n.mechanism;if(n.mechanism={type:"generic",handled:!0,...r,...t},t&&"data"in t){const e={...r?.data,...t.data};n.mechanism.data=e}}function sc(e){if(function(e){try{return e.me}catch{}}(e))return!0;try{Al(e,"__sentry_captured__",!0)}catch{}return!1}function ac(){return Ql()/1e3}function lc(){return(Zl??(Zl=function(){const{performance:e}=Ba;if(!e?.now||!e.timeOrigin)return ac;const t=e.timeOrigin;return()=>(t+Gl(()=>e.now()))/1e3}()))()}function cc(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||lc(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:tc()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function dc(e,t,n=2){if(!t||"object"!=typeof t||n<=0)return t;if(e&&0===Object.keys(t).length)return e;const r={...e};for(const e in t)({}).hasOwnProperty.call(t,e)&&(r[e]=dc(r[e],t[e],n-1));return r}function uc(){return tc()}function hc(){return tc().substring(16)}const mc="_sentrySpan";function fc(e,t){t?Al(e,mc,t):delete e[mc]}function pc(e){return e[mc]}class gc{constructor(){this.fe=!1,this.pe=[],this.ge=[],this.ye=[],this.ve=[],this.we={},this.be={},this.xe={},this.ke={},this.Se={},this.Ne={},this._e={traceId:uc(),sampleRand:Vl()}}clone(){const e=new gc;return e.ye=[...this.ye],e.be={...this.be},e.xe={...this.xe},e.ke={...this.ke},e.Se={...this.Se},this.Se.flags&&(e.Se.flags={values:[...this.Se.flags.values]}),e.we=this.we,e.Ce=this.Ce,e.$e=this.$e,e.Ie=this.Ie,e.Te=this.Te,e.ge=[...this.ge],e.ve=[...this.ve],e.Ne={...this.Ne},e._e={...this._e},e.Ee=this.Ee,e.Pe=this.Pe,e.ze=this.ze,fc(e,pc(this)),e}setClient(e){this.Ee=e}setLastEventId(e){this.Pe=e}getClient(){return this.Ee}lastEventId(){return this.Pe}addScopeListener(e){this.pe.push(e)}addEventProcessor(e){return this.ge.push(e),this}setUser(e){return this.we=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.$e&&cc(this.$e,{user:e}),this.De(),this}getUser(){return this.we}setConversationId(e){return this.ze=e||void 0,this.De(),this}setTags(e){return this.be={...this.be,...e},this.De(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this.xe={...this.xe,...e},this.De(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this.xe&&(delete this.xe[e],this.De()),this}setExtras(e){return this.ke={...this.ke,...e},this.De(),this}setExtra(e,t){return this.ke={...this.ke,[e]:t},this.De(),this}setFingerprint(e){return this.Te=e,this.De(),this}setLevel(e){return this.Ce=e,this.De(),this}setTransactionName(e){return this.Ie=e,this.De(),this}setContext(e,t){return null===t?delete this.Se[e]:this.Se[e]=t,this.De(),this}setSession(e){return e?this.$e=e:delete this.$e,this.De(),this}getSession(){return this.$e}update(e){if(!e)return this;const t="function"==typeof e?e(this):e,n=t instanceof gc?t.getScopeData():Il(t)?e:void 0,{tags:r,attributes:i,extra:o,user:s,contexts:a,level:l,fingerprint:c=[],propagationContext:d,conversationId:u}=n||{};return this.be={...this.be,...r},this.xe={...this.xe,...i},this.ke={...this.ke,...o},this.Se={...this.Se,...a},s&&Object.keys(s).length&&(this.we=s),l&&(this.Ce=l),c.length&&(this.Te=c),d&&(this._e=d),u&&(this.ze=u),this}clear(){return this.ye=[],this.be={},this.xe={},this.ke={},this.we={},this.Se={},this.Ce=void 0,this.Ie=void 0,this.Te=void 0,this.$e=void 0,this.ze=void 0,fc(this,void 0),this.ve=[],this.setPropagationContext({traceId:uc(),sampleRand:Vl()}),this.De(),this}addBreadcrumb(e,t){const n="number"==typeof t?t:100;if(n<=0)return this;const r={timestamp:ac(),...e,message:e.message?Jl(e.message,2048):e.message};return this.ye.push(r),this.ye.length>n&&(this.ye=this.ye.slice(-n),this.Ee?.recordDroppedEvent("buffer_overflow","log_item")),this.De(),this}getLastBreadcrumb(){return this.ye[this.ye.length-1]}clearBreadcrumbs(){return this.ye=[],this.De(),this}addAttachment(e){return this.ve.push(e),this}clearAttachments(){return this.ve=[],this}getScopeData(){return{breadcrumbs:this.ye,attachments:this.ve,contexts:this.Se,tags:this.be,attributes:this.xe,extra:this.ke,user:this.we,level:this.Ce,fingerprint:this.Te||[],eventProcessors:this.ge,propagationContext:this._e,sdkProcessingMetadata:this.Ne,transactionName:this.Ie,span:pc(this),conversationId:this.ze}}setSDKProcessingMetadata(e){return this.Ne=dc(this.Ne,e,2),this}setPropagationContext(e){return this._e=e,this}getPropagationContext(){return this._e}captureException(e,t){const n=t?.event_id||tc();if(!this.Ee)return La&&el("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this.Ee.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},this),n}captureMessage(e,t,n){const r=n?.event_id||tc();if(!this.Ee)return La&&el("No client configured on scope - will not capture message!"),r;const i=n?.syntheticException??new Error(e);return this.Ee.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r},this),r}captureEvent(e,t){const n=e.event_id||t?.event_id||tc();return this.Ee?(this.Ee.captureEvent(e,{...t,event_id:n},this),n):(La&&el("No client configured on scope - will not capture event!"),n)}De(){this.fe||(this.fe=!0,this.pe.forEach(e=>{e(this)}),this.fe=!1)}}const yc=e=>e instanceof Promise&&!e[vc],vc=Symbol("chained PromiseLike");class wc{constructor(e,t){let n,r;n=e||new gc,r=t||new gc,this.Re=[{scope:n}],this.Me=r}withScope(e){const t=this.Oe();let n;try{n=e(t)}catch(e){throw this.je(),e}return El(n)?((e,t,n)=>{const r=e.then(e=>(t(),e),e=>{throw n(),e});return yc(r)&&yc(e)?r:((e,t)=>{let n=!1;for(const r in e){if(r in t)continue;n=!0;const i=e[r];"function"==typeof i?Object.defineProperty(t,r,{value:(...t)=>i.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[r]=i}return n&&Object.assign(t,{[vc]:!0}),t})(e,r)})(n,()=>this.je(),()=>this.je()):(this.je(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.Me}getStackTop(){return this.Re[this.Re.length-1]}Oe(){const e=this.getScope().clone();return this.Re.push({client:this.getClient(),scope:e}),e}je(){return!(this.Re.length<=1||!this.Re.pop())}}function bc(){const e=Ha(Fa());return e.stack=e.stack||new wc(Ua("defaultCurrentScope",()=>new gc),Ua("defaultIsolationScope",()=>new gc))}function xc(e){return bc().withScope(e)}function kc(e,t){const n=bc();return n.withScope(()=>(n.getStackTop().scope=e,t(e)))}function Sc(e){return bc().withScope(()=>e(bc().getIsolationScope()))}function Nc(e){const t=Ha(e);return t.acs?t.acs:{withIsolationScope:Sc,withScope:xc,withSetScope:kc,withSetIsolationScope:(e,t)=>Sc(t),getCurrentScope:()=>bc().getScope(),getIsolationScope:()=>bc().getIsolationScope()}}function _c(){return Nc(Fa()).getCurrentScope()}function Cc(){return Nc(Fa()).getIsolationScope()}function $c(...e){const t=Nc(Fa());if(2===e.length){const[n,r]=e;return n?t.withSetScope(n,r):t.withScope(r)}return t.withScope(e[0])}function Ic(){return _c().getClient()}function Tc(e){const t=e.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:i}=t,o={trace_id:n,span_id:i||hc()};return r&&(o.parent_span_id=r),o}const Ec="sentry.profile_id",Pc="sentry.exclusive_time";function zc(e){if(e){if("object"==typeof e&&"deref"in e&&"function"==typeof e.deref)try{return e.deref()}catch{return}return e}}function Dc(e){const t=e;return{scope:t.We,isolationScope:zc(t.Ae)}}function Rc(e){return e.split(",").map(e=>{const t=e.indexOf("=");return-1===t?[]:[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,n])=>(t&&n&&(e[t]=n),e),{})}const Mc=/^o(\d+)\./,Oc=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function jc(e,t=!1){const{host:n,path:r,pass:i,port:o,projectId:s,protocol:a,publicKey:l}=e;return`${a}://${l}${t&&i?`:${i}`:""}@${n}${o?`:${o}`:""}/${r?`${r}/`:r}${s}`}function Wc(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function Ac(e){const t=e.getOptions(),{host:n}=e.getDsn()||{};let r;return t.orgId?r=String(t.orgId):n&&(r=function(e){const t=e.match(Mc);return t?.[1]}(n)),r}let Lc=!1;function Bc(e){const{spanId:t,traceId:n,isRemote:r}=e.spanContext(),i=r?t:Uc(e).parent_span_id,o=Dc(e).scope;return{parent_span_id:i,span_id:r?o?.getPropagationContext().propagationSpanId||hc():t,trace_id:n}}function qc(e){return e&&e.length>0?e.map(({context:{spanId:e,traceId:t,traceFlags:n,...r},attributes:i})=>({span_id:e,trace_id:t,sampled:1===n,attributes:i,...r})):void 0}function Fc(e){return"number"==typeof e?Hc(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?Hc(e.getTime()):lc()}function Hc(e){return e>9999999999?e/1e3:e}function Uc(e){if(function(e){return"function"==typeof e.getSpanJSON}(e))return e.getSpanJSON();const{spanId:t,traceId:n}=e.spanContext();if(function(e){const t=e;return!!(t.attributes&&t.startTime&&t.name&&t.endTime&&t.status)}(e)){const{attributes:r,startTime:i,name:o,endTime:s,status:a,links:l}=e;return{span_id:t,trace_id:n,data:r,description:o,parent_span_id:Yc(e),start_timestamp:Fc(i),timestamp:Fc(s)||void 0,status:Zc(a),op:r["sentry.op"],origin:r["sentry.origin"],links:qc(l)}}return{span_id:t,trace_id:n,start_timestamp:0,data:{}}}function Yc(e){return"parentSpanId"in e?e.parentSpanId:"parentSpanContext"in e?e.parentSpanContext?.spanId:void 0}function Zc(e){if(e&&0!==e.code)return 1===e.code?"ok":e.message||"internal_error"}const Gc=function(e){return e.Le||e};function Vc(){Lc||(Ga(()=>{}),Lc=!0)}function Qc(e){Xa(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function Jc(e,t){if(!t?.length||!e.description)return!1;for(const n of t){if(Xc(n)){if(Xl(e.description,n))return La&&Qc(e),!0;continue}if(!n.name&&!n.op)continue;const t=!n.name||Xl(e.description,n.name),r=!n.op||e.op&&Xl(e.op,n.op);if(t&&r)return La&&Qc(e),!0}return!1}function Kc(e,t){const n=t.parent_span_id,r=t.span_id;if(n)for(const t of e)t.parent_span_id===r&&(t.parent_span_id=n)}function Xc(e){return"string"==typeof e||e instanceof RegExp}const ed="production";function td(e,t){const n=t.getOptions(),{publicKey:r}=t.getDsn()||{},i={environment:n.environment||ed,release:n.release,public_key:r,trace_id:e,org_id:Ac(t)};return t.emit("createDsc",i),i}function nd(e){const t=Ic();if(!t)return{};const n=Gc(e),r=Uc(n),i=r.data,o=n.spanContext().traceState,s=o?.get("sentry.sample_rate")??i["sentry.sample_rate"]??i["sentry.previous_trace_sample_rate"];function a(e){return"number"!=typeof s&&"string"!=typeof s||(e.sample_rate=`${s}`),e}const l=n.Be;if(l)return a(l);const c=o?.get("sentry.dsc"),d=c&&function(e){const t=function(e){if(e&&(_l(e)||Array.isArray(e)))return Array.isArray(e)?e.reduce((e,t)=>{const n=Rc(t);return Object.entries(n).forEach(([t,n])=>{e[t]=n}),e},{}):Rc(e)}(e);if(!t)return;const n=Object.entries(t).reduce((e,[t,n])=>(t.startsWith("sentry-")&&(e[t.slice(7)]=n),e),{});return Object.keys(n).length>0?n:void 0}(c);if(d)return a(d);const u=td(e.spanContext().traceId,t),h=i["sentry.source"]??i["sentry.span.source"],m=r.description;return"url"!==h&&m&&(u.transaction=m),function(){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const e=Ic()?.getOptions();return!(!e||null==e.tracesSampleRate&&!e.tracesSampler)}()&&(u.sampled=String(function(e){const{traceFlags:t}=e.spanContext();return 1===t}(n)),u.sample_rand=o?.get("sentry.sample_rand")??Dc(n).scope?.getPropagationContext().sampleRand.toString()),a(u),t.emit("createDsc",u,n),u}function rd(e,t=100,n=1/0){try{return od("",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function id(e,t=3,n=102400){const r=rd(e,t);return i=r,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(i))>n?id(e,t-1,n):r;var i}function od(e,t,n=1/0,r=1/0,i=function(){const e=new WeakSet;return[function(t){return!!e.has(t)||(e.add(t),!1)},function(t){e.delete(t)}]}()){const[o,s]=i;if(null==t||["boolean","string"].includes(typeof t)||"number"==typeof t&&Number.isFinite(t))return t;const a=function(e,t){try{if("domain"===e&&t&&"object"==typeof t&&t.qe)return"[Domain]";if("domainEmitter"===e)return"[DomainEmitter]";if("undefined"!=typeof global&&t===global)return"[Global]";if("undefined"!=typeof window&&t===window)return"[Window]";if("undefined"!=typeof document&&t===document)return"[Document]";if(zl(t))return dl(t);if(Il(n=t)&&"nativeEvent"in n&&"preventDefault"in n&&"stopPropagation"in n)return"[SyntheticEvent]";if("number"==typeof t&&!Number.isFinite(t))return`[${t}]`;if("function"==typeof t)return`[Function: ${ll(t)}]`;if("symbol"==typeof t)return`[${String(t)}]`;if("bigint"==typeof t)return`[BigInt: ${String(t)}]`;const r=function(e){const t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:"null prototype"}(t);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(e){return`**non-serializable** (${e})`}var n}(e,t);if(!a.startsWith("[object "))return a;if(t.Fe)return t;const l="number"==typeof t.He?t.He:n;if(0===l)return a.replace("object ","");if(o(t))return"[Circular ~]";const c=t;if(c&&"function"==typeof c.toJSON)try{return od("",c.toJSON(),l-1,r,i)}catch{}const d=Array.isArray(t)?[]:{};let u=0;const h=ql(t);for(const e in h){if(!{}.hasOwnProperty.call(h,e))continue;if(u>=r){d[e]="[MaxProperties ~]";break}const t=h[e];d[e]=od(e,t,l-1,r,i),u++}return s(t),d}function sd(e,t=[]){return[e,t]}function ad(e,t){const[n,r]=e;return[n,[...r,t]]}function ld(e,t){const n=e[1];for(const e of n)if(t(e,e[0].type))return!0;return!1}function cd(e){const t=Ha(Ba);return t.encodePolyfill?t.encodePolyfill(e):(new TextEncoder).encode(e)}function dd(e){const[t,n]=e;let r=JSON.stringify(t);function i(e){"string"==typeof r?r="string"==typeof e?r+e:[cd(r),e]:r.push("string"==typeof e?cd(e):e)}for(const e of n){const[t,n]=e;if(i(`\n${JSON.stringify(t)}\n`),"string"==typeof n||n instanceof Uint8Array)i(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(rd(n))}i(e)}}return"string"==typeof r?r:function(e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(r)}function ud(e){const t="string"==typeof e.data?cd(e.data):e.data;return[{type:"attachment",length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}const hd={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function md(e){return function(e){return e in hd}(e)?hd[e]:e}function fd(e){if(!e?.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}function pd(e,t){const{extra:n,tags:r,attributes:i,user:o,contexts:s,level:a,sdkProcessingMetadata:l,breadcrumbs:c,fingerprint:d,eventProcessors:u,attachments:h,propagationContext:m,transactionName:f,span:p}=t;gd(e,"extra",n),gd(e,"tags",r),gd(e,"attributes",i),gd(e,"user",o),gd(e,"contexts",s),e.sdkProcessingMetadata=dc(e.sdkProcessingMetadata,l,2),a&&(e.level=a),f&&(e.transactionName=f),p&&(e.span=p),c.length&&(e.breadcrumbs=[...e.breadcrumbs,...c]),d.length&&(e.fingerprint=[...e.fingerprint,...d]),u.length&&(e.eventProcessors=[...e.eventProcessors,...u]),h.length&&(e.attachments=[...e.attachments,...h]),e.propagationContext={...e.propagationContext,...m}}function gd(e,t,n){e[t]=dc(e[t],n,1)}function yd(e,t){const n=Ua("globalScope",()=>new gc).getScopeData();return e&&pd(n,e.getScopeData()),t&&pd(n,t.getScopeData()),n}function vd(e){return new bd(t=>{t(e)})}function wd(e){return new bd((t,n)=>{n(e)})}class bd{constructor(e){this.Ue=0,this.Ye=[],this.Ze(e)}then(e,t){return new bd((n,r)=>{this.Ye.push([!1,t=>{if(e)try{n(e(t))}catch(e){r(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){r(e)}else r(e)}]),this.Ge()})}catch(e){return this.then(e=>e,e)}finally(e){return new bd((t,n)=>{let r,i;return this.then(t=>{i=!1,r=t,e&&e()},t=>{i=!0,r=t,e&&e()}).then(()=>{i?n(r):t(r)})})}Ge(){if(0===this.Ue)return;const e=this.Ye.slice();this.Ye=[],e.forEach(e=>{e[0]||(1===this.Ue&&e[1](this.Ve),2===this.Ue&&e[2](this.Ve),e[0]=!0)})}Ze(e){const t=(e,t)=>{0===this.Ue&&(El(t)?t.then(n,r):(this.Ue=e,this.Ve=t,this.Ge()))},n=e=>{t(1,e)},r=e=>{t(2,e)};try{e(n,r)}catch(e){r(e)}}}function xd(e,t,n,r=0){try{const i=kd(t,n,e,r);return El(i)?i:vd(i)}catch(e){return wd(e)}}function kd(e,t,n,r){const i=n[r];if(!e||!i)return e;const o=i({...e},t);return La&&null===o&&Xa(`Event processor "${i.id||"?"}" dropped event`),El(o)?o.then(e=>kd(e,t,n,r+1)):kd(o,t,n,r+1)}let Sd,Nd,_d,Cd;function $d(e,t,n,r,i,o){const{normalizeDepth:s=3,normalizeMaxBreadth:a=1e3}=e,l={...t,event_id:t.event_id||n.event_id||tc(),timestamp:t.timestamp||ac()},c=n.integrations||e.integrations.map(e=>e.name);!function(e,t){const{environment:n,release:r,dist:i,maxValueLength:o}=t;e.environment=e.environment||n||ed,!e.release&&r&&(e.release=r),!e.dist&&i&&(e.dist=i);const s=e.request;s?.url&&o&&(s.url=Jl(s.url,o)),o&&e.exception?.values?.forEach(e=>{e.value&&(e.value=Jl(e.value,o))})}(l,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(l,c),i&&i.emit("applyFrameMetadata",t),void 0===t.type&&function(e,t){const n=function(e){const t=Ba.Qe,n=Ba.Je;if(!t&&!n)return{};const r=t?Object.keys(t):[],i=n?Object.keys(n):[];if(Cd&&r.length===Nd&&i.length===_d)return Cd;Nd=r.length,_d=i.length,Cd={},Sd||(Sd={});const o=(t,n)=>{for(const r of t){const t=n[r],i=Sd?.[r];if(i&&Cd&&t)Cd[i[0]]=t,Sd&&(Sd[r]=[i[0],t]);else if(t){const n=e(r);for(let e=n.length-1;e>=0;e--){const i=n[e],o=i?.filename;if(o&&Cd&&Sd){Cd[o]=t,Sd[r]=[o,t];break}}}}};return t&&o(r,t),n&&o(i,n),Cd}(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=n[e.filename])})})}(l,e.stackParser);const d=function(e,t){if(!t)return e;const n=e?e.clone():new gc;return n.update(t),n}(r,n.captureContext);n.mechanism&&oc(l,n.mechanism);const u=i?i.getEventProcessors():[],h=yd(o,d),m=[...n.attachments||[],...h.attachments];m.length&&(n.attachments=m),function(e,t){const{fingerprint:n,span:r,breadcrumbs:i,sdkProcessingMetadata:o}=t;!function(e,t){const{extra:n,tags:r,user:i,contexts:o,level:s,transactionName:a}=t;Object.keys(n).length&&(e.extra={...n,...e.extra}),Object.keys(r).length&&(e.tags={...r,...e.tags}),Object.keys(i).length&&(e.user={...i,...e.user}),Object.keys(o).length&&(e.contexts={...o,...e.contexts}),s&&(e.level=s),a&&"transaction"!==e.type&&(e.transaction=a)}(e,t),r&&function(e,t){e.contexts={trace:Bc(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:nd(t),...e.sdkProcessingMetadata};const n=Uc(Gc(t)).description;n&&!e.transaction&&"transaction"===e.type&&(e.transaction=n)}(e,r),function(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint.length||delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,i),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,o)}(l,h);const f=[...u,...h.eventProcessors];return(n.data&&!0===n.data.Ke?vd(l):xd(f,l,n)).then(e=>(e&&function(e){const t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{n.push({type:"sourcemap",code_file:e,debug_id:t})})}(e),"number"==typeof s&&s>0?function(e,t,n){if(!e)return null;const r={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:rd(e.data,t,n)}}))},...e.user&&{user:rd(e.user,t,n)},...e.contexts&&{contexts:rd(e.contexts,t,n)},...e.extra&&{extra:rd(e.extra,t,n)}};return e.contexts?.trace&&r.contexts&&(r.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(r.contexts.trace.data=rd(e.contexts.trace.data,t,n))),e.spans&&(r.spans=e.spans.map(e=>({...e,...e.data&&{data:rd(e.data,t,n)}}))),e.contexts?.flags&&r.contexts&&(r.contexts.flags=rd(e.contexts.flags,3,n)),r}(e,s,a):e))}function Id(e){return _c().captureException(e,void 0)}function Td(e,t){const n="string"==typeof t?t:void 0,r="string"!=typeof t?{captureContext:t}:void 0;return _c().captureMessage(e,n,r)}function Ed(e,t){return _c().captureEvent(e,t)}function Pd(e){const t=Cc(),{user:n}=yd(t,_c()),{userAgent:r}=Ba.navigator||{},i=function(e){const t=lc(),n={sid:tc(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return{sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}}}(n)};return e&&cc(n,e),n}({user:n,...r&&{userAgent:r},...e}),o=t.getSession();return"ok"===o?.status&&cc(o,{status:"exited"}),zd(),t.setSession(i),i}function zd(){const e=Cc(),t=_c().getSession()||e.getSession();t&&function(e){let t={};"ok"===e.status&&(t={status:"exited"}),cc(e,t)}(t),Dd(),e.setSession()}function Dd(){const e=Cc(),t=Ic(),n=e.getSession();n&&t&&t.captureSession(n)}function Rd(e=!1){e?zd():Dd()}const Md=[];function Od(e){const t=e.defaultIntegrations||[],n=e.integrations;let r;if(t.forEach(e=>{e.isDefaultInstance=!0}),Array.isArray(n))r=[...t,...n];else if("function"==typeof n){const e=n(t);r=Array.isArray(e)?e:[e]}else r=t;return function(e){const t={};return e.forEach(e=>{const{name:n}=e,r=t[n];r&&!r.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)}),Object.values(t)}(r)}function jd(e,t){for(const n of t)n?.afterAllSetup&&n.afterAllSetup(e)}function Wd(e,t,n){if(n[t.name])La&&Xa(`Integration skipped because it was already installed: ${t.name}`);else{if(n[t.name]=t,Md.includes(t.name)||"function"!=typeof t.setupOnce||(t.setupOnce(),Md.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),"function"==typeof t.preprocessEvent){const n=t.preprocessEvent.bind(t);e.on("preprocessEvent",(t,r)=>n(t,r,e))}if("function"==typeof t.processEvent){const n=t.processEvent.bind(t),r=Object.assign((t,r)=>n(t,r,e),{id:t.name});e.addEventProcessor(r)}La&&Xa(`Integration installed: ${t.name}`)}}function Ad(e,t){const n=t??function(e){return Ld().get(e)}(e)??[];if(0===n.length)return;const r=e.getOptions(),i=function(e,t,n,r){const i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=jc(r)),sd(i,[(o=e,[{type:"log",item_count:o.length,content_type:"application/vnd.sentry.items.log+json"},{items:o}])]);var o}(n,r.Xe,r.tunnel,e.getDsn());Ld().set(e,[]),e.emit("flushLogs"),e.sendEnvelope(i)}function Ld(){return Ua("clientToLogBufferMap",()=>new WeakMap)}function Bd(e,t){const n=t??function(e){return qd().get(e)}(e)??[];if(0===n.length)return;const r=e.getOptions(),i=function(e,t,n,r){const i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=jc(r)),sd(i,[(o=e,[{type:"trace_metric",item_count:o.length,content_type:"application/vnd.sentry.items.trace-metric+json"},{items:o}])]);var o}(n,r.Xe,r.tunnel,e.getDsn());qd().set(e,[]),e.emit("flushMetrics"),e.sendEnvelope(i)}function qd(){return Ua("clientToMetricBufferMap",()=>new WeakMap)}function Fd(e){return"object"==typeof e&&"function"==typeof e.unref&&e.unref(),e}const Hd=Symbol.for("SentryBufferFullError");function Ud(e=100){const t=new Set;function n(e){t.delete(e)}return{get $(){return Array.from(t)},add:function(r){if(!(t.size<e))return wd(Hd);const i=r();return t.add(i),i.then(()=>n(i),()=>n(i)),i},drain:function(e){if(!t.size)return vd(!0);const n=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return n;const r=[n,new Promise(t=>Fd(setTimeout(()=>t(!1),e)))];return Promise.race(r)}}}function Yd(e,t,n=Ud(e.bufferSize||64)){let r={};return{send:function(i){const o=[];if(ld(i,(t,n)=>{const i=md(n);!function(e,t,n=Ql()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(r,i)?o.push(t):e.recordDroppedEvent("ratelimit_backoff",i)}),0===o.length)return Promise.resolve({});const s=sd(i[0],o),a=t=>{!function(e,t){return ld(e,(e,n)=>t.includes(n))}(s,["client_report"])?ld(s,(n,r)=>{e.recordDroppedEvent(t,md(r))}):La&&el(`Dropping client report. Will not send outcomes (reason: ${t}).`)};return n.add(()=>t({body:dd(s)}).then(e=>413===e.statusCode?(La&&tl("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),a("send_error"),e):(La&&void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&el(`Sentry responded with status code ${e.statusCode} to sent event.`),r=function(e,{statusCode:t,headers:n},r=Ql()){const i={...e},o=n?.["x-sentry-rate-limits"],s=n?.["retry-after"];if(o)for(const e of o.trim().split(",")){const[t,n,,,o]=e.split(":",5),s=parseInt(t,10),a=1e3*(isNaN(s)?60:s);if(n)for(const e of n.split(";"))"metric_bucket"===e&&o&&!o.split(";").includes("custom")||(i[e]=r+a);else i.all=r+a}else s?i.all=r+function(e,t=Ql()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const r=Date.parse(`${e}`);return isNaN(r)?6e4:r-t}(s,r):429===t&&(i.all=r+6e4);return i}(r,e),e),e=>{throw a("network_error"),La&&tl("Encountered error running transport request:",e),e})).then(e=>e,e=>{if(e===Hd)return La&&tl("Skipped sending event because buffer is full."),a("queue_overflow"),Promise.resolve({});throw e})},flush:e=>n.drain(e)}}function Zd(e){const t=[];e.message&&t.push(e.message);try{const n=e.exception.values[e.exception.values.length-1];n?.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`))}catch{}return t}const Gd="Not capturing exception because it's already been captured.",Vd="Discarded session because of missing or non-string release",Qd=Symbol.for("SentryInternalError"),Jd=Symbol.for("SentryDoNotSendEventError");function Kd(e){return{message:e,[Qd]:!0}}function Xd(e){return{message:e,[Jd]:!0}}function eu(e){return!!e&&"object"==typeof e&&Qd in e}function tu(e){return!!e&&"object"==typeof e&&Jd in e}function nu(e,t,n,r,i){let o,s=0,a=!1;e.on(n,()=>{s=0,clearTimeout(o),a=!1}),e.on(t,t=>{s+=r(t),s>=8e5?i(e):a||(a=!0,o=Fd(setTimeout(()=>{i(e)},5e3)))}),e.on("flush",()=>{i(e)})}class ru{constructor(e){if(this.et=e,this.nt={},this.rt=0,this.it={},this.ot={},this.ge=[],this.st=Ud(e.transportOptions?.bufferSize??64),e.dsn?this.lt=function(e){const t="string"==typeof e?function(e){const t=Oc.exec(e);if(!t)return void Ga(()=>{});const[n,r,i="",o="",s="",a=""]=t.slice(1);let l="",c=a;const d=c.split("/");if(d.length>1&&(l=d.slice(0,-1).join("/"),c=d.pop()),c){const e=c.match(/^\d+/);e&&(c=e[0])}return Wc({host:o,pass:i,path:l,projectId:c,port:s,protocol:n,publicKey:r})}(e):Wc(e);if(t&&function(e){if(!La)return!0;const{port:t,projectId:n,protocol:r}=e;return!(["protocol","publicKey","host","projectId"].find(t=>!e[t]&&(tl(`Invalid Sentry Dsn: ${t} missing`),!0))||(n.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(r)?t&&isNaN(parseInt(t,10))&&(tl(`Invalid Sentry Dsn: Invalid port ${t}`),1):(tl(`Invalid Sentry Dsn: Invalid protocol ${r}`),1):(tl(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}(e.dsn):La&&el("No DSN provided, client will not send events."),this.lt){const i=(t=this.lt,n=e.tunnel,r=e.Xe?e.Xe.sdk:void 0,n||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",n=e.port?`:${e.port}`:"";return`${t}//${e.host}${n}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(t)}?${function(e,t){const n={sentry_version:"7"};return e.publicKey&&(n.sentry_key=e.publicKey),t&&(n.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(n).toString()}(t,r)}`);this.ct=e.transport({tunnel:this.et.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:i})}var t,n,r;this.et.enableLogs=this.et.enableLogs??this.et.ut?.enableLogs,this.et.enableLogs&&nu(this,"afterCaptureLog","flushLogs",lu,Ad),(this.et.enableMetrics??this.et.ut?.enableMetrics??1)&&nu(this,"afterCaptureMetric","flushMetrics",au,Bd)}captureException(e,t,n){const r=tc();if(sc(e))return La&&Xa(Gd),r;const i={event_id:r,...t};return this.ht(()=>this.eventFromException(e,i).then(e=>this.ft(e,i,n)).then(e=>e),"error"),i.event_id}captureMessage(e,t,n,r){const i={event_id:tc(),...n},o=Cl(e)?e:String(e),s=$l(e),a=s?this.eventFromMessage(o,t,i):this.eventFromException(e,i);return this.ht(()=>a.then(e=>this.ft(e,i,r)),s?"unknown":"error"),i.event_id}captureEvent(e,t,n){const r=tc();if(t?.originalException&&sc(t.originalException))return La&&Xa(Gd),r;const i={event_id:r,...t},o=e.sdkProcessingMetadata||{},s=o.capturedSpanScope,a=o.capturedSpanIsolationScope,l=iu(e.type);return this.ht(()=>this.ft(e,i,s||n,a),l),i.event_id}captureSession(e){this.sendSession(e),cc(e,{init:!1})}getDsn(){return this.lt}getOptions(){return this.et}getSdkMetadata(){return this.et.Xe}getTransport(){return this.ct}async flush(e){const t=this.ct;if(!t)return!0;this.emit("flush");const n=await this.gt(e),r=await t.flush(e);return n&&r}async close(e){Ad(this);const t=await this.flush(e);return this.getOptions().enabled=!1,this.emit("close"),t}getEventProcessors(){return this.ge}addEventProcessor(e){this.ge.push(e)}init(){(this.yt()||this.et.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this.vt()}getIntegrationByName(e){return this.nt[e]}addIntegration(e){const t=this.nt[e.name];!t&&e.beforeSetup&&e.beforeSetup(this),Wd(this,e,this.nt),t||jd(this,[e])}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);let n=function(e,t,n,r){const i=fd(n),o=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){if(!t)return e;const n=e.sdk||{};e.sdk={...n,name:n.name||t.name,version:n.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0}}(e,n?.sdk);const s=function(e,t,n,r){const i=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&{sdk:t},...!!n&&r&&{dsn:jc(r)},...i&&{trace:i}}}(e,i,r,t);return delete e.sdkProcessingMetadata,sd(s,[[{type:o},e]])}(e,this.lt,this.et.Xe,this.et.tunnel);for(const e of t.attachments||[])n=ad(n,ud(e));this.sendEnvelope(n).then(t=>this.emit("afterSendEvent",e,t))}sendSession(e){const{release:t,environment:n=ed}=this.et;if("aggregates"in e){const r=e.attrs||{};if(!r.release&&!t)return void(La&&el(Vd));r.release=r.release||t,r.environment=r.environment||n,e.attrs=r}else{if(!e.release&&!t)return void(La&&el(Vd));e.release=e.release||t,e.environment=e.environment||n}this.emit("beforeSendSession",e);const r=function(e,t,n,r){const i=fd(n);return sd({sent_at:(new Date).toISOString(),...i&&{sdk:i},...!!r&&t&&{dsn:jc(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this.lt,this.et.Xe,this.et.tunnel);this.sendEnvelope(r)}recordDroppedEvent(e,t,n=1){if(this.et.sendClientReports){const r=`${e}:${t}`;La&&Xa(`Recording outcome: "${r}"${n>1?` (${n} times)`:""}`),this.it[r]=(this.it[r]||0)+n}}on(e,t){const n=this.ot[e]=this.ot[e]||new Set,r=(...e)=>t(...e);return n.add(r),()=>{n.delete(r)}}emit(e,...t){const n=this.ot[e];n&&n.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit("beforeEnvelope",e),this.yt()&&this.ct)try{return await this.ct.send(e)}catch(e){return La&&tl("Error while sending envelope:",e),{}}return La&&tl("Transport disabled"),{}}dispose(){}vt(){const{integrations:e}=this.et;this.nt=function(e,t){const n={};return t.forEach(t=>{t?.beforeSetup&&t.beforeSetup(e)}),t.forEach(t=>{t&&Wd(e,t,n)}),n}(this,e),jd(this,e)}wt(e,t){let n="fatal"===t.level,r=!1;const i=t.exception?.values;if(i){r=!0,n=!1;for(const e of i)if(!1===e.mechanism?.handled){n=!0;break}}const o="ok"===e.status;(o&&0===e.errors||o&&n)&&(cc(e,{...n&&{status:"crashed"},errors:e.errors||Number(r||n)}),this.captureSession(e))}async gt(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this.rt)return!0;t++}return!1}yt(){return!1!==this.getOptions().enabled&&void 0!==this.ct}bt(e,t,n,r){const i=this.getOptions(),o=Object.keys(this.nt);return!t.integrations&&o?.length&&(t.integrations=o),this.emit("preprocessEvent",e,t),e.type||r.setLastEventId(e.event_id||t.event_id),$d(i,e,t,n,this,r).then(e=>{if(null===e)return e;this.emit("postprocessEvent",e,t),e.contexts={trace:{...e.contexts?.trace,...Tc(n)},...e.contexts};const r=function(e,t){const n=t.getPropagationContext();return n.dsc||td(n.traceId,e)}(this,n);return e.sdkProcessingMetadata={dynamicSamplingContext:r,...e.sdkProcessingMetadata},e})}ft(e,t={},n=_c(),r=Cc()){return La&&ou(e)&&Xa(`Captured error event \`${Zd(e)[0]||"<unknown>"}\``),this.xt(e,t,n,r).then(e=>e.event_id,e=>{La&&(tu(e)?Xa(e.message):eu(e)?el(e.message):el(e))})}xt(e,t,n,r){const i=this.getOptions(),{sampleRate:o}=i,s=su(e),a=ou(e),l=`before send for type \`${e.type||"error"}\``,c=void 0===o?void 0:function(e){if("boolean"==typeof e)return Number(e);const t="string"==typeof e?parseFloat(e):e;return"number"!=typeof t||isNaN(t)||t<0||t>1?void 0:t}(o);if(a&&"number"==typeof c&&Vl()>c)return this.recordDroppedEvent("sample_rate","error"),wd(Xd(`Discarding event because it's not included in the random sample (sampling rate = ${o})`));const d=iu(e.type);return this.bt(e,t,n,r).then(e=>{if(null===e)throw this.recordDroppedEvent("event_processor",d),Xd("An event processor returned `null`, will not send event.");if(!0===t.data?.Ke)return e;const n=function(e,t,n,r){const{beforeSend:i,beforeSendTransaction:o,ignoreSpans:s}=t,a=!((l=t.beforeSendSpan)&&"function"==typeof l&&"kt"in l&&l.kt)&&t.beforeSendSpan;var l;let c=n;if(ou(c)&&i)return i(c,r);if(su(c)){if(a||s){const t=function(e){const{trace_id:t,parent_span_id:n,span_id:r,status:i,origin:o,data:s,op:a}=e.contexts?.trace??{};return{data:s??{},description:e.transaction,op:a,parent_span_id:n,span_id:r??"",start_timestamp:e.start_timestamp??0,status:i,timestamp:e.timestamp,trace_id:t??"",origin:o,profile_id:s?.[Ec],exclusive_time:s?.[Pc],measurements:e.measurements,is_segment:!0}}(c);if(s?.length&&Jc(t,s))return null;if(a){const e=a(t);e?c=dc(n,{type:"transaction",timestamp:(d=e).timestamp,start_timestamp:d.start_timestamp,transaction:d.description,contexts:{trace:{trace_id:d.trace_id,span_id:d.span_id,parent_span_id:d.parent_span_id,op:d.op,status:d.status,origin:d.origin,data:{...d.data,...d.profile_id&&{[Ec]:d.profile_id},...d.exclusive_time&&{[Pc]:d.exclusive_time}}}},measurements:d.measurements}):Vc()}if(c.spans){const t=[],n=c.spans;for(const e of n)if(s?.length&&Jc(e,s))Kc(n,e);else if(a){const n=a(e);n?t.push(n):(Vc(),t.push(e))}else t.push(e);const r=c.spans.length-t.length;r&&e.recordDroppedEvent("before_send","span",r),c.spans=t}}if(o){if(c.spans){const e=c.spans.length;c.sdkProcessingMetadata={...n.sdkProcessingMetadata,spanCountBeforeProcessing:e}}return o(c,r)}}var d;return c}(this,i,e,t);return function(e,t){const n=`${t} must return \`null\` or a valid event.`;if(El(e))return e.then(e=>{if(!Il(e)&&null!==e)throw Kd(n);return e},e=>{throw Kd(`${t} rejected with ${e}`)});if(!Il(e)&&null!==e)throw Kd(n);return e}(n,l)}).then(i=>{if(null===i){if(this.recordDroppedEvent("before_send",d),s){const t=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",t)}throw Xd(`${l} returned \`null\`, will not send event.`)}const o=n.getSession()||r.getSession();if(a&&o&&this.wt(o,i),s){const e=(i.sdkProcessingMetadata?.spanCountBeforeProcessing||0)-(i.spans?i.spans.length:0);e>0&&this.recordDroppedEvent("before_send","span",e)}const c=i.transaction_info;if(s&&c&&i.transaction!==e.transaction){const e="custom";i.transaction_info={...c,source:e}}return this.sendEvent(i,t),i}).then(null,e=>{if(tu(e)||eu(e))throw e;throw this.captureException(e,{mechanism:{handled:!1,type:"internal"},data:{Ke:!0},originalException:e}),Kd(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`)})}ht(e,t){this.rt++,this.st.add(e).then(e=>(this.rt--,e),e=>(this.rt--,e===Hd&&this.recordDroppedEvent("queue_overflow",t),e))}St(){const e=this.it;return this.it={},Object.entries(e).map(([e,t])=>{const[n,r]=e.split(":");return{reason:n,category:r,quantity:t}})}Nt(){La&&Xa("Flushing outcomes...");const e=this.St();if(0===e.length)return void(La&&Xa("No outcomes to send"));if(!this.lt)return void(La&&Xa("No dsn provided, will not send outcomes"));La&&Xa("Sending outcomes:",e);const t=(n=e,sd((r=this.et.tunnel&&jc(this.lt))?{dsn:r}:{},[[{type:"client_report"},{timestamp:ac(),discarded_events:n}]]));var n,r;this.sendEnvelope(t)}}function iu(e){return"replay_event"===e?"replay":e||"error"}function ou(e){return void 0===e.type}function su(e){return"transaction"===e.type}function au(e){let t=0;return e.name&&(t+=2*e.name.length),t+=8,t+cu(e.attributes)}function lu(e){let t=0;return e.message&&(t+=2*e.message.length),t+cu(e.attributes)}function cu(e){if(!e)return 0;let t=0;return Object.values(e).forEach(e=>{Array.isArray(e)?t+=e.length*du(e[0]):$l(e)?t+=du(e):t+=100}),t}function du(e){return"string"==typeof e?2*e.length:"number"==typeof e?8:"boolean"==typeof e?4:0}function uu(e){return function(e){return xl(e)&&"_t"in e&&"string"==typeof e._t}(e)?`${e.message} (${e._t})`:e.message}function hu(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:n,hash:r,relative:t[5]+n+r}}function mu(e){"aggregates"in e?void 0===e.attrs?.ip_address&&(e.attrs={...e.attrs,ip_address:"{{auto}}"}):void 0===e.ipAddress&&(e.ipAddress="{{auto}}")}const fu=100;function pu(e,t){const n=Ic(),r=Cc();if(!n)return;const{beforeBreadcrumb:i=null,maxBreadcrumbs:o=fu}=n.getOptions();if(o<=0)return;const s={timestamp:ac(),...e},a=i?Ga(()=>i(s,t)):s;null!==a&&(n.emit&&n.emit("beforeAddBreadcrumb",a,t),r.addBreadcrumb(a,o))}let gu;const yu=new WeakMap,vu=()=>({name:"FunctionToString",setupOnce(){gu=function(){}.toString;try{Function.prototype.toString=function(...e){const t=Bl(this),n=yu.has(Ic())&&void 0!==t?t:this;return gu.apply(n,e)}}catch{}},setup(e){yu.set(e,!0)}}),wu=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],bu=(e={})=>{let t;return{name:"EventFilters",setup(n){const r=n.getOptions();t=ku(e,r)},processEvent(n,r,i){if(!t){const n=i.getOptions();t=ku(e,n)}return function(e,t){if(e.type){if("transaction"===e.type&&function(e,t){if(!t?.length)return!1;const n=e.transaction;return!!n&&ec(n,t)}(e,t.ignoreTransactions))return La&&el(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${rc(e)}`),!0}else{if(function(e,t){return!!t?.length&&Zd(e).some(e=>ec(e,t))}(e,t.ignoreErrors))return La&&el(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${rc(e)}`),!0;if(function(e){return!!e.exception?.values?.length&&(!e.message&&!e.exception.values.some(e=>e.stacktrace||e.type&&"Error"!==e.type||e.value))}(e))return La&&el(`Event dropped due to not having an error message, error type or stacktrace.\nEvent: ${rc(e)}`),!0;if(function(e,t){if(!t?.length)return!1;const n=Su(e);return!!n&&ec(n,t)}(e,t.denyUrls))return La&&el(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${rc(e)}.\nUrl: ${Su(e)}`),!0;if(!function(e,t){if(!t?.length)return!0;const n=Su(e);return!n||ec(n,t)}(e,t.allowUrls))return La&&el(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${rc(e)}.\nUrl: ${Su(e)}`),!0}return!1}(n,t)?null:n}}},xu=(e={})=>({...bu(e),name:"InboundFilters"});function ku(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:wu],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[]]}}function Su(e){try{const t=[...e.exception?.values??[]].reverse().find(e=>void 0===e.mechanism?.parent_id&&e.stacktrace?.frames?.length),n=t?.stacktrace?.frames;return n?function(e=[]){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&"<anonymous>"!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null}(n):null}catch{return La&&tl(`Cannot extract url for event ${rc(e)}`),null}}function Nu(e,t,n,r,i,o){if(!i.exception?.values||!o||!Pl(o.originalException,Error))return;const s=i.exception.values.length>0?i.exception.values[i.exception.values.length-1]:void 0;s&&(i.exception.values=_u(e,t,r,o.originalException,n,i.exception.values,s,0))}function _u(e,t,n,r,i,o,s,a){if(o.length>=n+1)return o;let l=[...o];if(Pl(r[i],Error)){$u(s,a,r);const o=e(t,r[i]),c=l.length;Iu(o,i,c,a),l=_u(e,t,n,r[i],i,[o,...l],o,c)}return Cu(r)&&r.errors.forEach((o,c)=>{if(Pl(o,Error)){$u(s,a,r);const d=e(t,o),u=l.length;Iu(d,`errors[${c}]`,u,a),l=_u(e,t,n,o,i,[d,...l],d,u)}}),l}function Cu(e){return Array.isArray(e.errors)}function $u(e,t,n){e.mechanism={handled:!0,type:"auto.core.linked_errors",...Cu(n)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function Iu(e,t,n,r){e.mechanism={handled:!0,...e.mechanism,type:"chained",source:t,exception_id:n,parent_id:r}}function Tu(){"console"in Ba&&Ya.forEach(function(e){e in Ba.console&&Wl(Ba.console,e,function(t){return Za[e]=t,function(...t){pl("console",{args:t,level:e});const n=Za[e];n?.apply(Ba.console,t)}})})}const Eu=()=>{let e;return{name:"Dedupe",processEvent(t){if(t.type)return t;try{if(function(e,t){return!!t&&(!!function(e,t){const n=e.message,r=t.message;return!(!n&&!r)&&(!(n&&!r||!n&&r)&&(n===r&&(!!zu(e,t)&&!!Pu(e,t))))}(e,t)||!!function(e,t){const n=Du(t),r=Du(e);return!(!n||!r)&&(n.type===r.type&&n.value===r.value&&(!!zu(e,t)&&!!Pu(e,t)))}(e,t))}(t,e))return La&&el("Event dropped due to being a duplicate of previously captured event."),null}catch{}return e=t}}};function Pu(e,t){let n=cl(e),r=cl(t);if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;if(r.length!==n.length)return!1;for(let e=0;e<r.length;e++){const t=r[e],i=n[e];if(t.filename!==i.filename||t.lineno!==i.lineno||t.colno!==i.colno||t.function!==i.function)return!1}return!0}function zu(e,t){let n=e.fingerprint,r=t.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;try{return!(n.join("")!==r.join(""))}catch{return!1}}function Du(e){return e.exception?.values?.[0]}function Ru(e){return void 0===e?void 0:e>=400&&e<500?"warning":e>=500?"error":void 0}const Mu=Ba;function Ou(e){return e&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function ju(e,t){const n="fetch";ml(n,e),fl(n,()=>function(e,t=!1){t&&!function(){if("string"==typeof EdgeRuntime)return!0;if(!function(){if(!("fetch"in Mu))return!1;try{return new Headers,new Request("data:,"),new Response,!0}catch{return!1}}())return!1;if(Ou(Mu.fetch))return!0;let e=!1;const t=Mu.document;if(t&&"function"==typeof t.createElement)try{const n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n),n.contentWindow?.fetch&&(e=Ou(n.contentWindow.fetch)),t.head.removeChild(n)}catch(e){La&&el("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return e}()||Wl(Ba,"fetch",function(e){return function(...t){const n=new Error,{method:r,url:i}=function(e){if(0===e.length)return{method:"GET",url:""};if(2===e.length){const[t,n]=e;return{url:Au(t),method:Wu(n,"method")?String(n.method).toUpperCase():Dl(t)&&Wu(t,"method")?String(t.method).toUpperCase():"GET"}}const t=e[0];return{url:Au(t),method:Wu(t,"method")?String(t.method).toUpperCase():"GET"}}(t),o={args:t,fetchData:{method:r,url:i},startTimestamp:1e3*lc(),virtualError:n,headers:Lu(t)};return pl("fetch",{...o}),e.apply(Ba,t).then(async e=>(pl("fetch",{...o,endTimestamp:1e3*lc(),response:e}),e),e=>{pl("fetch",{...o,endTimestamp:1e3*lc(),error:e}),xl(e)&&void 0===e.stack&&(e.stack=n.stack,Al(e,"framesToPop",1));const t=Ic(),r=t?.getOptions().enhanceFetchErrorMessages??"always";if(!1!==r&&e instanceof TypeError&&("Failed to fetch"===e.message||"Load failed"===e.message||"NetworkError when attempting to fetch resource."===e.message))try{const t=new URL(o.fetchData.url).host;"always"===r?e.message=`${e.message} (${t})`:Al(e,"__sentry_fetch_url_host__",t)}catch{}throw e})}})}(0,t))}function Wu(e,t){return!!e&&"object"==typeof e&&!!e[t]}function Au(e){return"string"==typeof e?e:e?Wu(e,"url")?e.url:e.toString?e.toString():"":""}function Lu(e){const[t,n]=e;try{if("object"==typeof n&&null!==n&&"headers"in n&&n.headers)return new Headers(n.headers);if(Dl(t))return new Headers(t.headers)}catch{}}const Bu=Ba;let qu=0;function Fu(){return qu>0}function Hu(e,t={}){if(!function(e){return"function"==typeof e}(e))return e;try{const t=e.Ct;if(t)return"function"==typeof t?t:e;if(Bl(e))return e}catch{return e}const n=function(...n){try{const r=n.map(e=>Hu(e,t));return e.apply(this,r)}catch(e){throw qu++,setTimeout(()=>{qu--}),$c(r=>{r.addEventProcessor(e=>(t.mechanism&&(ic(e,void 0),oc(e,t.mechanism)),e.extra={...e.extra,arguments:n},e)),Id(e)}),e}};try{for(const t in e)({}).hasOwnProperty.call(e,t)&&(n[t]=e[t])}catch{}Ll(n,e),Al(e,"__sentry_wrapped__",n);try{Object.getOwnPropertyDescriptor(n,"name").configurable&&Object.defineProperty(n,"name",{get:()=>e.name})}catch{}return n}function Uu(e,t){const n=Zu(e,t),r={type:Qu(t),value:Ju(t)};return n.length&&(r.stacktrace={frames:n}),void 0===r.type&&""===r.value&&(r.value="Unrecoverable error caught"),r}function Yu(e,t){return{exception:{values:[Uu(e,t)]}}}function Zu(e,t){const n=t.stacktrace||t.stack||"",r=function(e){return e&&Gu.test(e.message)?1:0}(t),i=function(e){return"number"==typeof e.framesToPop?e.framesToPop:0}(t);try{return e(n,r,i)}catch{}return[]}const Gu=/Minified React error #\d+;/i;function Vu(e){return"undefined"!=typeof WebAssembly&&void 0!==WebAssembly.Exception&&e instanceof WebAssembly.Exception}function Qu(e){const t=e?.name;return!t&&Vu(e)?e.message&&Array.isArray(e.message)&&2==e.message.length?e.message[0]:"WebAssembly.Exception":t}function Ju(e){const t=e?.message;return Vu(e)?Array.isArray(e.message)&&2==e.message.length?e.message[1]:"wasm exception":t?t.error&&"string"==typeof t.error.message?uu(t.error):uu(e):"No error message"}function Ku(e,t,n,r,i){let o;if(Sl(t)&&t.error)return Yu(e,t.error);if(Nl(t)||kl(t,"DOMException")){const i=t;if("stack"in t)o=Yu(e,t);else{const t=i.name||(Nl(i)?"DOMError":"DOMException"),s=i.message?`${t}: ${i.message}`:t;o=Xu(e,s,n,r),ic(o,s)}return"code"in i&&(o.tags={...o.tags,"DOMException.code":`${i.code}`}),o}return xl(t)?Yu(e,t):Il(t)||Tl(t)?(o=function(e,t,n,r){const i=Ic(),o=i?.getOptions().normalizeDepth,s=(a=t,Object.values(a).find(e=>e instanceof Error));var a;const l={$t:id(t,o)};if(s)return{exception:{values:[Uu(e,s)]},extra:l};const c={exception:{values:[{type:Tl(t)?t.constructor.name:r?"UnhandledRejection":"Error",value:eh(t,{isUnhandledRejection:r})}]},extra:l};if(n){const t=Zu(e,n);t.length&&(c.exception.values[0].stacktrace={frames:t})}return c}(e,t,n,i),oc(o,{synthetic:!0}),o):(o=Xu(e,t,n,r),ic(o,`${t}`),oc(o,{synthetic:!0}),o)}function Xu(e,t,n,r){const i={};if(r&&n){const r=Zu(e,n);r.length&&(i.exception={values:[{value:t,stacktrace:{frames:r}}]}),oc(i,{synthetic:!0})}if(Cl(t)){const{le:e,ce:n}=t;return i.logentry={message:e,params:n},i}return i.message=t,i}function eh(e,{isUnhandledRejection:t}){const n=function(e){const t=Object.keys(ql(e));return t.sort(),t[0]?t.join(", "):"[object has no keys]"}(e),r=t?"promise rejection":"exception";return Sl(e)?`Event \`ErrorEvent\` captured as ${r} with message \`${e.message}\``:Tl(e)?`Event \`${function(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}(e)}\` (type=${e.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}class th extends ru{constructor(e){const t=(n=e,{release:"string"==typeof __SENTRY_RELEASE__?__SENTRY_RELEASE__:Bu.SENTRY_RELEASE?.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...n});var n;!function(e,t,n=[t],r="npm"){const i=(e.Xe=e.Xe||{}).sdk=e.Xe.sdk||{};i.name||(i.name=`sentry.javascript.${t}`,i.packages=n.map(e=>({name:`${r}:@sentry/${e}`,version:qa})),i.version=qa)}(t,"browser",["browser"],Bu.SENTRY_SDK_SOURCE||"npm"),t.Xe?.sdk&&(t.Xe.sdk.settings={infer_ip:t.sendDefaultPii?"auto":"never",...t.Xe.sdk.settings}),super(t);const{sendDefaultPii:r,sendClientReports:i,enableLogs:o,ut:s,enableMetrics:a}=this.et,l=a??s?.enableMetrics??!0;Bu.document&&(i||o||l)&&Bu.document.addEventListener("visibilitychange",()=>{"hidden"===Bu.document.visibilityState&&(i&&this.Nt(),o&&Ad(this),l&&Bd(this))}),r&&this.on("beforeSendSession",mu)}eventFromException(e,t){return function(e,t,n,r){const i=Ku(e,t,n?.syntheticException||void 0,r);return oc(i),i.level="error",n?.event_id&&(i.event_id=n.event_id),vd(i)}(this.et.stackParser,e,t,this.et.attachStacktrace)}eventFromMessage(e,t="info",n){return function(e,t,n="info",r,i){const o=Xu(e,t,r?.syntheticException||void 0,i);return o.level=n,r?.event_id&&(o.event_id=r.event_id),vd(o)}(this.et.stackParser,e,t,n,this.et.attachStacktrace)}bt(e,t,n,r){return e.platform=e.platform||"javascript",super.bt(e,t,n,r)}}const nh="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,rh=Ba;let ih,oh,sh,ah;function lh(){if(!rh.document)return;const e=pl.bind(null,"dom"),t=ch(e,!0);rh.document.addEventListener("click",t,!1),rh.document.addEventListener("keypress",t,!1),["EventTarget","Node"].forEach(t=>{const n=rh,r=n[t]?.prototype;r?.hasOwnProperty?.("addEventListener")&&(Wl(r,"addEventListener",function(t){return function(n,r,i){if("click"===n||"keypress"==n)try{const r=this.It=this.It||{},o=r[n]=r[n]||{refCount:0};if(!o.handler){const r=ch(e);o.handler=r,t.call(this,n,r,i)}o.refCount++}catch{}return t.call(this,n,r,i)}}),Wl(r,"removeEventListener",function(e){return function(t,n,r){if("click"===t||"keypress"==t)try{const n=this.It||{},i=n[t];i&&(i.refCount--,i.refCount<=0&&(e.call(this,t,i.handler,r),i.handler=void 0,delete n[t]),0===Object.keys(n).length&&delete this.It)}catch{}return e.call(this,t,n,r)}}))})}function ch(e,t=!1){return n=>{if(!n||n.Tt)return;const r=function(e){try{return e.target}catch{return null}}(n);if(function(e,t){return"keypress"===e&&(!t?.tagName||"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)}(n.type,r))return;Al(n,"_sentryCaptured",!0),r&&!r.Et&&Al(r,"_sentryId",tc());const i="keypress"===n.type?"input":n.type;(function(e){if(e.type!==oh)return!1;try{if(!e.target||e.target.Et!==sh)return!1}catch{}return!0})(n)||(e({event:n,name:i,global:t}),oh=n.type,sh=r?r.Et:void 0),clearTimeout(ih),ih=rh.setTimeout(()=>{sh=void 0,oh=void 0},1e3)}}function dh(e){const t="history";ml(t,e),fl(t,uh)}function uh(){function e(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const r=ah,i=function(e){try{return new URL(e,rh.location.origin).toString()}catch{return e}}(String(n));if(ah=i,r===i)return e.apply(this,t);pl("history",{from:r,to:i})}return e.apply(this,t)}}rh.addEventListener("popstate",()=>{const e=rh.location.href,t=ah;ah=e,t!==e&&pl("history",{from:t,to:e})}),"history"in Mu&&Mu.history&&(Wl(rh.history,"pushState",e),Wl(rh.history,"replaceState",e))}const hh={},mh="__sentry_xhr_v3__";function fh(){if(!rh.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;e.open=new Proxy(e.open,{apply(e,t,n){const r=new Error,i=1e3*lc(),o=_l(n[0])?n[0].toUpperCase():void 0,s=function(e){if(_l(e))return e;try{return e.toString()}catch{}}(n[1]);if(!o||!s)return e.apply(t,n);t[mh]={method:o,url:s,request_headers:{}},"POST"===o&&s.match(/sentry_key/)&&(t.Pt=!0);const a=()=>{const e=t[mh];if(e&&4===t.readyState){try{e.status_code=t.status}catch{}pl("xhr",{endTimestamp:1e3*lc(),startTimestamp:i,xhr:t,virtualError:r})}};return"onreadystatechange"in t&&"function"==typeof t.onreadystatechange?t.onreadystatechange=new Proxy(t.onreadystatechange,{apply:(e,t,n)=>(a(),e.apply(t,n))}):t.addEventListener("readystatechange",a),t.setRequestHeader=new Proxy(t.setRequestHeader,{apply(e,t,n){const[r,i]=n,o=t[mh];return o&&_l(r)&&_l(i)&&(o.request_headers[r.toLowerCase()]=i),e.apply(t,n)}}),e.apply(t,n)}}),e.send=new Proxy(e.send,{apply(e,t,n){const r=t[mh];return r?(void 0!==n[0]&&(r.body=n[0]),pl("xhr",{startTimestamp:1e3*lc(),xhr:t}),e.apply(t,n)):e.apply(t,n)}})}function ph(e,t=function(e){const t=hh[e];if(t)return t;let n=rh[e];if(Ou(n))return hh[e]=n.bind(rh);const r=rh.document;if(r&&"function"==typeof r.createElement)try{const t=r.createElement("iframe");t.hidden=!0,r.head.appendChild(t);const i=t.contentWindow;i?.[e]&&(n=i[e]),r.head.removeChild(t)}catch(t){nh&&el(`Could not create sandbox iframe for ${e} check, bailing to window.${e}: `,t)}return n?hh[e]=n.bind(rh):n}("fetch")){let n=0,r=0;return Yd(e,async function(i){const o=i.body.length;n+=o,r++;const s={body:i.body,method:"POST",referrerPolicy:"strict-origin",headers:e.headers,keepalive:n<=6e4&&r<15,...e.fetchOptions};try{const n=await t(e.url,s);return{statusCode:n.status,headers:{"x-sentry-rate-limits":n.headers.get("X-Sentry-Rate-Limits"),"retry-after":n.headers.get("Retry-After")}}}catch(e){throw hh.fetch=void 0,e}finally{n-=o,r--}},Ud(e.bufferSize||40))}const gh="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function yh(e,t,n,r){const i={filename:e,function:"<anonymous>"===t?nl:t,in_app:!0};return void 0!==n&&(i.lineno=n),void 0!==r&&(i.colno=r),i}const vh=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,wh=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,bh=/\((\S*)(?::(\d+))(?::(\d+))\)/,xh=/at (.+?) ?\(data:(.+?),/,kh=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Sh=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Nh=ol([30,e=>{const t=e.match(xh);if(t)return{filename:`<data:${t[2]}>`,function:t[1]};const n=vh.exec(e);if(n){const[,e,t,r]=n;return yh(e,nl,+t,+r)}const r=wh.exec(e);if(r){if(0===r[2]?.indexOf("eval")){const e=bh.exec(r[2]);e&&(r[2]=e[1],r[3]=e[2],r[4]=e[3])}const[e,t]=_h(r[1]||nl,r[2]);return yh(t,e,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}}],[50,e=>{const t=kh.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const e=Sh.exec(t[3]);e&&(t[1]=t[1]||"eval",t[3]=e[1],t[4]=e[2],t[5]="")}let e=t[3],n=t[1]||nl;return[n,e]=_h(n,e),yh(e,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]),_h=(e,t)=>{const n=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return n||r?[-1!==e.indexOf("@")?e.split("@")[0]:nl,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Ch=(e={})=>{const t={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e};return{name:"Breadcrumbs",setup(e){var n;t.console&&function(e){const t="console";ml(t,e),fl(t,Tu)}(function(e){return function(t){if(Ic()!==e)return;const n={category:"console",data:{arguments:t.args,logger:"console"},level:(r=t.level,"warn"===r?"warning":["fatal","error","warning","log","info","debug"].includes(r)?r:"log"),message:Kl(t.args," ")};var r;if("assert"===t.level){if(!1!==t.args[0])return;n.message=`Assertion failed: ${Kl(t.args.slice(1)," ")||"console.assert"}`,n.data.arguments=t.args.slice(1)}pu(n,{input:t.args,level:t.level})}}(e)),t.dom&&(n=function(e,t){return function(n){if(Ic()!==e)return;let r,i,o="object"==typeof t?t.serializeAttribute:void 0,s="object"==typeof t&&"number"==typeof t.maxStringLength?t.maxStringLength:void 0;s&&s>1024&&(gh&&el(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${s} was configured. Sentry will use 1024 instead.`),s=1024),"string"==typeof o&&(o=[o]);try{const e=n.event,t=function(e){return!!e&&!!e.target}(e)?e.target:e;r=Ml(t,{keyAttrs:o,maxStringLength:s}),i=function(e){if(!Rl.HTMLElement)return null;let t=e;for(let e=0;e<5;e++){if(!t)return null;if(t instanceof HTMLElement){if(t.dataset.sentryComponent)return t.dataset.sentryComponent;if(t.dataset.sentryElement)return t.dataset.sentryElement}t=t.parentNode}return null}(t)}catch{r="<unknown>"}if(0===r.length)return;const a={category:`ui.${n.name}`,message:r};i&&(a.data={"ui.component_name":i}),pu(a,{event:n.event,name:n.name,global:n.global})}}(e,t.dom),ml("dom",n),fl("dom",lh)),t.xhr&&function(e){ml("xhr",e),fl("xhr",fh)}(function(e){return function(t){if(Ic()!==e)return;const{startTimestamp:n,endTimestamp:r}=t,i=t.xhr[mh];if(!n||!r||!i)return;const{method:o,url:s,status_code:a,body:l}=i,c={method:o,url:s,status_code:a},d={xhr:t.xhr,input:l,startTimestamp:n,endTimestamp:r},u={category:"xhr",data:c,type:"http",level:Ru(a)};e.emit("beforeOutgoingRequestBreadcrumb",u,d),pu(u,d)}}(e)),t.fetch&&ju(function(e){return function(t){if(Ic()!==e)return;const{startTimestamp:n,endTimestamp:r}=t;if(r&&(!t.fetchData.url.match(/sentry_key/)||"POST"!==t.fetchData.method))if(t.error){const i={data:t.error,input:t.args,startTimestamp:n,endTimestamp:r},o={category:"fetch",data:t.fetchData,level:"error",type:"http"};e.emit("beforeOutgoingRequestBreadcrumb",o,i),pu(o,i)}else{const i=t.response,o={...t.fetchData,status_code:i?.status},s={input:t.args,response:i,startTimestamp:n,endTimestamp:r},a={category:"fetch",data:o,type:"http",level:Ru(o.status_code)};e.emit("beforeOutgoingRequestBreadcrumb",a,s),pu(a,s)}}}(e)),t.history&&dh(function(e){return function(t){if(Ic()!==e)return;let n=t.from,r=t.to;const i=hu(Bu.location.href);let o=n?hu(n):void 0;const s=hu(r);o?.path||(o=i),i.protocol===s.protocol&&i.host===s.host&&(r=s.relative),i.protocol===o.protocol&&i.host===o.host&&(n=o.relative),pu({category:"navigation",data:{from:n,to:r}})}}(e)),t.sentry&&e.on("beforeSendEvent",function(e){return function(t){Ic()===e&&pu({category:"sentry."+("transaction"===t.type?"transaction":"event"),event_id:t.event_id,level:t.level,message:rc(t)},{event:t})}}(e))}}},$h="EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(","),Ih=(e={})=>{const t={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...e};return{name:"BrowserApiErrors",setupOnce(){t.setTimeout&&Wl(Bu,"setTimeout",Th),t.setInterval&&Wl(Bu,"setInterval",Th),t.requestAnimationFrame&&Wl(Bu,"requestAnimationFrame",Eh),t.XMLHttpRequest&&"XMLHttpRequest"in Bu&&Wl(XMLHttpRequest.prototype,"send",Ph);const e=t.eventTarget;e&&(Array.isArray(e)?e:$h).forEach(e=>function(e,t){const n=Bu,r=n[e]?.prototype;r?.hasOwnProperty?.("addEventListener")&&(Wl(r,"addEventListener",function(n){return function(r,i,o){try{"function"==typeof i.handleEvent&&(i.handleEvent=Hu(i.handleEvent,{mechanism:{data:{handler:ll(i),target:e},handled:!1,type:"auto.browser.browserapierrors.handleEvent"}}))}catch{}return t.unregisterOriginalCallbacks&&function(e,t,n){e&&"object"==typeof e&&"removeEventListener"in e&&"function"==typeof e.removeEventListener&&e.removeEventListener(t,n)}(this,r,i),n.apply(this,[r,Hu(i,{mechanism:{data:{handler:ll(i),target:e},handled:!1,type:"auto.browser.browserapierrors.addEventListener"}}),o])}}),Wl(r,"removeEventListener",function(e){return function(t,n,r){try{const i=n.Ct;i&&e.call(this,t,i,r)}catch{}return e.call(this,t,n,r)}}))}(e,t))}}};function Th(e){return function(...t){const n=t[0];return t[0]=Hu(n,{mechanism:{handled:!1,type:`auto.browser.browserapierrors.${ll(e)}`}}),e.apply(this,t)}}function Eh(e){return function(t){return e.apply(this,[Hu(t,{mechanism:{data:{handler:ll(e)},handled:!1,type:"auto.browser.browserapierrors.requestAnimationFrame"}})])}}function Ph(e){return function(...t){const n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(e=>{e in n&&"function"==typeof n[e]&&Wl(n,e,function(t){const n={mechanism:{data:{handler:ll(t)},handled:!1,type:`auto.browser.browserapierrors.xhr.${e}`}},r=Bl(t);return r&&(n.mechanism.data.handler=ll(r)),Hu(t,n)})}),e.apply(this,t)}}const zh=(e={})=>{const t=e.lifecycle??"route";return{name:"BrowserSession",setupOnce(){if(void 0===Bu.document)return void(gh&&el("Using the `browserSessionIntegration` in non-browser environments is not supported."));Pd({ignoreDuration:!0}),Rd();const e=Cc();let n=e.getUser();e.addScopeListener(e=>{const t=e.getUser();n?.id===t?.id&&n?.ip_address===t?.ip_address||(Rd(),n=t)}),"route"===t&&dh(({from:e,to:t})=>{e!==t&&(Pd({ignoreDuration:!0}),Rd())})}}},Dh=(e={})=>{const t={onerror:!0,onunhandledrejection:!0,...e};return{name:"GlobalHandlers",setupOnce(){Error.stackTraceLimit=50},setup(e){t.onerror&&(function(e){!function(){const t="error";ml(t,t=>{const{stackParser:n,attachStacktrace:r}=Mh();if(Ic()!==e||Fu())return;const{msg:i,url:o,line:s,column:a,error:l}=t,c=function(e,t,n,r){const i=e.exception=e.exception||{},o=i.values=i.values||[],s=o[0]=o[0]||{},a=s.stacktrace=s.stacktrace||{},l=a.frames=a.frames||[];return 0===l.length&&l.push({colno:r,lineno:n,filename:Oh(t)??jl(),function:nl,in_app:!0}),e}(Ku(n,l||i,void 0,r,!1),o,s,a);c.level="error",Ed(c,{originalException:l,mechanism:{handled:!1,type:"auto.browser.global_handlers.onerror"}})}),fl(t,yl)}()}(e),Rh("onerror")),t.onunhandledrejection&&(function(e){!function(){const t="unhandledrejection";ml(t,t=>{const{stackParser:n,attachStacktrace:r}=Mh();if(Ic()!==e||Fu())return;const i=function(e){if($l(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}(t),o=$l(i)?{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`}]}}:Ku(n,i,void 0,r,!0);o.level="error",Ed(o,{originalException:i,mechanism:{handled:!1,type:"auto.browser.global_handlers.onunhandledrejection"}})}),fl(t,wl)}()}(e),Rh("onunhandledrejection"))}}};function Rh(e){gh&&Xa(`Global Handler attached: ${e}`)}function Mh(){const e=Ic();return e?.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}function Oh(e){if(_l(e)&&0!==e.length)return e.startsWith("data:")?`<${function(e,t=!0){if(e.startsWith("data:")){const n=e.match(/^data:([^;,]+)/),r=n?n[1]:"text/plain",i=e.includes(";base64,"),o=e.indexOf(",");let s="";if(t&&-1!==o){const t=e.slice(o+1);s=t.length>10?`${t.slice(0,10)}... [truncated]`:t}return`data:${r}${i?",base64":""}${s?`,${s}`:""}`}return e}(e,!1)}>`:e}const jh=(e={})=>{const t=e.limit||5,n=e.key||"cause";return{name:"LinkedErrors",preprocessEvent(e,r,i){Nu(Uu,i.getOptions().stackParser,n,t,e,r)}}};function Wh(e={}){const t=!e.skipBrowserExtensionCheck&&!!function(){if(void 0===Bu.window)return!1;const e=Bu;if(e.nw)return!1;const t=e.chrome||e.browser;if(!t?.runtime?.id)return!1;const n=jl();return!(Bu===Bu.top&&/^(?:chrome-extension|moz-extension|ms-browser-extension|safari-web-extension):\/\//.test(n))}()&&(gh&&Ga(()=>{}),!0);let n=null==e.defaultIntegrations?[xu(),vu(),{name:"ConversationId",setup(e){e.on("spanStart",e=>{const t=_c().getScopeData(),n=Cc().getScopeData(),r=t.conversationId||n.conversationId;r&&e.setAttribute("gen_ai.conversation.id",r)})}},Ih(),Ch(),Dh(),jh(),Eu(),{name:"HttpContext",preprocessEvent(e){if(!Bu.navigator&&!Bu.location&&!Bu.document)return;const t=function(){const e=jl(),{referrer:t}=Bu.document||{},{userAgent:n}=Bu.navigator||{};return{url:e,headers:{...t&&{Referer:t},...n&&{"User-Agent":n}}}}(),n={...t.headers,...e.request?.headers};e.request={...t,...e.request,headers:n}}},{name:"CultureContext",preprocessEvent(e){const t=function(){try{const e=Bu.Intl;if(!e)return;const t=e.DateTimeFormat().resolvedOptions();return{locale:t.locale,timezone:t.timeZone,calendar:t.calendar}}catch{return}}();t&&(e.contexts={...e.contexts,culture:{...t,...e.contexts?.culture}})}},zh()]:e.defaultIntegrations;const r={...e,enabled:!t&&e.enabled,stackParser:(i=e.stackParser||Nh,Array.isArray(i)?ol(...i):i),integrations:Od({integrations:e.integrations,defaultIntegrations:n}),transport:e.transport||ph};var i;return function(e,t){!0===t.debug&&(La?Ka():Ga(()=>{})),_c().update(t.initialScope);const n=new e(t);return function(e){_c().setClient(e)}(n),n.init(),n}(th,r)}let Ah=!1;function Lh(t){if(Ah)e();else if(t.enabled&&t.dsn)try{const n=t.bundleUrlPatterns||[/cdn\.insure-os\.com/,/api\.os\.insure.*\/dist/,/localhost:\d+\/dist/,/index\.(esm|umd|cjs)\.js/];Wh({dsn:t.dsn,environment:t.environment||"production",release:t.release,beforeSend:t=>function(e,t){var n,r,i,o;const s=null===(o=null===(i=null===(r=null===(n=e.exception)||void 0===n?void 0:n.values)||void 0===r?void 0:r[0])||void 0===i?void 0:i.stacktrace)||void 0===o?void 0:o.frames;if(!s||0===s.length)return!0;return s.some(e=>!!e.filename&&t.some(t=>t.test(e.filename||"")))}(t,n)?(t.tags={...t.tags,source:"insureos-widget"},e(t.exception),t):(e(t.exception),null),allowUrls:n,sampleRate:t.sampleRate||1,tracesSampleRate:t.tracesSampleRate||.1,integrations:[Ch({console:!0,dom:!0,fetch:!0,history:!1,xhr:!0}),Eu()],ignoreErrors:["top.GLOBALS","originalCreateNotification","canvas.contentDocument","MyApp_RemoveAllHighlights","atomicFindClose","Can't find variable: ZiteReader","jigsaw is not defined","ComboSearch is not defined","ResizeObserver loop limit exceeded","ResizeObserver loop completed with undelivered notifications"]}),Ah=!0,e()}catch(e){}else e()}function Bh(t,n){if(Ah)try{n?$c(e=>{Object.entries(n).forEach(([t,n])=>{e.setContext(t,n)}),Id(t)}):Id(t)}catch(t){e()}}function qh(t,n="info",r){if(Ah)try{r?$c(e=>{Object.entries(r).forEach(([t,n])=>{e.setContext(t,n)}),Td(t,n)}):Td(t,n)}catch(t){e()}}function Fh(t){if(Ah)try{!function(e){Cc().setUser(e)}(t)}catch(t){e()}}function Hh(t){if(Ah)try{pu(t)}catch(t){e()}}function Uh(t,n){if(Ah)try{!function(e,t){Cc().setTag(e,t)}(t,n)}catch(t){e()}}function Yh(){return Ah}var Zh=Object.freeze({__proto__:null,addBreadcrumb:Hh,captureException:Bh,captureMessage:qh,initializeSentry:Lh,isSentryInitialized:Yh,setTag:Uh,setUser:Fh});const Gh="https://a73b48791ca06287db6bc587f376f7b9@o490277.ingest.us.sentry.io/4510139918450688",Vh="production",Qh="insureos-scripts",Jh=!0,Kh=1,Xh=.1;class em{constructor(e={}){var t,n,r,i;this.dataLayerAvailable=!1,this.config={enabled:null===(t=e.enabled)||void 0===t||t,customDataLayer:null!==(n=e.customDataLayer)&&void 0!==n?n:"dataLayer",includePersonalData:null!==(r=e.includePersonalData)&&void 0!==r&&r,debug:null!==(i=e.debug)&&void 0!==i&&i},"undefined"!=typeof window?this.initializeDataLayer():this.dataLayerAvailable=!1}initializeDataLayer(){try{const e=this.config.customDataLayer;window[e]||(window[e]=[],this.logDebug(`Created new ${e} array`)),Array.isArray(window[e])?(this.dataLayerAvailable=!0,this.logDebug(`✅ Data layer '${e}' is available and ready`)):(this.dataLayerAvailable=!1,this.logDebug(`⚠️ Data layer '${e}' exists but is not an array`))}catch(e){this.dataLayerAvailable=!1,this.logDebug("⚠️ Failed to initialize data layer:",e)}}isEnabled(){return this.config.enabled&&this.dataLayerAvailable}getDataLayer(){if(!this.isEnabled())return null;try{const e=window[this.config.customDataLayer];return Array.isArray(e)?e:null}catch(e){return this.logDebug("Failed to get data layer:",e),null}}push(e){if(!this.isEnabled())return void this.logDebug("📊 Analytics disabled or data layer not available, skipping event:",e.event);const t=this.getDataLayer();if(t)try{const n=this.config.includePersonalData?e:this.removePII(e);t.push(n),this.logDebug("📊 Pushed event to data layer:",n)}catch(e){this.logDebug("❌ Failed to push event to data layer:",e)}else this.logDebug("⚠️ Data layer not available, skipping event:",e.event)}removePII(e){const t={...e},n=["email","phone","name","address","client_name","client_email"];for(const e of n)e in t&&delete t[e];return t}logDebug(...t){this.config.debug&&e("[Analytics]",...t)}clear(){if(this.dataLayerAvailable)try{window[this.config.customDataLayer]=[],this.logDebug("🧹 Cleared data layer")}catch(e){this.logDebug("Failed to clear data layer:",e)}}getConfig(){return{...this.config}}updateConfig(e){this.config={...this.config,...e},(e.customDataLayer||void 0!==e.enabled)&&this.initializeDataLayer(),this.logDebug("Updated analytics configuration:",this.config)}}class tm{constructor(){this.sentryInitialized=!1,this.analyticsManager=null,this.pendingPromoCodes=new Map}initializeSentryOnce(){if(!this.sentryInitialized)try{Lh({dsn:Gh,environment:Vh,release:Qh,enabled:Jh,sampleRate:Kh,tracesSampleRate:Xh}),this.sentryInitialized=!0,e()}catch(t){e()}}validateConfig(e){if(!e.orgId)throw new Error("orgId is required");if("payment"===e.mode&&!e.paymentLinkId)throw new Error("paymentLinkId is required when mode is 'payment'")}initializeAnalyticsOnce(t){var n,r,i,o,s;if(!this.analyticsManager)try{this.analyticsManager=new em({enabled:null===(n=t.analyticsConfig)||void 0===n?void 0:n.enabled,customDataLayer:null===(r=t.analyticsConfig)||void 0===r?void 0:r.customDataLayer,includePersonalData:null===(i=t.analyticsConfig)||void 0===i?void 0:i.includePersonalData,debug:null!==(s=null===(o=t.analyticsConfig)||void 0===o?void 0:o.debug)&&void 0!==s?s:t.debug}),Me(this.analyticsManager),e()}catch(t){e()}}async mount(e,r){r.debug&&(globalThis.insureOSDebug=!0),this.validateConfig(r),this.initializeSentryOnce(),this.initializeAnalyticsOnce(r),function(e,r){var i,o,s;r==document&&(r=document.documentElement),n.m&&n.m(e,r),i=r.i,o=[],s=[],A(r,e=r.i=S(_,null,[e]),i||y,y,r.namespaceURI,i?null:r.firstChild?t.call(r.childNodes):null,o,i?i.v:r.firstChild,!1,s),B(o,e,s)}(S(Aa,{config:r,initializeFormContext:this.initializeFormContext.bind(this)}),e)}createHttpClient(e){var t,n,r,i,o,s,a,l,c,d;if(!e.orgId)throw new Error("orgId is required");const u=e.apiBaseUrl||"https://api.os.insure";return new X({orgId:e.orgId,apiBaseUrl:u,timeout:(null===(t=e.httpConfig)||void 0===t?void 0:t.timeout)||1e4,retryConfig:{maxRetries:(null===(r=null===(n=e.httpConfig)||void 0===n?void 0:n.retryConfig)||void 0===r?void 0:r.maxRetries)||3,baseDelay:(null===(o=null===(i=e.httpConfig)||void 0===i?void 0:i.retryConfig)||void 0===o?void 0:o.baseDelay)||1e3,maxDelay:(null===(a=null===(s=e.httpConfig)||void 0===s?void 0:s.retryConfig)||void 0===a?void 0:a.maxDelay)||1e4,retryableStatusCodes:(null===(c=null===(l=e.httpConfig)||void 0===l?void 0:l.retryConfig)||void 0===c?void 0:c.retryableStatusCodes)||[429,500,502,503,504],...null===(d=e.httpConfig)||void 0===d?void 0:d.retryConfig}})}createClient(e){const t=this.createHttpClient(e);return new Ge(t)}clearQuoteStateForOrg(e){try{if(window.localStorage){window.localStorage.removeItem("insure-os-selected-product"),window.localStorage.removeItem(`insure_os_quote_intent_${e}`),window.localStorage.removeItem(`insure-os-pending-promo-${e}`);for(let t=window.localStorage.length-1;t>=0;t--){const n=window.localStorage.key(t);n&&n.startsWith("insure_os_")&&n.endsWith(e)&&window.localStorage.removeItem(n)}}window.sessionStorage&&window.sessionStorage.removeItem(`insure_os_quote_intent_${e}`)}catch(e){}}async initializeFormContext(t){var n,r,i,o,s;const a=this.createHttpClient(t),l=new URLSearchParams(window.location.search),c=l.get("p")||l.get("pl_ref");if(c)return e(),this.clearQuoteStateForOrg(t.orgId),{httpClient:a,stateManager:null,quoteIntent:null,quoteIntentStore:null,formStateManager:null,paymentLinkConfig:{paymentLinkId:c,signedUrl:void 0}};const d=l.get("q")||l.get("qi");if(d){e();try{const t=await a.resumeQuoteIntent(d);if("redirect"===(null==t?void 0:t.mode)&&t.payment_link_short_code){const n=window.location.pathname+`?p=${encodeURIComponent(t.payment_link_short_code)}`;return e(),window.location.replace(n),new Promise(()=>{})}}catch(t){e(null==t||t.message)}t.quoteIntentUrl=`${t.apiBaseUrl}/quote-intents/${d}`,this.clearQuoteStateForOrg(t.orgId)}if("payment"===t.mode)return e(),{httpClient:a,stateManager:null,quoteIntent:null,quoteIntentStore:null,formStateManager:null,paymentLinkConfig:{paymentLinkId:t.paymentLinkId,signedUrl:t.signedUrl}};const u="sessionStorage"===t.storageType?new te:new ee;u.isAvailable()?e(u.constructor.name):e();const h=new ie(u),m=new oe(h),f=t.products,p=null==f?void 0:f.includes("*"),g=!f||0===f.length,y=g||p||f&&f.length>1,v=f&&1===f.length&&!p,w=localStorage.getItem("insure-os-selected-product"),b=new URLSearchParams(window.location.search),x=!!(b.get("transactionId")||b.get("transaction_id")||b.get("payment_id")),k=b.get("code");if("1"===b.get("clear")){e(),localStorage.clear(),b.delete("clear");const t=b.toString()?`${window.location.pathname}?${b.toString()}`:window.location.pathname;window.history.replaceState({},"",t),e()}const S=`insure-os-pending-promo-${t.orgId}`,N="skipPendingPromoCode"in t&&!0===t.skipPendingPromoCode;if(k&&!x&&!N){const n={code:k,ts:Date.now()};localStorage.setItem(S,JSON.stringify(n)),this.pendingPromoCodes.set(t.orgId,k),e(),b.delete("code");const r=b.toString()?`${window.location.pathname}?${b.toString()}`:window.location.pathname;window.history.replaceState({},"",r)}const _="promoCode"in t?t.promoCode:void 0;let C=null;if(!N)try{const e=localStorage.getItem(S);if(e){const t=JSON.parse(e);"object"==typeof t&&t.code&&Date.now()-t.ts<36e5?C=t.code:"string"==typeof t?C=t:localStorage.removeItem(S)}}catch(e){localStorage.removeItem(S)}const $=N?void 0:this.pendingPromoCodes.get(t.orgId),I=k||_||C||$||null;if(e(),I&&!x){const i=h.getQuoteIntent(t.orgId);if(null===(n=null==i?void 0:i.form_data)||void 0===n?void 0:n.page_data){const n=i.form_data.page_data,o=null===(r=Object.values(n).find(e=>e&&"object"==typeof e&&"promo_code"in e))||void 0===r?void 0:r.promo_code;o&&o!==I&&(e(),m.clearQuoteIntent(t.orgId))}}const T=async n=>{var r;e(n.id);const i=new Ye(n,a,m,{autoSave:!1,autoSaveInterval:n.form_definition.settings.autoSaveInterval});if("prefillFormData"in t&&t.prefillFormData){const o=(null===(r=n.form_definition)||void 0===r?void 0:r.pages.length)||0,s=Array.from({length:o},(e,t)=>t);i.restoreFormProgress({page_data:t.prefillFormData,current_page:o-1,completed_pages:s,last_updated:(new Date).toISOString()}),e()}else n.form_data&&i.restoreFormProgress(n.form_data);if(I){const t=i.getFormDefinition().pages.find(e=>e.fields.some(e=>"promo_code"===(e.code||e.id)));t?(i.updateFieldValue(t.id,"promo_code",I),e(t.id)):e()}if(n.cached_result&&(e(),i.restoreCalculationResult(n.cached_result)),n.organisation&&n.organisation.theme)try{await $a.loadTheme({slug:n.organisation.slug,theme_url:n.organisation.theme.css_url})}catch(t){e()}const o="skipAutoCalculation"in t&&!!t.skipAutoCalculation;return await this.handleAutoCalculationIfComplete(i,o),{httpClient:a,stateManager:h,quoteIntent:n,quoteIntentStore:m,formStateManager:i,urlPromoCode:I||void 0}};if(y&&!t.quoteIntentUrl&&!w){const n=x?null:h.getQuoteIntent(t.orgId);if(n)try{const r=await a.getQuoteIntent(n.url),l={id:r.quote_intent.id,url:r.url,calculate_url:r.calculate_url,delete_calculations_url:r.delete_calculations_url,expires_at:new Date(r.quote_intent.expires_at).getTime(),updated_at:new Date(r.quote_intent.updated_at).getTime(),created_at:new Date(r.quote_intent.created_at).getTime(),org_id:t.orgId,product_id:r.product.id,product_name:r.product.description||r.product.name,form_definition:r.product.form_definition,form_data:r.quote_intent.form_data,status:r.quote_intent.status,reference:r.quote_intent.reference,organisation:r.organisation,cached_result:r.cached_result};if(h.saveQuoteIntent(t.orgId,l),null===(o=null===(i=l.form_data)||void 0===i?void 0:i.completed_pages)||void 0===o?void 0:o.length){if(e(),null===(s=l.organisation)||void 0===s?void 0:s.theme)try{await $a.loadTheme({slug:l.organisation.slug,theme_url:l.organisation.theme.css_url})}catch(t){e()}const{firstName:n,lastUpdated:r}=(e=>{var t;const n=["client_first_name","first_name","firstName","fname","given_name"],r=null===(t=e.form_data)||void 0===t?void 0:t.page_data;let i=null;if(r)for(const e of Object.values(r)){if(!e||"object"!=typeof e)continue;const t=e;for(const e of n)if(t[e]){i=String(t[e]);break}if(i)break}return{firstName:i,lastUpdated:e.updated_at?new Date(e.updated_at).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"}):null}})(l);return{httpClient:a,stateManager:h,quoteIntent:null,quoteIntentStore:m,formStateManager:null,resumePrompt:{reference:l.reference||null,productName:l.product_name||null,firstName:n,lastUpdated:r,onContinue:async()=>T(l),onStartFresh:async()=>{m.clearQuoteIntent(t.orgId);const e=await a.fetchAvailableProducts(g?void 0:f);return{httpClient:a,stateManager:h,quoteIntent:null,quoteIntentStore:m,formStateManager:null,availableProducts:e.products,productCodes:f}}}}}}catch(n){e(),m.clearQuoteIntent(t.orgId)}e();const r=await a.fetchAvailableProducts(g?void 0:f);if(e(),r.organisation&&r.organisation.theme)try{const t=await Promise.resolve().then(function(){return Ia}).then(e=>e.ThemeLoader);await t.loadTheme({slug:r.organisation.slug,theme_url:r.organisation.theme.css_url}),e()}catch(t){e()}return{httpClient:a,stateManager:h,quoteIntent:null,quoteIntentStore:m,formStateManager:null,availableProducts:r.products,productCodes:f}}let E;w?(e(),E=w,localStorage.removeItem("insure-os-selected-product")):v&&(E=f[0]);const P=async()=>{e();const n=t.quoteIntentUrl?await a.getQuoteIntent(t.quoteIntentUrl):await a.createQuoteIntent({code:E,...t.dealerOrganisationId&&{dealer_organisation_id:t.dealerOrganisationId}});return e(),{id:n.quote_intent.id,url:n.url,calculate_url:n.calculate_url,delete_calculations_url:n.delete_calculations_url,calculate_url_v2:n.calculate_url_v2,reprice_url_v2:n.reprice_url_v2,bind_url_v2:n.bind_url_v2,calculator_version:n.product.calculator_version,expires_at:new Date(n.quote_intent.expires_at).getTime(),updated_at:new Date(n.quote_intent.updated_at).getTime(),created_at:new Date(n.quote_intent.created_at).getTime(),org_id:t.orgId,product_id:n.product.id,product_name:n.product.description||n.product.name,form_definition:n.product.form_definition,form_data:n.quote_intent.form_data,status:n.quote_intent.status,reference:n.quote_intent.reference,organisation:n.organisation,payment_transactions:n.payment_transactions,cached_result:n.cached_result}},z=async e=>{var n;const r=new URLSearchParams(window.location.search),i=r.get("transaction_id")||r.get("payment_id")||r.get("transactionId"),o=await a.getQuoteIntent(e);let s;const l=r.get("status");if(i&&"processing"!==l){const e=null===(n=o.payment_transactions)||void 0===n?void 0:n.find(e=>e.id===i);if(e){let t="unknown";switch(e.status){case"completed":t="success";break;case"failed":t="declined";break;case"cancelled":t="cancelled";break;default:t="error"}s={paymentTransactionId:e.id,paymentStatus:t,transactionStatus:e}}else if(l){let e="error";switch(l.toLowerCase()){case"success":case"completed":e="success";break;case"failed":case"declined":e="declined";break;case"cancelled":case"canceled":e="cancelled";break;default:e="error"}s={paymentTransactionId:i,paymentStatus:e,transactionStatus:void 0}}}const c={id:o.quote_intent.id,url:o.url,calculate_url:o.calculate_url,delete_calculations_url:o.delete_calculations_url,calculate_url_v2:o.calculate_url_v2,reprice_url_v2:o.reprice_url_v2,bind_url_v2:o.bind_url_v2,calculator_version:o.product.calculator_version,expires_at:new Date(o.quote_intent.expires_at).getTime(),updated_at:new Date(o.quote_intent.updated_at).getTime(),created_at:new Date(o.quote_intent.created_at).getTime(),org_id:t.orgId,product_id:o.product.id,product_name:o.product.description||o.product.name,form_definition:o.product.form_definition,form_data:o.quote_intent.form_data,status:o.quote_intent.status,reference:o.quote_intent.reference,organisation:o.organisation,payment_return:s,payment_transactions:o.payment_transactions,cached_result:o.cached_result};return s&&h.saveQuoteIntent(t.orgId,c),c};return(async()=>{let e=null,n=!1;try{const r=h.getQuoteIntent(t.orgId),i=await m.getOrCreateQuoteIntent(t.orgId,P,z);i.payment_return&&h.saveQuoteIntent(t.orgId,i),e=i,n=!r}catch(r){if(!(r instanceof Z&&404===r.statusCode))throw r;m.clearQuoteIntent(t.orgId),e=await m.getOrCreateQuoteIntent(t.orgId,P,z),n=!0}if(n&&e&&We(e),!e)throw new Error("Failed to initialize quote intent state");return T(e)})()}async handleAutoCalculationIfComplete(t,n=!1){try{if(n)return void e();const r=t.getQuoteIntent();if("paid"===r.status||"completed"===r.status)return void e();if(t.hasCalculationResponse())return void e();if(t.hasLastCalculationFailed())return void e();const i=t.getPageCompletionStatus(),{totalPages:o,completedPages:s}=i,a=s.length===o;e((s.length,t.getIsCalculating(),t.hasLastCalculationFailed())),a&&!t.getIsCalculating()&&(e(),await t.calculateQuote(),e())}catch(t){e()}}}const nm=new tm;"undefined"!=typeof window&&(window.InsureOS=nm,function(){const e=document.querySelectorAll('script[src*="insureos"]'),t=e[e.length-1];if(t&&t.src){const e=new URL(t.src),n=e.searchParams.get("orgId"),r=e.searchParams.get("productCode"),i=e.searchParams.get("productCodes"),o=i?i.split(","):r?[r]:null;if(n&&o){const t=e.searchParams.get("container"),r=t?document.getElementById(t):document.body;if(r){const e={orgId:n,products:o};r.dataset.insureosConfig=JSON.stringify(e);const t=async()=>{try{await nm.mount(r,e)}catch(e){}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}}}}());class rm{constructor(e={}){var t,n,r;this.detectionResults=null,this.config={fetch:null===(t=e.fetch)||void 0===t||t,promise:null===(n=e.promise)||void 0===n||n,url:null===(r=e.url)||void 0===r||r}}async loadPolyfills(){this.detectionResults=this.detectFeatures(),this.config.fetch&&this.detectionResults.fetch&&await this.loadFetchPolyfill(),this.config.promise&&this.detectionResults.promise&&await this.loadPromisePolyfill(),this.config.url&&this.detectionResults.url&&await this.loadUrlPolyfill()}getDetectionResults(){return this.detectionResults}detectFeatures(){return{fetch:this.needsFetchPolyfill(),promise:this.needsPromisePolyfill(),url:this.needsUrlPolyfill()}}needsFetchPolyfill(){if("undefined"==typeof fetch)return!0;if("undefined"==typeof Headers||"undefined"==typeof Request||"undefined"==typeof Response)return!0;try{return new Headers,new Request("http://example.com"),new Response,!1}catch(e){return!0}}needsPromisePolyfill(){if("undefined"==typeof Promise)return!0;if("function"!=typeof Promise.resolve||"function"!=typeof Promise.reject||"function"!=typeof Promise.all)return!0;try{const e=Promise.resolve(42);return"function"!=typeof e.then||"function"!=typeof e.catch}catch(e){return!0}}needsUrlPolyfill(){if("undefined"==typeof URL)return!0;try{const e=new URL("http://example.com/path?param=value#hash");if("string"!=typeof e.protocol||"string"!=typeof e.hostname||"string"!=typeof e.pathname||"string"!=typeof e.search||"string"!=typeof e.hash)return!0;if("undefined"==typeof URLSearchParams)return!0;const t=new URLSearchParams("param=value");return"function"!=typeof t.get||"function"!=typeof t.set}catch(e){return!0}}async loadFetchPolyfill(){if(this.needsFetchPolyfill())try{const{fetch:e,Headers:t,Request:n,Response:r}=await Promise.resolve().then(function(){return lm});void 0===globalThis.fetch&&(globalThis.fetch=e),void 0===globalThis.Headers&&(globalThis.Headers=t),void 0===globalThis.Request&&(globalThis.Request=n),void 0===globalThis.Response&&(globalThis.Response=r)}catch(e){}}async loadPromisePolyfill(){if(this.needsPromisePolyfill())try{const{PromisePolyfill:e}=await Promise.resolve().then(function(){return dm});void 0===globalThis.Promise&&(globalThis.Promise=e)}catch(e){}}async loadUrlPolyfill(){if(this.needsUrlPolyfill())try{const{URLPolyfill:e,URLSearchParamsPolyfill:t}=await Promise.resolve().then(function(){return hm});void 0===globalThis.URL&&(globalThis.URL=e),void 0===globalThis.URLSearchParams&&(globalThis.URLSearchParams=t)}catch(e){}}}class im{constructor(){if(this.measurements=new Map,this.completedMeasurements=new Map,this.apiCallMetrics=[],this.initializationTime=0,im.instance)return im.instance;im.instance=this}startMeasurement(e){this.measurements.set(e,this.now())}endMeasurement(e){const t=this.measurements.get(e);if(void 0===t)throw new Error(`No measurement started for: ${e}`);const n=this.now()-t;return this.measurements.delete(e),this.completedMeasurements.has(e)||this.completedMeasurements.set(e,[]),this.completedMeasurements.get(e).push(n),"initialization"===e&&(this.initializationTime=n),n}async measureApiCall(e,t){const n=this.now();let r,i=!1;try{const e=await t();return i=!0,e}catch(e){throw i=!1,r=e instanceof Error?e.message:"Unknown error",e}finally{const t=this.now()-n;this.apiCallMetrics.push({operation:e,duration:t,timestamp:Date.now(),success:i,error:r})}}measureMemoryUsage(){return"undefined"!=typeof performance&&"memory"in performance&&performance.memory.usedJSHeapSize||0}getDetailedMemoryInfo(){if("undefined"!=typeof performance&&"memory"in performance){const e=performance.memory;return{usedJSHeapSize:e.usedJSHeapSize||0,totalJSHeapSize:e.totalJSHeapSize||0,jsHeapSizeLimit:e.jsHeapSizeLimit||0}}return null}getMetrics(){var e;const t=this.apiCallMetrics.filter(e=>e.success).map(e=>e.duration),n=t.length>0?t.reduce((e,t)=>e+t,0)/t.length:0,r={};return this.completedMeasurements.forEach((e,t)=>{r[t]=[...e]}),{bundleSize:{esm:0,umd:0,cjs:0,gzipped:{esm:0,umd:0,cjs:0}},runtime:{initializationTime:this.initializationTime,apiCallTime:t.length>0&&null!==(e=t[t.length-1])&&void 0!==e?e:0,memoryUsage:this.measureMemoryUsage(),averageApiCallTime:n,totalApiCalls:this.apiCallMetrics.length},measurements:r}}getApiCallMetrics(){return[...this.apiCallMetrics]}clearMetrics(){this.completedMeasurements.clear(),this.apiCallMetrics=[],this.initializationTime=0}generateReport(){const e=this.getMetrics(),t=this.getDetailedMemoryInfo();let n="=== Performance Report ===\n\n";if(n+="Runtime Performance:\n",n+=` Initialization Time: ${e.runtime.initializationTime.toFixed(2)}ms\n`,n+=` Total API Calls: ${e.runtime.totalApiCalls}\n`,n+=` Average API Call Time: ${e.runtime.averageApiCallTime.toFixed(2)}ms\n`,n+=` Current Memory Usage: ${(e.runtime.memoryUsage/1024/1024).toFixed(2)}MB\n\n`,t&&(n+="Memory Details:\n",n+=` Used Heap: ${(t.usedJSHeapSize/1024/1024).toFixed(2)}MB\n`,n+=` Total Heap: ${(t.totalJSHeapSize/1024/1024).toFixed(2)}MB\n`,n+=` Heap Limit: ${(t.jsHeapSizeLimit/1024/1024).toFixed(2)}MB\n\n`),this.apiCallMetrics.length>0){n+="API Call Breakdown:\n";const e=new Map;this.apiCallMetrics.forEach(t=>{e.has(t.operation)||e.set(t.operation,{count:0,totalTime:0,errors:0});const n=e.get(t.operation);n.count++,n.totalTime+=t.duration,t.success||n.errors++}),e.forEach((e,t)=>{const r=e.totalTime/e.count,i=(e.errors/e.count*100).toFixed(1);n+=` ${t}: ${e.count} calls, ${r.toFixed(2)}ms avg, ${i}% errors\n`})}return n}static async getBundleSizes(){return{esm:0,umd:0,cjs:0,gzipped:{esm:0,umd:0,cjs:0}}}now(){return"undefined"!=typeof performance&&performance.now?performance.now():Date.now()}static startMeasurement(e){(new im).startMeasurement(e)}static endMeasurement(e){return(new im).endMeasurement(e)}static measureMemoryUsage(){return(new im).measureMemoryUsage()}static async measureApiCall(e,t){return(new im).measureApiCall(e,t)}static getMetrics(){return(new im).getMetrics()}static generateReport(){return(new im).generateReport()}}let om=class e{constructor(t){this.headers=new Map,t&&(Array.isArray(t)?t.forEach(([e,t])=>this.set(e,t)):t instanceof e?t.forEach((e,t)=>this.set(t,e)):Object.entries(t).forEach(([e,t])=>this.set(e,t)))}append(e,t){const n=this.get(e);this.set(e,n?`${n}, ${t}`:t)}delete(e){this.headers.delete(e.toLowerCase())}get(e){return this.headers.get(e.toLowerCase())||null}has(e){return this.headers.has(e.toLowerCase())}set(e,t){this.headers.set(e.toLowerCase(),t)}forEach(e){this.headers.forEach(e)}},sm=class{constructor(e,t={}){var n;"string"==typeof e?(this.url=e,this.method=t.method||"GET",this.headers=new om(t.headers),this.body=t.body||null,this.signal=t.signal||void 0):(this.url=e.url,this.method=t.method||e.method,this.headers=new om(t.headers||e.headers),this.body=void 0!==t.body?t.body:e.body,this.signal=void 0!==t.signal?null!==(n=t.signal)&&void 0!==n?n:void 0:e.signal)}},am=class{constructor(e="",t={}){this.status=t.status||200,this.statusText=t.statusText||"OK",this.headers=new om(t.headers),this.ok=this.status>=200&&this.status<300,this.zt=e}async text(){return this.zt}async json(){return JSON.parse(this.zt)}};var lm=Object.freeze({__proto__:null,Headers:om,Request:sm,Response:am,fetch:async function(e,t={}){return new Promise((n,r)=>{const i=new sm(e,t),o=new XMLHttpRequest;i.signal&&i.signal.addEventListener("abort",()=>{o.abort(),r(new Error("Request aborted"))}),o.open(i.method,i.url),i.headers.forEach((e,t)=>{o.setRequestHeader(t,e)}),o.onload=()=>{const e=new om;o.getAllResponseHeaders().split("\r\n").forEach(t=>{const[n,r]=t.split(": ");n&&r&&e.set(n,r)});const t=new am(o.responseText,{status:o.status,statusText:o.statusText,headers:e});n(t)},o.onerror=()=>{r(new TypeError("Network request failed"))},o.ontimeout=()=>{r(new TypeError("Network request timed out"))},o.send(i.body)})}});class cm{constructor(e){this.state="pending",this.onFulfilledCallbacks=[],this.onRejectedCallbacks=[];try{e(this.resolve.bind(this),this.reject.bind(this))}catch(e){this.reject(e)}}resolve(e){"pending"===this.state&&(this.state="fulfilled",this.value=e,this.onFulfilledCallbacks.forEach(t=>{setTimeout(()=>t(e),0)}))}reject(e){"pending"===this.state&&(this.state="rejected",this.reason=e,this.onRejectedCallbacks.forEach(t=>{setTimeout(()=>t(e),0)}))}then(e,t){return new cm((n,r)=>{const i=t=>{try{if(e){const i=e(t);i instanceof cm?i.then(n,r):n(i)}else n(t)}catch(e){r(e)}},o=e=>{try{if(t){const i=t(e);i instanceof cm?i.then(n,r):n(i)}else r(e)}catch(e){r(e)}};"fulfilled"===this.state?setTimeout(()=>i(this.value),0):"rejected"===this.state?setTimeout(()=>o(this.reason),0):(this.onFulfilledCallbacks.push(i),this.onRejectedCallbacks.push(o))})}catch(e){return this.then(void 0,e)}static resolve(e){return new cm(t=>t(e))}static reject(e){return new cm((t,n)=>n(e))}static all(e){return new cm((t,n)=>{if(0===e.length)return void t([]);const r=[];let i=0;e.forEach((o,s)=>{o.then(n=>{r[s]=n,i++,i===e.length&&t(r)},n)})})}}var dm=Object.freeze({__proto__:null,PromisePolyfill:cm});class um{constructor(e){this.params=new Map,"string"==typeof e?this.parseString(e):e&&"object"==typeof e&&"forEach"in e&&"function"==typeof e.forEach?e.forEach((e,t)=>this.append(t,e)):e&&"object"==typeof e&&Object.entries(e).forEach(([e,t])=>this.set(e,t))}parseString(e){const t=e.startsWith("?")?e.slice(1):e;t&&t.split("&").forEach(e=>{if(!e)return;const t=e.indexOf("=");let n,r;-1===t?(n=e,r=""):(n=e.substring(0,t),r=e.substring(t+1)),n&&this.append(decodeURIComponent(n),decodeURIComponent(r))})}append(e,t){const n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}delete(e){this.params.delete(e)}get(e){var t;const n=this.params.get(e);return n&&n.length>0&&null!==(t=n[0])&&void 0!==t?t:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}forEach(e){this.params.forEach((t,n)=>{t.forEach(t=>e(t,n))})}toString(){const e=[];return this.params.forEach((t,n)=>{t.forEach(t=>{e.push(`${encodeURIComponent(n)}=${encodeURIComponent(t)}`)})}),e.join("&")}}var hm=Object.freeze({__proto__:null,URLPolyfill:class{constructor(e,t){const n=this.parseUrl(e,t);this.protocol=n.protocol,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.hash=n.hash,this.host=this.port?`${this.hostname}:${this.port}`:this.hostname,this.origin=`${this.protocol}//${this.host}`,this.href=this.toString(),this.searchParams=new um(this.search)}parseUrl(e,t){const n=document.createElement("a");if(t){const r=document.createElement("a");r.href=t,n.href=this.resolveUrl(e,r.href)}else n.href=e;return{protocol:n.protocol,hostname:n.hostname,port:n.port,pathname:n.pathname,search:n.search,hash:n.hash}}resolveUrl(e,t){if(e.includes("://"))return e;if(e.startsWith("/")){const n=document.createElement("a");return n.href=t,`${n.protocol}//${n.host}${e}`}return`${t.split("/").slice(0,-1).join("/")}/${e}`}toString(){return`${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`}},URLSearchParamsPolyfill:um});export{em as DataLayerManager,X as EnhancedHttpClient,G as ErrorHandlingStrategy,g as ErrorType,Ye as FormStateManager,nm as InsureOS,tm as InsureOSClient,Z as InsureOSError,ie as LocalStateManager,ee as LocalStorageAdapter,ne as MemoryStorageAdapter,im as PerformanceMonitor,rm as PolyfillManager,V as RetryStrategy,te as SessionStorageAdapter,$a as ThemeLoader,Hh as addBreadcrumb,Bh as captureException,qh as captureMessage,Ne as createAppError,Oe as getAnalytics,De as getSupportMessage,we as groupErrorsByField,Me as initializeAnalytics,Lh as initializeSentry,Yh as isSentryInitialized,ve as parseServerValidationErrors,Uh as setTag,Fh as setUser,Pe as shouldShowErrorPage,ze as shouldShowMaintenancePage,Ae as trackFormProgress,He as trackPaymentCompleted,Ue as trackPaymentFailed,Fe as trackPaymentInitiated,Be as trackQuoteAtCheckout,Le as trackQuoteCalculated,qe as trackQuoteReferred,We as trackQuoteStarted,ge as validateField,ye as validatePage};
2
2
  //# sourceMappingURL=index.esm.js.map