@iai-lib/any-chat-widget 0.1.0-alpha.7 → 0.1.0-alpha.74

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.
@@ -1,91 +1,280 @@
1
- (function(F,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(F=typeof globalThis<"u"?globalThis:F||self,B(F.AnyChatbot={}))})(this,function(F){"use strict";var dn=(F,B,Q)=>{if(!B.has(F))throw TypeError("Cannot "+Q)};var ms=(F,B,Q)=>(dn(F,B,"read from private field"),Q?Q.call(F):B.get(F)),Ws=(F,B,Q)=>{if(B.has(F))throw TypeError("Cannot add the same private member more than once");B instanceof WeakSet?B.add(F):B.set(F,Q)},je=(F,B,Q,Xe)=>(dn(F,B,"write to private field"),Xe?Xe.call(F,Q):B.set(F,Q),Q);/**
1
+ (function(Wo,vl){typeof exports=="object"&&typeof module<"u"?vl(exports):typeof define=="function"&&define.amd?define(["exports"],vl):(Wo=typeof globalThis<"u"?globalThis:Wo||self,vl(Wo.AnyChatbot={}))})(this,function(Wo){"use strict";var R2;function vl(t,e){for(var r=0;r<e.length;r++){const n=e[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(n,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var Zo=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Bs=function(t,e,r,n,i,a,s,o,u,l){var c=this;c.numeralDecimalMark=t||".",c.numeralIntegerScale=e>0?e:0,c.numeralDecimalScale=r>=0?r:2,c.numeralThousandsGroupStyle=n||Bs.groupStyle.thousand,c.numeralPositiveOnly=!!i,c.stripLeadingZeroes=a!==!1,c.prefix=s||s===""?s:"",c.signBeforePrefix=!!o,c.tailPrefix=!!u,c.delimiter=l||l===""?l:",",c.delimiterRE=l?new RegExp("\\"+l,"g"):""};Bs.groupStyle={thousand:"thousand",lakh:"lakh",wan:"wan",none:"none"},Bs.prototype={getRawValue:function(t){return t.replace(this.delimiterRE,"").replace(this.numeralDecimalMark,".")},format:function(t){var e=this,r,n,i,a,s="";switch(t=t.replace(/[A-Za-z]/g,"").replace(e.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",e.numeralPositiveOnly?"":"-").replace("M",e.numeralDecimalMark),e.stripLeadingZeroes&&(t=t.replace(/^(-)?0+(?=\d)/,"$1")),n=t.slice(0,1)==="-"?"-":"",typeof e.prefix<"u"?e.signBeforePrefix?i=n+e.prefix:i=e.prefix+n:i=n,a=t,t.indexOf(e.numeralDecimalMark)>=0&&(r=t.split(e.numeralDecimalMark),a=r[0],s=e.numeralDecimalMark+r[1].slice(0,e.numeralDecimalScale)),n==="-"&&(a=a.slice(1)),e.numeralIntegerScale>0&&(a=a.slice(0,e.numeralIntegerScale)),e.numeralThousandsGroupStyle){case Bs.groupStyle.lakh:a=a.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+e.delimiter);break;case Bs.groupStyle.wan:a=a.replace(/(\d)(?=(\d{4})+$)/g,"$1"+e.delimiter);break;case Bs.groupStyle.thousand:a=a.replace(/(\d)(?=(\d{3})+$)/g,"$1"+e.delimiter);break}return e.tailPrefix?n+a.toString()+(e.numeralDecimalScale>0?s.toString():"")+e.prefix:i+a.toString()+(e.numeralDecimalScale>0?s.toString():"")}};var M2=Bs,Jw=function(t,e,r){var n=this;n.date=[],n.blocks=[],n.datePattern=t,n.dateMin=e.split("-").reverse().map(function(i){return parseInt(i,10)}),n.dateMin.length===2&&n.dateMin.unshift(0),n.dateMax=r.split("-").reverse().map(function(i){return parseInt(i,10)}),n.dateMax.length===2&&n.dateMax.unshift(0),n.initBlocks()};Jw.prototype={initBlocks:function(){var t=this;t.datePattern.forEach(function(e){e==="Y"?t.blocks.push(4):t.blocks.push(2)})},getISOFormatDate:function(){var t=this,e=t.date;return e[2]?e[2]+"-"+t.addLeadingZero(e[1])+"-"+t.addLeadingZero(e[0]):""},getBlocks:function(){return this.blocks},getValidatedDate:function(t){var e=this,r="";return t=t.replace(/[^\d]/g,""),e.blocks.forEach(function(n,i){if(t.length>0){var a=t.slice(0,n),s=a.slice(0,1),o=t.slice(n);switch(e.datePattern[i]){case"d":a==="00"?a="01":parseInt(s,10)>3?a="0"+s:parseInt(a,10)>31&&(a="31");break;case"m":a==="00"?a="01":parseInt(s,10)>1?a="0"+s:parseInt(a,10)>12&&(a="12");break}r+=a,t=o}}),this.getFixedDateString(r)},getFixedDateString:function(t){var e=this,r=e.datePattern,n=[],i=0,a=0,s=0,o=0,u=0,l=0,c,d,f,m=!1;t.length===4&&r[0].toLowerCase()!=="y"&&r[1].toLowerCase()!=="y"&&(o=r[0]==="d"?0:2,u=2-o,c=parseInt(t.slice(o,o+2),10),d=parseInt(t.slice(u,u+2),10),n=this.getFixedDate(c,d,0)),t.length===8&&(r.forEach(function(A,N){switch(A){case"d":i=N;break;case"m":a=N;break;default:s=N;break}}),l=s*2,o=i<=s?i*2:i*2+2,u=a<=s?a*2:a*2+2,c=parseInt(t.slice(o,o+2),10),d=parseInt(t.slice(u,u+2),10),f=parseInt(t.slice(l,l+4),10),m=t.slice(l,l+4).length===4,n=this.getFixedDate(c,d,f)),t.length===4&&(r[0]==="y"||r[1]==="y")&&(u=r[0]==="m"?0:2,l=2-u,d=parseInt(t.slice(u,u+2),10),f=parseInt(t.slice(l,l+2),10),m=t.slice(l,l+2).length===2,n=[0,d,f]),t.length===6&&(r[0]==="Y"||r[1]==="Y")&&(u=r[0]==="m"?0:4,l=2-.5*u,d=parseInt(t.slice(u,u+2),10),f=parseInt(t.slice(l,l+4),10),m=t.slice(l,l+4).length===4,n=[0,d,f]),n=e.getRangeFixedDate(n),e.date=n;var b=n.length===0?t:r.reduce(function(A,N){switch(N){case"d":return A+(n[0]===0?"":e.addLeadingZero(n[0]));case"m":return A+(n[1]===0?"":e.addLeadingZero(n[1]));case"y":return A+(m?e.addLeadingZeroForYear(n[2],!1):"");case"Y":return A+(m?e.addLeadingZeroForYear(n[2],!0):"")}},"");return b},getRangeFixedDate:function(t){var e=this,r=e.datePattern,n=e.dateMin||[],i=e.dateMax||[];return!t.length||n.length<3&&i.length<3||r.find(function(a){return a.toLowerCase()==="y"})&&t[2]===0?t:i.length&&(i[2]<t[2]||i[2]===t[2]&&(i[1]<t[1]||i[1]===t[1]&&i[0]<t[0]))?i:n.length&&(n[2]>t[2]||n[2]===t[2]&&(n[1]>t[1]||n[1]===t[1]&&n[0]>t[0]))?n:t},getFixedDate:function(t,e,r){return t=Math.min(t,31),e=Math.min(e,12),r=parseInt(r||0,10),(e<7&&e%2===0||e>8&&e%2===1)&&(t=Math.min(t,e===2?this.isLeapYear(r)?29:28:30)),[t,e,r]},isLeapYear:function(t){return t%4===0&&t%100!==0||t%400===0},addLeadingZero:function(t){return(t<10?"0":"")+t},addLeadingZeroForYear:function(t,e){return e?(t<10?"000":t<100?"00":t<1e3?"0":"")+t:(t<10?"0":"")+t}};var N2=Jw,Yw=function(t,e){var r=this;r.time=[],r.blocks=[],r.timePattern=t,r.timeFormat=e,r.initBlocks()};Yw.prototype={initBlocks:function(){var t=this;t.timePattern.forEach(function(){t.blocks.push(2)})},getISOFormatTime:function(){var t=this,e=t.time;return e[2]?t.addLeadingZero(e[0])+":"+t.addLeadingZero(e[1])+":"+t.addLeadingZero(e[2]):""},getBlocks:function(){return this.blocks},getTimeFormatOptions:function(){var t=this;return String(t.timeFormat)==="12"?{maxHourFirstDigit:1,maxHours:12,maxMinutesFirstDigit:5,maxMinutes:60}:{maxHourFirstDigit:2,maxHours:23,maxMinutesFirstDigit:5,maxMinutes:60}},getValidatedTime:function(t){var e=this,r="";t=t.replace(/[^\d]/g,"");var n=e.getTimeFormatOptions();return e.blocks.forEach(function(i,a){if(t.length>0){var s=t.slice(0,i),o=s.slice(0,1),u=t.slice(i);switch(e.timePattern[a]){case"h":parseInt(o,10)>n.maxHourFirstDigit?s="0"+o:parseInt(s,10)>n.maxHours&&(s=n.maxHours+"");break;case"m":case"s":parseInt(o,10)>n.maxMinutesFirstDigit?s="0"+o:parseInt(s,10)>n.maxMinutes&&(s=n.maxMinutes+"");break}r+=s,t=u}}),this.getFixedTimeString(r)},getFixedTimeString:function(t){var e=this,r=e.timePattern,n=[],i=0,a=0,s=0,o=0,u=0,l=0,c,d,f;return t.length===6&&(r.forEach(function(m,b){switch(m){case"s":i=b*2;break;case"m":a=b*2;break;case"h":s=b*2;break}}),l=s,u=a,o=i,c=parseInt(t.slice(o,o+2),10),d=parseInt(t.slice(u,u+2),10),f=parseInt(t.slice(l,l+2),10),n=this.getFixedTime(f,d,c)),t.length===4&&e.timePattern.indexOf("s")<0&&(r.forEach(function(m,b){switch(m){case"m":a=b*2;break;case"h":s=b*2;break}}),l=s,u=a,c=0,d=parseInt(t.slice(u,u+2),10),f=parseInt(t.slice(l,l+2),10),n=this.getFixedTime(f,d,c)),e.time=n,n.length===0?t:r.reduce(function(m,b){switch(b){case"s":return m+e.addLeadingZero(n[2]);case"m":return m+e.addLeadingZero(n[1]);case"h":return m+e.addLeadingZero(n[0])}},"")},getFixedTime:function(t,e,r){return r=Math.min(parseInt(r||0,10),60),e=Math.min(e,60),t=Math.min(t,60),[t,e,r]},addLeadingZero:function(t){return(t<10?"0":"")+t}};var L2=Yw,Qw=function(t,e){var r=this;r.delimiter=e||e===""?e:" ",r.delimiterRE=e?new RegExp("\\"+e,"g"):"",r.formatter=t};Qw.prototype={setFormatter:function(t){this.formatter=t},format:function(t){var e=this;e.formatter.clear(),t=t.replace(/[^\d+]/g,""),t=t.replace(/^\+/,"B").replace(/\+/g,"").replace("B","+"),t=t.replace(e.delimiterRE,"");for(var r="",n,i=!1,a=0,s=t.length;a<s;a++)n=e.formatter.inputDigit(t.charAt(a)),/[\s()-]/g.test(n)?(r=n,i=!0):i||(r=n);return r=r.replace(/[()]/g,""),r=r.replace(/[\s-]/g,e.delimiter),r}};var D2=Qw,rv={blocks:{uatp:[4,5,6],amex:[4,6,5],diners:[4,6,4],discover:[4,4,4,4],mastercard:[4,4,4,4],dankort:[4,4,4,4],instapayment:[4,4,4,4],jcb15:[4,6,5],jcb:[4,4,4,4],maestro:[4,4,4,4],visa:[4,4,4,4],mir:[4,4,4,4],unionPay:[4,4,4,4],general:[4,4,4,4]},re:{uatp:/^(?!1800)1\d{0,14}/,amex:/^3[47]\d{0,13}/,discover:/^(?:6011|65\d{0,2}|64[4-9]\d?)\d{0,12}/,diners:/^3(?:0([0-5]|9)|[689]\d?)\d{0,11}/,mastercard:/^(5[1-5]\d{0,2}|22[2-9]\d{0,1}|2[3-7]\d{0,2})\d{0,12}/,dankort:/^(5019|4175|4571)\d{0,12}/,instapayment:/^63[7-9]\d{0,13}/,jcb15:/^(?:2131|1800)\d{0,11}/,jcb:/^(?:35\d{0,2})\d{0,12}/,maestro:/^(?:5[0678]\d{0,2}|6304|67\d{0,2})\d{0,12}/,mir:/^220[0-4]\d{0,12}/,visa:/^4\d{0,15}/,unionPay:/^(62|81)\d{0,14}/},getStrictBlocks:function(t){var e=t.reduce(function(r,n){return r+n},0);return t.concat(19-e)},getInfo:function(t,e){var r=rv.blocks,n=rv.re;e=!!e;for(var i in n)if(n[i].test(t)){var a=r[i];return{type:i,blocks:e?this.getStrictBlocks(a):a}}return{type:"unknown",blocks:e?this.getStrictBlocks(r.general):r.general}}},j2=rv,U2={noop:function(){},strip:function(t,e){return t.replace(e,"")},getPostDelimiter:function(t,e,r){if(r.length===0)return t.slice(-e.length)===e?e:"";var n="";return r.forEach(function(i){t.slice(-i.length)===i&&(n=i)}),n},getDelimiterREByDelimiter:function(t){return new RegExp(t.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),"g")},getNextCursorPosition:function(t,e,r,n,i){return e.length===t?r.length:t+this.getPositionOffset(t,e,r,n,i)},getPositionOffset:function(t,e,r,n,i){var a,s,o;return a=this.stripDelimiters(e.slice(0,t),n,i),s=this.stripDelimiters(r.slice(0,t),n,i),o=a.length-s.length,o!==0?o/Math.abs(o):0},stripDelimiters:function(t,e,r){var n=this;if(r.length===0){var i=e?n.getDelimiterREByDelimiter(e):"";return t.replace(i,"")}return r.forEach(function(a){a.split("").forEach(function(s){t=t.replace(n.getDelimiterREByDelimiter(s),"")})}),t},headStr:function(t,e){return t.slice(0,e)},getMaxLength:function(t){return t.reduce(function(e,r){return e+r},0)},getPrefixStrippedValue:function(t,e,r,n,i,a,s,o,u){if(r===0)return t;if(t===e&&t!=="")return"";if(u&&t.slice(0,1)=="-"){var l=n.slice(0,1)=="-"?n.slice(1):n;return"-"+this.getPrefixStrippedValue(t.slice(1),e,r,l,i,a,s,o,u)}if(n.slice(0,r)!==e&&!o)return s&&!n&&t?t:"";if(n.slice(-r)!==e&&o)return s&&!n&&t?t:"";var c=this.stripDelimiters(n,i,a);return t.slice(0,r)!==e&&!o?c.slice(r):t.slice(-r)!==e&&o?c.slice(0,-r-1):o?t.slice(0,-r):t.slice(r)},getFirstDiffIndex:function(t,e){for(var r=0;t.charAt(r)===e.charAt(r);)if(t.charAt(r++)==="")return-1;return r},getFormattedValue:function(t,e,r,n,i,a){var s="",o=i.length>0,u="";return r===0?t:(e.forEach(function(l,c){if(t.length>0){var d=t.slice(0,l),f=t.slice(l);o?u=i[a?c-1:c]||u:u=n,a?(c>0&&(s+=u),s+=d):(s+=d,d.length===l&&c<r-1&&(s+=u)),t=f}}),s)},fixPrefixCursor:function(t,e,r,n){if(t){var i=t.value,a=r||n[0]||" ";if(!(!t.setSelectionRange||!e||e.length+a.length<=i.length)){var s=i.length*2;setTimeout(function(){t.setSelectionRange(s,s)},1)}}},checkFullSelection:function(t){try{var e=window.getSelection()||document.getSelection()||{};return e.toString().length===t.length}catch{}return!1},setSelection:function(t,e,r){if(t===this.getActiveElement(r)&&!(t&&t.value.length<=e))if(t.createTextRange){var n=t.createTextRange();n.move("character",e),n.select()}else try{t.setSelectionRange(e,e)}catch{console.warn("The input element type does not support selection")}},getActiveElement:function(t){var e=t.activeElement;return e&&e.shadowRoot?this.getActiveElement(e.shadowRoot):e},isAndroid:function(){return navigator&&/android/i.test(navigator.userAgent)},isAndroidBackspaceKeydown:function(t,e){return!this.isAndroid()||!t||!e?!1:e===t.slice(0,-1)}},F2=U2,B2={assign:function(t,e){return t=t||{},e=e||{},t.creditCard=!!e.creditCard,t.creditCardStrictMode=!!e.creditCardStrictMode,t.creditCardType="",t.onCreditCardTypeChanged=e.onCreditCardTypeChanged||function(){},t.phone=!!e.phone,t.phoneRegionCode=e.phoneRegionCode||"AU",t.phoneFormatter={},t.time=!!e.time,t.timePattern=e.timePattern||["h","m","s"],t.timeFormat=e.timeFormat||"24",t.timeFormatter={},t.date=!!e.date,t.datePattern=e.datePattern||["d","m","Y"],t.dateMin=e.dateMin||"",t.dateMax=e.dateMax||"",t.dateFormatter={},t.numeral=!!e.numeral,t.numeralIntegerScale=e.numeralIntegerScale>0?e.numeralIntegerScale:0,t.numeralDecimalScale=e.numeralDecimalScale>=0?e.numeralDecimalScale:2,t.numeralDecimalMark=e.numeralDecimalMark||".",t.numeralThousandsGroupStyle=e.numeralThousandsGroupStyle||"thousand",t.numeralPositiveOnly=!!e.numeralPositiveOnly,t.stripLeadingZeroes=e.stripLeadingZeroes!==!1,t.signBeforePrefix=!!e.signBeforePrefix,t.tailPrefix=!!e.tailPrefix,t.swapHiddenInput=!!e.swapHiddenInput,t.numericOnly=t.creditCard||t.date||!!e.numericOnly,t.uppercase=!!e.uppercase,t.lowercase=!!e.lowercase,t.prefix=t.creditCard||t.date?"":e.prefix||"",t.noImmediatePrefix=!!e.noImmediatePrefix,t.prefixLength=t.prefix.length,t.rawValueTrimPrefix=!!e.rawValueTrimPrefix,t.copyDelimiter=!!e.copyDelimiter,t.initValue=e.initValue!==void 0&&e.initValue!==null?e.initValue.toString():"",t.delimiter=e.delimiter||e.delimiter===""?e.delimiter:e.date?"/":e.time?":":e.numeral?",":(e.phone," "),t.delimiterLength=t.delimiter.length,t.delimiterLazyShow=!!e.delimiterLazyShow,t.delimiters=e.delimiters||[],t.blocks=e.blocks||[],t.blocksLength=t.blocks.length,t.root=typeof Zo=="object"&&Zo?Zo:window,t.document=e.document||t.root.document,t.maxLength=0,t.backspace=!1,t.result="",t.onValueChanged=e.onValueChanged||function(){},t}},z2=B2,Tr=function(t,e){var r=this,n=!1;if(typeof t=="string"?(r.element=document.querySelector(t),n=document.querySelectorAll(t).length>1):typeof t.length<"u"&&t.length>0?(r.element=t[0],n=t.length>1):r.element=t,!r.element)throw new Error("[cleave.js] Please check the element");if(n)try{console.warn("[cleave.js] Multiple input fields matched, cleave.js will only take the first one.")}catch{}e.initValue=r.element.value,r.properties=Tr.DefaultProperties.assign({},e),r.init()};Tr.prototype={init:function(){var t=this,e=t.properties;if(!e.numeral&&!e.phone&&!e.creditCard&&!e.time&&!e.date&&e.blocksLength===0&&!e.prefix){t.onInput(e.initValue);return}e.maxLength=Tr.Util.getMaxLength(e.blocks),t.isAndroid=Tr.Util.isAndroid(),t.lastInputValue="",t.isBackward="",t.onChangeListener=t.onChange.bind(t),t.onKeyDownListener=t.onKeyDown.bind(t),t.onFocusListener=t.onFocus.bind(t),t.onCutListener=t.onCut.bind(t),t.onCopyListener=t.onCopy.bind(t),t.initSwapHiddenInput(),t.element.addEventListener("input",t.onChangeListener),t.element.addEventListener("keydown",t.onKeyDownListener),t.element.addEventListener("focus",t.onFocusListener),t.element.addEventListener("cut",t.onCutListener),t.element.addEventListener("copy",t.onCopyListener),t.initPhoneFormatter(),t.initDateFormatter(),t.initTimeFormatter(),t.initNumeralFormatter(),(e.initValue||e.prefix&&!e.noImmediatePrefix)&&t.onInput(e.initValue)},initSwapHiddenInput:function(){var t=this,e=t.properties;if(e.swapHiddenInput){var r=t.element.cloneNode(!0);t.element.parentNode.insertBefore(r,t.element),t.elementSwapHidden=t.element,t.elementSwapHidden.type="hidden",t.element=r,t.element.id=""}},initNumeralFormatter:function(){var t=this,e=t.properties;e.numeral&&(e.numeralFormatter=new Tr.NumeralFormatter(e.numeralDecimalMark,e.numeralIntegerScale,e.numeralDecimalScale,e.numeralThousandsGroupStyle,e.numeralPositiveOnly,e.stripLeadingZeroes,e.prefix,e.signBeforePrefix,e.tailPrefix,e.delimiter))},initTimeFormatter:function(){var t=this,e=t.properties;e.time&&(e.timeFormatter=new Tr.TimeFormatter(e.timePattern,e.timeFormat),e.blocks=e.timeFormatter.getBlocks(),e.blocksLength=e.blocks.length,e.maxLength=Tr.Util.getMaxLength(e.blocks))},initDateFormatter:function(){var t=this,e=t.properties;e.date&&(e.dateFormatter=new Tr.DateFormatter(e.datePattern,e.dateMin,e.dateMax),e.blocks=e.dateFormatter.getBlocks(),e.blocksLength=e.blocks.length,e.maxLength=Tr.Util.getMaxLength(e.blocks))},initPhoneFormatter:function(){var t=this,e=t.properties;if(e.phone)try{e.phoneFormatter=new Tr.PhoneFormatter(new e.root.Cleave.AsYouTypeFormatter(e.phoneRegionCode),e.delimiter)}catch{throw new Error("[cleave.js] Please include phone-type-formatter.{country}.js lib")}},onKeyDown:function(t){var e=this,r=t.which||t.keyCode;e.lastInputValue=e.element.value,e.isBackward=r===8},onChange:function(t){var e=this,r=e.properties,n=Tr.Util;e.isBackward=e.isBackward||t.inputType==="deleteContentBackward";var i=n.getPostDelimiter(e.lastInputValue,r.delimiter,r.delimiters);e.isBackward&&i?r.postDelimiterBackspace=i:r.postDelimiterBackspace=!1,this.onInput(this.element.value)},onFocus:function(){var t=this,e=t.properties;t.lastInputValue=t.element.value,e.prefix&&e.noImmediatePrefix&&!t.element.value&&this.onInput(e.prefix),Tr.Util.fixPrefixCursor(t.element,e.prefix,e.delimiter,e.delimiters)},onCut:function(t){Tr.Util.checkFullSelection(this.element.value)&&(this.copyClipboardData(t),this.onInput(""))},onCopy:function(t){Tr.Util.checkFullSelection(this.element.value)&&this.copyClipboardData(t)},copyClipboardData:function(t){var e=this,r=e.properties,n=Tr.Util,i=e.element.value,a="";r.copyDelimiter?a=i:a=n.stripDelimiters(i,r.delimiter,r.delimiters);try{t.clipboardData?t.clipboardData.setData("Text",a):window.clipboardData.setData("Text",a),t.preventDefault()}catch{}},onInput:function(t){var e=this,r=e.properties,n=Tr.Util,i=n.getPostDelimiter(t,r.delimiter,r.delimiters);if(!r.numeral&&r.postDelimiterBackspace&&!i&&(t=n.headStr(t,t.length-r.postDelimiterBackspace.length)),r.phone){r.prefix&&(!r.noImmediatePrefix||t.length)?r.result=r.prefix+r.phoneFormatter.format(t).slice(r.prefix.length):r.result=r.phoneFormatter.format(t),e.updateValueState();return}if(r.numeral){r.prefix&&r.noImmediatePrefix&&t.length===0?r.result="":r.result=r.numeralFormatter.format(t),e.updateValueState();return}if(r.date&&(t=r.dateFormatter.getValidatedDate(t)),r.time&&(t=r.timeFormatter.getValidatedTime(t)),t=n.stripDelimiters(t,r.delimiter,r.delimiters),t=n.getPrefixStrippedValue(t,r.prefix,r.prefixLength,r.result,r.delimiter,r.delimiters,r.noImmediatePrefix,r.tailPrefix,r.signBeforePrefix),t=r.numericOnly?n.strip(t,/[^\d]/g):t,t=r.uppercase?t.toUpperCase():t,t=r.lowercase?t.toLowerCase():t,r.prefix&&(r.tailPrefix?t=t+r.prefix:t=r.prefix+t,r.blocksLength===0)){r.result=t,e.updateValueState();return}r.creditCard&&e.updateCreditCardPropsByValue(t),t=n.headStr(t,r.maxLength),r.result=n.getFormattedValue(t,r.blocks,r.blocksLength,r.delimiter,r.delimiters,r.delimiterLazyShow),e.updateValueState()},updateCreditCardPropsByValue:function(t){var e=this,r=e.properties,n=Tr.Util,i;n.headStr(r.result,4)!==n.headStr(t,4)&&(i=Tr.CreditCardDetector.getInfo(t,r.creditCardStrictMode),r.blocks=i.blocks,r.blocksLength=r.blocks.length,r.maxLength=n.getMaxLength(r.blocks),r.creditCardType!==i.type&&(r.creditCardType=i.type,r.onCreditCardTypeChanged.call(e,r.creditCardType)))},updateValueState:function(){var t=this,e=Tr.Util,r=t.properties;if(t.element){var n=t.element.selectionEnd,i=t.element.value,a=r.result;if(n=e.getNextCursorPosition(n,i,a,r.delimiter,r.delimiters),t.isAndroid){window.setTimeout(function(){t.element.value=a,e.setSelection(t.element,n,r.document,!1),t.callOnValueChanged()},1);return}t.element.value=a,r.swapHiddenInput&&(t.elementSwapHidden.value=t.getRawValue()),e.setSelection(t.element,n,r.document,!1),t.callOnValueChanged()}},callOnValueChanged:function(){var t=this,e=t.properties;e.onValueChanged.call(t,{target:{name:t.element.name,value:e.result,rawValue:t.getRawValue()}})},setPhoneRegionCode:function(t){var e=this,r=e.properties;r.phoneRegionCode=t,e.initPhoneFormatter(),e.onChange()},setRawValue:function(t){var e=this,r=e.properties;t=t!=null?t.toString():"",r.numeral&&(t=t.replace(".",r.numeralDecimalMark)),r.postDelimiterBackspace=!1,e.element.value=t,e.onInput(t)},getRawValue:function(){var t=this,e=t.properties,r=Tr.Util,n=t.element.value;return e.rawValueTrimPrefix&&(n=r.getPrefixStrippedValue(n,e.prefix,e.prefixLength,e.result,e.delimiter,e.delimiters,e.noImmediatePrefix,e.tailPrefix,e.signBeforePrefix)),e.numeral?n=e.numeralFormatter.getRawValue(n):n=r.stripDelimiters(n,e.delimiter,e.delimiters),n},getISOFormatDate:function(){var t=this,e=t.properties;return e.date?e.dateFormatter.getISOFormatDate():""},getISOFormatTime:function(){var t=this,e=t.properties;return e.time?e.timeFormatter.getISOFormatTime():""},getFormattedValue:function(){return this.element.value},destroy:function(){var t=this;t.element.removeEventListener("input",t.onChangeListener),t.element.removeEventListener("keydown",t.onKeyDownListener),t.element.removeEventListener("focus",t.onFocusListener),t.element.removeEventListener("cut",t.onCutListener),t.element.removeEventListener("copy",t.onCopyListener)},toString:function(){return"[Cleave Object]"}},Tr.NumeralFormatter=M2,Tr.DateFormatter=N2,Tr.TimeFormatter=L2,Tr.PhoneFormatter=D2,Tr.CreditCardDetector=j2,Tr.Util=F2,Tr.DefaultProperties=z2,(typeof Zo=="object"&&Zo?Zo:window).Cleave=Tr;var H2=Tr;/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */var we,qe;const B=globalThis,Q=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Xe=Symbol(),Ks=new WeakMap;let Js=class{constructor(s,e,t){if(this._$cssResult$=!0,t!==Xe)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=s,this.t=e}get styleSheet(){let s=this.o;const e=this.t;if(Q&&s===void 0){const t=e!==void 0&&e.length===1;t&&(s=Ks.get(e)),s===void 0&&((this.o=s=new CSSStyleSheet).replaceSync(this.cssText),t&&Ks.set(e,s))}return s}toString(){return this.cssText}};const ln=s=>new Js(typeof s=="string"?s:s+"",void 0,Xe),Qe=(s,...e)=>{const t=s.length===1?s[0]:e.reduce((i,n,r)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+s[r+1],s[0]);return new Js(t,s,Xe)},un=(s,e)=>{if(Q)s.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=B.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,s.appendChild(i)}},qs=Q?s=>s:s=>s instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return ln(t)})(s):s;/**
5
+ */const Bd=globalThis,nv=Bd.ShadowRoot&&(Bd.ShadyCSS===void 0||Bd.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,iv=Symbol(),Xw=new WeakMap;let e0=class{constructor(e,r,n){if(this._$cssResult$=!0,n!==iv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=r}get styleSheet(){let e=this.o;const r=this.t;if(nv&&e===void 0){const n=r!==void 0&&r.length===1;n&&(e=Xw.get(r)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Xw.set(r,e))}return e}toString(){return this.cssText}};const q2=t=>new e0(typeof t=="string"?t:t+"",void 0,iv),V2=(t,...e)=>{const r=t.length===1?t[0]:e.reduce((n,i,a)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[a+1],t[0]);return new e0(r,t,iv)},W2=(t,e)=>{if(nv)t.adoptedStyleSheets=e.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(const r of e){const n=document.createElement("style"),i=Bd.litNonce;i!==void 0&&n.setAttribute("nonce",i),n.textContent=r.cssText,t.appendChild(n)}},t0=nv?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let r="";for(const n of e.cssRules)r+=n.cssText;return q2(r)})(t):t;/**
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:hn,defineProperty:pn,getOwnPropertyDescriptor:mn,getOwnPropertyNames:fn,getOwnPropertySymbols:gn,getPrototypeOf:yn}=Object,et=globalThis,Ys=et.trustedTypes,vn=Ys?Ys.emptyScript:"",Gs=et.reactiveElementPolyfillSupport,ht=(s,e)=>s,Dt={toAttribute(s,e){switch(e){case Boolean:s=s?vn:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,e){let t=s;switch(e){case Boolean:t=s!==null;break;case Number:t=s===null?null:Number(s);break;case Object:case Array:try{t=JSON.parse(s)}catch{t=null}}return t}},fs=(s,e)=>!hn(s,e),Xs={attribute:!0,type:String,converter:Dt,reflect:!1,hasChanged:fs};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),et.litPropertyMetadata??(et.litPropertyMetadata=new WeakMap);class tt extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Xs){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&pn(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:r}=mn(this.prototype,e)??{get(){return this[t]},set(a){this[t]=a}};return{get(){return n==null?void 0:n.call(this)},set(a){const o=n==null?void 0:n.call(this);r.call(this,a),this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Xs}static _$Ei(){if(this.hasOwnProperty(ht("elementProperties")))return;const e=yn(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ht("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ht("properties"))){const t=this.properties,i=[...fn(t),...gn(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(qs(n))}else e!==void 0&&t.push(qs(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return un(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EC(e,t){var i;const n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&n.reflect===!0){const a=(((i=n.converter)==null?void 0:i.toAttribute)!==void 0?n.converter:Dt).toAttribute(t,n.type);this._$Em=e,a==null?this.removeAttribute(r):this.setAttribute(r,a),this._$Em=null}}_$AK(e,t){var i;const n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const a=n.getPropertyOptions(r),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((i=a.converter)==null?void 0:i.fromAttribute)!==void 0?a.converter:Dt;this._$Em=r,this[r]=o.fromAttribute(t,a.type),this._$Em=null}}requestUpdate(e,t,i){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??fs)(this[e],t))return;this.P(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,a]of this._$Ep)this[r]=a;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[r,a]of n)a.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],a)}let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),(e=this._$EO)==null||e.forEach(n=>{var r;return(r=n.hostUpdate)==null?void 0:r.call(n)}),this.update(i)):this._$EU()}catch(n){throw t=!1,this._$EU(),n}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EC(t,this[t]))),this._$EU()}updated(e){}firstUpdated(e){}}tt.elementStyles=[],tt.shadowRootOptions={mode:"open"},tt[ht("elementProperties")]=new Map,tt[ht("finalized")]=new Map,Gs==null||Gs({ReactiveElement:tt}),(et.reactiveElementVersions??(et.reactiveElementVersions=[])).push("2.0.4");/**
9
+ */const{is:Z2,defineProperty:G2,getOwnPropertyDescriptor:K2,getOwnPropertyNames:J2,getOwnPropertySymbols:Y2,getPrototypeOf:Q2}=Object,Ka=globalThis,r0=Ka.trustedTypes,X2=r0?r0.emptyScript:"",av=Ka.reactiveElementPolyfillSupport,ml=(t,e)=>t,zd={toAttribute(t,e){switch(e){case Boolean:t=t?X2:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=t!==null;break;case Number:r=t===null?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch{r=null}}return r}},sv=(t,e)=>!Z2(t,e),n0={attribute:!0,type:String,converter:zd,reflect:!1,hasChanged:sv};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ka.litPropertyMetadata??(Ka.litPropertyMetadata=new WeakMap);let Go=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,r=n0){if(r.state&&(r.attribute=!1),this._$Ei(),this.elementProperties.set(e,r),!r.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(e,n,r);i!==void 0&&G2(this.prototype,e,i)}}static getPropertyDescriptor(e,r,n){const{get:i,set:a}=K2(this.prototype,e)??{get(){return this[r]},set(s){this[r]=s}};return{get(){return i==null?void 0:i.call(this)},set(s){const o=i==null?void 0:i.call(this);a.call(this,s),this.requestUpdate(e,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??n0}static _$Ei(){if(this.hasOwnProperty(ml("elementProperties")))return;const e=Q2(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ml("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ml("properties"))){const r=this.properties,n=[...J2(r),...Y2(r)];for(const i of n)this.createProperty(i,r[i])}const e=this[Symbol.metadata];if(e!==null){const r=litPropertyMetadata.get(e);if(r!==void 0)for(const[n,i]of r)this.elementProperties.set(n,i)}this._$Eh=new Map;for(const[r,n]of this.elementProperties){const i=this._$Eu(r,n);i!==void 0&&this._$Eh.set(i,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const r=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const i of n)r.unshift(t0(i))}else e!==void 0&&r.push(t0(e));return r}static _$Eu(e,r){const n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(r=>r(this))}addController(e){var r;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)==null||r.call(e))}removeController(e){var r;(r=this._$EO)==null||r.delete(e)}_$E_(){const e=new Map,r=this.constructor.elementProperties;for(const n of r.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return W2(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(r=>{var n;return(n=r.hostConnected)==null?void 0:n.call(r)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(r=>{var n;return(n=r.hostDisconnected)==null?void 0:n.call(r)})}attributeChangedCallback(e,r,n){this._$AK(e,n)}_$EC(e,r){var a;const n=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,n);if(i!==void 0&&n.reflect===!0){const s=(((a=n.converter)==null?void 0:a.toAttribute)!==void 0?n.converter:zd).toAttribute(r,n.type);this._$Em=e,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(e,r){var a;const n=this.constructor,i=n._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const s=n.getPropertyOptions(i),o=typeof s.converter=="function"?{fromAttribute:s.converter}:((a=s.converter)==null?void 0:a.fromAttribute)!==void 0?s.converter:zd;this._$Em=i,this[i]=o.fromAttribute(r,s.type),this._$Em=null}}requestUpdate(e,r,n){if(e!==void 0){if(n??(n=this.constructor.getPropertyOptions(e)),!(n.hasChanged??sv)(this[e],r))return;this.P(e,r,n)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,r,n){this._$AL.has(e)||this._$AL.set(e,r),n.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var n;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[a,s]of this._$Ep)this[a]=s;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[a,s]of i)s.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.P(a,this[a],s)}let e=!1;const r=this._$AL;try{e=this.shouldUpdate(r),e?(this.willUpdate(r),(n=this._$EO)==null||n.forEach(i=>{var a;return(a=i.hostUpdate)==null?void 0:a.call(i)}),this.update(r)):this._$EU()}catch(i){throw e=!1,this._$EU(),i}e&&this._$AE(r)}willUpdate(e){}_$AE(e){var r;(r=this._$EO)==null||r.forEach(n=>{var i;return(i=n.hostUpdated)==null?void 0:i.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(r=>this._$EC(r,this[r]))),this._$EU()}updated(e){}firstUpdated(e){}};Go.elementStyles=[],Go.shadowRootOptions={mode:"open"},Go[ml("elementProperties")]=new Map,Go[ml("finalized")]=new Map,av==null||av({ReactiveElement:Go}),(Ka.reactiveElementVersions??(Ka.reactiveElementVersions=[])).push("2.0.4");/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */const Ut=globalThis,Ht=Ut.trustedTypes,Qs=Ht?Ht.createPolicy("lit-html",{createHTML:s=>s}):void 0,gs="$lit$",ge=`lit$${(Math.random()+"").slice(9)}$`,ys="?"+ge,bn=`<${ys}>`,Re=document,pt=()=>Re.createComment(""),mt=s=>s===null||typeof s!="object"&&typeof s!="function",ei=Array.isArray,ti=s=>ei(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",vs=`[
14
- \f\r]`,ft=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,si=/-->/g,ii=/>/g,Ze=RegExp(`>|${vs}(?:([^\\s"'>=/]+)(${vs}*=${vs}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),ni=/'/g,ri=/"/g,ai=/^(?:script|style|textarea|title)$/i,wn=s=>(e,...t)=>({_$litType$:s,strings:e,values:t}),z=wn(1),ue=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),oi=new WeakMap,Le=Re.createTreeWalker(Re,129);function ci(s,e){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Qs!==void 0?Qs.createHTML(e):e}const di=(s,e)=>{const t=s.length-1,i=[];let n,r=e===2?"<svg>":"",a=ft;for(let o=0;o<t;o++){const c=s[o];let l,h,p=-1,d=0;for(;d<c.length&&(a.lastIndex=d,h=a.exec(c),h!==null);)d=a.lastIndex,a===ft?h[1]==="!--"?a=si:h[1]!==void 0?a=ii:h[2]!==void 0?(ai.test(h[2])&&(n=RegExp("</"+h[2],"g")),a=Ze):h[3]!==void 0&&(a=Ze):a===Ze?h[0]===">"?(a=n??ft,p=-1):h[1]===void 0?p=-2:(p=a.lastIndex-h[2].length,l=h[1],a=h[3]===void 0?Ze:h[3]==='"'?ri:ni):a===ri||a===ni?a=Ze:a===si||a===ii?a=ft:(a=Ze,n=void 0);const b=a===Ze&&s[o+1].startsWith("/>")?" ":"";r+=a===ft?c+bn:p>=0?(i.push(l),c.slice(0,p)+gs+c.slice(p)+ge+b):c+ge+(p===-2?o:b)}return[ci(s,r+(s[t]||"<?>")+(e===2?"</svg>":"")),i]};class gt{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let r=0,a=0;const o=e.length-1,c=this.parts,[l,h]=di(e,t);if(this.el=gt.createElement(l,i),Le.currentNode=this.el.content,t===2){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(n=Le.nextNode())!==null&&c.length<o;){if(n.nodeType===1){if(n.hasAttributes())for(const p of n.getAttributeNames())if(p.endsWith(gs)){const d=h[a++],b=n.getAttribute(p).split(ge),N=/([.?@])?(.*)/.exec(d);c.push({type:1,index:r,name:N[2],strings:b,ctor:N[1]==="."?ui:N[1]==="?"?hi:N[1]==="@"?pi:yt}),n.removeAttribute(p)}else p.startsWith(ge)&&(c.push({type:6,index:r}),n.removeAttribute(p));if(ai.test(n.tagName)){const p=n.textContent.split(ge),d=p.length-1;if(d>0){n.textContent=Ht?Ht.emptyScript:"";for(let b=0;b<d;b++)n.append(p[b],pt()),Le.nextNode(),c.push({type:2,index:++r});n.append(p[d],pt())}}}else if(n.nodeType===8)if(n.data===ys)c.push({type:2,index:r});else{let p=-1;for(;(p=n.data.indexOf(ge,p+1))!==-1;)c.push({type:7,index:r}),p+=ge.length-1}r++}}static createElement(e,t){const i=Re.createElement("template");return i.innerHTML=e,i}}function ze(s,e,t=s,i){var n,r;if(e===ue)return e;let a=i!==void 0?(n=t._$Co)==null?void 0:n[i]:t._$Cl;const o=mt(e)?void 0:e._$litDirective$;return(a==null?void 0:a.constructor)!==o&&((r=a==null?void 0:a._$AO)==null||r.call(a,!1),o===void 0?a=void 0:(a=new o(s),a._$AT(s,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=a:t._$Cl=a),a!==void 0&&(e=ze(s,a._$AS(s,e.values),a,i)),e}class li{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,n=((e==null?void 0:e.creationScope)??Re).importNode(t,!0);Le.currentNode=n;let r=Le.nextNode(),a=0,o=0,c=i[0];for(;c!==void 0;){if(a===c.index){let l;c.type===2?l=new st(r,r.nextSibling,this,e):c.type===1?l=new c.ctor(r,c.name,c.strings,this,e):c.type===6&&(l=new mi(r,this,e)),this._$AV.push(l),c=i[++o]}a!==(c==null?void 0:c.index)&&(r=Le.nextNode(),a++)}return Le.currentNode=Re,n}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class st{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,n){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ze(this,e,t),mt(e)?e===V||e==null||e===""?(this._$AH!==V&&this._$AR(),this._$AH=V):e!==this._$AH&&e!==ue&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ti(e)?this.k(e):this._(e)}S(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}_(e){this._$AH!==V&&mt(this._$AH)?this._$AA.nextSibling.data=e:this.T(Re.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:n}=e,r=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=gt.createElement(ci(n.h,n.h[0]),this.options)),n);if(((t=this._$AH)==null?void 0:t._$AD)===r)this._$AH.p(i);else{const a=new li(r,this),o=a.u(this.options);a.p(i),this.T(o),this._$AH=a}}_$AC(e){let t=oi.get(e.strings);return t===void 0&&oi.set(e.strings,t=new gt(e)),t}k(e){ei(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,n=0;for(const r of e)n===t.length?t.push(i=new st(this.S(pt()),this.S(pt()),this,this.options)):i=t[n],i._$AI(r),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e&&e!==this._$AB;){const n=e.nextSibling;e.remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class yt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,n,r){this.type=1,this._$AH=V,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=V}_$AI(e,t=this,i,n){const r=this.strings;let a=!1;if(r===void 0)e=ze(this,e,t,0),a=!mt(e)||e!==this._$AH&&e!==ue,a&&(this._$AH=e);else{const o=e;let c,l;for(e=r[0],c=0;c<r.length-1;c++)l=ze(this,o[i+c],t,c),l===ue&&(l=this._$AH[c]),a||(a=!mt(l)||l!==this._$AH[c]),l===V?e=V:e!==V&&(e+=(l??"")+r[c+1]),this._$AH[c]=l}a&&!n&&this.j(e)}j(e){e===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ui extends yt{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===V?void 0:e}}class hi extends yt{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==V)}}class pi extends yt{constructor(e,t,i,n,r){super(e,t,i,n,r),this.type=5}_$AI(e,t=this){if((e=ze(this,e,t,0)??V)===ue)return;const i=this._$AH,n=e===V&&i!==V||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==V&&(i===V||n);n&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class mi{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){ze(this,e)}}const _n={P:gs,A:ge,C:ys,M:1,L:di,R:li,D:ti,V:ze,I:st,H:yt,N:hi,U:pi,B:ui,F:mi},fi=Ut.litHtmlPolyfillSupport;fi==null||fi(gt,st),(Ut.litHtmlVersions??(Ut.litHtmlVersions=[])).push("3.1.2");const xn=(s,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let n=i._$litPart$;if(n===void 0){const r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=n=new st(e.insertBefore(pt(),r),r,void 0,t??{})}return n._$AI(s),n};/**
13
+ */const gl=globalThis,Hd=gl.trustedTypes,i0=Hd?Hd.createPolicy("lit-html",{createHTML:t=>t}):void 0,a0="$lit$",Ja=`lit$${Math.random().toFixed(9).slice(2)}$`,s0="?"+Ja,eO=`<${s0}>`,zs=document,yl=()=>zs.createComment(""),bl=t=>t===null||typeof t!="object"&&typeof t!="function",o0=Array.isArray,tO=t=>o0(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",ov=`[
14
+ \f\r]`,wl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,u0=/-->/g,l0=/>/g,Hs=RegExp(`>|${ov}(?:([^\\s"'>=/]+)(${ov}*=${ov}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),c0=/'/g,d0=/"/g,f0=/^(?:script|style|textarea|title)$/i,rO=t=>(e,...r)=>({_$litType$:t,strings:e,values:r}),qd=rO(1),zi=Symbol.for("lit-noChange"),rn=Symbol.for("lit-nothing"),h0=new WeakMap,qs=zs.createTreeWalker(zs,129);function p0(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return i0!==void 0?i0.createHTML(e):e}const nO=(t,e)=>{const r=t.length-1,n=[];let i,a=e===2?"<svg>":"",s=wl;for(let o=0;o<r;o++){const u=t[o];let l,c,d=-1,f=0;for(;f<u.length&&(s.lastIndex=f,c=s.exec(u),c!==null);)f=s.lastIndex,s===wl?c[1]==="!--"?s=u0:c[1]!==void 0?s=l0:c[2]!==void 0?(f0.test(c[2])&&(i=RegExp("</"+c[2],"g")),s=Hs):c[3]!==void 0&&(s=Hs):s===Hs?c[0]===">"?(s=i??wl,d=-1):c[1]===void 0?d=-2:(d=s.lastIndex-c[2].length,l=c[1],s=c[3]===void 0?Hs:c[3]==='"'?d0:c0):s===d0||s===c0?s=Hs:s===u0||s===l0?s=wl:(s=Hs,i=void 0);const m=s===Hs&&t[o+1].startsWith("/>")?" ":"";a+=s===wl?u+eO:d>=0?(n.push(l),u.slice(0,d)+a0+u.slice(d)+Ja+m):u+Ja+(d===-2?o:m)}return[p0(t,a+(t[r]||"<?>")+(e===2?"</svg>":"")),n]};class _l{constructor({strings:e,_$litType$:r},n){let i;this.parts=[];let a=0,s=0;const o=e.length-1,u=this.parts,[l,c]=nO(e,r);if(this.el=_l.createElement(l,n),qs.currentNode=this.el.content,r===2){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=qs.nextNode())!==null&&u.length<o;){if(i.nodeType===1){if(i.hasAttributes())for(const d of i.getAttributeNames())if(d.endsWith(a0)){const f=c[s++],m=i.getAttribute(d).split(Ja),b=/([.?@])?(.*)/.exec(f);u.push({type:1,index:a,name:b[2],strings:m,ctor:b[1]==="."?aO:b[1]==="?"?sO:b[1]==="@"?oO:Vd}),i.removeAttribute(d)}else d.startsWith(Ja)&&(u.push({type:6,index:a}),i.removeAttribute(d));if(f0.test(i.tagName)){const d=i.textContent.split(Ja),f=d.length-1;if(f>0){i.textContent=Hd?Hd.emptyScript:"";for(let m=0;m<f;m++)i.append(d[m],yl()),qs.nextNode(),u.push({type:2,index:++a});i.append(d[f],yl())}}}else if(i.nodeType===8)if(i.data===s0)u.push({type:2,index:a});else{let d=-1;for(;(d=i.data.indexOf(Ja,d+1))!==-1;)u.push({type:7,index:a}),d+=Ja.length-1}a++}}static createElement(e,r){const n=zs.createElement("template");return n.innerHTML=e,n}}function Ko(t,e,r=t,n){var s,o;if(e===zi)return e;let i=n!==void 0?(s=r._$Co)==null?void 0:s[n]:r._$Cl;const a=bl(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==a&&((o=i==null?void 0:i._$AO)==null||o.call(i,!1),a===void 0?i=void 0:(i=new a(t),i._$AT(t,r,n)),n!==void 0?(r._$Co??(r._$Co=[]))[n]=i:r._$Cl=i),i!==void 0&&(e=Ko(t,i._$AS(t,e.values),i,n)),e}class iO{constructor(e,r){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:r},parts:n}=this._$AD,i=((e==null?void 0:e.creationScope)??zs).importNode(r,!0);qs.currentNode=i;let a=qs.nextNode(),s=0,o=0,u=n[0];for(;u!==void 0;){if(s===u.index){let l;u.type===2?l=new kl(a,a.nextSibling,this,e):u.type===1?l=new u.ctor(a,u.name,u.strings,this,e):u.type===6&&(l=new uO(a,this,e)),this._$AV.push(l),u=n[++o]}s!==(u==null?void 0:u.index)&&(a=qs.nextNode(),s++)}return qs.currentNode=zs,i}p(e){let r=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,r),r+=n.strings.length-2):n._$AI(e[r])),r++}}class kl{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,r,n,i){this.type=2,this._$AH=rn,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=n,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=Ko(this,e,r),bl(e)?e===rn||e==null||e===""?(this._$AH!==rn&&this._$AR(),this._$AH=rn):e!==this._$AH&&e!==zi&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):tO(e)?this.k(e):this._(e)}S(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}_(e){this._$AH!==rn&&bl(this._$AH)?this._$AA.nextSibling.data=e:this.T(zs.createTextNode(e)),this._$AH=e}$(e){var a;const{values:r,_$litType$:n}=e,i=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=_l.createElement(p0(n.h,n.h[0]),this.options)),n);if(((a=this._$AH)==null?void 0:a._$AD)===i)this._$AH.p(r);else{const s=new iO(i,this),o=s.u(this.options);s.p(r),this.T(o),this._$AH=s}}_$AC(e){let r=h0.get(e.strings);return r===void 0&&h0.set(e.strings,r=new _l(e)),r}k(e){o0(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let n,i=0;for(const a of e)i===r.length?r.push(n=new kl(this.S(yl()),this.S(yl()),this,this.options)):n=r[i],n._$AI(a),i++;i<r.length&&(this._$AR(n&&n._$AB.nextSibling,i),r.length=i)}_$AR(e=this._$AA.nextSibling,r){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,r);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var r;this._$AM===void 0&&(this._$Cv=e,(r=this._$AP)==null||r.call(this,e))}}class Vd{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,r,n,i,a){this.type=1,this._$AH=rn,this._$AN=void 0,this.element=e,this.name=r,this._$AM=i,this.options=a,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=rn}_$AI(e,r=this,n,i){const a=this.strings;let s=!1;if(a===void 0)e=Ko(this,e,r,0),s=!bl(e)||e!==this._$AH&&e!==zi,s&&(this._$AH=e);else{const o=e;let u,l;for(e=a[0],u=0;u<a.length-1;u++)l=Ko(this,o[n+u],r,u),l===zi&&(l=this._$AH[u]),s||(s=!bl(l)||l!==this._$AH[u]),l===rn?e=rn:e!==rn&&(e+=(l??"")+a[u+1]),this._$AH[u]=l}s&&!i&&this.j(e)}j(e){e===rn?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class aO extends Vd{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===rn?void 0:e}}class sO extends Vd{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==rn)}}class oO extends Vd{constructor(e,r,n,i,a){super(e,r,n,i,a),this.type=5}_$AI(e,r=this){if((e=Ko(this,e,r,0)??rn)===zi)return;const n=this._$AH,i=e===rn&&n!==rn||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,a=e!==rn&&(n===rn||i);i&&this.element.removeEventListener(this.name,this,n),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var r;typeof this._$AH=="function"?this._$AH.call(((r=this.options)==null?void 0:r.host)??this.element,e):this._$AH.handleEvent(e)}}let uO=class{constructor(e,r,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=r,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Ko(this,e)}};const uv=gl.litHtmlPolyfillSupport;uv==null||uv(_l,kl),(gl.litHtmlVersions??(gl.litHtmlVersions=[])).push("3.1.4");const lO=(t,e,r)=>{const n=(r==null?void 0:r.renderBefore)??e;let i=n._$litPart$;if(i===void 0){const a=(r==null?void 0:r.renderBefore)??null;n._$litPart$=i=new kl(e.insertBefore(yl(),a),a,void 0,r??{})}return i._$AI(t),i};/**
16
16
  * @license
17
17
  * Copyright 2017 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
19
- */let se=class extends tt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var s;const e=super.createRenderRoot();return(s=this.renderOptions).renderBefore??(s.renderBefore=e.firstChild),e}update(s){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(s),this._$Do=xn(e,this.renderRoot,this.renderOptions)}connectedCallback(){var s;super.connectedCallback(),(s=this._$Do)==null||s.setConnected(!0)}disconnectedCallback(){var s;super.disconnectedCallback(),(s=this._$Do)==null||s.setConnected(!1)}render(){return ue}};var gi;se._$litElement$=!0,se.finalized=!0,(gi=globalThis.litElementHydrateSupport)==null||gi.call(globalThis,{LitElement:se});const yi=globalThis.litElementPolyfillSupport;yi==null||yi({LitElement:se}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.4");const Ee=Qe`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-8{bottom:2rem}.left-0{left:0}.left-8{left:2rem}.right-0{right:0}.right-8{right:2rem}.top-0{top:0}.z-50{z-index:50}.m-0{margin:0}.m-0\\.5{margin:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-auto{margin-top:auto;margin-bottom:auto}.mb-1{margin-bottom:.25rem}.mb-\\[-8px\\]{margin-bottom:-8px}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-20{margin-left:5rem}.mr-2{margin-right:.5rem}.mr-20{margin-right:5rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.hidden{display:none}.h-0{height:0px}.h-3\\/5{height:60%}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-9{height:2.25rem}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.max-h-\\[90vh\\]{max-height:90vh}.w-0{width:0px}.w-3\\/5{width:60%}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.max-w-\\[90vw\\]{max-width:90vw}.flex-1{flex:1 1 0%}.flex-grow{flex-grow:1}.resize{resize:both}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-4{gap:1rem}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-t-lg{border-top-left-radius:.5rem;border-top-right-radius:.5rem}.border{border-width:1px}.border-x-8{border-left-width:8px;border-right-width:8px}.border-t-8{border-top-width:8px}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity))}.border-x-transparent{border-left-color:transparent;border-right-color:transparent}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-opacity-50{--tw-bg-opacity: .5}.p-2{padding:.5rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.px-0{padding-left:0;padding-right:0}.px-4{padding-left:1rem;padding-right:1rem}.px-8{padding-left:2rem;padding-right:2rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.pb-0{padding-bottom:0}.pb-8{padding-bottom:2rem}.text-center{text-align:center}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-semibold{font-weight:600}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:host{font-size:16px;line-height:1.2;color:#000;text-align:left;--iai-chat-i-primary-color: var(--iai-chat-primary-color, #3B82F6);--iai-chat-i-text-color: var(--iai-chat-text-color, #FFF);--iai-chat-i-header-bg: var(--iai-chat-header-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-header-fg: var(--iai-chat-header-text-color, var(--iai-chat-i-text-color));--iai-chat-i-button-bg: var(--iai-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-button-fg: var(--iai-chat-button-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-user-bg: var(--iai-chat-messages-user-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-message-user-fg: var(--iai-chat-messages-user-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-assistant-bg: var(--iai-chat-messages-assistant-background-color, #6B7280);--iai-chat-i-message-assistant-fg: var(--iai-chat-messages-assistant-text-color, var(--iai-chat-i-text-color));--iai-chat-i-ocb-bg: var(--iai-chat-open-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-ocb-fg: var(--iai-chat-open-chat-button-icon-color, var(--iai-chat-i-text-color));--iai-chat-i-iframe-modal-header-bg: var(--iai-chat-iframe-modal-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-iframe-modal-header-fg: var(--iai-chat-iframe-modal-text-color, var(--iai-chat-i-text-color))}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.disabled\\:bg-gray-200:disabled{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity))}.disabled\\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\\:bottom-8{bottom:2rem}.md\\:left-8{left:2rem}.md\\:right-8{right:2rem}.md\\:flex{display:flex}.md\\:h-\\[500px\\]{height:500px}.md\\:h-fit{height:-moz-fit-content;height:fit-content}.md\\:w-\\[350px\\]{width:350px}.md\\:w-fit{width:-moz-fit-content;width:fit-content}.md\\:p-0{padding:0}.md\\:px-0{padding-left:0;padding-right:0}.md\\:pb-0{padding-bottom:0}}`;/**
19
+ */class Jo extends Go{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var r;const e=super.createRenderRoot();return(r=this.renderOptions).renderBefore??(r.renderBefore=e.firstChild),e}update(e){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=lO(r,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return zi}}Jo._$litElement$=!0,Jo.finalized=!0,(R2=globalThis.litElementHydrateSupport)==null||R2.call(globalThis,{LitElement:Jo});const lv=globalThis.litElementPolyfillSupport;lv==null||lv({LitElement:Jo}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.6");/**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const Ce=s=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(s,e)}):customElements.define(s,e)};/**
23
+ */const v0=t=>(e,r)=>{r!==void 0?r.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)};/**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
- */const kn={attribute:!0,type:String,converter:Dt,reflect:!1,hasChanged:fs},Sn=(s=kn,e,t)=>{const{kind:i,metadata:n}=t;let r=globalThis.litPropertyMetadata.get(n);if(r===void 0&&globalThis.litPropertyMetadata.set(n,r=new Map),r.set(t.name,s),i==="accessor"){const{name:a}=t;return{set(o){const c=e.get.call(this);e.set.call(this,o),this.requestUpdate(a,c,s)},init(o){return o!==void 0&&this.P(a,void 0,s),o}}}if(i==="setter"){const{name:a}=t;return function(o){const c=this[a];e.call(this,o),this.requestUpdate(a,c,s)}}throw Error("Unsupported decorator location: "+i)};function J(s){return(e,t)=>typeof t=="object"?Sn(s,e,t):((i,n,r)=>{const a=n.hasOwnProperty(r);return n.constructor.createProperty(r,a?{...i,wrapped:!0}:i),a?Object.getOwnPropertyDescriptor(n,r):void 0})(s,e,t)}/**
27
+ */const cO={attribute:!0,type:String,converter:zd,reflect:!1,hasChanged:sv},dO=(t=cO,e,r)=>{const{kind:n,metadata:i}=r;let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),a.set(r.name,t),n==="accessor"){const{name:s}=r;return{set(o){const u=e.get.call(this);e.set.call(this,o),this.requestUpdate(s,u,t)},init(o){return o!==void 0&&this.P(s,void 0,t),o}}}if(n==="setter"){const{name:s}=r;return function(o){const u=this[s];e.call(this,o),this.requestUpdate(s,u,t)}}throw Error("Unsupported decorator location: "+n)};function m0(t){return(e,r)=>typeof r=="object"?dO(t,e,r):((n,i,a)=>{const s=i.hasOwnProperty(a);return i.constructor.createProperty(a,s?{...n,wrapped:!0}:n),s?Object.getOwnPropertyDescriptor(i,a):void 0})(t,e,r)}/**
28
28
  * @license
29
29
  * Copyright 2017 Google LLC
30
30
  * SPDX-License-Identifier: BSD-3-Clause
31
- */function it(s){return J({...s,state:!0,attribute:!1})}/**
31
+ */function fO(t){return m0({...t,state:!0,attribute:!1})}/**
32
32
  * @license
33
33
  * Copyright 2017 Google LLC
34
34
  * SPDX-License-Identifier: BSD-3-Clause
35
- */const vi=(s,e,t)=>(t.configurable=!0,t.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(s,e,t),t);/**
35
+ */const hO=(t,e,r)=>(r.configurable=!0,r.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(t,e,r),r);/**
36
36
  * @license
37
37
  * Copyright 2017 Google LLC
38
38
  * SPDX-License-Identifier: BSD-3-Clause
39
- */function Tn(s,e){return(t,i,n)=>{const r=a=>{var o;return((o=a.renderRoot)==null?void 0:o.querySelector(s))??null};if(e){const{get:a,set:o}=typeof i=="object"?t:n??(()=>{const c=Symbol();return{get(){return this[c]},set(l){this[c]=l}}})();return vi(t,i,{get(){let c=a.call(this);return c===void 0&&(c=r(this),(c!==null||this.hasUpdated)&&o.call(this,c)),c}})}return vi(t,i,{get(){return r(this)}})}}/**
39
+ */function pO(t,e){return(r,n,i)=>{const a=s=>{var o;return((o=s.renderRoot)==null?void 0:o.querySelector(t))??null};return hO(r,n,{get(){return a(this)}})}}/**
40
40
  * @license
41
41
  * Copyright 2017 Google LLC
42
42
  * SPDX-License-Identifier: BSD-3-Clause
43
- */const Bt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ft=s=>(...e)=>({_$litDirective$:s,values:e});let Vt=class{constructor(s){}get _$AU(){return this._$AM._$AU}_$AT(s,e,t){this._$Ct=s,this._$AM=e,this._$Ci=t}_$AS(s,e){return this.update(s,e)}update(s,e){return this.render(...e)}};/**
43
+ */const Yo={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},vO=t=>(...e)=>({_$litDirective$:t,values:e});let mO=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,r,n){this._$Ct=e,this._$AM=r,this._$Ci=n}_$AS(e,r){return this.update(e,r)}update(e,r){return this.render(...r)}};/**
44
44
  * @license
45
- * Copyright 2018 Google LLC
45
+ * Copyright 2020 Google LLC
46
46
  * SPDX-License-Identifier: BSD-3-Clause
47
- */const bi=Ft(class extends Vt{constructor(s){var e;if(super(s),s.type!==Bt.ATTRIBUTE||s.name!=="class"||((e=s.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter(e=>s[e]).join(" ")+" "}update(s,[e]){var t,i;if(this.st===void 0){this.st=new Set,s.strings!==void 0&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in e)e[r]&&!((t=this.nt)!=null&&t.has(r))&&this.st.add(r);return this.render(e)}const n=s.element.classList;for(const r of this.st)r in e||(n.remove(r),this.st.delete(r));for(const r in e){const a=!!e[r];a===this.st.has(r)||(i=this.nt)!=null&&i.has(r)||(a?(n.add(r),this.st.add(r)):(n.remove(r),this.st.delete(r)))}return ue}});/**
47
+ */const gO=t=>t.strings===void 0,yO={},bO=(t,e=yO)=>t._$AH=e;/**
48
48
  * @license
49
- * Copyright 2018 Google LLC
49
+ * Copyright 2020 Google LLC
50
50
  * SPDX-License-Identifier: BSD-3-Clause
51
- */const wi="important",$n=" !"+wi,vt=Ft(class extends Vt{constructor(s){var e;if(super(s),s.type!==Bt.ATTRIBUTE||s.name!=="style"||((e=s.strings)==null?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce((e,t)=>{const i=s[t];return i==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[e]){const{style:t}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const i of this.ft)e[i]==null&&(this.ft.delete(i),i.includes("-")?t.removeProperty(i):t[i]=null);for(const i in e){const n=e[i];if(n!=null){this.ft.add(i);const r=typeof n=="string"&&n.endsWith($n);i.includes("-")||r?t.setProperty(i,r?n.slice(0,-11):n,r?wi:""):t[i]=n}}return ue}});var j;(function(s){s.assertEqual=n=>n;function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const r={};for(const a of n)r[a]=a;return r},s.getValidEnumValues=n=>{const r=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),a={};for(const o of r)a[o]=n[o];return s.objectValues(a)},s.objectValues=n=>s.objectKeys(n).map(function(r){return n[r]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const r=[];for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&r.push(a);return r},s.find=(n,r)=>{for(const a of n)if(r(a))return a},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function i(n,r=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(r)}s.joinValues=i,s.jsonStringifyReplacer=(n,r)=>typeof r=="bigint"?r.toString():r})(j||(j={}));var bs;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(bs||(bs={}));const f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ae=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s instanceof Date?f.date:f.object;default:return f.unknown}},m=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),En=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class ie extends Error{constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(r){return r.message},i={_errors:[]},n=r=>{for(const a of r.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)i._errors.push(t(a));else{let o=i,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),i}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):i.push(e(n));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}ie.create=s=>new ie(s);const bt=(s,e)=>{let t;switch(s.code){case m.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case m.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,j.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(s.keys,", ")}`;break;case m.invalid_union:t="Invalid input";break;case m.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(s.options)}`;break;case m.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(s.options)}, received '${s.received}'`;break;case m.invalid_arguments:t="Invalid function arguments";break;case m.invalid_return_type:t="Invalid function return type";break;case m.invalid_date:t="Invalid date";break;case m.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:j.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case m.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case m.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case m.custom:t="Invalid input";break;case m.invalid_intersection_types:t="Intersection results could not be merged";break;case m.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case m.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(s)}return{message:t}};let _i=bt;function Cn(s){_i=s}function Wt(){return _i}const Kt=s=>{const{data:e,path:t,errorMaps:i,issueData:n}=s,r=[...t,...n.path||[]],a={...n,path:r};let o="";const c=i.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...n,path:r,message:n.message||o}},An=[];function g(s,e){const t=Kt({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,Wt(),bt].filter(i=>!!i)});s.common.issues.push(t)}class q{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const n of t){if(n.status==="aborted")return E;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const n of t)i.push({key:await n.key,value:await n.value});return q.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const n of t){const{key:r,value:a}=n;if(r.status==="aborted"||a.status==="aborted")return E;r.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(i[r.value]=a.value)}return{status:e.value,value:i}}}const E=Object.freeze({status:"aborted"}),xi=s=>({status:"dirty",value:s}),G=s=>({status:"valid",value:s}),ws=s=>s.status==="aborted",_s=s=>s.status==="dirty",wt=s=>s.status==="valid",Jt=s=>typeof Promise<"u"&&s instanceof Promise;var _;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));class he{constructor(e,t,i,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ki=(s,e)=>{if(wt(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ie(s.common.issues);return this._error=t,this._error}}};function C(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:n}=s;if(e&&(t||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(r,a)=>r.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:i??a.defaultError}:{message:t??a.defaultError},description:n}}class I{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new q,ctx:{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Jt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){var i;const n={common:{issues:[],async:(i=t==null?void 0:t.async)!==null&&i!==void 0?i:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},r=this._parseSync({data:e,path:n.path,parent:n});return ki(n,r)}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},n=this._parse({data:e,path:i.path,parent:i}),r=await(Jt(n)?n:Promise.resolve(n));return ki(i,r)}refine(e,t){const i=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,r)=>{const a=e(n),o=()=>r.addIssue({code:m.custom,...i(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof t=="function"?t(i,n):t),!1))}_refinement(e){return new ae({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ve.create(this,this._def)}nullable(){return Be.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return re.create(this,this._def)}promise(){return ot.create(this,this._def)}or(e){return St.create([this,e],this._def)}and(e){return Tt.create(this,e,this._def)}transform(e){return new ae({...C(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ot({...C(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new Ti({typeName:T.ZodBranded,type:this,...C(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new es({...C(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return It.create(this,e)}readonly(){return ss.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const On=/^c[^\s-]{8,}$/i,In=/^[a-z][a-z0-9]*$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Pn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Nn=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let xs;const Rn=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Zn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ln=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function zn(s,e){return!!((e==="v4"||!e)&&Rn.test(s)||(e==="v6"||!e)&&Zn.test(s))}class ne extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const n=this._getOrReturnCtx(e);return g(n,{code:m.invalid_type,expected:f.string,received:n.parsedType}),E}const t=new q;let i;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:m.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:m.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const r=e.data.length>n.value,a=e.data.length<n.value;(r||a)&&(i=this._getOrReturnCtx(e,i),r?g(i,{code:m.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&g(i,{code:m.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Nn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"email",code:m.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")xs||(xs=new RegExp(jn,"u")),xs.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"emoji",code:m.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Pn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"uuid",code:m.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")On.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid",code:m.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")In.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid2",code:m.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Mn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ulid",code:m.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),g(i,{validation:"url",code:m.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"regex",code:m.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(i=this._getOrReturnCtx(e,i),g(i,{code:m.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:m.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:m.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Ln(n).test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{code:m.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?zn(e.data,n.version)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ip",code:m.invalid_string,message:n.message}),t.dirty()):j.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,i){return this.refinement(n=>e.test(n),{validation:t,code:m.invalid_string,..._.errToObj(i)})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,..._.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,..._.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new ne({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ne.create=s=>{var e;return new ne({checks:[],typeName:T.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...C(s)})};function Dn(s,e){const t=(s.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=t>i?t:i,r=parseInt(s.toFixed(n).replace(".","")),a=parseInt(e.toFixed(n).replace(".",""));return r%a/Math.pow(10,n)}class Oe extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const n=this._getOrReturnCtx(e);return g(n,{code:m.invalid_type,expected:f.number,received:n.parsedType}),E}let t;const i=new q;for(const n of this._def.checks)n.kind==="int"?j.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:m.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:m.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:m.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="multipleOf"?Dn(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),g(t,{code:m.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:m.not_finite,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Oe.create=s=>new Oe({checks:[],typeName:T.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...C(s)});class Ie extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){const n=this._getOrReturnCtx(e);return g(n,{code:m.invalid_type,expected:f.bigint,received:n.parsedType}),E}let t;const i=new q;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:m.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:m.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),g(t,{code:m.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Ie({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ie.create=s=>{var e;return new Ie({checks:[],typeName:T.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...C(s)})};class _t extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const t=this._getOrReturnCtx(e);return g(t,{code:m.invalid_type,expected:f.boolean,received:t.parsedType}),E}return G(e.data)}}_t.create=s=>new _t({typeName:T.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...C(s)});class De extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const n=this._getOrReturnCtx(e);return g(n,{code:m.invalid_type,expected:f.date,received:n.parsedType}),E}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return g(n,{code:m.invalid_date}),E}const t=new q;let i;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:m.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:m.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):j.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}De.create=s=>new De({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:T.ZodDate,...C(s)});class qt extends I{_parse(e){if(this._getType(e)!==f.symbol){const t=this._getOrReturnCtx(e);return g(t,{code:m.invalid_type,expected:f.symbol,received:t.parsedType}),E}return G(e.data)}}qt.create=s=>new qt({typeName:T.ZodSymbol,...C(s)});class xt extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:m.invalid_type,expected:f.undefined,received:t.parsedType}),E}return G(e.data)}}xt.create=s=>new xt({typeName:T.ZodUndefined,...C(s)});class kt extends I{_parse(e){if(this._getType(e)!==f.null){const t=this._getOrReturnCtx(e);return g(t,{code:m.invalid_type,expected:f.null,received:t.parsedType}),E}return G(e.data)}}kt.create=s=>new kt({typeName:T.ZodNull,...C(s)});class nt extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}}nt.create=s=>new nt({typeName:T.ZodAny,...C(s)});class Ue extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}}Ue.create=s=>new Ue({typeName:T.ZodUnknown,...C(s)});class ye extends I{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:m.invalid_type,expected:f.never,received:t.parsedType}),E}}ye.create=s=>new ye({typeName:T.ZodNever,...C(s)});class Yt extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:m.invalid_type,expected:f.void,received:t.parsedType}),E}return G(e.data)}}Yt.create=s=>new Yt({typeName:T.ZodVoid,...C(s)});class re extends I{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return g(t,{code:m.invalid_type,expected:f.array,received:t.parsedType}),E;if(n.exactLength!==null){const a=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(a||o)&&(g(t,{code:a?m.too_big:m.too_small,minimum:o?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(g(t,{code:m.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(g(t,{code:m.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>n.type._parseAsync(new he(t,a,t.path,o)))).then(a=>q.mergeArray(i,a));const r=[...t.data].map((a,o)=>n.type._parseSync(new he(t,a,t.path,o)));return q.mergeArray(i,r)}get element(){return this._def.type}min(e,t){return new re({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new re({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new re({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}re.create=(s,e)=>new re({type:s,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...C(e)});function rt(s){if(s instanceof U){const e={};for(const t in s.shape){const i=s.shape[t];e[t]=ve.create(rt(i))}return new U({...s._def,shape:()=>e})}else return s instanceof re?new re({...s._def,type:rt(s.element)}):s instanceof ve?ve.create(rt(s.unwrap())):s instanceof Be?Be.create(rt(s.unwrap())):s instanceof pe?pe.create(s.items.map(e=>rt(e))):s}class U extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const c=this._getOrReturnCtx(e);return g(c,{code:m.invalid_type,expected:f.object,received:c.parsedType}),E}const{status:t,ctx:i}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof ye&&this._def.unknownKeys==="strip"))for(const c in i.data)r.includes(c)||a.push(c);const o=[];for(const c of r){const l=n[c],h=i.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new he(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ye){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of a)o.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(g(i,{code:m.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of a){const h=i.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new he(i,h,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>q.mergeObjectSync(t,c)):q.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new U({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{var n,r,a,o;const c=(a=(r=(n=this._def).errorMap)===null||r===void 0?void 0:r.call(n,t,i).message)!==null&&a!==void 0?a:i.defaultError;return t.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new U({...this._def,unknownKeys:"strip"})}passthrough(){return new U({...this._def,unknownKeys:"passthrough"})}extend(e){return new U({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new U({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new U({...this._def,catchall:e})}pick(e){const t={};return j.objectKeys(e).forEach(i=>{e[i]&&this.shape[i]&&(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}omit(e){const t={};return j.objectKeys(this.shape).forEach(i=>{e[i]||(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}deepPartial(){return rt(this)}partial(e){const t={};return j.objectKeys(this.shape).forEach(i=>{const n=this.shape[i];e&&!e[i]?t[i]=n:t[i]=n.optional()}),new U({...this._def,shape:()=>t})}required(e){const t={};return j.objectKeys(this.shape).forEach(i=>{if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof ve;)n=n._def.innerType;t[i]=n}}),new U({...this._def,shape:()=>t})}keyof(){return Si(j.objectKeys(this.shape))}}U.create=(s,e)=>new U({shape:()=>s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...C(e)}),U.strictCreate=(s,e)=>new U({shape:()=>s,unknownKeys:"strict",catchall:ye.create(),typeName:T.ZodObject,...C(e)}),U.lazycreate=(s,e)=>new U({shape:s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...C(e)});class St extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;function n(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=r.map(o=>new ie(o.ctx.common.issues));return g(t,{code:m.invalid_union,unionErrors:a}),E}if(t.common.async)return Promise.all(i.map(async r=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(n);{let r;const a=[];for(const c of i){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!r&&(r={result:h,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=a.map(c=>new ie(c));return g(t,{code:m.invalid_union,unionErrors:o}),E}}get options(){return this._def.options}}St.create=(s,e)=>new St({options:s,typeName:T.ZodUnion,...C(e)});const Gt=s=>s instanceof Et?Gt(s.schema):s instanceof ae?Gt(s.innerType()):s instanceof Ct?[s.value]:s instanceof Me?s.options:s instanceof At?Object.keys(s.enum):s instanceof Ot?Gt(s._def.innerType):s instanceof xt?[void 0]:s instanceof kt?[null]:null;class Xt extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return g(t,{code:m.invalid_type,expected:f.object,received:t.parsedType}),E;const i=this.discriminator,n=t.data[i],r=this.optionsMap.get(n);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,i){const n=new Map;for(const r of t){const a=Gt(r.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,r)}}return new Xt({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...C(i)})}}function ks(s,e){const t=Ae(s),i=Ae(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&i===f.object){const n=j.objectKeys(e),r=j.objectKeys(s).filter(o=>n.indexOf(o)!==-1),a={...s,...e};for(const o of r){const c=ks(s[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===f.array&&i===f.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let r=0;r<s.length;r++){const a=s[r],o=e[r],c=ks(a,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&i===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class Tt extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=(r,a)=>{if(ws(r)||ws(a))return E;const o=ks(r.value,a.value);return o.valid?((_s(r)||_s(a))&&t.dirty(),{status:t.value,value:o.data}):(g(i,{code:m.invalid_intersection_types}),E)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([r,a])=>n(r,a)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}Tt.create=(s,e,t)=>new Tt({left:s,right:e,typeName:T.ZodIntersection,...C(t)});class pe extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.array)return g(i,{code:m.invalid_type,expected:f.array,received:i.parsedType}),E;if(i.data.length<this._def.items.length)return g(i,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&i.data.length>this._def.items.length&&(g(i,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((r,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new he(i,r,i.path,a)):null}).filter(r=>!!r);return i.common.async?Promise.all(n).then(r=>q.mergeArray(t,r)):q.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new pe({...this._def,rest:e})}}pe.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:s,typeName:T.ZodTuple,rest:null,...C(e)})};class $t extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.object)return g(i,{code:m.invalid_type,expected:f.object,received:i.parsedType}),E;const n=[],r=this._def.keyType,a=this._def.valueType;for(const o in i.data)n.push({key:r._parse(new he(i,o,i.path,o)),value:a._parse(new he(i,i.data[o],i.path,o))});return i.common.async?q.mergeObjectAsync(t,n):q.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,i){return t instanceof I?new $t({keyType:e,valueType:t,typeName:T.ZodRecord,...C(i)}):new $t({keyType:ne.create(),valueType:e,typeName:T.ZodRecord,...C(t)})}}class Qt extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.map)return g(i,{code:m.invalid_type,expected:f.map,received:i.parsedType}),E;const n=this._def.keyType,r=this._def.valueType,a=[...i.data.entries()].map(([o,c],l)=>({key:n._parse(new he(i,o,i.path,[l,"key"])),value:r._parse(new he(i,c,i.path,[l,"value"]))}));if(i.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return E;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return E;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}Qt.create=(s,e,t)=>new Qt({valueType:e,keyType:s,typeName:T.ZodMap,...C(t)});class He extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.set)return g(i,{code:m.invalid_type,expected:f.set,received:i.parsedType}),E;const n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(g(i,{code:m.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(g(i,{code:m.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const r=this._def.valueType;function a(c){const l=new Set;for(const h of c){if(h.status==="aborted")return E;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...i.data.values()].map((c,l)=>r._parse(new he(i,c,i.path,l)));return i.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new He({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new He({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}He.create=(s,e)=>new He({valueType:s,minSize:null,maxSize:null,typeName:T.ZodSet,...C(e)});class at extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return g(t,{code:m.invalid_type,expected:f.function,received:t.parsedType}),E;function i(o,c){return Kt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wt(),bt].filter(l=>!!l),issueData:{code:m.invalid_arguments,argumentsError:c}})}function n(o,c){return Kt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wt(),bt].filter(l=>!!l),issueData:{code:m.invalid_return_type,returnTypeError:c}})}const r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ot){const o=this;return G(async function(...c){const l=new ie([]),h=await o._def.args.parseAsync(c,r).catch(d=>{throw l.addIssue(i(c,d)),l}),p=await Reflect.apply(a,this,h);return await o._def.returns._def.type.parseAsync(p,r).catch(d=>{throw l.addIssue(n(p,d)),l})})}else{const o=this;return G(function(...c){const l=o._def.args.safeParse(c,r);if(!l.success)throw new ie([i(c,l.error)]);const h=Reflect.apply(a,this,l.data),p=o._def.returns.safeParse(h,r);if(!p.success)throw new ie([n(h,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new at({...this._def,args:pe.create(e).rest(Ue.create())})}returns(e){return new at({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,i){return new at({args:e||pe.create([]).rest(Ue.create()),returns:t||Ue.create(),typeName:T.ZodFunction,...C(i)})}}class Et extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Et.create=(s,e)=>new Et({getter:s,typeName:T.ZodLazy,...C(e)});class Ct extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ct.create=(s,e)=>new Ct({value:s,typeName:T.ZodLiteral,...C(e)});function Si(s,e){return new Me({values:s,typeName:T.ZodEnum,...C(e)})}class Me extends I{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{expected:j.joinValues(i),received:t.parsedType,code:m.invalid_type}),E}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{received:t.data,code:m.invalid_enum_value,options:i}),E}return G(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Me.create(e)}exclude(e){return Me.create(this.options.filter(t=>!e.includes(t)))}}Me.create=Si;class At extends I{_parse(e){const t=j.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==f.string&&i.parsedType!==f.number){const n=j.objectValues(t);return g(i,{expected:j.joinValues(n),received:i.parsedType,code:m.invalid_type}),E}if(t.indexOf(e.data)===-1){const n=j.objectValues(t);return g(i,{received:i.data,code:m.invalid_enum_value,options:n}),E}return G(e.data)}get enum(){return this._def.values}}At.create=(s,e)=>new At({values:s,typeName:T.ZodNativeEnum,...C(e)});class ot extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return g(t,{code:m.invalid_type,expected:f.promise,received:t.parsedType}),E;const i=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return G(i.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ot.create=(s,e)=>new ot({type:s,typeName:T.ZodPromise,...C(e)});class ae extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:a=>{g(i,a),a.fatal?t.abort():t.dirty()},get path(){return i.path}};if(r.addIssue=r.addIssue.bind(r),n.type==="preprocess"){const a=n.transform(i.data,r);return i.common.issues.length?{status:"dirty",value:i.data}:i.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:i.path,parent:i})):this._def.schema._parseSync({data:a,path:i.path,parent:i})}if(n.type==="refinement"){const a=o=>{const c=n.refinement(o,r);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!wt(a))return a;const o=n.transform(a.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>wt(a)?Promise.resolve(n.transform(a.value,r)).then(o=>({status:t.value,value:o})):a);j.assertNever(n)}}ae.create=(s,e,t)=>new ae({schema:s,typeName:T.ZodEffects,effect:e,...C(t)}),ae.createWithPreprocess=(s,e,t)=>new ae({schema:e,effect:{type:"preprocess",transform:s},typeName:T.ZodEffects,...C(t)});class ve extends I{_parse(e){return this._getType(e)===f.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(s,e)=>new ve({innerType:s,typeName:T.ZodOptional,...C(e)});class Be extends I{_parse(e){return this._getType(e)===f.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Be.create=(s,e)=>new Be({innerType:s,typeName:T.ZodNullable,...C(e)});class Ot extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===f.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ot.create=(s,e)=>new Ot({innerType:s,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});class es extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Jt(n)?n.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}es.create=(s,e)=>new es({innerType:s,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});class ts extends I{_parse(e){if(this._getType(e)!==f.nan){const t=this._getOrReturnCtx(e);return g(t,{code:m.invalid_type,expected:f.nan,received:t.parsedType}),E}return{status:"valid",value:e.data}}}ts.create=s=>new ts({typeName:T.ZodNaN,...C(s)});const Un=Symbol("zod_brand");class Ti extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class It extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?E:n.status==="dirty"?(t.dirty(),xi(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?E:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,t){return new It({in:e,out:t,typeName:T.ZodPipeline})}}class ss extends I{_parse(e){const t=this._def.innerType._parse(e);return wt(t)&&(t.value=Object.freeze(t.value)),t}}ss.create=(s,e)=>new ss({innerType:s,typeName:T.ZodReadonly,...C(e)});const $i=(s,e={},t)=>s?nt.create().superRefine((i,n)=>{var r,a;if(!s(i)){const o=typeof e=="function"?e(i):typeof e=="string"?{message:e}:e,c=(a=(r=o.fatal)!==null&&r!==void 0?r:t)!==null&&a!==void 0?a:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):nt.create(),Hn={object:U.lazycreate};var T;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(T||(T={}));const Bn=(s,e={message:`Input not instance of ${s.name}`})=>$i(t=>t instanceof s,e),Ei=ne.create,Ci=Oe.create,Fn=ts.create,Vn=Ie.create,Ai=_t.create,Wn=De.create,Kn=qt.create,Jn=xt.create,qn=kt.create,Yn=nt.create,Gn=Ue.create,Xn=ye.create,Qn=Yt.create,er=re.create,tr=U.create,sr=U.strictCreate,ir=St.create,nr=Xt.create,rr=Tt.create,ar=pe.create,or=$t.create,cr=Qt.create,dr=He.create,lr=at.create,ur=Et.create,hr=Ct.create,pr=Me.create,mr=At.create,fr=ot.create,Oi=ae.create,gr=ve.create,yr=Be.create,vr=ae.createWithPreprocess,br=It.create;var w=Object.freeze({__proto__:null,defaultErrorMap:bt,setErrorMap:Cn,getErrorMap:Wt,makeIssue:Kt,EMPTY_PATH:An,addIssueToContext:g,ParseStatus:q,INVALID:E,DIRTY:xi,OK:G,isAborted:ws,isDirty:_s,isValid:wt,isAsync:Jt,get util(){return j},get objectUtil(){return bs},ZodParsedType:f,getParsedType:Ae,ZodType:I,ZodString:ne,ZodNumber:Oe,ZodBigInt:Ie,ZodBoolean:_t,ZodDate:De,ZodSymbol:qt,ZodUndefined:xt,ZodNull:kt,ZodAny:nt,ZodUnknown:Ue,ZodNever:ye,ZodVoid:Yt,ZodArray:re,ZodObject:U,ZodUnion:St,ZodDiscriminatedUnion:Xt,ZodIntersection:Tt,ZodTuple:pe,ZodRecord:$t,ZodMap:Qt,ZodSet:He,ZodFunction:at,ZodLazy:Et,ZodLiteral:Ct,ZodEnum:Me,ZodNativeEnum:At,ZodPromise:ot,ZodEffects:ae,ZodTransformer:ae,ZodOptional:ve,ZodNullable:Be,ZodDefault:Ot,ZodCatch:es,ZodNaN:ts,BRAND:Un,ZodBranded:Ti,ZodPipeline:It,ZodReadonly:ss,custom:$i,Schema:I,ZodSchema:I,late:Hn,get ZodFirstPartyTypeKind(){return T},coerce:{string:s=>ne.create({...s,coerce:!0}),number:s=>Oe.create({...s,coerce:!0}),boolean:s=>_t.create({...s,coerce:!0}),bigint:s=>Ie.create({...s,coerce:!0}),date:s=>De.create({...s,coerce:!0})},any:Yn,array:er,bigint:Vn,boolean:Ai,date:Wn,discriminatedUnion:nr,effect:Oi,enum:pr,function:lr,instanceof:Bn,intersection:rr,lazy:ur,literal:hr,map:cr,nan:Fn,nativeEnum:mr,never:Xn,null:qn,nullable:yr,number:Ci,object:tr,oboolean:()=>Ai().optional(),onumber:()=>Ci().optional(),optional:gr,ostring:()=>Ei().optional(),pipeline:br,preprocess:vr,promise:fr,record:or,set:dr,strictObject:sr,string:Ei,symbol:Kn,transformer:Oi,tuple:ar,undefined:Jn,union:ir,unknown:Gn,void:Qn,NEVER:E,ZodIssueCode:m,quotelessJson:En,ZodError:ie});const is=w.object({assistantId:w.string(),params:w.record(w.any()).default({}),config:w.object({historyKey:w.string().refine(s=>s.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:w.string().default("Hello! How can I help you today?"),placement:w.enum(["left","right"]).default("right"),openChatButton:w.object({imageSrc:w.string().optional(),width:w.union([w.string(),w.number()]).default("48px"),height:w.union([w.string(),w.number()]).default("48px"),cta:w.string().optional()}).default({}),chatWindow:w.object({header:w.object({text:w.string().nullable().default("AI Chat"),imageSrc:w.string().optional()}).default({}),showCloseButton:w.boolean().default(!0)}).default({}),styles:w.object({primaryColor:w.string().optional(),textColor:w.string().optional(),openChatButton:w.object({backgroundColor:w.string().optional(),iconColor:w.string().optional()}).optional(),header:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional(),button:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional(),messages:w.object({user:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional(),assistant:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional()}).optional()}).default({})}).default({}),handlers:w.object({functionCalls:w.record(w.function().returns(w.union([w.any(),w.promise(w.any())]))).default({}),enhancedContent:w.record(w.function().returns(w.union([w.any(),w.promise(w.any())]))).default({})}).default({})});function wr(s){if(Array.isArray(s)){for(var e=0,t=Array(s.length);e<s.length;e++)t[e]=s[e];return t}else return Array.from(s)}var Ss=!1;if(typeof window<"u"){var Ii={get passive(){Ss=!0}};window.addEventListener("testPassive",null,Ii),window.removeEventListener("testPassive",null,Ii)}var ns=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1),Fe=[],rs=!1,Mi=-1,Mt=void 0,Ve=void 0,Pt=void 0,Pi=function(s){return Fe.some(function(e){return!!(e.options.allowTouchMove&&e.options.allowTouchMove(s))})},Ts=function(s){var e=s||window.event;return Pi(e.target)||e.touches.length>1?!0:(e.preventDefault&&e.preventDefault(),!1)},_r=function(s){if(Pt===void 0){var e=!!s&&s.reserveScrollBarGap===!0,t=window.innerWidth-document.documentElement.clientWidth;if(e&&t>0){var i=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Pt=document.body.style.paddingRight,document.body.style.paddingRight=i+t+"px"}}Mt===void 0&&(Mt=document.body.style.overflow,document.body.style.overflow="hidden")},xr=function(){Pt!==void 0&&(document.body.style.paddingRight=Pt,Pt=void 0),Mt!==void 0&&(document.body.style.overflow=Mt,Mt=void 0)},kr=function(){return window.requestAnimationFrame(function(){if(Ve===void 0){Ve={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var s=window,e=s.scrollY,t=s.scrollX,i=s.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-t,setTimeout(function(){return window.requestAnimationFrame(function(){var n=i-window.innerHeight;n&&e>=i&&(document.body.style.top=-(e+n))})},300)}})},Sr=function(){if(Ve!==void 0){var s=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ve.position,document.body.style.top=Ve.top,document.body.style.left=Ve.left,window.scrollTo(e,s),Ve=void 0}},Tr=function(s){return s?s.scrollHeight-s.scrollTop<=s.clientHeight:!1},$r=function(s,e){var t=s.targetTouches[0].clientY-Mi;return Pi(s.target)?!1:e&&e.scrollTop===0&&t>0||Tr(e)&&t<0?Ts(s):(s.stopPropagation(),!0)},Er=function(s,e){if(!s){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}if(!Fe.some(function(i){return i.targetElement===s})){var t={targetElement:s,options:e||{}};Fe=[].concat(wr(Fe),[t]),ns?kr():_r(e),ns&&(s.ontouchstart=function(i){i.targetTouches.length===1&&(Mi=i.targetTouches[0].clientY)},s.ontouchmove=function(i){i.targetTouches.length===1&&$r(i,s)},rs||(document.addEventListener("touchmove",Ts,Ss?{passive:!1}:void 0),rs=!0))}},Ni=function(s){if(!s){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}Fe=Fe.filter(function(e){return e.targetElement!==s}),ns&&(s.ontouchstart=null,s.ontouchmove=null,rs&&Fe.length===0&&(document.removeEventListener("touchmove",Ts,Ss?{passive:!1}:void 0),rs=!1)),ns?Sr():xr()},Cr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ji(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var $s={};(function(s){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function t(o,c,l,h){var p={timer:void 0,lastArgs:[]},d=function(){for(var b=this,N=[],H=0;H<arguments.length;H++)N[H]=arguments[H];p.lastArgs=N,p.timer?clearTimeout(p.timer):c&&l.apply(this,p.lastArgs),p.timer=setTimeout(function(){c||l.apply(b,p.lastArgs),p.timer=void 0},o)};return h&&(d=d.bind(h)),d.options=p,d}function i(o,c,l,h){var p;Object.defineProperty(l,h,{configurable:!0,enumerable:!1,get:function(){return p},set:function(d){p=t(o,c,d,this)}})}function n(o,c,l){var h=l.value;return l.value=t(o,c,h),l}function r(o,c){for(var l=[],h=2;h<arguments.length;h++)l[h-2]=arguments[h];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var p=l[0],d=l[1],b=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(p,d);if(b)return n(o,c,b);i(o,c,p,d)}function a(){for(var o=[],c=0;c<arguments.length;c++)o[c]=arguments[c];var l=500,h=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var p=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(p=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(p=o[1]),p&&(h=p.leading),function(){for(var d=[],b=0;b<arguments.length;b++)d[b]=arguments[b];return r.apply(void 0,[l,h].concat(d))}}return r.apply(void 0,[l,h].concat(o))}Object.defineProperty(s,"__esModule",{value:!0}),s.cancel=e,s.debounce=a})($s);var Ar=Object.defineProperty,Or=Object.getOwnPropertyDescriptor,Nt=(s,e,t,i)=>{for(var n=i>1?void 0:i?Or(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ar(e,t,n),n};let We=class extends se{constructor(){super(...arguments),this.isOpen=!0,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?Er(this):Ni(this)}}connectedCallback(){super.connectedCallback(),this.cleanOptions=is.parse(this.options),this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),Ni(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const s=this.cleanOptions.config.placement!=="left",e=bi({fixed:!0,"bottom-0":!0,"w-full":this.isOpen,"h-full":this.isOpen,...s&&{"right-0":!0,"md:right-8":!0},...!s&&{"left-0":!0,"md:left-8":!0},"md:bottom-8":!0,"md:w-fit":!0,"md:h-fit":!0}),t=bi({"mt-4":!0,"px-8":!0,"pb-8":!0,"w-full":!0,hidden:this.isOpen,flex:!this.isOpen,"md:px-0":!0,"md:pb-0":!0,"md:w-[350px]":!0,"md:flex":!0});return z`
52
- <div
53
- class=${e}
54
- >
55
- <div
56
- class="w-full h-full p-2 md:w-[350px] md:h-[500px] md:p-0"
57
- style=${vt({display:this.isOpen?"block":"none"})}
58
- >
59
- <iai-chat
60
- .options=${this.options}
61
- @iai-chat-close=${this.toggleChat}
62
- />
63
- </div>
64
-
65
- <div
66
- class=${t}
67
- style=${vt({justifyContent:s?"flex-end":"flex-start"})}
51
+ */const cv=vO(class extends mO{constructor(t){if(super(t),t.type!==Yo.PROPERTY&&t.type!==Yo.ATTRIBUTE&&t.type!==Yo.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!gO(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===zi||e===rn)return e;const r=t.element,n=t.name;if(t.type===Yo.PROPERTY){if(e===r[n])return zi}else if(t.type===Yo.BOOLEAN_ATTRIBUTE){if(!!e===r.hasAttribute(n))return zi}else if(t.type===Yo.ATTRIBUTE&&r.getAttribute(n)===e+"")return zi;return bO(t),e}});/**
52
+ * @license
53
+ * Copyright 2021 Google LLC
54
+ * SPDX-License-Identifier: BSD-3-Clause
55
+ */function wO(t,e,r){return t?e(t):r==null?void 0:r(t)}var pr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(pr||(pr={}));var dv;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(dv||(dv={}));const mt=pr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ya=t=>{switch(typeof t){case"undefined":return mt.undefined;case"string":return mt.string;case"number":return isNaN(t)?mt.nan:mt.number;case"boolean":return mt.boolean;case"function":return mt.function;case"bigint":return mt.bigint;case"symbol":return mt.symbol;case"object":return Array.isArray(t)?mt.array:t===null?mt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?mt.promise:typeof Map<"u"&&t instanceof Map?mt.map:typeof Set<"u"&&t instanceof Set?mt.set:typeof Date<"u"&&t instanceof Date?mt.date:mt.object;default:return mt.unknown}},nt=pr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),_O=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Zn extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof Zn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Zn.create=t=>new Zn(t);const Qo=(t,e)=>{let r;switch(t.code){case nt.invalid_type:t.received===mt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case nt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,pr.jsonStringifyReplacer)}`;break;case nt.unrecognized_keys:r=`Unrecognized key(s) in object: ${pr.joinValues(t.keys,", ")}`;break;case nt.invalid_union:r="Invalid input";break;case nt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${pr.joinValues(t.options)}`;break;case nt.invalid_enum_value:r=`Invalid enum value. Expected ${pr.joinValues(t.options)}, received '${t.received}'`;break;case nt.invalid_arguments:r="Invalid function arguments";break;case nt.invalid_return_type:r="Invalid function return type";break;case nt.invalid_date:r="Invalid date";break;case nt.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:pr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case nt.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case nt.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case nt.custom:r="Invalid input";break;case nt.invalid_intersection_types:r="Intersection results could not be merged";break;case nt.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case nt.not_finite:r="Number must be finite";break;default:r=e.defaultError,pr.assertNever(t)}return{message:r}};let g0=Qo;function kO(t){g0=t}function Wd(){return g0}const Zd=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:o}},SO=[];function ft(t,e){const r=Wd(),n=Zd({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Qo?void 0:Qo].filter(i=>!!i)});t.common.issues.push(n)}class mn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return qt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r){const a=await i.key,s=await i.value;n.push({key:a,value:s})}return mn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return qt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const qt=Object.freeze({status:"aborted"}),Xo=t=>({status:"dirty",value:t}),Tn=t=>({status:"valid",value:t}),fv=t=>t.status==="aborted",hv=t=>t.status==="dirty",Sl=t=>t.status==="valid",$l=t=>typeof Promise<"u"&&t instanceof Promise;function Gd(t,e,r,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function y0(t,e,r,n,i){if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}typeof SuppressedError=="function"&&SuppressedError;var Mt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Mt||(Mt={}));var Tl,El;class Hi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const b0=(t,e)=>{if(Sl(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Zn(t.common.issues);return this._error=r,this._error}}};function rr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,o)=>{var u,l;const{message:c}=t;return s.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:(u=c??n)!==null&&u!==void 0?u:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(l=c??r)!==null&&l!==void 0?l:o.defaultError}},description:i}}class ur{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ya(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ya(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new mn,ctx:{common:e.parent.common,data:e.data,parsedType:Ya(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if($l(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ya(e)},a=this._parseSync({data:e,path:i.path,parent:i});return b0(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ya(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await($l(i)?i:Promise.resolve(i));return b0(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:nt.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new ki({schema:this,typeName:Ft.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Vi.create(this,this._def)}nullable(){return ts.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _i.create(this,this._def)}promise(){return nu.create(this,this._def)}or(e){return Il.create([this,e],this._def)}and(e){return Al.create(this,e,this._def)}transform(e){return new ki({...rr(this._def),schema:this,typeName:Ft.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Ll({...rr(this._def),innerType:this,defaultValue:r,typeName:Ft.ZodDefault})}brand(){return new mv({typeName:Ft.ZodBranded,type:this,...rr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Dl({...rr(this._def),innerType:this,catchValue:r,typeName:Ft.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return jl.create(this,e)}readonly(){return Ul.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $O=/^c[^\s-]{8,}$/i,TO=/^[0-9a-z]+$/,EO=/^[0-9A-HJKMNP-TV-Z]{26}$/,CO=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,RO=/^[a-z0-9_-]{21}$/i,xO=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,IO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,AO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pv;const OO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,PO=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,MO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,w0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",NO=new RegExp(`^${w0}$`);function _0(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function LO(t){return new RegExp(`^${_0(t)}$`)}function k0(t){let e=`${w0}T${_0(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function DO(t,e){return!!((e==="v4"||!e)&&OO.test(t)||(e==="v6"||!e)&&PO.test(t))}class wi extends ur{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==mt.string){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.string,received:a.parsedType}),qt}const n=new mn;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const s=e.data.length>a.value,o=e.data.length<a.value;(s||o)&&(i=this._getOrReturnCtx(e,i),s?ft(i,{code:nt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&ft(i,{code:nt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")IO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"email",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")pv||(pv=new RegExp(AO,"u")),pv.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"emoji",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")CO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"uuid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")RO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"nanoid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")$O.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"cuid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")TO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"cuid2",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")EO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"ulid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),ft(i,{validation:"url",code:nt.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"regex",code:nt.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?k0(a).test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?NO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?LO(a).test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?xO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"duration",code:nt.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?DO(e.data,a.version)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"ip",code:nt.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?MO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"base64",code:nt.invalid_string,message:a.message}),n.dirty()):pr.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:nt.invalid_string,...Mt.errToObj(n)})}_addCheck(e){return new wi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Mt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Mt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Mt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Mt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Mt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Mt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Mt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Mt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Mt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Mt.errToObj(e)})}datetime(e){var r,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Mt.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Mt.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Mt.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Mt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Mt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Mt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Mt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Mt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Mt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Mt.errToObj(r)})}nonempty(e){return this.min(1,Mt.errToObj(e))}trim(){return new wi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}wi.create=t=>{var e;return new wi({checks:[],typeName:Ft.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};function jO(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class Qa extends ur{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==mt.number){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.number,received:a.parsedType}),qt}let n;const i=new mn;for(const a of this._def.checks)a.kind==="int"?pr.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?jO(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_finite,message:a.message}),i.dirty()):pr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Mt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Mt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Mt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Mt.toString(r))}setLimit(e,r,n,i){return new Qa({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Qa({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Mt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Mt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Mt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Mt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Mt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Mt.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&pr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Qa.create=t=>new Qa({checks:[],typeName:Ft.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class Xa extends ur{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==mt.bigint){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.bigint,received:a.parsedType}),qt}let n;const i=new mn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):pr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Mt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Mt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Mt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Mt.toString(r))}setLimit(e,r,n,i){return new Xa({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Xa({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Mt.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Xa.create=t=>{var e;return new Xa({checks:[],typeName:Ft.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};class Cl extends ur{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==mt.boolean){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.boolean,received:n.parsedType}),qt}return Tn(e.data)}}Cl.create=t=>new Cl({typeName:Ft.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class Vs extends ur{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==mt.date){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.date,received:a.parsedType}),qt}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_date}),qt}const n=new mn;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):pr.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Vs({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Mt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Mt.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Vs.create=t=>new Vs({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ft.ZodDate,...rr(t)});class Kd extends ur{_parse(e){if(this._getType(e)!==mt.symbol){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.symbol,received:n.parsedType}),qt}return Tn(e.data)}}Kd.create=t=>new Kd({typeName:Ft.ZodSymbol,...rr(t)});class Rl extends ur{_parse(e){if(this._getType(e)!==mt.undefined){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.undefined,received:n.parsedType}),qt}return Tn(e.data)}}Rl.create=t=>new Rl({typeName:Ft.ZodUndefined,...rr(t)});class xl extends ur{_parse(e){if(this._getType(e)!==mt.null){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.null,received:n.parsedType}),qt}return Tn(e.data)}}xl.create=t=>new xl({typeName:Ft.ZodNull,...rr(t)});class eu extends ur{constructor(){super(...arguments),this._any=!0}_parse(e){return Tn(e.data)}}eu.create=t=>new eu({typeName:Ft.ZodAny,...rr(t)});class Ws extends ur{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Tn(e.data)}}Ws.create=t=>new Ws({typeName:Ft.ZodUnknown,...rr(t)});class ga extends ur{_parse(e){const r=this._getOrReturnCtx(e);return ft(r,{code:nt.invalid_type,expected:mt.never,received:r.parsedType}),qt}}ga.create=t=>new ga({typeName:Ft.ZodNever,...rr(t)});class Jd extends ur{_parse(e){if(this._getType(e)!==mt.undefined){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.void,received:n.parsedType}),qt}return Tn(e.data)}}Jd.create=t=>new Jd({typeName:Ft.ZodVoid,...rr(t)});class _i extends ur{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==mt.array)return ft(r,{code:nt.invalid_type,expected:mt.array,received:r.parsedType}),qt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(ft(r,{code:s?nt.too_big:nt.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(ft(r,{code:nt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(ft(r,{code:nt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Hi(r,s,r.path,o)))).then(s=>mn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Hi(r,s,r.path,o)));return mn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new _i({...this._def,minLength:{value:e,message:Mt.toString(r)}})}max(e,r){return new _i({...this._def,maxLength:{value:e,message:Mt.toString(r)}})}length(e,r){return new _i({...this._def,exactLength:{value:e,message:Mt.toString(r)}})}nonempty(e){return this.min(1,e)}}_i.create=(t,e)=>new _i({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ft.ZodArray,...rr(e)});function tu(t){if(t instanceof Wr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Vi.create(tu(n))}return new Wr({...t._def,shape:()=>e})}else return t instanceof _i?new _i({...t._def,type:tu(t.element)}):t instanceof Vi?Vi.create(tu(t.unwrap())):t instanceof ts?ts.create(tu(t.unwrap())):t instanceof qi?qi.create(t.items.map(e=>tu(e))):t}class Wr extends ur{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=pr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==mt.object){const l=this._getOrReturnCtx(e);return ft(l,{code:nt.invalid_type,expected:mt.object,received:l.parsedType}),qt}const{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof ga&&this._def.unknownKeys==="strip"))for(const l in i.data)s.includes(l)||o.push(l);const u=[];for(const l of s){const c=a[l],d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Hi(i,d,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof ga){const l=this._def.unknownKeys;if(l==="passthrough")for(const c of o)u.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(l==="strict")o.length>0&&(ft(i,{code:nt.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const c of o){const d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Hi(i,d,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const c of u){const d=await c.key,f=await c.value;l.push({key:d,value:f,alwaysSet:c.alwaysSet})}return l}).then(l=>mn.mergeObjectSync(n,l)):mn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Mt.errToObj,new Wr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Mt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Wr({...this._def,unknownKeys:"strip"})}passthrough(){return new Wr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Wr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Wr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ft.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Wr({...this._def,catchall:e})}pick(e){const r={};return pr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Wr({...this._def,shape:()=>r})}omit(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Wr({...this._def,shape:()=>r})}deepPartial(){return tu(this)}partial(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Wr({...this._def,shape:()=>r})}required(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Vi;)a=a._def.innerType;r[n]=a}}),new Wr({...this._def,shape:()=>r})}keyof(){return S0(pr.objectKeys(this.shape))}}Wr.create=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strip",catchall:ga.create(),typeName:Ft.ZodObject,...rr(e)}),Wr.strictCreate=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strict",catchall:ga.create(),typeName:Ft.ZodObject,...rr(e)}),Wr.lazycreate=(t,e)=>new Wr({shape:t,unknownKeys:"strip",catchall:ga.create(),typeName:Ft.ZodObject,...rr(e)});class Il extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Zn(o.ctx.common.issues));return ft(r,{code:nt.invalid_union,unionErrors:s}),qt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Zn(u));return ft(r,{code:nt.invalid_union,unionErrors:o}),qt}}get options(){return this._def.options}}Il.create=(t,e)=>new Il({options:t,typeName:Ft.ZodUnion,...rr(e)});const ya=t=>t instanceof Pl?ya(t.schema):t instanceof ki?ya(t.innerType()):t instanceof Ml?[t.value]:t instanceof es?t.options:t instanceof Nl?pr.objectValues(t.enum):t instanceof Ll?ya(t._def.innerType):t instanceof Rl?[void 0]:t instanceof xl?[null]:t instanceof Vi?[void 0,...ya(t.unwrap())]:t instanceof ts?[null,...ya(t.unwrap())]:t instanceof mv||t instanceof Ul?ya(t.unwrap()):t instanceof Dl?ya(t._def.innerType):[];class Yd extends ur{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.object)return ft(r,{code:nt.invalid_type,expected:mt.object,received:r.parsedType}),qt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(ft(r,{code:nt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),qt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=ya(a.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new Yd({typeName:Ft.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...rr(n)})}}function vv(t,e){const r=Ya(t),n=Ya(e);if(t===e)return{valid:!0,data:t};if(r===mt.object&&n===mt.object){const i=pr.objectKeys(e),a=pr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=vv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===mt.array&&n===mt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=vv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===mt.date&&n===mt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Al extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(fv(a)||fv(s))return qt;const o=vv(a.value,s.value);return o.valid?((hv(a)||hv(s))&&r.dirty(),{status:r.value,value:o.data}):(ft(n,{code:nt.invalid_intersection_types}),qt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Al.create=(t,e,r)=>new Al({left:t,right:e,typeName:Ft.ZodIntersection,...rr(r)});class qi extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.array)return ft(n,{code:nt.invalid_type,expected:mt.array,received:n.parsedType}),qt;if(n.data.length<this._def.items.length)return ft(n,{code:nt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),qt;!this._def.rest&&n.data.length>this._def.items.length&&(ft(n,{code:nt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((s,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new Hi(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(a).then(s=>mn.mergeArray(r,s)):mn.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new qi({...this._def,rest:e})}}qi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new qi({items:t,typeName:Ft.ZodTuple,rest:null,...rr(e)})};class Ol extends ur{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.object)return ft(n,{code:nt.invalid_type,expected:mt.object,received:n.parsedType}),qt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Hi(n,o,n.path,o)),value:s._parse(new Hi(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?mn.mergeObjectAsync(r,i):mn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ur?new Ol({keyType:e,valueType:r,typeName:Ft.ZodRecord,...rr(n)}):new Ol({keyType:wi.create(),valueType:e,typeName:Ft.ZodRecord,...rr(r)})}}class Qd extends ur{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.map)return ft(n,{code:nt.invalid_type,expected:mt.map,received:n.parsedType}),qt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Hi(n,o,n.path,[l,"key"])),value:a._parse(new Hi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Qd.create=(t,e,r)=>new Qd({valueType:e,keyType:t,typeName:Ft.ZodMap,...rr(r)});class Zs extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.set)return ft(n,{code:nt.invalid_type,expected:mt.set,received:n.parsedType}),qt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ft(n,{code:nt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ft(n,{code:nt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return qt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Hi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new Zs({...this._def,minSize:{value:e,message:Mt.toString(r)}})}max(e,r){return new Zs({...this._def,maxSize:{value:e,message:Mt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Zs.create=(t,e)=>new Zs({valueType:t,minSize:null,maxSize:null,typeName:Ft.ZodSet,...rr(e)});class ru extends ur{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.function)return ft(r,{code:nt.invalid_type,expected:mt.function,received:r.parsedType}),qt;function n(o,u){return Zd({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Wd(),Qo].filter(l=>!!l),issueData:{code:nt.invalid_arguments,argumentsError:u}})}function i(o,u){return Zd({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Wd(),Qo].filter(l=>!!l),issueData:{code:nt.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof nu){const o=this;return Tn(async function(...u){const l=new Zn([]),c=await o._def.args.parseAsync(u,a).catch(m=>{throw l.addIssue(n(u,m)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(m=>{throw l.addIssue(i(d,m)),l})})}else{const o=this;return Tn(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Zn([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Zn([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ru({...this._def,args:qi.create(e).rest(Ws.create())})}returns(e){return new ru({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new ru({args:e||qi.create([]).rest(Ws.create()),returns:r||Ws.create(),typeName:Ft.ZodFunction,...rr(n)})}}class Pl extends ur{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Pl.create=(t,e)=>new Pl({getter:t,typeName:Ft.ZodLazy,...rr(e)});class Ml extends ur{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return ft(r,{received:r.data,code:nt.invalid_literal,expected:this._def.value}),qt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ml.create=(t,e)=>new Ml({value:t,typeName:Ft.ZodLiteral,...rr(e)});function S0(t,e){return new es({values:t,typeName:Ft.ZodEnum,...rr(e)})}class es extends ur{constructor(){super(...arguments),Tl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return ft(r,{expected:pr.joinValues(n),received:r.parsedType,code:nt.invalid_type}),qt}if(Gd(this,Tl)||y0(this,Tl,new Set(this._def.values)),!Gd(this,Tl).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return ft(r,{received:r.data,code:nt.invalid_enum_value,options:n}),qt}return Tn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return es.create(e,{...this._def,...r})}exclude(e,r=this._def){return es.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}Tl=new WeakMap,es.create=S0;class Nl extends ur{constructor(){super(...arguments),El.set(this,void 0)}_parse(e){const r=pr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==mt.string&&n.parsedType!==mt.number){const i=pr.objectValues(r);return ft(n,{expected:pr.joinValues(i),received:n.parsedType,code:nt.invalid_type}),qt}if(Gd(this,El)||y0(this,El,new Set(pr.getValidEnumValues(this._def.values))),!Gd(this,El).has(e.data)){const i=pr.objectValues(r);return ft(n,{received:n.data,code:nt.invalid_enum_value,options:i}),qt}return Tn(e.data)}get enum(){return this._def.values}}El=new WeakMap,Nl.create=(t,e)=>new Nl({values:t,typeName:Ft.ZodNativeEnum,...rr(e)});class nu extends ur{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.promise&&r.common.async===!1)return ft(r,{code:nt.invalid_type,expected:mt.promise,received:r.parsedType}),qt;const n=r.parsedType===mt.promise?r.data:Promise.resolve(r.data);return Tn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}nu.create=(t,e)=>new nu({type:t,typeName:Ft.ZodPromise,...rr(e)});class ki extends ur{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ft.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{ft(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return qt;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?qt:u.status==="dirty"||r.value==="dirty"?Xo(u.value):u});{if(r.value==="aborted")return qt;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?qt:o.status==="dirty"||r.value==="dirty"?Xo(o.value):o}}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?qt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?qt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Sl(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>Sl(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);pr.assertNever(i)}}ki.create=(t,e,r)=>new ki({schema:t,typeName:Ft.ZodEffects,effect:e,...rr(r)}),ki.createWithPreprocess=(t,e,r)=>new ki({schema:e,effect:{type:"preprocess",transform:t},typeName:Ft.ZodEffects,...rr(r)});class Vi extends ur{_parse(e){return this._getType(e)===mt.undefined?Tn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Vi.create=(t,e)=>new Vi({innerType:t,typeName:Ft.ZodOptional,...rr(e)});class ts extends ur{_parse(e){return this._getType(e)===mt.null?Tn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ts.create=(t,e)=>new ts({innerType:t,typeName:Ft.ZodNullable,...rr(e)});class Ll extends ur{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===mt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Ll.create=(t,e)=>new Ll({innerType:t,typeName:Ft.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...rr(e)});class Dl extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $l(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Zn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Dl.create=(t,e)=>new Dl({innerType:t,typeName:Ft.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...rr(e)});class Xd extends ur{_parse(e){if(this._getType(e)!==mt.nan){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.nan,received:n.parsedType}),qt}return{status:"valid",value:e.data}}}Xd.create=t=>new Xd({typeName:Ft.ZodNaN,...rr(t)});const UO=Symbol("zod_brand");class mv extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class jl extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?qt:a.status==="dirty"?(r.dirty(),Xo(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?qt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new jl({in:e,out:r,typeName:Ft.ZodPipeline})}}class Ul extends ur{_parse(e){const r=this._def.innerType._parse(e),n=i=>(Sl(i)&&(i.value=Object.freeze(i.value)),i);return $l(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}Ul.create=(t,e)=>new Ul({innerType:t,typeName:Ft.ZodReadonly,...rr(e)});function $0(t,e={},r){return t?eu.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):eu.create()}const FO={object:Wr.lazycreate};var Ft;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Ft||(Ft={}));const BO=(t,e={message:`Input not instance of ${t.name}`})=>$0(r=>r instanceof t,e),T0=wi.create,E0=Qa.create,zO=Xd.create,HO=Xa.create,C0=Cl.create,qO=Vs.create,VO=Kd.create,WO=Rl.create,ZO=xl.create,GO=eu.create,KO=Ws.create,JO=ga.create,YO=Jd.create,QO=_i.create,XO=Wr.create,eP=Wr.strictCreate,tP=Il.create,rP=Yd.create,nP=Al.create,iP=qi.create,aP=Ol.create,sP=Qd.create,oP=Zs.create,uP=ru.create,lP=Pl.create,cP=Ml.create,dP=es.create,fP=Nl.create,hP=nu.create,R0=ki.create,pP=Vi.create,vP=ts.create,mP=ki.createWithPreprocess,gP=jl.create;var Fl=Object.freeze({__proto__:null,defaultErrorMap:Qo,setErrorMap:kO,getErrorMap:Wd,makeIssue:Zd,EMPTY_PATH:SO,addIssueToContext:ft,ParseStatus:mn,INVALID:qt,DIRTY:Xo,OK:Tn,isAborted:fv,isDirty:hv,isValid:Sl,isAsync:$l,get util(){return pr},get objectUtil(){return dv},ZodParsedType:mt,getParsedType:Ya,ZodType:ur,datetimeRegex:k0,ZodString:wi,ZodNumber:Qa,ZodBigInt:Xa,ZodBoolean:Cl,ZodDate:Vs,ZodSymbol:Kd,ZodUndefined:Rl,ZodNull:xl,ZodAny:eu,ZodUnknown:Ws,ZodNever:ga,ZodVoid:Jd,ZodArray:_i,ZodObject:Wr,ZodUnion:Il,ZodDiscriminatedUnion:Yd,ZodIntersection:Al,ZodTuple:qi,ZodRecord:Ol,ZodMap:Qd,ZodSet:Zs,ZodFunction:ru,ZodLazy:Pl,ZodLiteral:Ml,ZodEnum:es,ZodNativeEnum:Nl,ZodPromise:nu,ZodEffects:ki,ZodTransformer:ki,ZodOptional:Vi,ZodNullable:ts,ZodDefault:Ll,ZodCatch:Dl,ZodNaN:Xd,BRAND:UO,ZodBranded:mv,ZodPipeline:jl,ZodReadonly:Ul,custom:$0,Schema:ur,ZodSchema:ur,late:FO,get ZodFirstPartyTypeKind(){return Ft},coerce:{string:t=>wi.create({...t,coerce:!0}),number:t=>Qa.create({...t,coerce:!0}),boolean:t=>Cl.create({...t,coerce:!0}),bigint:t=>Xa.create({...t,coerce:!0}),date:t=>Vs.create({...t,coerce:!0})},any:GO,array:QO,bigint:HO,boolean:C0,date:qO,discriminatedUnion:rP,effect:R0,enum:dP,function:uP,instanceof:BO,intersection:nP,lazy:lP,literal:cP,map:sP,nan:zO,nativeEnum:fP,never:JO,null:ZO,nullable:vP,number:E0,object:XO,oboolean:()=>C0().optional(),onumber:()=>E0().optional(),optional:pP,ostring:()=>T0().optional(),pipeline:gP,preprocess:mP,promise:hP,record:aP,set:oP,strictObject:eP,string:T0,symbol:VO,transformer:R0,tuple:iP,undefined:WO,union:tP,unknown:KO,void:YO,NEVER:qt,ZodIssueCode:nt,quotelessJson:_O,ZodError:Zn});const x0=V2`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.static{position:static}.relative{position:relative}.my-4{margin-top:1rem;margin-bottom:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rounded{border-radius:.25rem}.border{border-width:1px}.border-red-400{--tw-border-opacity: 1;border-color:rgb(248 113 113 / var(--tw-border-opacity))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity))}.px-4{padding-left:1rem;padding-right:1rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}input{width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:.25rem;border-width:1px;padding:.5rem .75rem;line-height:1.25;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity));--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}label{margin-bottom:.5rem;display:block;font-size:.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-primary{border-radius:.25rem;padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.btn-primary:hover{opacity:.95}.btn-primary:disabled{pointer-events:none;opacity:.5}.btn-primary{background-color:var(--iai-chat-i-button-bg);color:var(--iai-chat-i-button-fg)}.btn-secondary{padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-secondary:hover{opacity:.95}.btn-secondary:disabled{pointer-events:none;opacity:.5}`;var ln=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yP(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function bP(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}(function(){function t(L,W){var ie=L.split("."),He=ce;ie[0]in He||!He.execScript||He.execScript("var "+ie[0]);for(var ct;ie.length&&(ct=ie.shift());)ie.length||W===void 0?He=He[ct]?He[ct]:He[ct]={}:He[ct]=W}function e(L,W){function ie(){}ie.prototype=W.prototype,L.M=W.prototype,L.prototype=new ie,L.prototype.constructor=L,L.N=function(He,ct,bt){for(var zt=Array(arguments.length-2),tr=2;tr<arguments.length;tr++)zt[tr-2]=arguments[tr];return W.prototype[ct].apply(He,zt)}}function r(L,W){L!=null&&this.a.apply(this,arguments)}function n(L){L.b=""}function i(L,W){L.sort(W||a)}function a(L,W){return L>W?1:L<W?-1:0}function s(L){var W,ie=[],He=0;for(W in L)ie[He++]=L[W];return ie}function o(L,W){this.b=L,this.a={};for(var ie=0;ie<W.length;ie++){var He=W[ie];this.a[He.b]=He}}function u(L){return L=s(L.a),i(L,function(W,ie){return W.b-ie.b}),L}function l(L,W){switch(this.b=L,this.g=!!W.v,this.a=W.c,this.i=W.type,this.h=!1,this.a){case be:case pt:case Ze:case Jt:case At:case Be:case Ke:this.h=!0}this.f=W.defaultValue}function c(){this.a={},this.f=this.j().a,this.b=this.g=null}function d(L,W){for(var ie=u(L.j()),He=0;He<ie.length;He++){var ct=ie[He],bt=ct.b;if(W.a[bt]!=null){L.b&&delete L.b[ct.b];var zt=ct.a==11||ct.a==10;if(ct.g)for(var ct=f(W,bt)||[],tr=0;tr<ct.length;tr++){var Re=L,Ne=bt,pe=zt?ct[tr].clone():ct[tr];Re.a[Ne]||(Re.a[Ne]=[]),Re.a[Ne].push(pe),Re.b&&delete Re.b[Ne]}else ct=f(W,bt),zt?(zt=f(L,bt))?d(zt,ct):N(L,bt,ct.clone()):N(L,bt,ct)}}}function f(L,W){var ie=L.a[W];if(ie==null)return null;if(L.g){if(!(W in L.b)){var He=L.g,ct=L.f[W];if(ie!=null)if(ct.g){for(var bt=[],zt=0;zt<ie.length;zt++)bt[zt]=He.b(ct,ie[zt]);ie=bt}else ie=He.b(ct,ie);return L.b[W]=ie}return L.b[W]}return ie}function m(L,W,ie){var He=f(L,W);return L.f[W].g?He[ie||0]:He}function b(L,W){var ie;if(L.a[W]!=null)ie=m(L,W,void 0);else e:{if(ie=L.f[W],ie.f===void 0){var He=ie.i;if(He===Boolean)ie.f=!1;else if(He===Number)ie.f=0;else{if(He!==String){ie=new He;break e}ie.f=ie.h?"0":""}}ie=ie.f}return ie}function A(L,W){return L.f[W].g?L.a[W]!=null?L.a[W].length:0:L.a[W]!=null?1:0}function N(L,W,ie){L.a[W]=ie,L.b&&(L.b[W]=ie)}function z(L,W){var ie,He=[];for(ie in W)ie!=0&&He.push(new l(ie,W[ie]));return new o(L,He)}function X(){c.call(this)}function Ee(){c.call(this)}function Ie(){c.call(this)}function Fe(){}function Oe(){}function ze(){}function V(){this.a={}}function xe(L){return L.length==0||Mr.test(L)}function _e(L,W){if(W==null)return null;W=W.toUpperCase();var ie=L.a[W];if(ie==null){if(ie=ut[W],ie==null)return null;ie=new ze().a(Ie.j(),ie),L.a[W]=ie}return ie}function se(L){return L=St[L],L==null?"ZZ":L[0]}function Te(L){this.H=RegExp(" "),this.C="",this.m=new r,this.w="",this.i=new r,this.u=new r,this.l=!0,this.A=this.o=this.F=!1,this.G=V.b(),this.s=0,this.b=new r,this.B=!1,this.h="",this.a=new r,this.f=[],this.D=L,this.J=this.g=re(this,this.D)}function re(L,W){var ie;if(W!=null&&isNaN(W)&&W.toUpperCase()in ut){if(ie=_e(L.G,W),ie==null)throw Error("Invalid region code: "+W);ie=b(ie,10)}else ie=0;return ie=_e(L.G,se(ie)),ie??Fr}function oe(L){for(var W=L.f.length,ie=0;ie<W;++ie){var He=L.f[ie],ct=b(He,1);if(L.w==ct)return!1;var bt;bt=L;var zt=He,tr=b(zt,1);if(tr.indexOf("|")!=-1)bt=!1;else{tr=tr.replace(dr,"\\d"),tr=tr.replace(fr,"\\d"),n(bt.m);var Re;Re=bt;var zt=b(zt,2),Ne="999999999999999".match(tr)[0];Ne.length<Re.a.b.length?Re="":(Re=Ne.replace(new RegExp(tr,"g"),zt),Re=Re.replace(RegExp("9","g")," ")),0<Re.length?(bt.m.a(Re),bt=!0):bt=!1}if(bt)return L.w=ct,L.B=Ot.test(m(He,4)),L.s=0,!0}return L.l=!1}function q(L,W){for(var ie=[],He=W.length-3,ct=L.f.length,bt=0;bt<ct;++bt){var zt=L.f[bt];A(zt,3)==0?ie.push(L.f[bt]):(zt=m(zt,3,Math.min(He,A(zt,3)-1)),W.search(zt)==0&&ie.push(L.f[bt]))}L.f=ie}function ne(L,W){L.i.a(W);var ie=W;if(et.test(ie)||L.i.b.length==1&&br.test(ie)){var He,ie=W;ie=="+"?(He=ie,L.u.a(ie)):(He=or[ie],L.u.a(He),L.a.a(He)),W=He}else L.l=!1,L.F=!0;if(!L.l){if(!L.F){if(Ct(L)){if(rt(L))return Se(L)}else if(0<L.h.length&&(ie=L.a.toString(),n(L.a),L.a.a(L.h),L.a.a(ie),ie=L.b.toString(),He=ie.lastIndexOf(L.h),n(L.b),L.b.a(ie.substring(0,He))),L.h!=Xe(L))return L.b.a(" "),Se(L)}return L.i.toString()}switch(L.u.b.length){case 0:case 1:case 2:return L.i.toString();case 3:if(!Ct(L))return L.h=Xe(L),ke(L);L.A=!0;default:return L.A?(rt(L)&&(L.A=!1),L.b.toString()+L.a.toString()):0<L.f.length?(ie=je(L,W),He=H(L),0<He.length?He:(q(L,L.a.toString()),oe(L)?M(L):L.l?ye(L,ie):L.i.toString())):ke(L)}}function Se(L){return L.l=!0,L.A=!1,L.f=[],L.s=0,n(L.m),L.w="",ke(L)}function H(L){for(var W=L.a.toString(),ie=L.f.length,He=0;He<ie;++He){var ct=L.f[He],bt=b(ct,1);if(new RegExp("^(?:"+bt+")$").test(W))return L.B=Ot.test(m(ct,4)),W=W.replace(new RegExp(bt,"g"),m(ct,2)),ye(L,W)}return""}function ye(L,W){var ie=L.b.b.length;return L.B&&0<ie&&L.b.toString().charAt(ie-1)!=" "?L.b+" "+W:L.b+W}function ke(L){var W=L.a.toString();if(3<=W.length){for(var ie=L.o&&L.h.length==0&&0<A(L.g,20)?f(L.g,20)||[]:f(L.g,19)||[],He=ie.length,ct=0;ct<He;++ct){var bt=ie[ct];0<L.h.length&&xe(b(bt,4))&&!m(bt,6)&&bt.a[5]==null||(L.h.length!=0||L.o||xe(b(bt,4))||m(bt,6))&&Wt.test(b(bt,2))&&L.f.push(bt)}return q(L,W),W=H(L),0<W.length?W:oe(L)?M(L):L.i.toString()}return ye(L,W)}function M(L){var W=L.a.toString(),ie=W.length;if(0<ie){for(var He="",ct=0;ct<ie;ct++)He=je(L,W.charAt(ct));return L.l?ye(L,He):L.i.toString()}return L.b.toString()}function Xe(L){var W,ie=L.a.toString(),He=0;return m(L.g,10)!=1?W=!1:(W=L.a.toString(),W=W.charAt(0)=="1"&&W.charAt(1)!="0"&&W.charAt(1)!="1"),W?(He=1,L.b.a("1").a(" "),L.o=!0):L.g.a[15]!=null&&(W=new RegExp("^(?:"+m(L.g,15)+")"),W=ie.match(W),W!=null&&W[0]!=null&&0<W[0].length&&(L.o=!0,He=W[0].length,L.b.a(ie.substring(0,He)))),n(L.a),L.a.a(ie.substring(He)),ie.substring(0,He)}function Ct(L){var W=L.u.toString(),ie=new RegExp("^(?:\\+|"+m(L.g,11)+")"),ie=W.match(ie);return ie!=null&&ie[0]!=null&&0<ie[0].length&&(L.o=!0,ie=ie[0].length,n(L.a),L.a.a(W.substring(ie)),n(L.b),L.b.a(W.substring(0,ie)),W.charAt(0)!="+"&&L.b.a(" "),!0)}function rt(L){if(L.a.b.length==0)return!1;var W,ie=new r;e:{if(W=L.a.toString(),W.length!=0&&W.charAt(0)!="0"){for(var He,ct=W.length,bt=1;3>=bt&&bt<=ct;++bt)if(He=parseInt(W.substring(0,bt),10),He in St){ie.a(W.substring(bt)),W=He;break e}}W=0}return W!=0&&(n(L.a),L.a.a(ie.toString()),ie=se(W),ie=="001"?L.g=_e(L.G,""+W):ie!=L.D&&(L.g=re(L,ie)),L.b.a(""+W).a(" "),L.h="",!0)}function je(L,W){var ie=L.m.toString();if(0<=ie.substring(L.s).search(L.H)){var He=ie.search(L.H),ie=ie.replace(L.H,W);return n(L.m),L.m.a(ie),L.s=He,ie.substring(0,L.s+1)}return L.f.length==1&&(L.l=!1),L.w="",L.i.toString()}var ce=this;r.prototype.b="",r.prototype.set=function(L){this.b=""+L},r.prototype.a=function(L,W,ie){if(this.b+=String(L),W!=null)for(var He=1;He<arguments.length;He++)this.b+=arguments[He];return this},r.prototype.toString=function(){return this.b};var Ke=1,Be=2,be=3,pt=4,Ze=6,Jt=16,At=18;c.prototype.set=function(L,W){N(this,L.b,W)},c.prototype.clone=function(){var L=new this.constructor;return L!=this&&(L.a={},L.b&&(L.b={}),d(L,this)),L},e(X,c);var Q=null;e(Ee,c);var Ue=null;e(Ie,c);var ot=null;X.prototype.j=function(){var L=Q;return L||(Q=L=z(X,{0:{name:"NumberFormat",I:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",v:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}})),L},X.j=X.prototype.j,Ee.prototype.j=function(){var L=Ue;return L||(Ue=L=z(Ee,{0:{name:"PhoneNumberDesc",I:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},9:{name:"possible_length",v:!0,c:5,type:Number},10:{name:"possible_length_local_only",v:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String}})),L},Ee.j=Ee.prototype.j,Ie.prototype.j=function(){var L=ot;return L||(ot=L=z(Ie,{0:{name:"PhoneMetadata",I:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:Ee},2:{name:"fixed_line",c:11,type:Ee},3:{name:"mobile",c:11,type:Ee},4:{name:"toll_free",c:11,type:Ee},5:{name:"premium_rate",c:11,type:Ee},6:{name:"shared_cost",c:11,type:Ee},7:{name:"personal_number",c:11,type:Ee},8:{name:"voip",c:11,type:Ee},21:{name:"pager",c:11,type:Ee},25:{name:"uan",c:11,type:Ee},27:{name:"emergency",c:11,type:Ee},28:{name:"voicemail",c:11,type:Ee},29:{name:"short_code",c:11,type:Ee},30:{name:"standard_rate",c:11,type:Ee},31:{name:"carrier_specific",c:11,type:Ee},33:{name:"sms_services",c:11,type:Ee},24:{name:"no_international_dialling",c:11,type:Ee},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,type:Boolean},19:{name:"number_format",v:!0,c:11,type:X},20:{name:"intl_number_format",v:!0,c:11,type:X},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}})),L},Ie.j=Ie.prototype.j,Fe.prototype.a=function(L){throw new L.b,Error("Unimplemented")},Fe.prototype.b=function(L,W){if(L.a==11||L.a==10)return W instanceof c?W:this.a(L.i.prototype.j(),W);if(L.a==14){if(typeof W=="string"&&Pe.test(W)){var ie=Number(W);if(0<ie)return ie}return W}if(!L.h)return W;if(ie=L.i,ie===String){if(typeof W=="number")return String(W)}else if(ie===Number&&typeof W=="string"&&(W==="Infinity"||W==="-Infinity"||W==="NaN"||Pe.test(W)))return Number(W);return W};var Pe=/^-?[0-9]+$/;e(Oe,Fe),Oe.prototype.a=function(L,W){var ie=new L.b;return ie.g=this,ie.a=W,ie.b={},ie},e(ze,Oe),ze.prototype.b=function(L,W){return L.a==8?!!W:Fe.prototype.b.apply(this,arguments)},ze.prototype.a=function(L,W){return ze.M.a.call(this,L,W)};var St={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" ")},ut={AG:[null,[null,null,"(?:268|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"268(?:4(?:6[0-38]|84)|56[0-2])\\d{4}",null,null,null,"2684601234",null,null,null,[7]],[null,null,"268(?:464|7(?:1[3-9]|2\\d|3[246]|64|[78][0-689]))\\d{4}",null,null,null,"2684641234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"26848[01]\\d{4}",null,null,null,"2684801234",null,null,null,[7]],"AG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"26840[69]\\d{4}",null,null,null,"2684061234",null,null,null,[7]],null,"268",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AI:[null,[null,null,"(?:264|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"2644(?:6[12]|9[78])\\d{4}",null,null,null,"2644612345",null,null,null,[7]],[null,null,"264(?:235|476|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}",null,null,null,"2642351234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AI",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"264",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AS:[null,[null,null,"(?:[58]\\d\\d|684|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"6846(?:22|33|44|55|77|88|9[19])\\d{4}",null,null,null,"6846221234",null,null,null,[7]],[null,null,"684(?:2(?:5[2468]|72)|7(?:3[13]|70))\\d{4}",null,null,null,"6847331234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"684",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BB:[null,[null,null,"(?:246|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"246(?:2(?:2[78]|7[0-4])|4(?:1[024-6]|2\\d|3[2-9])|5(?:20|[34]\\d|54|7[1-3])|6(?:2\\d|38)|7[35]7|9(?:1[89]|63))\\d{4}",null,null,null,"2464123456",null,null,null,[7]],[null,null,"246(?:2(?:[356]\\d|4[0-57-9]|8[0-79])|45\\d|69[5-7]|8(?:[2-5]\\d|83))\\d{4}",null,null,null,"2462501234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"(?:246976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002123456",null,null,null,[7]],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"24631\\d{5}",null,null,null,"2463101234",null,null,null,[7]],"BB",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"246",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"246(?:292|367|4(?:1[7-9]|3[01]|44|67)|7(?:36|53))\\d{4}",null,null,null,"2464301234",null,null,null,[7]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BM:[null,[null,null,"(?:441|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"441(?:2(?:02|23|[3479]\\d|61)|[46]\\d\\d|5(?:4\\d|60|89)|824)\\d{4}",null,null,null,"4412345678",null,null,null,[7]],[null,null,"441(?:[37]\\d|5[0-39])\\d{5}",null,null,null,"4413701234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"441",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BS:[null,[null,null,"(?:242|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[347]|8[0-4]|9[2-467])|461|502|6(?:0[1-4]|12|2[013]|[45]0|7[67]|8[78]|9[89])|7(?:02|88))\\d{4}",null,null,null,"2423456789",null,null,null,[7]],[null,null,"242(?:3(?:5[79]|7[56]|95)|4(?:[23][1-9]|4[1-35-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-46-9]|65|77)|6[34]6|7(?:27|38)|8(?:0[1-9]|1[02-9]|2\\d|[89]9))\\d{4}",null,null,null,"2423591234",null,null,null,[7]],[null,null,"(?:242300|8(?:00|33|44|55|66|77|88)[2-9]\\d\\d)\\d{4}",null,null,null,"8002123456",null,null,null,[7]],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"242",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"242225[0-46-9]\\d{3}",null,null,null,"2422250123"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],CA:[null,[null,null,"(?:[2-8]\\d|90)\\d{8}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"(?:5(?:00|2[12]|33|44|66|77|88)|622)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"600[2-9]\\d{6}",null,null,null,"6002012345"],"CA",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DM:[null,[null,null,"(?:[58]\\d\\d|767|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"767(?:2(?:55|66)|4(?:2[01]|4[0-25-9])|50[0-4]|70[1-3])\\d{4}",null,null,null,"7674201234",null,null,null,[7]],[null,null,"767(?:2(?:[2-4689]5|7[5-7])|31[5-7]|61[1-7])\\d{4}",null,null,null,"7672251234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"767",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DO:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"8(?:[04]9[2-9]\\d\\d|29(?:2(?:[0-59]\\d|6[04-9]|7[0-27]|8[0237-9])|3(?:[0-35-9]\\d|4[7-9])|[45]\\d\\d|6(?:[0-27-9]\\d|[3-5][1-9]|6[0135-8])|7(?:0[013-9]|[1-37]\\d|4[1-35689]|5[1-4689]|6[1-57-9]|8[1-79]|9[1-8])|8(?:0[146-9]|1[0-48]|[248]\\d|3[1-79]|5[01589]|6[013-68]|7[124-8]|9[0-8])|9(?:[0-24]\\d|3[02-46-9]|5[0-79]|60|7[0169]|8[57-9]|9[02-9])))\\d{4}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8[024]9[2-9]\\d{6}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DO",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"8[024]9",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GD:[null,[null,null,"(?:473|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"473(?:2(?:3[0-2]|69)|3(?:2[89]|86)|4(?:[06]8|3[5-9]|4[0-49]|5[5-79]|73|90)|63[68]|7(?:58|84)|800|938)\\d{4}",null,null,null,"4732691234",null,null,null,[7]],[null,null,"473(?:4(?:0[2-79]|1[04-9]|2[0-5]|58)|5(?:2[01]|3[3-8])|901)\\d{4}",null,null,null,"4734031234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GD",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"473",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GU:[null,[null,null,"(?:[58]\\d\\d|671|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GU",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"671",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],JM:[null,[null,null,"(?:[58]\\d\\d|658|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:658[2-9]\\d\\d|876(?:5(?:0[12]|1[0-468]|2[35]|63)|6(?:0[1-3579]|1[0237-9]|[23]\\d|40|5[06]|6[2-589]|7[05]|8[04]|9[4-9])|7(?:0[2-689]|[1-6]\\d|8[056]|9[45])|9(?:0[1-8]|1[02378]|[2-8]\\d|9[2-468])))\\d{4}",null,null,null,"8765230123",null,null,null,[7]],[null,null,"876(?:(?:2[14-9]|[348]\\d)\\d|5(?:0[3-9]|[2-57-9]\\d|6[0-24-9])|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579]))\\d{4}",null,null,null,"8762101234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"JM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"658|876",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KN:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"869(?:2(?:29|36)|302|4(?:6[015-9]|70))\\d{4}",null,null,null,"8692361234",null,null,null,[7]],[null,null,"869(?:5(?:5[6-8]|6[5-7])|66\\d|76[02-7])\\d{4}",null,null,null,"8697652917",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KN",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"869",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KY:[null,[null,null,"(?:345|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"345(?:2(?:22|44)|444|6(?:23|38|40)|7(?:4[35-79]|6[6-9]|77)|8(?:00|1[45]|25|[48]8)|9(?:14|4[035-9]))\\d{4}",null,null,null,"3452221234",null,null,null,[7]],[null,null,"345(?:32[1-9]|5(?:1[67]|2[5-79]|4[6-9]|50|76)|649|9(?:1[67]|2[2-9]|3[689]))\\d{4}",null,null,null,"3453231234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"(?:345976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KY",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"345849\\d{4}",null,null,null,"3458491234"],null,"345",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],LC:[null,[null,null,"(?:[58]\\d\\d|758|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"758(?:4(?:30|5\\d|6[2-9]|8[0-2])|57[0-2]|638)\\d{4}",null,null,null,"7584305678",null,null,null,[7]],[null,null,"758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2\\d|3[01]))\\d{4}",null,null,null,"7582845678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"LC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"758",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MP:[null,[null,null,"(?:[58]\\d\\d|(?:67|90)0)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MP",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"670",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MS:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d\\d|66449)\\d{5}",null,null,null,null,null,null,[10],[7]],[null,null,"664491\\d{4}",null,null,null,"6644912345",null,null,null,[7]],[null,null,"66449[2-6]\\d{4}",null,null,null,"6644923456",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"664",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],PR:[null,[null,null,"(?:[589]\\d\\d|787)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"PR",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"787|939",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],SX:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d|7215)\\d{6}",null,null,null,null,null,null,[10],[7]],[null,null,"7215(?:4[2-8]|8[239]|9[056])\\d{4}",null,null,null,"7215425678",null,null,null,[7]],[null,null,"7215(?:1[02]|2\\d|5[034679]|8[014-8])\\d{4}",null,null,null,"7215205678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"SX",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"721",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TC:[null,[null,null,"(?:[58]\\d\\d|649|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"649(?:712|9(?:4\\d|50))\\d{4}",null,null,null,"6497121234",null,null,null,[7]],[null,null,"649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-8])|4[34][1-3])\\d{4}",null,null,null,"6492311234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"64971[01]\\d{4}",null,null,null,"6497101234",null,null,null,[7]],"TC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"649",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TT:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"868(?:2(?:01|[23]\\d)|6(?:0[7-9]|1[02-8]|2[1-9]|[3-69]\\d|7[0-79])|82[124])\\d{4}",null,null,null,"8682211234",null,null,null,[7]],[null,null,"868(?:2(?:6[6-9]|[7-9]\\d)|[37](?:0[1-9]|1[02-9]|[2-9]\\d)|4[6-9]\\d|6(?:20|78|8\\d))\\d{4}",null,null,null,"8682911234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"TT",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"868",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,"868619\\d{4}",null,null,null,"8686191234",null,null,null,[7]]],US:[null,[null,null,"[2-9]\\d{9}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"US",1,"011","1",null,null,"1",null,null,1,[[null,"(\\d{3})(\\d{4})","$1-$2",["[2-9]"]],[null,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],null,null,1]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[2-9]"]]],[null,null,null,null,null,null,null,null,null,[-1]],1,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"710[2-9]\\d{6}",null,null,null,"7102123456"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VC:[null,[null,null,"(?:[58]\\d\\d|784|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"784(?:266|3(?:6[6-9]|7\\d|8[0-24-6])|4(?:38|5[0-36-8]|8[0-8])|5(?:55|7[0-2]|93)|638|784)\\d{4}",null,null,null,"7842661234",null,null,null,[7]],[null,null,"784(?:4(?:3[0-5]|5[45]|89|9[0-8])|5(?:2[6-9]|3[0-4]))\\d{4}",null,null,null,"7844301234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"784",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VG:[null,[null,null,"(?:284|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"284(?:(?:229|774|8(?:52|6[459]))\\d|4(?:22\\d|9(?:[45]\\d|6[0-5])))\\d{3}",null,null,null,"2842291234",null,null,null,[7]],[null,null,"284(?:(?:3(?:0[0-3]|4[0-7]|68|9[34])|54[0-57])\\d|4(?:(?:4[0-6]|68)\\d|9(?:6[6-9]|9\\d)))\\d{3}",null,null,null,"2843001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"284",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VI:[null,[null,null,"(?:(?:34|90)0|[58]\\d\\d)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VI",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"340",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]]};V.b=function(){return V.a?V.a:V.a=new V};var or={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"},br=RegExp("[++]+"),et=RegExp("([0-90-9٠-٩۰-۹])"),Mr=/^\(?\$1\)?$/,Fr=new Ie;N(Fr,11,"NA");var dr=/\[([^\[\]])*\]/g,fr=/\d(?=[^,}][^,}])/g,Wt=RegExp("^[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*(\\$\\d[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*)+$"),Ot=/[- ]/;Te.prototype.K=function(){this.C="",n(this.i),n(this.u),n(this.m),this.s=0,this.w="",n(this.b),this.h="",n(this.a),this.l=!0,this.A=this.o=this.F=!1,this.f=[],this.B=!1,this.g!=this.J&&(this.g=re(this,this.D))},Te.prototype.L=function(L){return this.C=ne(this,L)},t("Cleave.AsYouTypeFormatter",Te),t("Cleave.AsYouTypeFormatter.prototype.inputDigit",Te.prototype.L),t("Cleave.AsYouTypeFormatter.prototype.clear",Te.prototype.K)}).call(typeof ln=="object"&&ln?ln:window);var wP=Object.defineProperty,_P=Object.getOwnPropertyDescriptor,ef=(t,e,r,n)=>{for(var i=n>1?void 0:n?_P(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&wP(e,r,i),i};const I0=10,kP="1",SP=t=>{const e=t.replace(/\D/g,"");return e.length===I0+1&&e.startsWith(kP)?e.slice(1):e},$P=Fl.object({firstName:Fl.string().min(1,{message:"First name is required"}),lastName:Fl.string().min(1,{message:"Last name is required"}),email:Fl.string().email({message:"Invalid email address"}),phone:Fl.string().transform(SP).refine(t=>t.length===I0,{message:"Invalid phone number"})});let iu=class extends Jo{constructor(){super(...arguments),this.params={firstName:"",lastName:"",email:"",phone:""},this.errors=[]}firstUpdated(){this.phoneCleave=new H2(this.phoneInput,{phone:!0,phoneRegionCode:"US",delimiter:"-"}),this.params.phone&&(this.phoneCleave.setRawValue(this.params.phone),this.updateField("phone",this.phoneInput.value)),this.writePrefilledValues(),setTimeout(()=>this.writePrefilledValues(),0)}writePrefilledValues(){["firstName","lastName","email"].forEach(t=>{var n;const e=(n=this.shadowRoot)==null?void 0:n.querySelector(`#${t}`),r=this.params[t]||"";e&&e.value!==r&&(e.value=r)})}submit(t){t.preventDefault();try{this.params=$P.parse(this.params)}catch(e){this.errors=e.errors;return}this.dispatchEvent(new CustomEvent("submit",{composed:!0,detail:this.params}))}cancel(){this.dispatchEvent(new CustomEvent("cancel"))}updateField(t,e){this.params={...this.params,[t]:e}}render(){return qd`
56
+ <div>
57
+ <iai-chat-message-assistant
58
+ content="Your contact information is required to transfer to a live agent."
59
+ ></iai-chat-message-assistant>
60
+
61
+ <form
62
+ @submit=${this.submit}
63
+ class="mt-4"
64
+ autocomplete="off"
68
65
  >
69
- <iai-chat-open-chat-button
70
- .options=${this.cleanOptions}
71
- .isChatWindowOpen=${this.isOpen}
72
- @toggle-chat=${this.toggleChat}
73
- />
66
+ <div class="mb-4">
67
+ <label for="firstName">First Name</label>
68
+ <input
69
+ type="text"
70
+ id="firstName"
71
+ name="firstName"
72
+ .value=${cv(this.params.firstName||"")}
73
+ autocomplete="off"
74
+ @input=${t=>this.updateField("firstName",t.target.value)}
75
+ >
76
+ </div>
77
+
78
+ <div class="mb-4">
79
+ <label for="lastName">Last Name</label>
80
+ <input
81
+ type="text"
82
+ id="lastName"
83
+ name="lastName"
84
+ .value=${cv(this.params.lastName||"")}
85
+ autocomplete="off"
86
+ @input=${t=>this.updateField("lastName",t.target.value)}
87
+ >
88
+ </div>
89
+
90
+ <div class="mb-4">
91
+ <label for="email">Email</label>
92
+ <input
93
+ type="text"
94
+ id="email"
95
+ name="email"
96
+ .value=${cv(this.params.email||"")}
97
+ autocomplete="off"
98
+ @input=${t=>this.updateField("email",t.target.value)}
99
+ >
100
+ </div>
101
+
102
+ <div class="mb-4">
103
+ <label for="phone">Phone Number</label>
104
+ <input
105
+ type="text"
106
+ id="phone"
107
+ name="phone"
108
+ .value=${this.params.phone||""}
109
+ @input=${()=>setTimeout(()=>this.updateField("phone",this.phoneCleave.properties.result),100)}
110
+ >
111
+ </div>
112
+
113
+ ${wO(this.errors.length,()=>qd`
114
+ <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4" role="alert">
115
+ <ul>
116
+ ${this.errors.map(t=>qd`
117
+ <li>${t.message}</li>
118
+ `)}
119
+ </ul>
120
+ </div>
121
+ `)}
122
+
123
+ <button
124
+ type="submit"
125
+ class="btn-primary"
126
+ .disabled=${!this.params.firstName||!this.params.lastName||!this.params.email||!this.params.phone}
127
+ >
128
+ Submit
129
+ </button>
130
+
131
+ <button
132
+ type="button"
133
+ @click=${this.cancel}
134
+ class="btn-secondary"
135
+ >
136
+ Cancel
137
+ </button>
138
+ </form>
139
+ </div>
140
+ `}};iu.styles=[x0],ef([m0({type:Object})],iu.prototype,"params",2),ef([fO()],iu.prototype,"errors",2),ef([pO("#phone")],iu.prototype,"phoneInput",2),iu=ef([v0("any-contact-form")],iu);var TP=Object.defineProperty,EP=Object.getOwnPropertyDescriptor,CP=(t,e,r,n)=>{for(var i=n>1?void 0:n?EP(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&TP(e,r,i),i};let gv=class extends Jo{transfer(){this.dispatchEvent(new CustomEvent("transfer"))}cancel(){this.dispatchEvent(new CustomEvent("cancel"))}render(){return qd`
141
+ <div class="my-4">
142
+ <strong>Would you like to transfer to an agent?</strong>
143
+ <div>
144
+ <button class="btn-primary" @click=${this.transfer}>Transfer</button>
145
+ <button class="btn-secondary" @click=${this.cancel}>Cancel</button>
74
146
  </div>
75
147
  </div>
76
- `}toggleChat(){this.isOpen=!this.isOpen,this.onResizeHandler()}};We.styles=[Ee],Nt([J({type:Object})],We.prototype,"options",2),Nt([it()],We.prototype,"isOpen",2),Nt([Tn("iai-chat")],We.prototype,"chatWindow",2),Nt([$s.debounce(250)],We.prototype,"onResizeHandler",2),We=Nt([Ce("iai-chat-popup")],We);const Es="https://ai-dev.anyonehome.xyz";async function Ir(s,e={}){return await(await fetch(`${Es}/threads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assistantId:s,params:e})})).json()}async function Mr(s,e){return await(await fetch(`${Es}/threads/${s}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e})})).json()}async function Pr(s,e,t,i=!1){return await(await fetch(`${Es}/threads/${s}/functions/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:t,rerunLLM:i})})).json()}function Nr(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}class jr{constructor(e,t={}){this._assistantId="",this._params={},this._simulateDelays=!1,this._threadId="",this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.onStorageEvent=o=>{var c;const[l,h,p]=((c=o.key)==null?void 0:c.split("-"))||[];if(!(l!=="iaiChat"||h!==this._historyKey))switch(p){case"messageHistory":this.onMessageHistoryStorageEvent(o);break;case"threadId":this.setThreadId(JSON.parse(o.newValue||""),!0);break;case"typing":this.setTyping(JSON.parse(o.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(o.newValue||"false"),!0);break}},this._assistantId=e;const{params:i={},events:n,simulateDelays:r=!1,historyKey:a="main"}=t;if(this._params=i,this._simulateDelays=r,this._historyKey=a,this._emitter=Nr(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),a){const o=this.storageGet("messageHistory");o&&(this._messages=o);const c=this.storageGet("threadId");c&&this.setThreadId(c,!0);const l=this.storageGet("typing");l&&this.setTyping(l,!0);const h=this.storageGet("inputDisabled");h&&this.setInputDisabled(h,!0),window.addEventListener("storage",this.onStorageEvent)}n&&Object.entries(n).forEach(([o,c])=>{this._emitter.on(o,c)})}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const t=JSON.parse(e.newValue),i=this._messages.map(r=>r.id),n=t.map(r=>r.id);this._messages.forEach(r=>{n.includes(r.id)||this._emitter.emit("messageRemoved",r.id)}),t.forEach(r=>{i.includes(r.id)||this._emitter.emit("message",r)}),this._messages=t}reset(){this._messages=[],this.setTyping(!1),this.setInputDisabled(!1),this.storageRemoveAll(),this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this._emitter.emit("destroy")}async startChat(){if(this.chatStarted)return;const{id:e}=await Ir(this.assistantId,this.params);this.setThreadId(e)}addMessage(e){const t={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(t),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",t),t}removeMessage(e){this._messages=this._messages.filter(t=>t.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e)}async respondToFunctionCall(e,t,i){this.simulateDelay(1800).then(()=>this.setTyping(!0));const n=this.simulateDelay(2e3);await this.insertMessagesWithSimulatedDelays(Promise.all([Pr(this.threadId,e,t,i),n]).then(([r])=>r))}async sendUserMessage(e){try{this.addMessage({id:Math.random().toString(36).substring(7),role:"user",content:e}),this.simulateDelay(1800).then(()=>this.setTyping(!0));const t=this.simulateDelay(4800);this.chatStarted||await this.startChat();const{messages:i,functions:n}=await this.insertMessagesWithSimulatedDelays(Promise.all([Mr(this.threadId,e),t]).then(([r])=>r));return{messages:i,functions:n}}catch(t){throw console.error(t),new Error("There was an error sending the message")}}setThreadId(e,t=!1){this._threadId=e,t||this.storageSet("threadId",e)}setTyping(e,t=!1){this.isTyping=e,this._emitter.emit("typing",e),t||this.storageSet("typing",e)}setInputDisabled(e,t=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),t||this.storageSet("inputDisabled",e)}async insertMessagesWithSimulatedDelays(e){const t=await e;if(t.error)throw new Error(t.message);const{messages:i,functions:n}=t;return await Promise.all(i.map(async(r,a)=>(await this.simulateDelay(1e3*a),this.addMessage(r)))),this.setTyping(!1),n.forEach(r=>this._emitter.emit("functionCall",r)),{messages:i,functions:n}}simulateDelay(e){return this._simulateDelays?new Promise(t=>setTimeout(t,e)):Promise.resolve()}get assistantId(){return this._assistantId}get params(){return this._params}get threadId(){return this._threadId}get messages(){return this._messages}get chatStarted(){return!!this._threadId}storageSet(e,t){this._historyKey&&localStorage.setItem(`iaiChat-${this._historyKey}-${e}`,JSON.stringify(t))}storageGet(e){if(!this._historyKey)return null;const t=localStorage.getItem(`iaiChat-${this._historyKey}-${e}`);return t?JSON.parse(t):null}storageRemove(e){localStorage.removeItem(`iaiChat-${this._historyKey}-${e}`)}storageRemoveAll(){this._historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this._historyKey}-`)&&localStorage.removeItem(e)})}}function Rr(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}/**
148
+ `}};gv.styles=[x0],gv=CP([v0("any-transfer-confirmation")],gv);var RP=Object.defineProperty,xP=(t,e,r)=>e in t?RP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hr=(t,e,r)=>(xP(t,typeof e!="symbol"?e+"":e,r),r),IP=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},A0=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},yv=(t,e,r)=>(IP(t,e,"access private method"),r);/**
77
149
  * @license
78
- * Copyright 2021 Google LLC
150
+ * Copyright 2019 Google LLC
79
151
  * SPDX-License-Identifier: BSD-3-Clause
80
- */function ct(s,e,t){return s?e(s):t==null?void 0:t(s)}/**
152
+ */const tf=globalThis,bv=tf.ShadowRoot&&(tf.ShadyCSS===void 0||tf.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,wv=Symbol(),O0=new WeakMap;let P0=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==wv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(bv&&t===void 0){const r=e!==void 0&&e.length===1;r&&(t=O0.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&O0.set(e,t))}return t}toString(){return this.cssText}};const AP=t=>new P0(typeof t=="string"?t:t+"",void 0,wv),ba=(t,...e)=>{const r=t.length===1?t[0]:e.reduce((n,i,a)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[a+1],t[0]);return new P0(r,t,wv)},OP=(t,e)=>{if(bv)t.adoptedStyleSheets=e.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(const r of e){const n=document.createElement("style"),i=tf.litNonce;i!==void 0&&n.setAttribute("nonce",i),n.textContent=r.cssText,t.appendChild(n)}},M0=bv?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let r="";for(const n of e.cssRules)r+=n.cssText;return AP(r)})(t):t;/**
153
+ * @license
154
+ * Copyright 2017 Google LLC
155
+ * SPDX-License-Identifier: BSD-3-Clause
156
+ */const{is:PP,defineProperty:MP,getOwnPropertyDescriptor:NP,getOwnPropertyNames:LP,getOwnPropertySymbols:DP,getPrototypeOf:jP}=Object,au=globalThis,N0=au.trustedTypes,UP=N0?N0.emptyScript:"",L0=au.reactiveElementPolyfillSupport,Bl=(t,e)=>t,rf={toAttribute(t,e){switch(e){case Boolean:t=t?UP:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=t!==null;break;case Number:r=t===null?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch{r=null}}return r}},_v=(t,e)=>!PP(t,e),D0={attribute:!0,type:String,converter:rf,reflect:!1,hasChanged:_v};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),au.litPropertyMetadata??(au.litPropertyMetadata=new WeakMap);class su extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,r=D0){if(r.state&&(r.attribute=!1),this._$Ei(),this.elementProperties.set(e,r),!r.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(e,n,r);i!==void 0&&MP(this.prototype,e,i)}}static getPropertyDescriptor(e,r,n){const{get:i,set:a}=NP(this.prototype,e)??{get(){return this[r]},set(s){this[r]=s}};return{get(){return i==null?void 0:i.call(this)},set(s){const o=i==null?void 0:i.call(this);a.call(this,s),this.requestUpdate(e,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??D0}static _$Ei(){if(this.hasOwnProperty(Bl("elementProperties")))return;const e=jP(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Bl("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Bl("properties"))){const r=this.properties,n=[...LP(r),...DP(r)];for(const i of n)this.createProperty(i,r[i])}const e=this[Symbol.metadata];if(e!==null){const r=litPropertyMetadata.get(e);if(r!==void 0)for(const[n,i]of r)this.elementProperties.set(n,i)}this._$Eh=new Map;for(const[r,n]of this.elementProperties){const i=this._$Eu(r,n);i!==void 0&&this._$Eh.set(i,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const r=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const i of n)r.unshift(M0(i))}else e!==void 0&&r.push(M0(e));return r}static _$Eu(e,r){const n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(r=>r(this))}addController(e){var r;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)==null||r.call(e))}removeController(e){var r;(r=this._$EO)==null||r.delete(e)}_$E_(){const e=new Map,r=this.constructor.elementProperties;for(const n of r.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return OP(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(r=>{var n;return(n=r.hostConnected)==null?void 0:n.call(r)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(r=>{var n;return(n=r.hostDisconnected)==null?void 0:n.call(r)})}attributeChangedCallback(e,r,n){this._$AK(e,n)}_$EC(e,r){var n;const i=this.constructor.elementProperties.get(e),a=this.constructor._$Eu(e,i);if(a!==void 0&&i.reflect===!0){const s=(((n=i.converter)==null?void 0:n.toAttribute)!==void 0?i.converter:rf).toAttribute(r,i.type);this._$Em=e,s==null?this.removeAttribute(a):this.setAttribute(a,s),this._$Em=null}}_$AK(e,r){var n;const i=this.constructor,a=i._$Eh.get(e);if(a!==void 0&&this._$Em!==a){const s=i.getPropertyOptions(a),o=typeof s.converter=="function"?{fromAttribute:s.converter}:((n=s.converter)==null?void 0:n.fromAttribute)!==void 0?s.converter:rf;this._$Em=a,this[a]=o.fromAttribute(r,s.type),this._$Em=null}}requestUpdate(e,r,n){if(e!==void 0){if(n??(n=this.constructor.getPropertyOptions(e)),!(n.hasChanged??_v)(this[e],r))return;this.P(e,r,n)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,r,n){this._$AL.has(e)||this._$AL.set(e,r),n.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[a,s]of this._$Ep)this[a]=s;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[a,s]of i)s.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.P(a,this[a],s)}let r=!1;const n=this._$AL;try{r=this.shouldUpdate(n),r?(this.willUpdate(n),(e=this._$EO)==null||e.forEach(i=>{var a;return(a=i.hostUpdate)==null?void 0:a.call(i)}),this.update(n)):this._$EU()}catch(i){throw r=!1,this._$EU(),i}r&&this._$AE(n)}willUpdate(e){}_$AE(e){var r;(r=this._$EO)==null||r.forEach(n=>{var i;return(i=n.hostUpdated)==null?void 0:i.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(r=>this._$EC(r,this[r]))),this._$EU()}updated(e){}firstUpdated(e){}}su.elementStyles=[],su.shadowRootOptions={mode:"open"},su[Bl("elementProperties")]=new Map,su[Bl("finalized")]=new Map,L0==null||L0({ReactiveElement:su}),(au.reactiveElementVersions??(au.reactiveElementVersions=[])).push("2.0.4");/**
157
+ * @license
158
+ * Copyright 2017 Google LLC
159
+ * SPDX-License-Identifier: BSD-3-Clause
160
+ */const nf=globalThis,af=nf.trustedTypes,j0=af?af.createPolicy("lit-html",{createHTML:t=>t}):void 0,U0="$lit$",rs=`lit$${(Math.random()+"").slice(9)}$`,F0="?"+rs,FP=`<${F0}>`,Gs=document,sf=()=>Gs.createComment(""),zl=t=>t===null||typeof t!="object"&&typeof t!="function",B0=Array.isArray,BP=t=>B0(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",kv=`[
161
+ \f\r]`,Hl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,z0=/-->/g,H0=/>/g,Ks=RegExp(`>|${kv}(?:([^\\s"'>=/]+)(${kv}*=${kv}*(?:[^
162
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),q0=/'/g,V0=/"/g,W0=/^(?:script|style|textarea|title)$/i,ns=Symbol.for("lit-noChange"),Yr=Symbol.for("lit-nothing"),Z0=new WeakMap,Js=Gs.createTreeWalker(Gs,129);function G0(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return j0!==void 0?j0.createHTML(e):e}const zP=(t,e)=>{const r=t.length-1,n=[];let i,a=e===2?"<svg>":"",s=Hl;for(let o=0;o<r;o++){const u=t[o];let l,c,d=-1,f=0;for(;f<u.length&&(s.lastIndex=f,c=s.exec(u),c!==null);)f=s.lastIndex,s===Hl?c[1]==="!--"?s=z0:c[1]!==void 0?s=H0:c[2]!==void 0?(W0.test(c[2])&&(i=RegExp("</"+c[2],"g")),s=Ks):c[3]!==void 0&&(s=Ks):s===Ks?c[0]===">"?(s=i??Hl,d=-1):c[1]===void 0?d=-2:(d=s.lastIndex-c[2].length,l=c[1],s=c[3]===void 0?Ks:c[3]==='"'?V0:q0):s===V0||s===q0?s=Ks:s===z0||s===H0?s=Hl:(s=Ks,i=void 0);const m=s===Ks&&t[o+1].startsWith("/>")?" ":"";a+=s===Hl?u+FP:d>=0?(n.push(l),u.slice(0,d)+U0+u.slice(d)+rs+m):u+rs+(d===-2?o:m)}return[G0(t,a+(t[r]||"<?>")+(e===2?"</svg>":"")),n]};let Sv=class x2{constructor({strings:e,_$litType$:r},n){let i;this.parts=[];let a=0,s=0;const o=e.length-1,u=this.parts,[l,c]=zP(e,r);if(this.el=x2.createElement(l,n),Js.currentNode=this.el.content,r===2){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=Js.nextNode())!==null&&u.length<o;){if(i.nodeType===1){if(i.hasAttributes())for(const d of i.getAttributeNames())if(d.endsWith(U0)){const f=c[s++],m=i.getAttribute(d).split(rs),b=/([.?@])?(.*)/.exec(f);u.push({type:1,index:a,name:b[2],strings:m,ctor:b[1]==="."?qP:b[1]==="?"?VP:b[1]==="@"?WP:of}),i.removeAttribute(d)}else d.startsWith(rs)&&(u.push({type:6,index:a}),i.removeAttribute(d));if(W0.test(i.tagName)){const d=i.textContent.split(rs),f=d.length-1;if(f>0){i.textContent=af?af.emptyScript:"";for(let m=0;m<f;m++)i.append(d[m],sf()),Js.nextNode(),u.push({type:2,index:++a});i.append(d[f],sf())}}}else if(i.nodeType===8)if(i.data===F0)u.push({type:2,index:a});else{let d=-1;for(;(d=i.data.indexOf(rs,d+1))!==-1;)u.push({type:7,index:a}),d+=rs.length-1}a++}}static createElement(e,r){const n=Gs.createElement("template");return n.innerHTML=e,n}};function ou(t,e,r=t,n){var i,a;if(e===ns)return e;let s=n!==void 0?(i=r._$Co)==null?void 0:i[n]:r._$Cl;const o=zl(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(t),s._$AT(t,r,n)),n!==void 0?(r._$Co??(r._$Co=[]))[n]=s:r._$Cl=s),s!==void 0&&(e=ou(t,s._$AS(t,e.values),s,n)),e}let HP=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,n=((t==null?void 0:t.creationScope)??Gs).importNode(e,!0);Js.currentNode=n;let i=Js.nextNode(),a=0,s=0,o=r[0];for(;o!==void 0;){if(a===o.index){let u;o.type===2?u=new K0(i,i.nextSibling,this,t):o.type===1?u=new o.ctor(i,o.name,o.strings,this,t):o.type===6&&(u=new ZP(i,this,t)),this._$AV.push(u),o=r[++s]}a!==(o==null?void 0:o.index)&&(i=Js.nextNode(),a++)}return Js.currentNode=Gs,n}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},K0=class I2{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,r,n,i){this.type=2,this._$AH=Yr,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=n,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=ou(this,e,r),zl(e)?e===Yr||e==null||e===""?(this._$AH!==Yr&&this._$AR(),this._$AH=Yr):e!==this._$AH&&e!==ns&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):BP(e)?this.k(e):this._(e)}S(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}_(e){this._$AH!==Yr&&zl(this._$AH)?this._$AA.nextSibling.data=e:this.T(Gs.createTextNode(e)),this._$AH=e}$(e){var r;const{values:n,_$litType$:i}=e,a=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Sv.createElement(G0(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===a)this._$AH.p(n);else{const s=new HP(a,this),o=s.u(this.options);s.p(n),this.T(o),this._$AH=s}}_$AC(e){let r=Z0.get(e.strings);return r===void 0&&Z0.set(e.strings,r=new Sv(e)),r}k(e){B0(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let n,i=0;for(const a of e)i===r.length?r.push(n=new I2(this.S(sf()),this.S(sf()),this,this.options)):n=r[i],n._$AI(a),i++;i<r.length&&(this._$AR(n&&n._$AB.nextSibling,i),r.length=i)}_$AR(e=this._$AA.nextSibling,r){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,r);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var r;this._$AM===void 0&&(this._$Cv=e,(r=this._$AP)==null||r.call(this,e))}},of=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,n,i){this.type=1,this._$AH=Yr,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Yr}_$AI(t,e=this,r,n){const i=this.strings;let a=!1;if(i===void 0)t=ou(this,t,e,0),a=!zl(t)||t!==this._$AH&&t!==ns,a&&(this._$AH=t);else{const s=t;let o,u;for(t=i[0],o=0;o<i.length-1;o++)u=ou(this,s[r+o],e,o),u===ns&&(u=this._$AH[o]),a||(a=!zl(u)||u!==this._$AH[o]),u===Yr?t=Yr:t!==Yr&&(t+=(u??"")+i[o+1]),this._$AH[o]=u}a&&!n&&this.j(t)}j(t){t===Yr?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},qP=class extends of{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Yr?void 0:t}},VP=class extends of{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Yr)}},WP=class extends of{constructor(t,e,r,n,i){super(t,e,r,n,i),this.type=5}_$AI(t,e=this){if((t=ou(this,t,e,0)??Yr)===ns)return;const r=this._$AH,n=t===Yr&&r!==Yr||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,i=t!==Yr&&(r===Yr||n);n&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},ZP=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){ou(this,t)}};const J0=nf.litHtmlPolyfillSupport;J0==null||J0(Sv,K0),(nf.litHtmlVersions??(nf.litHtmlVersions=[])).push("3.1.2");/**
163
+ * @license
164
+ * Copyright 2017 Google LLC
165
+ * SPDX-License-Identifier: BSD-3-Clause
166
+ */const uf=globalThis,lf=uf.trustedTypes,Y0=lf?lf.createPolicy("lit-html",{createHTML:t=>t}):void 0,Q0="$lit$",is=`lit$${(Math.random()+"").slice(9)}$`,X0="?"+is,GP=`<${X0}>`,Ys=document,ql=()=>Ys.createComment(""),Vl=t=>t===null||typeof t!="object"&&typeof t!="function",e_=Array.isArray,KP=t=>e_(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",$v=`[
167
+ \f\r]`,Wl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,t_=/-->/g,r_=/>/g,Qs=RegExp(`>|${$v}(?:([^\\s"'>=/]+)(${$v}*=${$v}*(?:[^
168
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),n_=/'/g,i_=/"/g,a_=/^(?:script|style|textarea|title)$/i,JP=t=>(e,...r)=>({_$litType$:t,strings:e,values:r}),ar=JP(1),uu=Symbol.for("lit-noChange"),cn=Symbol.for("lit-nothing"),s_=new WeakMap,Xs=Ys.createTreeWalker(Ys,129);function o_(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Y0!==void 0?Y0.createHTML(e):e}const YP=(t,e)=>{const r=t.length-1,n=[];let i,a=e===2?"<svg>":"",s=Wl;for(let o=0;o<r;o++){const u=t[o];let l,c,d=-1,f=0;for(;f<u.length&&(s.lastIndex=f,c=s.exec(u),c!==null);)f=s.lastIndex,s===Wl?c[1]==="!--"?s=t_:c[1]!==void 0?s=r_:c[2]!==void 0?(a_.test(c[2])&&(i=RegExp("</"+c[2],"g")),s=Qs):c[3]!==void 0&&(s=Qs):s===Qs?c[0]===">"?(s=i??Wl,d=-1):c[1]===void 0?d=-2:(d=s.lastIndex-c[2].length,l=c[1],s=c[3]===void 0?Qs:c[3]==='"'?i_:n_):s===i_||s===n_?s=Qs:s===t_||s===r_?s=Wl:(s=Qs,i=void 0);const m=s===Qs&&t[o+1].startsWith("/>")?" ":"";a+=s===Wl?u+GP:d>=0?(n.push(l),u.slice(0,d)+Q0+u.slice(d)+is+m):u+is+(d===-2?o:m)}return[o_(t,a+(t[r]||"<?>")+(e===2?"</svg>":"")),n]};let Tv=class A2{constructor({strings:e,_$litType$:r},n){let i;this.parts=[];let a=0,s=0;const o=e.length-1,u=this.parts,[l,c]=YP(e,r);if(this.el=A2.createElement(l,n),Xs.currentNode=this.el.content,r===2){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=Xs.nextNode())!==null&&u.length<o;){if(i.nodeType===1){if(i.hasAttributes())for(const d of i.getAttributeNames())if(d.endsWith(Q0)){const f=c[s++],m=i.getAttribute(d).split(is),b=/([.?@])?(.*)/.exec(f);u.push({type:1,index:a,name:b[2],strings:m,ctor:b[1]==="."?XP:b[1]==="?"?eM:b[1]==="@"?tM:cf}),i.removeAttribute(d)}else d.startsWith(is)&&(u.push({type:6,index:a}),i.removeAttribute(d));if(a_.test(i.tagName)){const d=i.textContent.split(is),f=d.length-1;if(f>0){i.textContent=lf?lf.emptyScript:"";for(let m=0;m<f;m++)i.append(d[m],ql()),Xs.nextNode(),u.push({type:2,index:++a});i.append(d[f],ql())}}}else if(i.nodeType===8)if(i.data===X0)u.push({type:2,index:a});else{let d=-1;for(;(d=i.data.indexOf(is,d+1))!==-1;)u.push({type:7,index:a}),d+=is.length-1}a++}}static createElement(e,r){const n=Ys.createElement("template");return n.innerHTML=e,n}};function lu(t,e,r=t,n){var i,a;if(e===uu)return e;let s=n!==void 0?(i=r._$Co)==null?void 0:i[n]:r._$Cl;const o=Vl(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(t),s._$AT(t,r,n)),n!==void 0?(r._$Co??(r._$Co=[]))[n]=s:r._$Cl=s),s!==void 0&&(e=lu(t,s._$AS(t,e.values),s,n)),e}let QP=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,n=((t==null?void 0:t.creationScope)??Ys).importNode(e,!0);Xs.currentNode=n;let i=Xs.nextNode(),a=0,s=0,o=r[0];for(;o!==void 0;){if(a===o.index){let u;o.type===2?u=new Ev(i,i.nextSibling,this,t):o.type===1?u=new o.ctor(i,o.name,o.strings,this,t):o.type===6&&(u=new rM(i,this,t)),this._$AV.push(u),o=r[++s]}a!==(o==null?void 0:o.index)&&(i=Xs.nextNode(),a++)}return Xs.currentNode=Ys,n}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},Ev=class O2{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,r,n,i){this.type=2,this._$AH=cn,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=n,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=lu(this,e,r),Vl(e)?e===cn||e==null||e===""?(this._$AH!==cn&&this._$AR(),this._$AH=cn):e!==this._$AH&&e!==uu&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):KP(e)?this.k(e):this._(e)}S(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}_(e){this._$AH!==cn&&Vl(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ys.createTextNode(e)),this._$AH=e}$(e){var r;const{values:n,_$litType$:i}=e,a=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Tv.createElement(o_(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===a)this._$AH.p(n);else{const s=new QP(a,this),o=s.u(this.options);s.p(n),this.T(o),this._$AH=s}}_$AC(e){let r=s_.get(e.strings);return r===void 0&&s_.set(e.strings,r=new Tv(e)),r}k(e){e_(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let n,i=0;for(const a of e)i===r.length?r.push(n=new O2(this.S(ql()),this.S(ql()),this,this.options)):n=r[i],n._$AI(a),i++;i<r.length&&(this._$AR(n&&n._$AB.nextSibling,i),r.length=i)}_$AR(e=this._$AA.nextSibling,r){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,r);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var r;this._$AM===void 0&&(this._$Cv=e,(r=this._$AP)==null||r.call(this,e))}},cf=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,n,i){this.type=1,this._$AH=cn,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=cn}_$AI(t,e=this,r,n){const i=this.strings;let a=!1;if(i===void 0)t=lu(this,t,e,0),a=!Vl(t)||t!==this._$AH&&t!==uu,a&&(this._$AH=t);else{const s=t;let o,u;for(t=i[0],o=0;o<i.length-1;o++)u=lu(this,s[r+o],e,o),u===uu&&(u=this._$AH[o]),a||(a=!Vl(u)||u!==this._$AH[o]),u===cn?t=cn:t!==cn&&(t+=(u??"")+i[o+1]),this._$AH[o]=u}a&&!n&&this.j(t)}j(t){t===cn?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},XP=class extends cf{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===cn?void 0:t}},eM=class extends cf{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==cn)}},tM=class extends cf{constructor(t,e,r,n,i){super(t,e,r,n,i),this.type=5}_$AI(t,e=this){if((t=lu(this,t,e,0)??cn)===uu)return;const r=this._$AH,n=t===cn&&r!==cn||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,i=t!==cn&&(r===cn||n);n&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},rM=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){lu(this,t)}};const u_=uf.litHtmlPolyfillSupport;u_==null||u_(Tv,Ev),(uf.litHtmlVersions??(uf.litHtmlVersions=[])).push("3.1.2");const nM=(t,e,r)=>{const n=(r==null?void 0:r.renderBefore)??e;let i=n._$litPart$;if(i===void 0){const a=(r==null?void 0:r.renderBefore)??null;n._$litPart$=i=new Ev(e.insertBefore(ql(),a),a,void 0,r??{})}return i._$AI(t),i};/**
169
+ * @license
170
+ * Copyright 2017 Google LLC
171
+ * SPDX-License-Identifier: BSD-3-Clause
172
+ */let Ln=class extends su{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=nM(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return uu}};var l_;Ln._$litElement$=!0,Ln.finalized=!0,(l_=globalThis.litElementHydrateSupport)==null||l_.call(globalThis,{LitElement:Ln});const c_=globalThis.litElementPolyfillSupport;c_==null||c_({LitElement:Ln}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.4");/**
173
+ * @license
174
+ * Copyright 2017 Google LLC
175
+ * SPDX-License-Identifier: BSD-3-Clause
176
+ */const Wi=t=>(e,r)=>{r!==void 0?r.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)};/**
177
+ * @license
178
+ * Copyright 2017 Google LLC
179
+ * SPDX-License-Identifier: BSD-3-Clause
180
+ */const iM={attribute:!0,type:String,converter:rf,reflect:!1,hasChanged:_v},aM=(t=iM,e,r)=>{const{kind:n,metadata:i}=r;let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),a.set(r.name,t),n==="accessor"){const{name:s}=r;return{set(o){const u=e.get.call(this);e.set.call(this,o),this.requestUpdate(s,u,t)},init(o){return o!==void 0&&this.P(s,void 0,t),o}}}if(n==="setter"){const{name:s}=r;return function(o){const u=this[s];e.call(this,o),this.requestUpdate(s,u,t)}}throw Error("Unsupported decorator location: "+n)};function jr(t){return(e,r)=>typeof r=="object"?aM(t,e,r):((n,i,a)=>{const s=i.hasOwnProperty(a);return i.constructor.createProperty(a,s?{...n,wrapped:!0}:n),s?Object.getOwnPropertyDescriptor(i,a):void 0})(t,e,r)}/**
181
+ * @license
182
+ * Copyright 2017 Google LLC
183
+ * SPDX-License-Identifier: BSD-3-Clause
184
+ */function eo(t){return jr({...t,state:!0,attribute:!1})}/**
185
+ * @license
186
+ * Copyright 2017 Google LLC
187
+ * SPDX-License-Identifier: BSD-3-Clause
188
+ */const sM=(t,e,r)=>(r.configurable=!0,r.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(t,e,r),r);/**
189
+ * @license
190
+ * Copyright 2017 Google LLC
191
+ * SPDX-License-Identifier: BSD-3-Clause
192
+ */function df(t,e){return(r,n,i)=>{const a=s=>{var o;return((o=s.renderRoot)==null?void 0:o.querySelector(t))??null};return sM(r,n,{get(){return a(this)}})}}/**
193
+ * @license
194
+ * Copyright 2017 Google LLC
195
+ * SPDX-License-Identifier: BSD-3-Clause
196
+ */const ff=globalThis,hf=ff.trustedTypes,d_=hf?hf.createPolicy("lit-html",{createHTML:t=>t}):void 0,Cv="$lit$",wa=`lit$${Math.random().toFixed(9).slice(2)}$`,Rv="?"+wa,oM=`<${Rv}>`,to=document,pf=()=>to.createComment(""),Zl=t=>t===null||typeof t!="object"&&typeof t!="function",f_=Array.isArray,h_=t=>f_(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",xv=`[
197
+ \f\r]`,Gl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,p_=/-->/g,v_=/>/g,ro=RegExp(`>|${xv}(?:([^\\s"'>=/]+)(${xv}*=${xv}*(?:[^
198
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),m_=/'/g,g_=/"/g,y_=/^(?:script|style|textarea|title)$/i,cu=Symbol.for("lit-noChange"),dn=Symbol.for("lit-nothing"),b_=new WeakMap,no=to.createTreeWalker(to,129);function w_(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return d_!==void 0?d_.createHTML(e):e}const __=(t,e)=>{const r=t.length-1,n=[];let i,a=e===2?"<svg>":"",s=Gl;for(let o=0;o<r;o++){const u=t[o];let l,c,d=-1,f=0;for(;f<u.length&&(s.lastIndex=f,c=s.exec(u),c!==null);)f=s.lastIndex,s===Gl?c[1]==="!--"?s=p_:c[1]!==void 0?s=v_:c[2]!==void 0?(y_.test(c[2])&&(i=RegExp("</"+c[2],"g")),s=ro):c[3]!==void 0&&(s=ro):s===ro?c[0]===">"?(s=i??Gl,d=-1):c[1]===void 0?d=-2:(d=s.lastIndex-c[2].length,l=c[1],s=c[3]===void 0?ro:c[3]==='"'?g_:m_):s===g_||s===m_?s=ro:s===p_||s===v_?s=Gl:(s=ro,i=void 0);const m=s===ro&&t[o+1].startsWith("/>")?" ":"";a+=s===Gl?u+oM:d>=0?(n.push(l),u.slice(0,d)+Cv+u.slice(d)+wa+m):u+wa+(d===-2?o:m)}return[w_(t,a+(t[r]||"<?>")+(e===2?"</svg>":"")),n]};class Kl{constructor({strings:e,_$litType$:r},n){let i;this.parts=[];let a=0,s=0;const o=e.length-1,u=this.parts,[l,c]=__(e,r);if(this.el=Kl.createElement(l,n),no.currentNode=this.el.content,r===2){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=no.nextNode())!==null&&u.length<o;){if(i.nodeType===1){if(i.hasAttributes())for(const d of i.getAttributeNames())if(d.endsWith(Cv)){const f=c[s++],m=i.getAttribute(d).split(wa),b=/([.?@])?(.*)/.exec(f);u.push({type:1,index:a,name:b[2],strings:m,ctor:b[1]==="."?S_:b[1]==="?"?$_:b[1]==="@"?T_:Jl}),i.removeAttribute(d)}else d.startsWith(wa)&&(u.push({type:6,index:a}),i.removeAttribute(d));if(y_.test(i.tagName)){const d=i.textContent.split(wa),f=d.length-1;if(f>0){i.textContent=hf?hf.emptyScript:"";for(let m=0;m<f;m++)i.append(d[m],pf()),no.nextNode(),u.push({type:2,index:++a});i.append(d[f],pf())}}}else if(i.nodeType===8)if(i.data===Rv)u.push({type:2,index:a});else{let d=-1;for(;(d=i.data.indexOf(wa,d+1))!==-1;)u.push({type:7,index:a}),d+=wa.length-1}a++}}static createElement(e,r){const n=to.createElement("template");return n.innerHTML=e,n}}function io(t,e,r=t,n){var i,a;if(e===cu)return e;let s=n!==void 0?(i=r._$Co)==null?void 0:i[n]:r._$Cl;const o=Zl(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(t),s._$AT(t,r,n)),n!==void 0?(r._$Co??(r._$Co=[]))[n]=s:r._$Cl=s),s!==void 0&&(e=io(t,s._$AS(t,e.values),s,n)),e}class k_{constructor(e,r){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:r},parts:n}=this._$AD,i=((e==null?void 0:e.creationScope)??to).importNode(r,!0);no.currentNode=i;let a=no.nextNode(),s=0,o=0,u=n[0];for(;u!==void 0;){if(s===u.index){let l;u.type===2?l=new Iv(a,a.nextSibling,this,e):u.type===1?l=new u.ctor(a,u.name,u.strings,this,e):u.type===6&&(l=new E_(a,this,e)),this._$AV.push(l),u=n[++o]}s!==(u==null?void 0:u.index)&&(a=no.nextNode(),s++)}return no.currentNode=to,i}p(e){let r=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,r),r+=n.strings.length-2):n._$AI(e[r])),r++}}let Iv=class P2{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,r,n,i){this.type=2,this._$AH=dn,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=n,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=io(this,e,r),Zl(e)?e===dn||e==null||e===""?(this._$AH!==dn&&this._$AR(),this._$AH=dn):e!==this._$AH&&e!==cu&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):h_(e)?this.k(e):this._(e)}S(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}_(e){this._$AH!==dn&&Zl(this._$AH)?this._$AA.nextSibling.data=e:this.T(to.createTextNode(e)),this._$AH=e}$(e){var r;const{values:n,_$litType$:i}=e,a=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Kl.createElement(w_(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===a)this._$AH.p(n);else{const s=new k_(a,this),o=s.u(this.options);s.p(n),this.T(o),this._$AH=s}}_$AC(e){let r=b_.get(e.strings);return r===void 0&&b_.set(e.strings,r=new Kl(e)),r}k(e){f_(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let n,i=0;for(const a of e)i===r.length?r.push(n=new P2(this.S(pf()),this.S(pf()),this,this.options)):n=r[i],n._$AI(a),i++;i<r.length&&(this._$AR(n&&n._$AB.nextSibling,i),r.length=i)}_$AR(e=this._$AA.nextSibling,r){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,r);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var r;this._$AM===void 0&&(this._$Cv=e,(r=this._$AP)==null||r.call(this,e))}};class Jl{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,r,n,i,a){this.type=1,this._$AH=dn,this._$AN=void 0,this.element=e,this.name=r,this._$AM=i,this.options=a,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=dn}_$AI(e,r=this,n,i){const a=this.strings;let s=!1;if(a===void 0)e=io(this,e,r,0),s=!Zl(e)||e!==this._$AH&&e!==cu,s&&(this._$AH=e);else{const o=e;let u,l;for(e=a[0],u=0;u<a.length-1;u++)l=io(this,o[n+u],r,u),l===cu&&(l=this._$AH[u]),s||(s=!Zl(l)||l!==this._$AH[u]),l===dn?e=dn:e!==dn&&(e+=(l??"")+a[u+1]),this._$AH[u]=l}s&&!i&&this.j(e)}j(e){e===dn?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class S_ extends Jl{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===dn?void 0:e}}class $_ extends Jl{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==dn)}}class T_ extends Jl{constructor(e,r,n,i,a){super(e,r,n,i,a),this.type=5}_$AI(e,r=this){if((e=io(this,e,r,0)??dn)===cu)return;const n=this._$AH,i=e===dn&&n!==dn||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,a=e!==dn&&(n===dn||i);i&&this.element.removeEventListener(this.name,this,n),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var r;typeof this._$AH=="function"?this._$AH.call(((r=this.options)==null?void 0:r.host)??this.element,e):this._$AH.handleEvent(e)}}class E_{constructor(e,r,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=r,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){io(this,e)}}const uM={P:Cv,A:wa,C:Rv,M:1,L:__,R:k_,D:h_,V:io,I:Iv,H:Jl,N:$_,U:T_,B:S_,F:E_},C_=ff.litHtmlPolyfillSupport;C_==null||C_(Kl,Iv),(ff.litHtmlVersions??(ff.litHtmlVersions=[])).push("3.1.3");/**
199
+ * @license
200
+ * Copyright 2017 Google LLC
201
+ * SPDX-License-Identifier: BSD-3-Clause
202
+ */const lM={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},cM=t=>(...e)=>({_$litDirective$:t,values:e});let dM=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
81
203
  * @license
82
204
  * Copyright 2020 Google LLC
83
205
  * SPDX-License-Identifier: BSD-3-Clause
84
- */const{I:Zr}=_n,Ri=()=>document.createComment(""),jt=(s,e,t)=>{var i;const n=s._$AA.parentNode,r=e===void 0?s._$AB:e._$AA;if(t===void 0){const a=n.insertBefore(Ri(),r),o=n.insertBefore(Ri(),r);t=new Zr(a,o,s,s.options)}else{const a=t._$AB.nextSibling,o=t._$AM,c=o!==s;if(c){let l;(i=t._$AQ)==null||i.call(t,s),t._$AM=s,t._$AP!==void 0&&(l=s._$AU)!==o._$AU&&t._$AP(l)}if(a!==r||c){let l=t._$AA;for(;l!==a;){const h=l.nextSibling;n.insertBefore(l,r),l=h}}}return t},Ke=(s,e,t=s)=>(s._$AI(e,t),s),Lr={},zr=(s,e=Lr)=>s._$AH=e,Dr=s=>s._$AH,Cs=s=>{var e;(e=s._$AP)==null||e.call(s,!1,!0);let t=s._$AA;const i=s._$AB.nextSibling;for(;t!==i;){const n=t.nextSibling;t.remove(),t=n}};/**
206
+ */const{I:fM}=uM,R_=()=>document.createComment(""),Yl=(t,e,r)=>{var n;const i=t._$AA.parentNode,a=e===void 0?t._$AB:e._$AA;if(r===void 0){const s=i.insertBefore(R_(),a),o=i.insertBefore(R_(),a);r=new fM(s,o,t,t.options)}else{const s=r._$AB.nextSibling,o=r._$AM,u=o!==t;if(u){let l;(n=r._$AQ)==null||n.call(r,t),r._$AM=t,r._$AP!==void 0&&(l=t._$AU)!==o._$AU&&r._$AP(l)}if(s!==a||u){let l=r._$AA;for(;l!==s;){const c=l.nextSibling;i.insertBefore(l,a),l=c}}}return r},ao=(t,e,r=t)=>(t._$AI(e,r),t),hM={},pM=(t,e=hM)=>t._$AH=e,vM=t=>t._$AH,Av=t=>{var e;(e=t._$AP)==null||e.call(t,!1,!0);let r=t._$AA;const n=t._$AB.nextSibling;for(;r!==n;){const i=r.nextSibling;r.remove(),r=i}};/**
85
207
  * @license
86
208
  * Copyright 2017 Google LLC
87
209
  * SPDX-License-Identifier: BSD-3-Clause
88
- */const Zi=(s,e,t)=>{const i=new Map;for(let n=e;n<=t;n++)i.set(s[n],n);return i},Ur=Ft(class extends Vt{constructor(s){if(super(s),s.type!==Bt.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);const n=[],r=[];let a=0;for(const o of s)n[a]=i?i(o,a):a,r[a]=t(o,a),a++;return{values:r,keys:n}}render(s,e,t){return this.dt(s,e,t).values}update(s,[e,t,i]){const n=Dr(s),{values:r,keys:a}=this.dt(e,t,i);if(!Array.isArray(n))return this.ut=a,r;const o=this.ut??(this.ut=[]),c=[];let l,h,p=0,d=n.length-1,b=0,N=r.length-1;for(;p<=d&&b<=N;)if(n[p]===null)p++;else if(n[d]===null)d--;else if(o[p]===a[b])c[b]=Ke(n[p],r[b]),p++,b++;else if(o[d]===a[N])c[N]=Ke(n[d],r[N]),d--,N--;else if(o[p]===a[N])c[N]=Ke(n[p],r[N]),jt(s,c[N+1],n[p]),p++,N--;else if(o[d]===a[b])c[b]=Ke(n[d],r[b]),jt(s,n[p],n[d]),d--,b++;else if(l===void 0&&(l=Zi(a,b,N),h=Zi(o,p,d)),l.has(o[p]))if(l.has(o[d])){const H=h.get(a[b]),ee=H!==void 0?n[H]:null;if(ee===null){const _e=jt(s,n[p]);Ke(_e,r[b]),c[b]=_e}else c[b]=Ke(ee,r[b]),jt(s,n[p],ee),n[H]=null;b++}else Cs(n[d]),d--;else Cs(n[p]),p++;for(;b<=N;){const H=jt(s,c[N+1]);Ke(H,r[b]),c[b++]=H}for(;p<=d;){const H=n[p++];H!==null&&Cs(H)}return this.ut=a,zr(s,c),ue}}),As=z`
210
+ */const x_=(t,e,r)=>{const n=new Map;for(let i=e;i<=r;i++)n.set(t[i],i);return n},Ov=cM(class extends dM{constructor(t){if(super(t),t.type!==lM.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,r){let n;r===void 0?r=e:e!==void 0&&(n=e);const i=[],a=[];let s=0;for(const o of t)i[s]=n?n(o,s):s,a[s]=r(o,s),s++;return{values:a,keys:i}}render(t,e,r){return this.dt(t,e,r).values}update(t,[e,r,n]){const i=vM(t),{values:a,keys:s}=this.dt(e,r,n);if(!Array.isArray(i))return this.ut=s,a;const o=this.ut??(this.ut=[]),u=[];let l,c,d=0,f=i.length-1,m=0,b=a.length-1;for(;d<=f&&m<=b;)if(i[d]===null)d++;else if(i[f]===null)f--;else if(o[d]===s[m])u[m]=ao(i[d],a[m]),d++,m++;else if(o[f]===s[b])u[b]=ao(i[f],a[b]),f--,b--;else if(o[d]===s[b])u[b]=ao(i[d],a[b]),Yl(t,u[b+1],i[d]),d++,b--;else if(o[f]===s[m])u[m]=ao(i[f],a[m]),Yl(t,i[d],i[f]),f--,m++;else if(l===void 0&&(l=x_(s,m,b),c=x_(o,d,f)),l.has(o[d]))if(l.has(o[f])){const A=c.get(s[m]),N=A!==void 0?i[A]:null;if(N===null){const z=Yl(t,i[d]);ao(z,a[m]),u[m]=z}else u[m]=ao(N,a[m]),Yl(t,i[d],N),i[A]=null;m++}else Av(i[f]),f--;else Av(i[d]),d++;for(;m<=b;){const A=Yl(t,u[b+1]);ao(A,a[m]),u[m++]=A}for(;d<=f;){const A=i[d++];A!==null&&Av(A)}return this.ut=s,pM(t,u),cu}}),Zi=ba`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-\\[-1px\\]{bottom:-1px}.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-12{top:3rem}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.m-0{margin:0}.m-0\\.5{margin:.125rem}.m-2{margin:.5rem}.m-4{margin:1rem}.m-8{margin:2rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-8{margin-left:2rem;margin-right:2rem}.mx-auto{margin-left:auto;margin-right:auto}.my-auto{margin-top:auto;margin-bottom:auto}.mb-1{margin-bottom:.25rem}.mb-\\[-8px\\]{margin-bottom:-8px}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-20{margin-left:5rem}.mr-2{margin-right:.5rem}.mr-20{margin-right:5rem}.mt-1{margin-top:.25rem}.mt-4{margin-top:1rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.hidden{display:none}.h-0{height:0px}.h-12{height:3rem}.h-2{height:.5rem}.h-2\\.5{height:.625rem}.h-3\\/5{height:60%}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-9{height:2.25rem}.h-dvh{height:100dvh}.h-full{height:100%}.max-h-20{max-height:5rem}.max-h-\\[90vh\\]{max-height:90vh}.w-0{width:0px}.w-2{width:.5rem}.w-2\\.5{width:.625rem}.w-3\\/5{width:60%}.w-4{width:1rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-9{width:2.25rem}.w-dvw{width:100dvw}.max-w-\\[350px\\]{max-width:350px}.max-w-\\[90vw\\]{max-width:90vw}.flex-1{flex:1 1 0%}.flex-grow{flex-grow:1}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.resize{resize:both}.snap-x{scroll-snap-type:x var(--tw-scroll-snap-strictness)}.snap-mandatory{--tw-scroll-snap-strictness: mandatory}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.whitespace-pre-wrap{white-space:pre-wrap}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-b-lg{border-bottom-right-radius:.5rem;border-bottom-left-radius:.5rem}.rounded-t-lg{border-top-left-radius:.5rem;border-top-right-radius:.5rem}.border{border-width:1px}.border-x-8{border-left-width:8px;border-right-width:8px}.border-t-8{border-top-width:8px}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity))}.border-x-transparent{border-left-color:transparent;border-right-color:transparent}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity))}.bg-gray-600{--tw-bg-opacity: 1;background-color:rgb(75 85 99 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-opacity-50{--tw-bg-opacity: .5}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-white{--tw-gradient-from: #fff var(--tw-gradient-from-position);--tw-gradient-to: rgb(255 255 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-transparent{--tw-gradient-to: transparent var(--tw-gradient-to-position)}.p-0{padding:0}.p-2{padding:.5rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.pb-2{padding-bottom:.5rem}.pl-3{padding-left:.75rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-4{padding-top:1rem}.text-center{text-align:center}.text-right{text-align:right}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-semibold{font-weight:600}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.opacity-80{opacity:.8}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:host{font-size:16px;line-height:1.2;text-align:left;--iai-chat-i-primary-color: var(--iai-chat-primary-color, #0B64F4);--iai-chat-i-text-color: var(--iai-chat-text-color, #FFF);--iai-chat-i-link-color: var(--iai-chat-link-color, var(--iai-chat-i-primary-color));--iai-chat-i-header-bg: var(--iai-chat-header-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-header-fg: var(--iai-chat-header-text-color, var(--iai-chat-i-text-color));--iai-chat-i-button-bg: var(--iai-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-button-fg: var(--iai-chat-button-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-user-bg: var(--iai-chat-messages-user-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-message-user-fg: var(--iai-chat-messages-user-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-assistant-bg: var(--iai-chat-messages-assistant-background-color, #6B7280);--iai-chat-i-message-assistant-fg: var(--iai-chat-messages-assistant-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-assistant-rating-active: var(--iai-chat-messages-assistant-rating-active-color, var(--iai-chat-i-primary-color));--iai-chat-i-ocb-bg: var(--iai-chat-open-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-ocb-fg: var(--iai-chat-open-chat-button-icon-color, var(--iai-chat-i-text-color));--iai-chat-i-iframe-modal-header-bg: var(--iai-chat-iframe-modal-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-iframe-modal-header-fg: var(--iai-chat-iframe-modal-text-color, var(--iai-chat-i-text-color))}h1{font-size:1.5em}h2{font-size:1.17em}h3{font-size:1em}ol,ul{display:flex;flex-direction:column;padding:0;margin-left:20px;gap:8px}ol{list-style-type:decimal}a{color:var(--iai-chat-i-link-color);text-decoration:underline}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.disabled\\:bg-gray-200:disabled{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity))}.disabled\\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\\:mx-8{margin-left:2rem;margin-right:2rem}.md\\:block{display:block}.md\\:h-\\[400px\\]{height:400px}.md\\:h-\\[500px\\]{height:500px}.md\\:h-\\[600px\\]{height:600px}.md\\:h-\\[700px\\]{height:700px}.md\\:h-\\[800px\\]{height:800px}.md\\:w-\\[1200px\\]{width:1200px}.md\\:w-\\[350px\\]{width:350px}.md\\:w-\\[500px\\]{width:500px}.md\\:w-\\[760px\\]{width:760px}.md\\:w-\\[900px\\]{width:900px}}`;var mM=Object.defineProperty,gM=Object.getOwnPropertyDescriptor,vf=(t,e,r,n)=>{for(var i=n>1?void 0:n?gM(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&mM(e,r,i),i};let du=class extends Ln{constructor(){super(...arguments),this.activeIndex=0,this.items=[]}render(){return ar`
211
+ <div>
212
+ <div
213
+ id="carousel"
214
+ class="flex overflow-x-auto snap-x snap-mandatory overflow-scrolling-touch m-0 p-0"
215
+ @scroll="${this.onScroll}"
216
+ >
217
+ <slot @slotchange=${this.onSlotChange}>zzz</slot>
218
+ </div>
219
+
220
+ <div class="flex justify-between items-center">
221
+ <button class="cursor-pointer h-6" @click=${()=>this.scrollCarousel(-1)}>
222
+
223
+ <svg
224
+ xmlns="http://www.w3.org/2000/svg"
225
+ viewBox="0 0 24 24"
226
+ width="100%"
227
+ height="100%"
228
+ fill="currentColor"
229
+ >
230
+ <title>arrow-left</title>
231
+ <path d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z" />
232
+ </svg>
233
+ </button>
234
+
235
+ <div class="flex justify-center space-x-2">
236
+ ${Ov(this.items,(t,e)=>e,(t,e)=>ar`
237
+ <span
238
+ class="h-2.5 w-2.5 bg-gray-400 rounded-full inline-block ${this.activeIndex===e?"bg-gray-600":""}"
239
+ @click=${()=>this.scrollToIndex(e)}
240
+ />
241
+ `)}
242
+ </div>
243
+
244
+ <button class="cursor-pointer h-6" @click=${()=>this.scrollCarousel(1)}>
245
+ <svg
246
+ xmlns="http://www.w3.org/2000/svg"
247
+ viewBox="0 0 24 24"
248
+ width="100%"
249
+ height="100%"
250
+ fill="currentColor"
251
+ >
252
+ <title>arrow-right</title>
253
+ <path d="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z" />
254
+ </svg>
255
+ </button>
256
+ </div>
257
+ </div>
258
+ `}onSlotChange(t){const e=t.target;this.items=(e==null?void 0:e.assignedElements())||[]}onScroll(){const{carousel:t}=this;if(!t)return;let e=0,r=1/0;this.items.forEach((n,i)=>{const a=Math.abs(n.offsetLeft-t.scrollLeft);a<r&&(r=a,e=i)}),this.activeIndex=e}scrollCarousel(t){this.scrollToIndex(this.activeIndex+t)}scrollToIndex(t){t!==this.activeIndex&&(this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.scrollToActiveItem())}scrollToActiveItem(){const{carousel:t,items:e,activeIndex:r}=this;if(!t)return;const n=e[r];n&&t.scrollTo({left:n.offsetLeft-t.clientWidth/2+n.clientWidth/2,behavior:"smooth"})}};du.styles=[Zi,ba`
259
+ ::slotted(div) {
260
+ flex: 0 0 auto;
261
+ scroll-snap-align: start;
262
+ width: 100%;
263
+ padding: 1rem;
264
+ background-color: #f8f9fa;
265
+ border: 1px solid rgba(0, 0, 0, 0.125);
266
+ border-radius: 0.25rem;
267
+ margin-right: 1rem;
268
+ }
269
+ `],vf([jr({type:Number})],du.prototype,"activeIndex",2),vf([jr({type:Array})],du.prototype,"items",2),vf([df("#carousel")],du.prototype,"carousel",2),du=vf([Wi("iai-chat-carousel")],du);/**
270
+ * @license
271
+ * Copyright 2017 Google LLC
272
+ * SPDX-License-Identifier: BSD-3-Clause
273
+ */const Pv={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Mv=t=>(...e)=>({_$litDirective$:t,values:e});let Nv=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
274
+ * @license
275
+ * Copyright 2018 Google LLC
276
+ * SPDX-License-Identifier: BSD-3-Clause
277
+ */const I_="important",yM=" !"+I_,Ql=Mv(class extends Nv{constructor(t){var e;if(super(t),t.type!==Pv.ATTRIBUTE||t.name!=="style"||((e=t.strings)==null?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,r)=>{const n=t[r];return n==null?e:e+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`},"")}update(t,[e]){const{style:r}=t.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const n of this.ft)e[n]==null&&(this.ft.delete(n),n.includes("-")?r.removeProperty(n):r[n]=null);for(const n in e){const i=e[n];if(i!=null){this.ft.add(n);const a=typeof i=="string"&&i.endsWith(yM);n.includes("-")||a?r.setProperty(n,a?i.slice(0,-11):i,a?I_:""):r[n]=i}}return ns}}),Lv=ar`
89
278
  <svg
90
279
  xmlns="http://www.w3.org/2000/svg"
91
280
  viewBox="0 0 24 24"
@@ -97,7 +286,7 @@
97
286
  <path
98
287
  d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
99
288
  </svg>
100
- `,Hr=z`
289
+ `,bM=ar`
101
290
  <svg
102
291
  xmlns="http://www.w3.org/2000/svg"
103
292
  viewBox="0 0 24 24"
@@ -109,7 +298,7 @@
109
298
  <path
110
299
  d="M12,3C17.5,3 22,6.58 22,11C22,15.42 17.5,19 12,19C10.76,19 9.57,18.82 8.47,18.5C5.55,21 2,21 2,21C4.33,18.67 4.7,17.1 4.75,16.5C3.05,15.07 2,13.13 2,11C2,6.58 6.5,3 12,3Z"/>
111
300
  </svg>
112
- `,Br=z`
301
+ `,wM=ar`
113
302
  <svg
114
303
  xmlns="http://www.w3.org/2000/svg"
115
304
  viewBox="0 0 24 24"
@@ -120,7 +309,7 @@
120
309
  <title>send</title>
121
310
  <path d="M2,21L23,12L2,3V10L17,12L2,14V21Z"/>
122
311
  </svg>
123
- `,Fr=z`
312
+ `,_M=ar`
124
313
  <svg
125
314
  xmlns="http://www.w3.org/2000/svg"
126
315
  viewBox="0 0 24 24"
@@ -131,98 +320,309 @@
131
320
  <title>refresh</title>
132
321
  <path d="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z" />
133
322
  </svg>
134
- `;var Vr=Object.defineProperty,Wr=Object.getOwnPropertyDescriptor,be=(s,e,t,i)=>{for(var n=i>1?void 0:i?Wr(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Vr(e,t,n),n},Li=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},dt=(s,e,t)=>(Li(s,e,"read from private field"),t?t.call(s):e.get(s)),zi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Di=(s,e,t,i)=>(Li(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),Pe,as;let oe=class extends se{constructor(){super(),zi(this,Pe,void 0),zi(this,as,Promise.resolve()),this.disableInput=!1,this.showTyping=!1,this.messages=[],this.inputValue="",this.internalDisableInput=!1,this.internalShowTyping=!1,this._emitter=Rr(),this._emitter.on("*",(s,e)=>this.dispatchEvent(new CustomEvent(`iai-chat-${s.toString()}`,{bubbles:!0,composed:!0,detail:e})))}connectedCallback(){super.connectedCallback(),this.cleanOptions=is.parse(this.options||{});const{assistantId:s,params:e,config:t}=this.cleanOptions;Di(this,Pe,new jr(s,{params:e,simulateDelays:!0,historyKey:t.historyKey})),this.updateMessages(dt(this,Pe).messages),this.showTyping=dt(this,Pe).isTyping,this.disableInput=dt(this,Pe).inputDisabled,this.chatManager.on("functionCall",({id:i,name:n,params:r})=>{const a=this.cleanOptions.handlers.functionCalls[n];if(!a){console.warn(`No function call handler found for ${n}`);return}a.call(this,{id:i,params:r,html:z,chatWindow:this})}),this.chatManager.on("typing",i=>{this.showTyping=i}),this.chatManager.on("inputDisabled",i=>{this.disableInput=i}),this.chatManager.on("message",i=>{this.updateMessages([...this.messages,i])}),this.chatManager.on("messageRemoved",i=>{this.updateMessages(this.messages.filter(n=>n.id!==i))}),this.chatManager.on("reset",()=>{this.updateMessages([])}),this.chatManager.on("*",this._emitter.emit)}disconnectedCallback(){super.disconnectedCallback(),this._emitter.all.clear(),dt(this,Pe).destroy()}firstUpdated(){this.focusOnInput()}updateMessages(s){this.messages=[...s],this.scrollChatToBottom()}render(){const{header:s,showCloseButton:e}=this.cleanOptions.config.chatWindow;return z`
135
- <div class="flex flex-col h-full rounded-lg shadow-lg bg-white">
136
- <div class="header rounded-t-lg text-lg p-2 flex justify-between items-center">
323
+ `,kM=ar`
324
+ <svg
325
+ xmlns="http://www.w3.org/2000/svg"
326
+ viewBox="0 0 24 24"
327
+ width="100%"
328
+ height="100%"
329
+ fill="currentColor"
330
+ >
331
+ <title>minus</title>
332
+ <path d="M19,13H5V11H19V13Z" />
333
+ </svg>
334
+ `,SM=ar`
335
+ <svg
336
+ xmlns="http://www.w3.org/2000/svg"
337
+ viewBox="0 0 24 24"
338
+ width="100%"
339
+ height="100%"
340
+ fill="currentColor"
341
+ >
342
+ <title>thumb-up</title>
343
+ <path d="M23,10C23,8.89 22.1,8 21,8H14.68L15.64,3.43C15.66,3.33 15.67,3.22 15.67,3.11C15.67,2.7 15.5,2.32 15.23,2.05L14.17,1L7.59,7.58C7.22,7.95 7,8.45 7,9V19A2,2 0 0,0 9,21H18C18.83,21 19.54,20.5 19.84,19.78L22.86,12.73C22.95,12.5 23,12.26 23,12V10M1,21H5V9H1V21Z" />
344
+ </svg>
345
+ `,$M=ar`
346
+ <svg
347
+ xmlns="http://www.w3.org/2000/svg"
348
+ viewBox="0 0 24 24"
349
+ width="100%"
350
+ height="100%"
351
+ fill="currentColor"
352
+ >
353
+ <title>thumb-down</title>
354
+ <path d="M19,15H23V3H19M15,3H6C5.17,3 4.46,3.5 4.16,4.22L1.14,11.27C1.05,11.5 1,11.74 1,12V14A2,2 0 0,0 3,16H9.31L8.36,20.57C8.34,20.67 8.33,20.77 8.33,20.88C8.33,21.3 8.5,21.67 8.77,21.94L9.83,23L16.41,16.41C16.78,16.05 17,15.55 17,15V5C17,3.89 16.1,3 15,3Z" />
355
+ </svg>
356
+ `,TM=ar`
357
+ <svg
358
+ xmlns="http://www.w3.org/2000/svg"
359
+ viewBox="0 0 24 24"
360
+ width="100%"
361
+ height="100%"
362
+ fill="currentColor"
363
+ >
364
+ <title>thumb-up-outline</title>
365
+ <path d="M5,9V21H1V9H5M9,21A2,2 0 0,1 7,19V9C7,8.45 7.22,7.95 7.59,7.59L14.17,1L15.23,2.06C15.5,2.33 15.67,2.7 15.67,3.11L15.64,3.43L14.69,8H21C22.11,8 23,8.9 23,10V12C23,12.26 22.95,12.5 22.86,12.73L19.84,19.78C19.54,20.5 18.83,21 18,21H9M9,19H18.03L21,12V10H12.21L13.34,4.68L9,9.03V19Z" />
366
+ </svg>
367
+ `,EM=ar`
368
+ <svg
369
+ xmlns="http://www.w3.org/2000/svg"
370
+ viewBox="0 0 24 24"
371
+ width="100%"
372
+ height="100%"
373
+ fill="currentColor"
374
+ >
375
+ <title>thumb-down-outline</title>
376
+ <path d="M19,15V3H23V15H19M15,3A2,2 0 0,1 17,5V15C17,15.55 16.78,16.05 16.41,16.41L9.83,23L8.77,21.94C8.5,21.67 8.33,21.3 8.33,20.88L8.36,20.57L9.31,16H3C1.89,16 1,15.1 1,14V12C1,11.74 1.05,11.5 1.14,11.27L4.16,4.22C4.46,3.5 5.17,3 6,3H15M15,5H5.97L3,12V14H11.78L10.65,19.32L15,14.97V5Z" />
377
+ </svg>
378
+ `;var CM=Object.defineProperty,RM=Object.getOwnPropertyDescriptor,Dv=(t,e,r,n)=>{for(var i=n>1?void 0:n?RM(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&CM(e,r,i),i};let Xl=class extends Ln{constructor(){super(...arguments),this.message="",this.pointerPosition="right"}render(){return ar`
379
+ <div class="relative rounded-lg p-5 shadow-md bg-white text-black max-w-[350px]">
380
+ <button
381
+ class="absolute top-0 right-0 w-5 h-5 m-0.5"
382
+ @click="${this.hide}"
383
+ >${Lv}</button>
384
+
385
+ <span>${this.message}</span>
386
+
387
+ <div
388
+ class="absolute bottom-0 mx-4 mb-[-8px] w-0 h-0 border-x-8 border-t-8 border-x-transparent border-white"
389
+ style=${Ql({[this.pointerPosition]:0})}
390
+ />
391
+ </div>
392
+ `}hide(){this.dispatchEvent(new CustomEvent("hide"))}};Xl.styles=[Zi,ba`
393
+ :host {
394
+ display: inline-block;
395
+ }
396
+ `],Dv([jr({type:String})],Xl.prototype,"message",2),Dv([jr({type:String})],Xl.prototype,"pointerPosition",2),Xl=Dv([Wi("iai-chat-cta-bubble")],Xl);function xM(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}else return Array.from(t)}var jv=!1;if(typeof window<"u"){var A_={get passive(){jv=!0}};window.addEventListener("testPassive",null,A_),window.removeEventListener("testPassive",null,A_)}var mf=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1),so=[],gf=!1,O_=-1,ec=void 0,oo=void 0,tc=void 0,P_=function(t){return so.some(function(e){return!!(e.options.allowTouchMove&&e.options.allowTouchMove(t))})},Uv=function(t){var e=t||window.event;return P_(e.target)||e.touches.length>1?!0:(e.preventDefault&&e.preventDefault(),!1)},IM=function(t){if(tc===void 0){var e=!!t&&t.reserveScrollBarGap===!0,r=window.innerWidth-document.documentElement.clientWidth;if(e&&r>0){var n=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);tc=document.body.style.paddingRight,document.body.style.paddingRight=n+r+"px"}}ec===void 0&&(ec=document.body.style.overflow,document.body.style.overflow="hidden")},AM=function(){tc!==void 0&&(document.body.style.paddingRight=tc,tc=void 0),ec!==void 0&&(document.body.style.overflow=ec,ec=void 0)},OM=function(){return window.requestAnimationFrame(function(){if(oo===void 0){oo={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var t=window,e=t.scrollY,r=t.scrollX,n=t.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-r,setTimeout(function(){return window.requestAnimationFrame(function(){var i=n-window.innerHeight;i&&e>=n&&(document.body.style.top=-(e+i))})},300)}})},PM=function(){if(oo!==void 0){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=oo.position,document.body.style.top=oo.top,document.body.style.left=oo.left,window.scrollTo(e,t),oo=void 0}},MM=function(t){return t?t.scrollHeight-t.scrollTop<=t.clientHeight:!1},NM=function(t,e){var r=t.targetTouches[0].clientY-O_;return P_(t.target)?!1:e&&e.scrollTop===0&&r>0||MM(e)&&r<0?Uv(t):(t.stopPropagation(),!0)},LM=function(t,e){if(!t){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}if(!so.some(function(n){return n.targetElement===t})){var r={targetElement:t,options:e||{}};so=[].concat(xM(so),[r]),mf?OM():IM(e),mf&&(t.ontouchstart=function(n){n.targetTouches.length===1&&(O_=n.targetTouches[0].clientY)},t.ontouchmove=function(n){n.targetTouches.length===1&&NM(n,t)},gf||(document.addEventListener("touchmove",Uv,jv?{passive:!1}:void 0),gf=!0))}},M_=function(t){if(!t){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}so=so.filter(function(e){return e.targetElement!==t}),mf&&(t.ontouchstart=null,t.ontouchmove=null,gf&&so.length===0&&(document.removeEventListener("touchmove",Uv,jv?{passive:!1}:void 0),gf=!1)),mf?PM():AM()};/**
397
+ * @license
398
+ * Copyright 2018 Google LLC
399
+ * SPDX-License-Identifier: BSD-3-Clause
400
+ */const yf=Mv(class extends Nv{constructor(t){var e;if(super(t),t.type!==Pv.ATTRIBUTE||t.name!=="class"||((e=t.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){var r,n;if(this.st===void 0){this.st=new Set,t.strings!==void 0&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(a=>a!=="")));for(const a in e)e[a]&&!((r=this.nt)!=null&&r.has(a))&&this.st.add(a);return this.render(e)}const i=t.element.classList;for(const a of this.st)a in e||(i.remove(a),this.st.delete(a));for(const a in e){const s=!!e[a];s===this.st.has(a)||(n=this.nt)!=null&&n.has(a)||(s?(i.add(a),this.st.add(a)):(i.remove(a),this.st.delete(a)))}return ns}});/**
401
+ * @license
402
+ * Copyright 2021 Google LLC
403
+ * SPDX-License-Identifier: BSD-3-Clause
404
+ */function _a(t,e,r){return t?e(t):r==null?void 0:r(t)}const Fv="-",DM=t=>{const e=UM(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:i=>{const a=i.split(Fv);return a[0]===""&&a.length!==1&&a.shift(),N_(a,e)||jM(i)},getConflictingClassGroupIds:(i,a)=>{const s=r[i]||[];return a&&n[i]?[...s,...n[i]]:s}}},N_=(t,e)=>{var r;if(t.length===0)return e.classGroupId;const n=t[0],i=e.nextPart.get(n),a=i?N_(t.slice(1),i):void 0;if(a)return a;if(e.validators.length===0)return;const s=t.join(Fv);return(r=e.validators.find(({validator:o})=>o(s)))==null?void 0:r.classGroupId},L_=/^\[(.+)\]$/,jM=t=>{if(L_.test(t)){const e=L_.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},UM=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return BM(Object.entries(t.classGroups),r).forEach(([i,a])=>{Bv(a,n,i,e)}),n},Bv=(t,e,r,n)=>{t.forEach(i=>{if(typeof i=="string"){const a=i===""?e:D_(e,i);a.classGroupId=r;return}if(typeof i=="function"){if(FM(i)){Bv(i(n),e,r,n);return}e.validators.push({validator:i,classGroupId:r});return}Object.entries(i).forEach(([a,s])=>{Bv(s,D_(e,a),r,n)})})},D_=(t,e)=>{let r=t;return e.split(Fv).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},FM=t=>t.isThemeGetter,BM=(t,e)=>e?t.map(([r,n])=>{const i=n.map(a=>typeof a=="string"?e+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([s,o])=>[e+s,o])):a);return[r,i]}):t,zM=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const i=(a,s)=>{r.set(a,s),e++,e>t&&(e=0,n=r,r=new Map)};return{get(a){let s=r.get(a);if(s!==void 0)return s;if((s=n.get(a))!==void 0)return i(a,s),s},set(a,s){r.has(a)?r.set(a,s):i(a,s)}}},j_="!",HM=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,i=e[0],a=e.length,s=o=>{const u=[];let l=0,c=0,d;for(let N=0;N<o.length;N++){let z=o[N];if(l===0){if(z===i&&(n||o.slice(N,N+a)===e)){u.push(o.slice(c,N)),c=N+a;continue}if(z==="/"){d=N;continue}}z==="["?l++:z==="]"&&l--}const f=u.length===0?o:o.substring(c),m=f.startsWith(j_),b=m?f.substring(1):f,A=d&&d>c?d-c:void 0;return{modifiers:u,hasImportantModifier:m,baseClassName:b,maybePostfixModifierPosition:A}};return r?o=>r({className:o,parseClassName:s}):s},qM=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},VM=t=>({cache:zM(t.cacheSize),parseClassName:HM(t),...DM(t)}),WM=/\s+/,ZM=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i}=e,a=[],s=t.trim().split(WM);let o="";for(let u=s.length-1;u>=0;u-=1){const l=s[u],{modifiers:c,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:m}=r(l);let b=!!m,A=n(b?f.substring(0,m):f);if(!A){if(!b){o=l+(o.length>0?" "+o:o);continue}if(A=n(f),!A){o=l+(o.length>0?" "+o:o);continue}b=!1}const N=qM(c).join(":"),z=d?N+j_:N,X=z+A;if(a.includes(X))continue;a.push(X);const Ee=i(A,b);for(let Ie=0;Ie<Ee.length;++Ie){const Fe=Ee[Ie];a.push(z+Fe)}o=l+(o.length>0?" "+o:o)}return o};function GM(){let t=0,e,r,n="";for(;t<arguments.length;)(e=arguments[t++])&&(r=U_(e))&&(n&&(n+=" "),n+=r);return n}const U_=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=U_(t[n]))&&(r&&(r+=" "),r+=e);return r};function KM(t,...e){let r,n,i,a=s;function s(u){const l=e.reduce((c,d)=>d(c),t());return r=VM(l),n=r.cache.get,i=r.cache.set,a=o,o(u)}function o(u){const l=n(u);if(l)return l;const c=ZM(u,r);return i(u,c),c}return function(){return a(GM.apply(null,arguments))}}const Ur=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},F_=/^\[(?:([a-z-]+):)?(.+)\]$/i,JM=/^\d+\/\d+$/,YM=new Set(["px","full","screen"]),QM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,XM=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,eN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,tN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ka=t=>fu(t)||YM.has(t)||JM.test(t),as=t=>hu(t,"length",cN),fu=t=>!!t&&!Number.isNaN(Number(t)),zv=t=>hu(t,"number",fu),rc=t=>!!t&&Number.isInteger(Number(t)),nN=t=>t.endsWith("%")&&fu(t.slice(0,-1)),sr=t=>F_.test(t),ss=t=>QM.test(t),iN=new Set(["length","size","percentage"]),aN=t=>hu(t,iN,B_),sN=t=>hu(t,"position",B_),oN=new Set(["image","url"]),uN=t=>hu(t,oN,fN),lN=t=>hu(t,"",dN),nc=()=>!0,hu=(t,e,r)=>{const n=F_.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},cN=t=>XM.test(t)&&!eN.test(t),B_=()=>!1,dN=t=>tN.test(t),fN=t=>rN.test(t),hN=()=>{const t=Ur("colors"),e=Ur("spacing"),r=Ur("blur"),n=Ur("brightness"),i=Ur("borderColor"),a=Ur("borderRadius"),s=Ur("borderSpacing"),o=Ur("borderWidth"),u=Ur("contrast"),l=Ur("grayscale"),c=Ur("hueRotate"),d=Ur("invert"),f=Ur("gap"),m=Ur("gradientColorStops"),b=Ur("gradientColorStopPositions"),A=Ur("inset"),N=Ur("margin"),z=Ur("opacity"),X=Ur("padding"),Ee=Ur("saturate"),Ie=Ur("scale"),Fe=Ur("sepia"),Oe=Ur("skew"),ze=Ur("space"),V=Ur("translate"),xe=()=>["auto","contain","none"],_e=()=>["auto","hidden","clip","visible","scroll"],se=()=>["auto",sr,e],Te=()=>[sr,e],re=()=>["",ka,as],oe=()=>["auto",fu,sr],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",sr],ke=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>[fu,sr];return{cacheSize:500,separator:":",theme:{colors:[nc],spacing:[ka,as],blur:["none","",ss,sr],brightness:M(),borderColor:[t],borderRadius:["none","","full",ss,sr],borderSpacing:Te(),borderWidth:re(),contrast:M(),grayscale:ye(),hueRotate:M(),invert:ye(),gap:Te(),gradientColorStops:[t],gradientColorStopPositions:[nN,as],inset:se(),margin:se(),opacity:M(),padding:Te(),saturate:M(),scale:M(),sepia:ye(),skew:M(),space:Te(),translate:Te()},classGroups:{aspect:[{aspect:["auto","square","video",sr]}],container:["container"],columns:[{columns:[ss]}],"break-after":[{"break-after":ke()}],"break-before":[{"break-before":ke()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...q(),sr]}],overflow:[{overflow:_e()}],"overflow-x":[{"overflow-x":_e()}],"overflow-y":[{"overflow-y":_e()}],overscroll:[{overscroll:xe()}],"overscroll-x":[{"overscroll-x":xe()}],"overscroll-y":[{"overscroll-y":xe()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[A]}],"inset-x":[{"inset-x":[A]}],"inset-y":[{"inset-y":[A]}],start:[{start:[A]}],end:[{end:[A]}],top:[{top:[A]}],right:[{right:[A]}],bottom:[{bottom:[A]}],left:[{left:[A]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",rc,sr]}],basis:[{basis:se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",sr]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",rc,sr]}],"grid-cols":[{"grid-cols":[nc]}],"col-start-end":[{col:["auto",{span:["full",rc,sr]},sr]}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":[nc]}],"row-start-end":[{row:["auto",{span:[rc,sr]},sr]}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",sr]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",sr]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[X]}],px:[{px:[X]}],py:[{py:[X]}],ps:[{ps:[X]}],pe:[{pe:[X]}],pt:[{pt:[X]}],pr:[{pr:[X]}],pb:[{pb:[X]}],pl:[{pl:[X]}],m:[{m:[N]}],mx:[{mx:[N]}],my:[{my:[N]}],ms:[{ms:[N]}],me:[{me:[N]}],mt:[{mt:[N]}],mr:[{mr:[N]}],mb:[{mb:[N]}],ml:[{ml:[N]}],"space-x":[{"space-x":[ze]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[ze]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",sr,e]}],"min-w":[{"min-w":[sr,e,"min","max","fit"]}],"max-w":[{"max-w":[sr,e,"none","full","min","max","fit","prose",{screen:[ss]},ss]}],h:[{h:[sr,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[sr,e,"auto","min","max","fit"]}],"font-size":[{text:["base",ss,as]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",zv]}],"font-family":[{font:[nc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",sr]}],"line-clamp":[{"line-clamp":["none",fu,zv]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ka,sr]}],"list-image":[{"list-image":["none",sr]}],"list-style-type":[{list:["none","disc","decimal",sr]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[z]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[z]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ka,as]}],"underline-offset":[{"underline-offset":["auto",ka,sr]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Te()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",sr]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",sr]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[z]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...q(),sN]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",aN]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},uN]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[z]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[z]}],"divide-style":[{divide:ne()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ne()]}],"outline-offset":[{"outline-offset":[ka,sr]}],"outline-w":[{outline:[ka,as]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[z]}],"ring-offset-w":[{"ring-offset":[ka,as]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",ss,lN]}],"shadow-color":[{shadow:[nc]}],opacity:[{opacity:[z]}],"mix-blend":[{"mix-blend":[...Se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Se()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",ss,sr]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[d]}],saturate:[{saturate:[Ee]}],sepia:[{sepia:[Fe]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[z]}],"backdrop-saturate":[{"backdrop-saturate":[Ee]}],"backdrop-sepia":[{"backdrop-sepia":[Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",sr]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",sr]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",sr]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[Ie]}],"scale-x":[{"scale-x":[Ie]}],"scale-y":[{"scale-y":[Ie]}],rotate:[{rotate:[rc,sr]}],"translate-x":[{"translate-x":[V]}],"translate-y":[{"translate-y":[V]}],"skew-x":[{"skew-x":[Oe]}],"skew-y":[{"skew-y":[Oe]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",sr]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",sr]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Te()}],"scroll-mx":[{"scroll-mx":Te()}],"scroll-my":[{"scroll-my":Te()}],"scroll-ms":[{"scroll-ms":Te()}],"scroll-me":[{"scroll-me":Te()}],"scroll-mt":[{"scroll-mt":Te()}],"scroll-mr":[{"scroll-mr":Te()}],"scroll-mb":[{"scroll-mb":Te()}],"scroll-ml":[{"scroll-ml":Te()}],"scroll-p":[{"scroll-p":Te()}],"scroll-px":[{"scroll-px":Te()}],"scroll-py":[{"scroll-py":Te()}],"scroll-ps":[{"scroll-ps":Te()}],"scroll-pe":[{"scroll-pe":Te()}],"scroll-pt":[{"scroll-pt":Te()}],"scroll-pr":[{"scroll-pr":Te()}],"scroll-pb":[{"scroll-pb":Te()}],"scroll-pl":[{"scroll-pl":Te()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",sr]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ka,as,zv]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},pN=KM(hN);var vN=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function z_(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hv={};(function(t){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function r(o,u,l,c){var d={timer:void 0,lastArgs:[]},f=function(){for(var m=this,b=[],A=0;A<arguments.length;A++)b[A]=arguments[A];d.lastArgs=b,d.timer?clearTimeout(d.timer):u&&l.apply(this,d.lastArgs),d.timer=setTimeout(function(){u||l.apply(m,d.lastArgs),d.timer=void 0},o)};return c&&(f=f.bind(c)),f.options=d,f}function n(o,u,l,c){var d;Object.defineProperty(l,c,{configurable:!0,enumerable:!1,get:function(){return d},set:function(f){d=r(o,u,f,this)}})}function i(o,u,l){var c=l.value;return l.value=r(o,u,c),l}function a(o,u){for(var l=[],c=2;c<arguments.length;c++)l[c-2]=arguments[c];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var d=l[0],f=l[1],m=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(d,f);if(m)return i(o,u,m);n(o,u,d,f)}function s(){for(var o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];var l=500,c=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var d=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(d=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(d=o[1]),d&&(c=d.leading),function(){for(var f=[],m=0;m<arguments.length;m++)f[m]=arguments[m];return a.apply(void 0,[l,c].concat(f))}}return a.apply(void 0,[l,c].concat(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.cancel=e,t.debounce=s})(Hv);var yr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(yr||(yr={}));var qv;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(qv||(qv={}));const gt=yr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),os=t=>{switch(typeof t){case"undefined":return gt.undefined;case"string":return gt.string;case"number":return isNaN(t)?gt.nan:gt.number;case"boolean":return gt.boolean;case"function":return gt.function;case"bigint":return gt.bigint;case"symbol":return gt.symbol;case"object":return Array.isArray(t)?gt.array:t===null?gt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?gt.promise:typeof Map<"u"&&t instanceof Map?gt.map:typeof Set<"u"&&t instanceof Set?gt.set:typeof Date<"u"&&t instanceof Date?gt.date:gt.object;default:return gt.unknown}},st=yr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),mN=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Si extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,yr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Si.create=t=>new Si(t);const ic=(t,e)=>{let r;switch(t.code){case st.invalid_type:t.received===gt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case st.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,yr.jsonStringifyReplacer)}`;break;case st.unrecognized_keys:r=`Unrecognized key(s) in object: ${yr.joinValues(t.keys,", ")}`;break;case st.invalid_union:r="Invalid input";break;case st.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${yr.joinValues(t.options)}`;break;case st.invalid_enum_value:r=`Invalid enum value. Expected ${yr.joinValues(t.options)}, received '${t.received}'`;break;case st.invalid_arguments:r="Invalid function arguments";break;case st.invalid_return_type:r="Invalid function return type";break;case st.invalid_date:r="Invalid date";break;case st.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:yr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case st.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case st.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case st.custom:r="Invalid input";break;case st.invalid_intersection_types:r="Intersection results could not be merged";break;case st.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case st.not_finite:r="Number must be finite";break;default:r=e.defaultError,yr.assertNever(t)}return{message:r}};let H_=ic;function gN(t){H_=t}function bf(){return H_}const wf=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:i.message||o}},yN=[];function _t(t,e){const r=wf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bf(),ic].filter(n=>!!n)});t.common.issues.push(r)}class gn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return Xt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r)n.push({key:await i.key,value:await i.value});return gn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return Xt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const Xt=Object.freeze({status:"aborted"}),q_=t=>({status:"dirty",value:t}),En=t=>({status:"valid",value:t}),Vv=t=>t.status==="aborted",Wv=t=>t.status==="dirty",ac=t=>t.status==="valid",_f=t=>typeof Promise<"u"&&t instanceof Promise;var Dt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Dt||(Dt={}));class Gi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const V_=(t,e)=>{if(ac(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Si(t.common.issues);return this._error=r,this._error}}};function nr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>a.code!=="invalid_type"?{message:s.defaultError}:typeof s.data>"u"?{message:n??s.defaultError}:{message:r??s.defaultError},description:i}}class lr{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return os(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:os(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gn,ctx:{common:e.parent.common,data:e.data,parsedType:os(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(_f(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:os(e)},a=this._parseSync({data:e,path:i.path,parent:i});return V_(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:os(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(_f(i)?i:Promise.resolve(i));return V_(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:st.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new Ei({schema:this,typeName:Bt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return $a.create(this,this._def)}nullable(){return fo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ti.create(this,this._def)}promise(){return gu.create(this,this._def)}or(e){return lc.create([this,e],this._def)}and(e){return cc.create(this,e,this._def)}transform(e){return new Ei({...nr(this._def),schema:this,typeName:Bt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new vc({...nr(this._def),innerType:this,defaultValue:r,typeName:Bt.ZodDefault})}brand(){return new Z_({typeName:Bt.ZodBranded,type:this,...nr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Cf({...nr(this._def),innerType:this,catchValue:r,typeName:Bt.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return mc.create(this,e)}readonly(){return xf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const bN=/^c[^\s-]{8,}$/i,wN=/^[a-z][a-z0-9]*$/,_N=/^[0-9A-HJKMNP-TV-Z]{26}$/,kN=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,SN=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$N="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Zv;const TN=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,EN=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,CN=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function RN(t,e){return!!((e==="v4"||!e)&&TN.test(t)||(e==="v6"||!e)&&EN.test(t))}class $i extends lr{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==gt.string){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.string,received:i.parsedType}),Xt}const r=new gn;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,s=e.data.length<i.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?_t(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&_t(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")SN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"email",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Zv||(Zv=new RegExp($N,"u")),Zv.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"emoji",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")kN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"uuid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")bN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"cuid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")wN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"cuid2",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")_N.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"ulid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),_t(n,{validation:"url",code:st.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"regex",code:st.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?CN(i).test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="ip"?RN(e.data,i.version)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"ip",code:st.invalid_string,message:i.message}),r.dirty()):yr.assertNever(i);return{status:r.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:st.invalid_string,...Dt.errToObj(n)})}_addCheck(e){return new $i({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Dt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Dt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Dt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Dt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Dt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Dt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Dt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Dt.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,...Dt.errToObj(e==null?void 0:e.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Dt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Dt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Dt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Dt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Dt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Dt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Dt.errToObj(r)})}nonempty(e){return this.min(1,Dt.errToObj(e))}trim(){return new $i({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}$i.create=t=>{var e;return new $i({checks:[],typeName:Bt.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...nr(t)})};function xN(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class us extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==gt.number){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.number,received:i.parsedType}),Xt}let r;const n=new gn;for(const i of this._def.checks)i.kind==="int"?yr.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_t(r,{code:st.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?xN(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_finite,message:i.message}),n.dirty()):yr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Dt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Dt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Dt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Dt.toString(r))}setLimit(e,r,n,i){return new us({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(e){return new us({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Dt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Dt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Dt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Dt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Dt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Dt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Dt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Dt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Dt.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&yr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}us.create=t=>new us({checks:[],typeName:Bt.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...nr(t)});class ls extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==gt.bigint){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.bigint,received:i.parsedType}),Xt}let r;const n=new gn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):yr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Dt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Dt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Dt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Dt.toString(r))}setLimit(e,r,n,i){return new ls({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(e){return new ls({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Dt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Dt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Dt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Dt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Dt.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ls.create=t=>{var e;return new ls({checks:[],typeName:Bt.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...nr(t)})};class sc extends lr{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==gt.boolean){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.boolean,received:r.parsedType}),Xt}return En(e.data)}}sc.create=t=>new sc({typeName:Bt.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...nr(t)});class uo extends lr{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==gt.date){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.date,received:i.parsedType}),Xt}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_date}),Xt}const r=new gn;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):yr.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new uo({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Dt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Dt.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}uo.create=t=>new uo({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Bt.ZodDate,...nr(t)});class kf extends lr{_parse(e){if(this._getType(e)!==gt.symbol){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.symbol,received:r.parsedType}),Xt}return En(e.data)}}kf.create=t=>new kf({typeName:Bt.ZodSymbol,...nr(t)});class oc extends lr{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.undefined,received:r.parsedType}),Xt}return En(e.data)}}oc.create=t=>new oc({typeName:Bt.ZodUndefined,...nr(t)});class uc extends lr{_parse(e){if(this._getType(e)!==gt.null){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.null,received:r.parsedType}),Xt}return En(e.data)}}uc.create=t=>new uc({typeName:Bt.ZodNull,...nr(t)});class pu extends lr{constructor(){super(...arguments),this._any=!0}_parse(e){return En(e.data)}}pu.create=t=>new pu({typeName:Bt.ZodAny,...nr(t)});class lo extends lr{constructor(){super(...arguments),this._unknown=!0}_parse(e){return En(e.data)}}lo.create=t=>new lo({typeName:Bt.ZodUnknown,...nr(t)});class Sa extends lr{_parse(e){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.never,received:r.parsedType}),Xt}}Sa.create=t=>new Sa({typeName:Bt.ZodNever,...nr(t)});class Sf extends lr{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.void,received:r.parsedType}),Xt}return En(e.data)}}Sf.create=t=>new Sf({typeName:Bt.ZodVoid,...nr(t)});class Ti extends lr{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==gt.array)return _t(r,{code:st.invalid_type,expected:gt.array,received:r.parsedType}),Xt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(_t(r,{code:s?st.too_big:st.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(_t(r,{code:st.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(_t(r,{code:st.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Gi(r,s,r.path,o)))).then(s=>gn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Gi(r,s,r.path,o)));return gn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Ti({...this._def,minLength:{value:e,message:Dt.toString(r)}})}max(e,r){return new Ti({...this._def,maxLength:{value:e,message:Dt.toString(r)}})}length(e,r){return new Ti({...this._def,exactLength:{value:e,message:Dt.toString(r)}})}nonempty(e){return this.min(1,e)}}Ti.create=(t,e)=>new Ti({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Bt.ZodArray,...nr(e)});function vu(t){if(t instanceof Zr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=$a.create(vu(n))}return new Zr({...t._def,shape:()=>e})}else return t instanceof Ti?new Ti({...t._def,type:vu(t.element)}):t instanceof $a?$a.create(vu(t.unwrap())):t instanceof fo?fo.create(vu(t.unwrap())):t instanceof Ki?Ki.create(t.items.map(e=>vu(e))):t}class Zr extends lr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=yr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==gt.object){const u=this._getOrReturnCtx(e);return _t(u,{code:st.invalid_type,expected:gt.object,received:u.parsedType}),Xt}const{status:r,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof Sa&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||s.push(u);const o=[];for(const u of a){const l=i[u],c=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new Gi(n,c,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Sa){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of s)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(_t(n,{code:st.unrecognized_keys,keys:s}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of s){const c=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new Gi(n,c,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const c=await l.key;u.push({key:c,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>gn.mergeObjectSync(r,u)):gn.mergeObjectSync(r,o)}get shape(){return this._def.shape()}strict(e){return Dt.errToObj,new Zr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Dt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Zr({...this._def,unknownKeys:"strip"})}passthrough(){return new Zr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Zr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Zr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Bt.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Zr({...this._def,catchall:e})}pick(e){const r={};return yr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Zr({...this._def,shape:()=>r})}omit(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Zr({...this._def,shape:()=>r})}deepPartial(){return vu(this)}partial(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Zr({...this._def,shape:()=>r})}required(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof $a;)i=i._def.innerType;r[n]=i}}),new Zr({...this._def,shape:()=>r})}keyof(){return W_(yr.objectKeys(this.shape))}}Zr.create=(t,e)=>new Zr({shape:()=>t,unknownKeys:"strip",catchall:Sa.create(),typeName:Bt.ZodObject,...nr(e)}),Zr.strictCreate=(t,e)=>new Zr({shape:()=>t,unknownKeys:"strict",catchall:Sa.create(),typeName:Bt.ZodObject,...nr(e)}),Zr.lazycreate=(t,e)=>new Zr({shape:t,unknownKeys:"strip",catchall:Sa.create(),typeName:Bt.ZodObject,...nr(e)});class lc extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Si(o.ctx.common.issues));return _t(r,{code:st.invalid_union,unionErrors:s}),Xt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Si(u));return _t(r,{code:st.invalid_union,unionErrors:o}),Xt}}get options(){return this._def.options}}lc.create=(t,e)=>new lc({options:t,typeName:Bt.ZodUnion,...nr(e)});const $f=t=>t instanceof fc?$f(t.schema):t instanceof Ei?$f(t.innerType()):t instanceof hc?[t.value]:t instanceof cs?t.options:t instanceof pc?Object.keys(t.enum):t instanceof vc?$f(t._def.innerType):t instanceof oc?[void 0]:t instanceof uc?[null]:null;class Tf extends lr{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.object)return _t(r,{code:st.invalid_type,expected:gt.object,received:r.parsedType}),Xt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(_t(r,{code:st.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Xt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=$f(a.shape[e]);if(!s)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new Tf({typeName:Bt.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...nr(n)})}}function Gv(t,e){const r=os(t),n=os(e);if(t===e)return{valid:!0,data:t};if(r===gt.object&&n===gt.object){const i=yr.objectKeys(e),a=yr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=Gv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===gt.array&&n===gt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=Gv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===gt.date&&n===gt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class cc extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(Vv(a)||Vv(s))return Xt;const o=Gv(a.value,s.value);return o.valid?((Wv(a)||Wv(s))&&r.dirty(),{status:r.value,value:o.data}):(_t(n,{code:st.invalid_intersection_types}),Xt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}cc.create=(t,e,r)=>new cc({left:t,right:e,typeName:Bt.ZodIntersection,...nr(r)});class Ki extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.array)return _t(n,{code:st.invalid_type,expected:gt.array,received:n.parsedType}),Xt;if(n.data.length<this._def.items.length)return _t(n,{code:st.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Xt;!this._def.rest&&n.data.length>this._def.items.length&&(_t(n,{code:st.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((a,s)=>{const o=this._def.items[s]||this._def.rest;return o?o._parse(new Gi(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>gn.mergeArray(r,a)):gn.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Ki({...this._def,rest:e})}}Ki.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ki({items:t,typeName:Bt.ZodTuple,rest:null,...nr(e)})};class dc extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.object)return _t(n,{code:st.invalid_type,expected:gt.object,received:n.parsedType}),Xt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Gi(n,o,n.path,o)),value:s._parse(new Gi(n,n.data[o],n.path,o))});return n.common.async?gn.mergeObjectAsync(r,i):gn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof lr?new dc({keyType:e,valueType:r,typeName:Bt.ZodRecord,...nr(n)}):new dc({keyType:$i.create(),valueType:e,typeName:Bt.ZodRecord,...nr(r)})}}class Ef extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.map)return _t(n,{code:st.invalid_type,expected:gt.map,received:n.parsedType}),Xt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Gi(n,o,n.path,[l,"key"])),value:a._parse(new Gi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return Xt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return Xt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Ef.create=(t,e,r)=>new Ef({valueType:e,keyType:t,typeName:Bt.ZodMap,...nr(r)});class co extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.set)return _t(n,{code:st.invalid_type,expected:gt.set,received:n.parsedType}),Xt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(_t(n,{code:st.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(_t(n,{code:st.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return Xt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Gi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new co({...this._def,minSize:{value:e,message:Dt.toString(r)}})}max(e,r){return new co({...this._def,maxSize:{value:e,message:Dt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}co.create=(t,e)=>new co({valueType:t,minSize:null,maxSize:null,typeName:Bt.ZodSet,...nr(e)});class mu extends lr{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.function)return _t(r,{code:st.invalid_type,expected:gt.function,received:r.parsedType}),Xt;function n(o,u){return wf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bf(),ic].filter(l=>!!l),issueData:{code:st.invalid_arguments,argumentsError:u}})}function i(o,u){return wf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bf(),ic].filter(l=>!!l),issueData:{code:st.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof gu){const o=this;return En(async function(...u){const l=new Si([]),c=await o._def.args.parseAsync(u,a).catch(f=>{throw l.addIssue(n(u,f)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(f=>{throw l.addIssue(i(d,f)),l})})}else{const o=this;return En(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Si([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Si([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new mu({...this._def,args:Ki.create(e).rest(lo.create())})}returns(e){return new mu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new mu({args:e||Ki.create([]).rest(lo.create()),returns:r||lo.create(),typeName:Bt.ZodFunction,...nr(n)})}}class fc extends lr{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}fc.create=(t,e)=>new fc({getter:t,typeName:Bt.ZodLazy,...nr(e)});class hc extends lr{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return _t(r,{received:r.data,code:st.invalid_literal,expected:this._def.value}),Xt}return{status:"valid",value:e.data}}get value(){return this._def.value}}hc.create=(t,e)=>new hc({value:t,typeName:Bt.ZodLiteral,...nr(e)});function W_(t,e){return new cs({values:t,typeName:Bt.ZodEnum,...nr(e)})}class cs extends lr{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return _t(r,{expected:yr.joinValues(n),received:r.parsedType,code:st.invalid_type}),Xt}if(this._def.values.indexOf(e.data)===-1){const r=this._getOrReturnCtx(e),n=this._def.values;return _t(r,{received:r.data,code:st.invalid_enum_value,options:n}),Xt}return En(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e){return cs.create(e)}exclude(e){return cs.create(this.options.filter(r=>!e.includes(r)))}}cs.create=W_;class pc extends lr{_parse(e){const r=yr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==gt.string&&n.parsedType!==gt.number){const i=yr.objectValues(r);return _t(n,{expected:yr.joinValues(i),received:n.parsedType,code:st.invalid_type}),Xt}if(r.indexOf(e.data)===-1){const i=yr.objectValues(r);return _t(n,{received:n.data,code:st.invalid_enum_value,options:i}),Xt}return En(e.data)}get enum(){return this._def.values}}pc.create=(t,e)=>new pc({values:t,typeName:Bt.ZodNativeEnum,...nr(e)});class gu extends lr{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.promise&&r.common.async===!1)return _t(r,{code:st.invalid_type,expected:gt.promise,received:r.parsedType}),Xt;const n=r.parsedType===gt.promise?r.data:Promise.resolve(r.data);return En(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}gu.create=(t,e)=>new gu({type:t,typeName:Bt.ZodPromise,...nr(e)});class Ei extends lr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Bt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{_t(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(s).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:s,path:n.path,parent:n})}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Xt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Xt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ac(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>ac(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);yr.assertNever(i)}}Ei.create=(t,e,r)=>new Ei({schema:t,typeName:Bt.ZodEffects,effect:e,...nr(r)}),Ei.createWithPreprocess=(t,e,r)=>new Ei({schema:e,effect:{type:"preprocess",transform:t},typeName:Bt.ZodEffects,...nr(r)});class $a extends lr{_parse(e){return this._getType(e)===gt.undefined?En(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$a.create=(t,e)=>new $a({innerType:t,typeName:Bt.ZodOptional,...nr(e)});class fo extends lr{_parse(e){return this._getType(e)===gt.null?En(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fo.create=(t,e)=>new fo({innerType:t,typeName:Bt.ZodNullable,...nr(e)});class vc extends lr{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===gt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}vc.create=(t,e)=>new vc({innerType:t,typeName:Bt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...nr(e)});class Cf extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return _f(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Si(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Si(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Cf.create=(t,e)=>new Cf({innerType:t,typeName:Bt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...nr(e)});class Rf extends lr{_parse(e){if(this._getType(e)!==gt.nan){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.nan,received:r.parsedType}),Xt}return{status:"valid",value:e.data}}}Rf.create=t=>new Rf({typeName:Bt.ZodNaN,...nr(t)});const IN=Symbol("zod_brand");class Z_ extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class mc extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Xt:i.status==="dirty"?(r.dirty(),q_(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Xt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new mc({in:e,out:r,typeName:Bt.ZodPipeline})}}class xf extends lr{_parse(e){const r=this._def.innerType._parse(e);return ac(r)&&(r.value=Object.freeze(r.value)),r}}xf.create=(t,e)=>new xf({innerType:t,typeName:Bt.ZodReadonly,...nr(e)});const G_=(t,e={},r)=>t?pu.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):pu.create(),AN={object:Zr.lazycreate};var Bt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Bt||(Bt={}));const ON=(t,e={message:`Input not instance of ${t.name}`})=>G_(r=>r instanceof t,e),K_=$i.create,J_=us.create,PN=Rf.create,MN=ls.create,Y_=sc.create,NN=uo.create,LN=kf.create,DN=oc.create,jN=uc.create,UN=pu.create,FN=lo.create,BN=Sa.create,zN=Sf.create,HN=Ti.create,qN=Zr.create,VN=Zr.strictCreate,WN=lc.create,ZN=Tf.create,GN=cc.create,KN=Ki.create,JN=dc.create,YN=Ef.create,QN=co.create,XN=mu.create,e4=fc.create,t4=hc.create,r4=cs.create,n4=pc.create,i4=gu.create,Q_=Ei.create,a4=$a.create,s4=fo.create,o4=Ei.createWithPreprocess,u4=mc.create;var yt=Object.freeze({__proto__:null,defaultErrorMap:ic,setErrorMap:gN,getErrorMap:bf,makeIssue:wf,EMPTY_PATH:yN,addIssueToContext:_t,ParseStatus:gn,INVALID:Xt,DIRTY:q_,OK:En,isAborted:Vv,isDirty:Wv,isValid:ac,isAsync:_f,get util(){return yr},get objectUtil(){return qv},ZodParsedType:gt,getParsedType:os,ZodType:lr,ZodString:$i,ZodNumber:us,ZodBigInt:ls,ZodBoolean:sc,ZodDate:uo,ZodSymbol:kf,ZodUndefined:oc,ZodNull:uc,ZodAny:pu,ZodUnknown:lo,ZodNever:Sa,ZodVoid:Sf,ZodArray:Ti,ZodObject:Zr,ZodUnion:lc,ZodDiscriminatedUnion:Tf,ZodIntersection:cc,ZodTuple:Ki,ZodRecord:dc,ZodMap:Ef,ZodSet:co,ZodFunction:mu,ZodLazy:fc,ZodLiteral:hc,ZodEnum:cs,ZodNativeEnum:pc,ZodPromise:gu,ZodEffects:Ei,ZodTransformer:Ei,ZodOptional:$a,ZodNullable:fo,ZodDefault:vc,ZodCatch:Cf,ZodNaN:Rf,BRAND:IN,ZodBranded:Z_,ZodPipeline:mc,ZodReadonly:xf,custom:G_,Schema:lr,ZodSchema:lr,late:AN,get ZodFirstPartyTypeKind(){return Bt},coerce:{string:t=>$i.create({...t,coerce:!0}),number:t=>us.create({...t,coerce:!0}),boolean:t=>sc.create({...t,coerce:!0}),bigint:t=>ls.create({...t,coerce:!0}),date:t=>uo.create({...t,coerce:!0})},any:UN,array:HN,bigint:MN,boolean:Y_,date:NN,discriminatedUnion:ZN,effect:Q_,enum:r4,function:XN,instanceof:ON,intersection:GN,lazy:e4,literal:t4,map:YN,nan:PN,nativeEnum:n4,never:BN,null:jN,nullable:s4,number:J_,object:qN,oboolean:()=>Y_().optional(),onumber:()=>J_().optional(),optional:a4,ostring:()=>K_().optional(),pipeline:u4,preprocess:o4,promise:i4,record:JN,set:QN,strictObject:VN,string:K_,symbol:LN,transformer:Q_,tuple:KN,undefined:DN,union:WN,unknown:FN,void:zN,NEVER:Xt,ZodIssueCode:st,quotelessJson:mN,ZodError:Si});const l4={sm:"md:w-[350px]",md:"md:w-[500px]",lg:"md:w-[760px]",xl:"md:w-[900px]",xxl:"md:w-[1200px]"},c4={sm:"md:h-[400px]",md:"md:h-[500px]",lg:"md:h-[600px]",xl:"md:h-[700px]",xxl:"md:h-[800px]"},If=yt.object({assistantId:yt.string(),clientId:yt.string().optional(),params:yt.record(yt.any()).default({}),config:yt.object({historyKey:yt.string().refine(t=>t.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:yt.string().default("Hello! How can I help you today?"),focusOnOpen:yt.boolean().default(!0),inactivityWarningMessage:yt.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:yt.string().default("Chat Ended"),resetEndedChatOnLoad:yt.boolean().default(!1),disableMessageRating:yt.boolean().default(!1),initialReplyMessage:yt.string().nullable().default(null),disclaimerMessage:yt.string().nullable().default(null),disclaimerPopover:yt.object({message:yt.string().nullable().default(null),agreeButtonText:yt.string().default("I Agree"),rememberDurationMinutes:yt.number().default(60*24*3)}).default({}),placement:yt.enum(["left","right"]).default("right"),openChatButton:yt.object({imageSrc:yt.string().nullable().default(null),width:yt.union([yt.string(),yt.number()]).default("48px"),height:yt.union([yt.string(),yt.number()]).default("48px"),cta:yt.string().nullable().default(null)}).default({}),chatWindow:yt.object({width:yt.enum(["sm","md","lg","xl","xxl"]).default("sm"),height:yt.enum(["sm","md","lg","xl","xxl"]).default("md"),header:yt.object({text:yt.string().nullable().default("AI Chat"),imageSrc:yt.string().nullable().default(null)}).default({}),showCloseButton:yt.boolean().default(!0)}).default({}),styles:yt.object({primaryColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null),linkColor:yt.string().nullable().default(null),openChatButton:yt.object({backgroundColor:yt.string().nullable().default(null),iconColor:yt.string().nullable().default(null)}).default({}),header:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),button:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),messages:yt.object({user:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),assistant:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({})}).default({})}).default({})}).default({}),handlers:yt.object({functionCalls:yt.record(yt.function().returns(yt.union([yt.any(),yt.promise(yt.any())]))).default({}),enhancedContent:yt.record(yt.function().returns(yt.union([yt.any(),yt.promise(yt.any())]))).default({})}).default({})});var d4=Object.defineProperty,f4=Object.getOwnPropertyDescriptor,yu=(t,e,r,n)=>{for(var i=n>1?void 0:n?f4(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&d4(e,r,i),i};let ds=class extends Ln{constructor(){super(...arguments),this.isOpen=!1,this.ctaClosed=!1,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?(LM(this,{allowTouchMove:t=>t.nodeName==="IAI-CHAT-POPUP"}),this.isIosDevice||(document.documentElement.style.overflow="hidden")):(M_(this),this.isIosDevice||(document.documentElement.style.overflow=this.initialHtmlOverflow))}}connectedCallback(){super.connectedCallback(),this.cleanOptions=If.parse(this.options),this.identifyIosDevice(),this.setInitialHtmlOverflow(),this.initialScrollPosition={x:0,y:0},this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),M_(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const{placement:t,chatWindow:e}=this.cleanOptions.config,{height:r,cta:n}=this.cleanOptions.config.openChatButton,i=pN("chat-widget w-dvw h-dvh md:mx-8",l4[e.width],c4[e.height],this.isOpen?"":"invisible");return ar`
405
+ <div
406
+ class="chat-widget-popup fixed flex flex-col bottom-0 z-40 ${yf({"right-0 items-end":t==="right","left-0 items-start":t==="left"})}"
407
+ style=${Ql({colorScheme:"normal"})}
408
+ >
409
+ <iai-chat
410
+ .options=${this.options}
411
+ class="${i}"
412
+ style="${Ql({"--iai-i-button-height":`${r}`})}"
413
+ @iai-chat-close=${this.toggleChat}
414
+ ></iai-chat>
415
+
416
+ ${_a(n&&!this.ctaClosed&&!this.isOpen,()=>ar`
417
+ <iai-chat-cta-bubble
418
+ class="mx-8"
419
+ .message=${n}
420
+ .pointerPosition=${t}
421
+ @hide=${()=>this.ctaClosed=!0}
422
+ ></iai-chat-cta-bubble>
423
+ `)}
424
+
425
+ <iai-chat-open-chat-button
426
+ class="m-8 mt-4 ${yf({hidden:this.isOpen,"md:block":this.isOpen})}"
427
+ .options=${this.cleanOptions}
428
+ @toggle-chat=${this.toggleChat}
429
+ ></iai-chat-open-chat-button>
430
+ </div>
431
+ `}toggleChat(){this.isOpen=!this.isOpen,this.cleanOptions.config.focusOnOpen&&setTimeout(()=>this.chatWindow.focusOnInput(),0);const t=this.isIosDevice&&window.innerWidth<768;t&&this.isOpen&&(this.initialScrollPosition={x:window.scrollX,y:window.scrollY}),this.onResizeHandler(),t&&!this.isOpen&&setTimeout(()=>{window.scrollTo(this.initialScrollPosition.x,this.initialScrollPosition.y)},500)}identifyIosDevice(){const{platform:t="",maxTouchPoints:e=0}=window.navigator||{};this.isIosDevice=typeof window<"u"&&!!window.navigator&&!!t&&(/iP(ad|hone|od)/.test(t)||t==="MacIntel"&&e>1)}setInitialHtmlOverflow(){var t;const{overflow:e="auto"}=((t=document.documentElement)==null?void 0:t.style)||{};this.initialHtmlOverflow=e}};ds.styles=[Zi,ba`
432
+ .chat-widget-popup {
433
+ pointer-events: none;
434
+ }
435
+
436
+ .chat-widget-popup > * {
437
+ pointer-events: auto;
438
+ }
439
+
440
+ @media(min-width: 768px) {
441
+ .chat-widget {
442
+ min-height: calc(10rem);
443
+ max-height: calc(100dvh - var(--iai-i-button-height, 48px) - 4rem);
444
+ }
445
+ }
446
+ `],yu([jr({type:Object})],ds.prototype,"options",2),yu([eo()],ds.prototype,"isOpen",2),yu([eo()],ds.prototype,"ctaClosed",2),yu([df("iai-chat")],ds.prototype,"chatWindow",2),yu([Hv.debounce(250)],ds.prototype,"onResizeHandler",2),ds=yu([Wi("iai-chat-popup")],ds);const h4=typeof window<"u"&&window||typeof global<"u"&&global||{},p4=h4.IAI_BACKEND_URL||"https://api.ai.inhabit.services",bu={async get(t,e={}){return this.request(t,{...e,method:"GET"})},async post(t,e={},r={}){return this.request(t,{...r,method:"POST",body:JSON.stringify(e)})},async put(t,e={},r={}){return this.request(t,{...r,method:"PUT",body:JSON.stringify(e)})},async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})},async patch(t,e={},r={}){return this.request(t,{...r,method:"PATCH",body:JSON.stringify(e)})},async request(t,e={}){const{returnFullResponse:r=!1,...n}=e,i={...n,headers:{"Content-Type":"application/json",...n.headers}};t=t.replace(/^\//,"");const a=await fetch(`${p4}/${t}`,i);if(!a.ok){if(a.status===429){const o=+(a.headers.get("Retry-After")||30);throw new gc(`Rate limited fetching /${t}: retry after ${o} seconds`,a.status,{retryAfter:o})}const s=[`Failed to fetch /${t}:`];try{const{message:o}=await a.json();if(!o)throw new Error;s.push(o)}catch{s.push(`${a.status} (${a.statusText})`)}throw new gc(s.join(" "),a.status)}if(r)return a;try{return await a.json()}catch{return null}}};async function v4(t,e={},r){return bu.post("/threads",{assistantId:t,params:e,clientId:r})}async function m4(t,e="No reason provided"){await bu.post(`/threads/${t}/end`,{reason:e})}async function g4(t,e){return bu.post(`/threads/${t}/messages`,{content:e})}async function y4(t,e,r){await bu.put(`/threads/${t}/messages/${e}/rate`,{rating:r})}async function b4(t,e,r,n=!1){return bu.post(`/threads/${t}/functions/${e}`,{params:r,rerunLLM:n})}async function w4(t){return bu.post(`/threads/${t}/ping`)}class gc extends Error{constructor(e,r,n){super(e),this.status=r,this.details=n}}function _4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}class k4{constructor(e,r={}){if(this._assistantId="",this._recurringKeepAliveInterval=null,this._recurringKeepAliveCallers=new Set,this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this._resetCounter=0,this.onStorageEvent=n=>{var i;const[a,s,o]=((i=n.key)==null?void 0:i.split("-"))||[];if(!(a!=="iaiChat"||s!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(n);break;case"conversation":this.setConversationDetails(JSON.parse(n.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(n.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(n.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(n.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(n.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(n.newValue||"false"),!0);break}},this.userMessageTypingId=null,this._assistantId=e,this._clientId=r.clientId,this.options={params:{},resetEndedChatOnLoad:!1,historyKey:"main",...r},this._emitter=_4(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),r.events&&Object.entries(r.events).forEach(([n,i])=>{this._emitter.on(n,i)}),r.historyKey){this._messages=this.storageGet("messageHistory",[]);const n=this.storageGet("conversation");n&&this.setConversationDetails(n,!0);const i=this.storageGet("chatEndingWarningSent");i&&this.setChatEndingWarningSent(i,!0);const a=this.storageGet("chatEnded");a&&this.setChatEnded(a,!0);const s=this.storageGet("typing");s&&this.setTyping(s,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const u=this.storageGet("lastActivity");u&&setTimeout(()=>this.keepAlive(u,!0),0),setTimeout(()=>{this.chatEnded&&this.options.resetEndedChatOnLoad&&this.reset()},0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const r=JSON.parse(e.newValue),n=this._messages.map(a=>a.id),i=r.map(a=>a.id);this._messages.forEach(a=>{i.includes(a.id)||this._emitter.emit("messageRemoved",a.id)}),r.forEach(a=>{n.includes(a.id)||this._emitter.emit("message",a)}),this._messages=r}async endChat(e,r=!0){!this.threadId||this.chatEnded||(r&&(this._emitter.emit("chatEnded"),this.setChatEnded(!0)),this.stopInactivityTimers(),await m4(this.threadId,e))}reset(e){this.endChat(e,!1).then(()=>{}),this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this._recurringKeepAliveCallers.forEach(r=>r()),this.stopInactivityTimers(),this.setChatEndingWarningSent(!1),this.storageRemoveAll(),this._resetCounter+=1,this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),r=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:n,timeUntilWarnAboutChatEnding:i}=this;if(!n)return;r||this.storageSet("lastActivity",e);const a=Date.now()-e;if(a>n){if(this.chatEnded)return;this.setChatEnded(!0),this._emitter.emit("chatEnded")}else a>i?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),i-a),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a))}registerRecurringKeepAlive(){if(!this.chatStarted)throw new Error("Chat not started");const e=()=>{this._recurringKeepAliveCallers.delete(e),this._recurringKeepAliveCallers.size===0&&this._recurringKeepAliveInterval&&(clearInterval(this._recurringKeepAliveInterval),this._recurringKeepAliveInterval=null)};return this._recurringKeepAliveCallers.add(e),this._recurringKeepAliveInterval||(this._recurringKeepAliveInterval=setInterval(()=>{this.chatStarted&&(this.keepAlive(),w4(this.threadId).then(()=>{}))},3e4)),e}async startChat(){if(this.chatStarted)return;const e=this.getResetChecker(),{id:r,inactivityWaitTime:n,inactivityWarningTime:i}=await v4(this.assistantId,this.params,this.clientId);if(!r)throw new Kv("Could not start chat","ChatStartError");if(e.resetOccurred)throw new Kv("Chat was reset","ChatReset");this.setConversationDetails({threadId:r,inactivityWaitTime:n,inactivityWarningTime:i})}handleSendUserMessageResponse({messages:e,functions:r}){this.addMessages(e),r.forEach(n=>this._emitter.emit("functionCall",n))}addMessages(e){e.forEach(r=>this.addMessage(r))}addMessage(e){const r={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(r),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",r),r}removeMessage(e){this._messages.find(r=>r.id===e)&&(this._messages=this._messages.filter(r=>r.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e))}async respondToFunctionCall(e,r,n){if(!this.threadId)throw new Error("Thread not started");try{const i=this.getResetChecker();this.setTyping(!0),this.keepAlive();const a=await b4(this.threadId,e,r,n);if(i.resetOccurred)return;this.handleSendUserMessageResponse(a)}catch(i){i instanceof gc&&i.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${i.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",i)}finally{this.setTyping(!1)}}getTypingManager(){let e=null;return{start:()=>{e=Math.random().toString(36).substring(7),this.userMessageTypingId=e,this.setTyping(!0)},done:()=>{this.userMessageTypingId===e&&(this.setTyping(!1),this.userMessageTypingId=null)}}}async sendUserMessage(e){const r=this.getTypingManager();try{const n=this.getResetChecker();if(this.addMessage({role:"user",content:e}),r.start(),!this.chatStarted){const{initialReplyMessage:a}=this.options;a&&this.addMessage({role:"assistant",content:a});try{await this.startChat()}catch(s){if(s instanceof gc&&s.status===429){this.sendErrorMessage(`You are starting new chats too quickly. You may try again in ${s.details.retryAfter} second(s).`);return}if(s instanceof Kv&&s.name==="ChatReset")return;throw s}}this.keepAlive();const i=await g4(this.threadId,e);if(n.resetOccurred)return;this.handleSendUserMessageResponse(i)}catch(n){n instanceof gc&&n.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${n.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",n)}finally{r.done()}}async rateMessage(e,r){const n=this._messages.find(i=>i.id===e);!n||n.role!=="assistant"||(n.userRating=r,this.storageSet("messageHistory",this._messages),await y4(this.threadId,e,r))}sendErrorMessage(e="There was an unexpected error. Please try again later."){this.addMessage({role:"assistant",content:e})}setTyping(e,r=!1){this.isTyping=e,this._emitter.emit("typing",e),r||this.storageSet("typing",e)}setConversationDetails(e,r=!1){this._conversationDetails=e,r||this.storageSet("conversation",e)}setInputDisabled(e,r=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),r||this.storageSet("inputDisabled",e)}setChatEnded(e,r=!1){this.chatEnded=e,r||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,r=!1){this.chatEndingWarningSent=e,r||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}getResetChecker(){const e=this._resetCounter,r=this;return{get resetOccurred(){return e!==r._resetCounter}}}get assistantId(){return this._assistantId}get clientId(){return this._clientId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:r=0}=this._conversationDetails||{};return(e-r)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,r){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(r))}storageGet(e,r=null){if(!this.options.historyKey)return null;const n=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return n?JSON.parse(n):r}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}class Kv extends Error{constructor(e,r){super(e),this.name=r}}var X_={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(vN,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",b="date",A="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,X={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Ee=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Ie={s:Ee,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Ee(Se,2,"0")+":"+Ee(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:b,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Fe="en",Oe={};Oe[Fe]=X;var ze="$isDayjsObject",V=function(oe){return oe instanceof Te||!(!oe||!oe[ze])},xe=function oe(q,ne,Se){var H;if(!q)return Fe;if(typeof q=="string"){var ye=q.toLowerCase();Oe[ye]&&(H=ye),ne&&(Oe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var M=q.name;Oe[M]=q,H=M}return!Se&&H&&(Fe=H),H||!Se&&Fe},_e=function(oe,q){if(V(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Ie;se.l=xe,se.i=V,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=xe(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var M=ke[2]-1||0,Xe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)):new Date(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==A},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),M=function(be,pt){var Ze=se.w(H.$u?Date.UTC(H.$y,pt,be):new Date(H.$y,pt,be),H);return ye?Ze:Ze.endOf(l)},Xe=function(be,pt){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(pt)),H)},Ct=this.$W,rt=this.$M,je=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?M(1,0):M(31,11);case d:return ye?M(1,rt):M(0,rt+1);case c:var Ke=this.$locale().weekStart||0,Be=(Ct<Ke?Ct+7:Ct)-Ke;return M(ye?je-Be:je+(6-Be),rt);case l:case b:return Xe(ce+"Hours",0);case u:return Xe(ce+"Minutes",1);case o:return Xe(ce+"Seconds",2);case s:return Xe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),M=(H={},H[l]=ke+"Date",H[b]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Xe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(b,1);Ct.$d[M](Xe),Ct.init(),this.$d=Ct.set(b,Math.min(this.$D,Ct.daysInMonth())).$d}else M&&this.$d[M](Xe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),M=function(rt){var je=_e(ye);return se.w(je.date(je.date()+Math.round(rt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return M(1);if(ke===c)return M(7);var Xe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Xe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||A;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),M=this.$H,Xe=this.$m,Ct=this.$M,rt=H.weekdays,je=H.months,ce=H.meridiem,Ke=function(pt,Ze,Jt,At){return pt&&(pt[Ze]||pt(Se,ye))||Jt[Ze].slice(0,At)},Be=function(pt){return se.s(M%12||12,pt,"0")},be=ce||function(pt,Ze,Jt){var At=pt<12?"AM":"PM";return Jt?At.toLowerCase():At};return ye.replace(z,function(pt,Ze){return Ze||function(Jt){switch(Jt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ke(H.monthsShort,Ct,je,3);case"MMMM":return Ke(je,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ke(H.weekdaysMin,Se.$W,rt,2);case"ddd":return Ke(H.weekdaysShort,Se.$W,rt,3);case"dddd":return rt[Se.$W];case"H":return String(M);case"HH":return se.s(M,2,"0");case"h":return Be(1);case"hh":return Be(2);case"a":return be(M,Xe,!0);case"A":return be(M,Xe,!1);case"m":return String(Xe);case"mm":return se.s(Xe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(pt)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,M=se.p(Se),Xe=_e(ne),Ct=(Xe.utcOffset()-this.utcOffset())*n,rt=this-Xe,je=function(){return se.m(ke,Xe)};switch(M){case m:ye=je()/12;break;case d:ye=je();break;case f:ye=je()/3;break;case c:ye=(rt-Ct)/6048e5;break;case l:ye=(rt-Ct)/864e5;break;case u:ye=rt/i;break;case o:ye=rt/n;break;case s:ye=rt/r;break;default:ye=rt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Oe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=xe(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),re=Te.prototype;return _e.prototype=re,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",b]].forEach(function(oe){re[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=xe,_e.isDayjs=V,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Oe[Fe],_e.Ls=Oe,_e.p={},_e})})(X_);var S4=X_.exports;const e1=z_(S4);function $4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}/**
447
+ * @license
448
+ * Copyright 2017 Google LLC
449
+ * SPDX-License-Identifier: BSD-3-Clause
450
+ */class Jv extends Nv{constructor(e){if(super(e),this.it=Yr,e.type!==Pv.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===Yr||e==null)return this._t=void 0,this.it=e;if(e===ns)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const r=[e];return r.raw=r,this._t={_$litType$:this.constructor.resultType,strings:r,values:[]}}}Jv.directiveName="unsafeHTML",Jv.resultType=1;const T4=Mv(Jv);function Yv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ho=Yv();function t1(t){ho=t}const r1=/[&<>"']/,E4=new RegExp(r1.source,"g"),n1=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,C4=new RegExp(n1.source,"g"),R4={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},i1=t=>R4[t];function Gn(t,e){if(e){if(r1.test(t))return t.replace(E4,i1)}else if(n1.test(t))return t.replace(C4,i1);return t}const x4=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function I4(t){return t.replace(x4,(e,r)=>(r=r.toLowerCase(),r==="colon"?":":r.charAt(0)==="#"?r.charAt(1)==="x"?String.fromCharCode(parseInt(r.substring(2),16)):String.fromCharCode(+r.substring(1)):""))}const A4=/(^|[^\[])\^/g;function xr(t,e){let r=typeof t=="string"?t:t.source;e=e||"";const n={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(A4,"$1"),r=r.replace(i,s),n},getRegex:()=>new RegExp(r,e)};return n}function a1(t){try{t=encodeURI(t).replace(/%25/g,"%")}catch{return null}return t}const yc={exec:()=>null};function s1(t,e){const r=t.replace(/\|/g,(a,s,o)=>{let u=!1,l=s;for(;--l>=0&&o[l]==="\\";)u=!u;return u?"|":" |"}),n=r.split(/ \|/);let i=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(/\\\|/g,"|");return n}function Af(t,e,r){const n=t.length;if(n===0)return"";let i=0;for(;i<n;){const a=t.charAt(n-i-1);if(a===e&&!r)i++;else if(a!==e&&r)i++;else break}return t.slice(0,n-i)}function O4(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let n=0;n<t.length;n++)if(t[n]==="\\")n++;else if(t[n]===e[0])r++;else if(t[n]===e[1]&&(r--,r<0))return n;return-1}function o1(t,e,r,n){const i=e.href,a=e.title?Gn(e.title):null,s=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){n.state.inLink=!0;const o={type:"link",raw:r,href:i,title:a,text:s,tokens:n.inlineTokens(s)};return n.state.inLink=!1,o}return{type:"image",raw:r,href:i,title:a,text:Gn(s)}}function P4(t,e){const r=t.match(/^(\s+)(?:```)/);if(r===null)return e;const n=r[1];return e.split(`
451
+ `).map(i=>{const a=i.match(/^\s+/);if(a===null)return i;const[s]=a;return s.length>=n.length?i.slice(n.length):i}).join(`
452
+ `)}class Of{constructor(e){Hr(this,"options"),Hr(this,"rules"),Hr(this,"lexer"),this.options=e||ho}space(e){const r=this.rules.block.newline.exec(e);if(r&&r[0].length>0)return{type:"space",raw:r[0]}}code(e){const r=this.rules.block.code.exec(e);if(r){const n=r[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:r[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Af(n,`
453
+ `)}}}fences(e){const r=this.rules.block.fences.exec(e);if(r){const n=r[0],i=P4(n,r[3]||"");return{type:"code",raw:n,lang:r[2]?r[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):r[2],text:i}}}heading(e){const r=this.rules.block.heading.exec(e);if(r){let n=r[2].trim();if(/#$/.test(n)){const i=Af(n,"#");(this.options.pedantic||!i||/ $/.test(i))&&(n=i.trim())}return{type:"heading",raw:r[0],depth:r[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const r=this.rules.block.hr.exec(e);if(r)return{type:"hr",raw:r[0]}}blockquote(e){const r=this.rules.block.blockquote.exec(e);if(r){let n=r[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
454
+ $1`);n=Af(n.replace(/^ *>[ \t]?/gm,""),`
455
+ `);const i=this.lexer.state.top;this.lexer.state.top=!0;const a=this.lexer.blockTokens(n);return this.lexer.state.top=i,{type:"blockquote",raw:r[0],tokens:a,text:n}}}list(e){let r=this.rules.block.list.exec(e);if(r){let n=r[1].trim();const i=n.length>1,a={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");const s=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let o="",u="",l=!1;for(;e;){let c=!1;if(!(r=s.exec(e))||this.rules.block.hr.test(e))break;o=r[0],e=e.substring(o.length);let d=r[2].split(`
456
+ `,1)[0].replace(/^\t+/,z=>" ".repeat(3*z.length)),f=e.split(`
457
+ `,1)[0],m=0;this.options.pedantic?(m=2,u=d.trimStart()):(m=r[2].search(/[^ ]/),m=m>4?1:m,u=d.slice(m),m+=r[1].length);let b=!1;if(!d&&/^ *$/.test(f)&&(o+=f+`
458
+ `,e=e.substring(f.length+1),c=!0),!c){const z=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),X=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),Ee=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),Ie=new RegExp(`^ {0,${Math.min(3,m-1)}}#`);for(;e;){const Fe=e.split(`
459
+ `,1)[0];if(f=Fe,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),Ee.test(f)||Ie.test(f)||z.test(f)||X.test(e))break;if(f.search(/[^ ]/)>=m||!f.trim())u+=`
460
+ `+f.slice(m);else{if(b||d.search(/[^ ]/)>=4||Ee.test(d)||Ie.test(d)||X.test(d))break;u+=`
461
+ `+f}!b&&!f.trim()&&(b=!0),o+=Fe+`
462
+ `,e=e.substring(Fe.length+1),d=f.slice(m)}}a.loose||(l?a.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let A=null,N;this.options.gfm&&(A=/^\[[ xX]\] /.exec(u),A&&(N=A[0]!=="[ ] ",u=u.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:o,task:!!A,checked:N,loose:!1,text:u,tokens:[]}),a.raw+=o}a.items[a.items.length-1].raw=o.trimEnd(),a.items[a.items.length-1].text=u.trimEnd(),a.raw=a.raw.trimEnd();for(let c=0;c<a.items.length;c++)if(this.lexer.state.top=!1,a.items[c].tokens=this.lexer.blockTokens(a.items[c].text,[]),!a.loose){const d=a.items[c].tokens.filter(m=>m.type==="space"),f=d.length>0&&d.some(m=>/\n.*\n/.test(m.raw));a.loose=f}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].loose=!0;return a}}html(e){const r=this.rules.block.html.exec(e);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(e){const r=this.rules.block.def.exec(e);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),i=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:i,title:a}}}table(e){const r=this.rules.block.table.exec(e);if(!r||!/[:|]/.test(r[2]))return;const n=s1(r[1]),i=r[2].replace(/^\||\| *$/g,"").split("|"),a=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
463
+ `):[],s={type:"table",raw:r[0],header:[],align:[],rows:[]};if(n.length===i.length){for(const o of i)/^ *-+: *$/.test(o)?s.align.push("right"):/^ *:-+: *$/.test(o)?s.align.push("center"):/^ *:-+ *$/.test(o)?s.align.push("left"):s.align.push(null);for(const o of n)s.header.push({text:o,tokens:this.lexer.inline(o)});for(const o of a)s.rows.push(s1(o,s.header.length).map(u=>({text:u,tokens:this.lexer.inline(u)})));return s}}lheading(e){const r=this.rules.block.lheading.exec(e);if(r)return{type:"heading",raw:r[0],depth:r[2].charAt(0)==="="?1:2,text:r[1],tokens:this.lexer.inline(r[1])}}paragraph(e){const r=this.rules.block.paragraph.exec(e);if(r){const n=r[1].charAt(r[1].length-1)===`
464
+ `?r[1].slice(0,-1):r[1];return{type:"paragraph",raw:r[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const r=this.rules.block.text.exec(e);if(r)return{type:"text",raw:r[0],text:r[0],tokens:this.lexer.inline(r[0])}}escape(e){const r=this.rules.inline.escape.exec(e);if(r)return{type:"escape",raw:r[0],text:Gn(r[1])}}tag(e){const r=this.rules.inline.tag.exec(e);if(r)return!this.lexer.state.inLink&&/^<a /i.test(r[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(r[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:r[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:r[0]}}link(e){const r=this.rules.inline.link.exec(e);if(r){const n=r[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const s=Af(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{const s=O4(r[2],"()");if(s>-1){const o=(r[0].indexOf("!")===0?5:4)+r[1].length+s;r[2]=r[2].substring(0,s),r[0]=r[0].substring(0,o).trim(),r[3]=""}}let i=r[2],a="";if(this.options.pedantic){const s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);s&&(i=s[1],a=s[3])}else a=r[3]?r[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(n)?i=i.slice(1):i=i.slice(1,-1)),o1(r,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},r[0],this.lexer)}}reflink(e,r){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const i=(n[2]||n[1]).replace(/\s+/g," "),a=r[i.toLowerCase()];if(!a){const s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return o1(n,a,n[0],this.lexer)}}emStrong(e,r,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(/[\p{L}\p{N}]/u))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){const a=[...i[0]].length-1;let s,o,u=a,l=0;const c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,r=r.slice(-1*e.length+a);(i=c.exec(r))!=null;){if(s=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!s)continue;if(o=[...s].length,i[3]||i[4]){u+=o;continue}else if((i[5]||i[6])&&a%3&&!((a+o)%3)){l+=o;continue}if(u-=o,u>0)continue;o=Math.min(o,o+u+l);const d=[...i[0]][0].length,f=e.slice(0,a+i.index+d+o);if(Math.min(a,o)%2){const b=f.slice(1,-1);return{type:"em",raw:f,text:b,tokens:this.lexer.inlineTokens(b)}}const m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){const r=this.rules.inline.code.exec(e);if(r){let n=r[2].replace(/\n/g," ");const i=/[^ ]/.test(n),a=/^ /.test(n)&&/ $/.test(n);return i&&a&&(n=n.substring(1,n.length-1)),n=Gn(n,!0),{type:"codespan",raw:r[0],text:n}}}br(e){const r=this.rules.inline.br.exec(e);if(r)return{type:"br",raw:r[0]}}del(e){const r=this.rules.inline.del.exec(e);if(r)return{type:"del",raw:r[0],text:r[2],tokens:this.lexer.inlineTokens(r[2])}}autolink(e){const r=this.rules.inline.autolink.exec(e);if(r){let n,i;return r[2]==="@"?(n=Gn(r[1]),i="mailto:"+n):(n=Gn(r[1]),i=n),{type:"link",raw:r[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var r;let n;if(n=this.rules.inline.url.exec(e)){let i,a;if(n[2]==="@")i=Gn(n[0]),a="mailto:"+i;else{let s;do s=n[0],n[0]=((r=this.rules.inline._backpedal.exec(n[0]))==null?void 0:r[0])??"";while(s!==n[0]);i=Gn(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:i,href:a,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){const r=this.rules.inline.text.exec(e);if(r){let n;return this.lexer.state.inRawBlock?n=r[0]:n=Gn(r[0]),{type:"text",raw:r[0],text:n}}}}const M4=/^(?: *(?:\n|$))+/,N4=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,L4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,D4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,u1=/(?:[*+-]|\d{1,9}[.)])/,l1=xr(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,u1).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Qv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,j4=/^[^\n]+/,Xv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,U4=xr(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",Xv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),F4=xr(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,u1).getRegex(),Pf="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",em=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,B4=xr("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",em).replace("tag",Pf).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),c1=xr(Qv).replace("hr",bc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Pf).getRegex(),z4=xr(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",c1).getRegex(),tm={blockquote:z4,code:N4,def:U4,fences:L4,heading:D4,hr:bc,html:B4,lheading:l1,list:F4,newline:M4,paragraph:c1,table:yc,text:j4},d1=xr("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Pf).getRegex(),H4={...tm,table:d1,paragraph:xr(Qv).replace("hr",bc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",d1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Pf).getRegex()},q4={...tm,html:xr(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",em).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:yc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:xr(Qv).replace("hr",bc).replace("heading",` *#{1,6} *[^
465
+ ]`).replace("lheading",l1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},f1=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,V4=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,h1=/^( {2,}|\\)\n(?!\s*$)/,W4=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,wc="\\p{P}\\p{S}",Z4=xr(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,wc).getRegex(),G4=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,K4=xr(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,wc).getRegex(),J4=xr("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,wc).getRegex(),Y4=xr("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,wc).getRegex(),Q4=xr(/\\([punct])/,"gu").replace(/punct/g,wc).getRegex(),X4=xr(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),eL=xr(em).replace("(?:-->|$)","-->").getRegex(),tL=xr("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",eL).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Mf=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,rL=xr(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Mf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),p1=xr(/^!?\[(label)\]\[(ref)\]/).replace("label",Mf).replace("ref",Xv).getRegex(),v1=xr(/^!?\[(ref)\](?:\[\])?/).replace("ref",Xv).getRegex(),nL=xr("reflink|nolink(?!\\()","g").replace("reflink",p1).replace("nolink",v1).getRegex(),rm={_backpedal:yc,anyPunctuation:Q4,autolink:X4,blockSkip:G4,br:h1,code:V4,del:yc,emStrongLDelim:K4,emStrongRDelimAst:J4,emStrongRDelimUnd:Y4,escape:f1,link:rL,nolink:v1,punctuation:Z4,reflink:p1,reflinkSearch:nL,tag:tL,text:W4,url:yc},iL={...rm,link:xr(/^!?\[(label)\]\((.*?)\)/).replace("label",Mf).getRegex(),reflink:xr(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Mf).getRegex()},nm={...rm,escape:xr(f1).replace("])","~|])").getRegex(),url:xr(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},aL={...nm,br:xr(h1).replace("{2,}","*").getRegex(),text:xr(nm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Nf={normal:tm,gfm:H4,pedantic:q4},_c={normal:rm,gfm:nm,breaks:aL,pedantic:iL};class Ji{constructor(e){Hr(this,"tokens"),Hr(this,"options"),Hr(this,"state"),Hr(this,"tokenizer"),Hr(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ho,this.options.tokenizer=this.options.tokenizer||new Of,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const r={block:Nf.normal,inline:_c.normal};this.options.pedantic?(r.block=Nf.pedantic,r.inline=_c.pedantic):this.options.gfm&&(r.block=Nf.gfm,this.options.breaks?r.inline=_c.breaks:r.inline=_c.gfm),this.tokenizer.rules=r}static get rules(){return{block:Nf,inline:_c}}static lex(e,r){return new Ji(r).lex(e)}static lexInline(e,r){return new Ji(r).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
466
+ `),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){const n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(o,u,l)=>u+" ".repeat(l.length));let n,i,a,s;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(o=>(n=o.call({lexer:this},e,r))?(e=e.substring(n.raw.length),r.push(n),!0):!1))){if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length),n.raw.length===1&&r.length>0?r[r.length-1].raw+=`
467
+ `:r.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),i=r[r.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
468
+ `+n.raw,i.text+=`
469
+ `+n.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):r.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length),i=r[r.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
470
+ `+n.raw,i.text+=`
471
+ `+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),r.push(n);continue}if(a=e,this.options.extensions&&this.options.extensions.startBlock){let o=1/0;const u=e.slice(1);let l;this.options.extensions.startBlock.forEach(c=>{l=c.call({lexer:this},u),typeof l=="number"&&l>=0&&(o=Math.min(o,l))}),o<1/0&&o>=0&&(a=e.substring(0,o+1))}if(this.state.top&&(n=this.tokenizer.paragraph(a))){i=r[r.length-1],s&&i.type==="paragraph"?(i.raw+=`
472
+ `+n.raw,i.text+=`
473
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):r.push(n),s=a.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length),i=r[r.length-1],i&&i.type==="text"?(i.raw+=`
474
+ `+n.raw,i.text+=`
475
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):r.push(n);continue}if(e){const o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let n,i,a,s=e,o,u,l;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)c.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,o.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(u||(l=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(n=c.call({lexer:this},e,r))?(e=e.substring(n.raw.length),r.push(n),!0):!1))){if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),i=r[r.length-1],i&&n.type==="text"&&i.type==="text"?(i.raw+=n.raw,i.text+=n.text):r.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length),i=r[r.length-1],i&&n.type==="text"&&i.type==="text"?(i.raw+=n.raw,i.text+=n.text):r.push(n);continue}if(n=this.tokenizer.emStrong(e,s,l)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),r.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),r.push(n);continue}if(a=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const d=e.slice(1);let f;this.options.extensions.startInline.forEach(m=>{f=m.call({lexer:this},d),typeof f=="number"&&f>=0&&(c=Math.min(c,f))}),c<1/0&&c>=0&&(a=e.substring(0,c+1))}if(n=this.tokenizer.inlineText(a)){e=e.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(l=n.raw.slice(-1)),u=!0,i=r[r.length-1],i&&i.type==="text"?(i.raw+=n.raw,i.text+=n.text):r.push(n);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return r}}class kc{constructor(e){Hr(this,"options"),this.options=e||ho}code(e,r,n){var i;const a=(i=(r||"").match(/^\S*/))==null?void 0:i[0];return e=e.replace(/\n$/,"")+`
476
+ `,a?'<pre><code class="language-'+Gn(a)+'">'+(n?e:Gn(e,!0))+`</code></pre>
477
+ `:"<pre><code>"+(n?e:Gn(e,!0))+`</code></pre>
478
+ `}blockquote(e){return`<blockquote>
479
+ ${e}</blockquote>
480
+ `}html(e,r){return e}heading(e,r,n){return`<h${r}>${e}</h${r}>
481
+ `}hr(){return`<hr>
482
+ `}list(e,r,n){const i=r?"ol":"ul",a=r&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
483
+ `+e+"</"+i+`>
484
+ `}listitem(e,r,n){return`<li>${e}</li>
485
+ `}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>
486
+ `}table(e,r){return r&&(r=`<tbody>${r}</tbody>`),`<table>
487
+ <thead>
488
+ `+e+`</thead>
489
+ `+r+`</table>
490
+ `}tablerow(e){return`<tr>
491
+ ${e}</tr>
492
+ `}tablecell(e,r){const n=r.header?"th":"td";return(r.align?`<${n} align="${r.align}">`:`<${n}>`)+e+`</${n}>
493
+ `}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,r,n){const i=a1(e);if(i===null)return n;e=i;let a='<a href="'+e+'"';return r&&(a+=' title="'+r+'"'),a+=">"+n+"</a>",a}image(e,r,n){const i=a1(e);if(i===null)return n;e=i;let a=`<img src="${e}" alt="${n}"`;return r&&(a+=` title="${r}"`),a+=">",a}text(e){return e}}class im{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,r,n){return""+n}image(e,r,n){return""+n}br(){return""}}class Yi{constructor(e){Hr(this,"options"),Hr(this,"renderer"),Hr(this,"textRenderer"),this.options=e||ho,this.options.renderer=this.options.renderer||new kc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new im}static parse(e,r){return new Yi(r).parse(e)}static parseInline(e,r){return new Yi(r).parseInline(e)}parse(e,r=!0){let n="";for(let i=0;i<e.length;i++){const a=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const s=a,o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(s.type)){n+=o||"";continue}}switch(a.type){case"space":continue;case"hr":{n+=this.renderer.hr();continue}case"heading":{const s=a;n+=this.renderer.heading(this.parseInline(s.tokens),s.depth,I4(this.parseInline(s.tokens,this.textRenderer)));continue}case"code":{const s=a;n+=this.renderer.code(s.text,s.lang,!!s.escaped);continue}case"table":{const s=a;let o="",u="";for(let c=0;c<s.header.length;c++)u+=this.renderer.tablecell(this.parseInline(s.header[c].tokens),{header:!0,align:s.align[c]});o+=this.renderer.tablerow(u);let l="";for(let c=0;c<s.rows.length;c++){const d=s.rows[c];u="";for(let f=0;f<d.length;f++)u+=this.renderer.tablecell(this.parseInline(d[f].tokens),{header:!1,align:s.align[f]});l+=this.renderer.tablerow(u)}n+=this.renderer.table(o,l);continue}case"blockquote":{const s=a,o=this.parse(s.tokens);n+=this.renderer.blockquote(o);continue}case"list":{const s=a,o=s.ordered,u=s.start,l=s.loose;let c="";for(let d=0;d<s.items.length;d++){const f=s.items[d],m=f.checked,b=f.task;let A="";if(f.task){const N=this.renderer.checkbox(!!m);l?f.tokens.length>0&&f.tokens[0].type==="paragraph"?(f.tokens[0].text=N+" "+f.tokens[0].text,f.tokens[0].tokens&&f.tokens[0].tokens.length>0&&f.tokens[0].tokens[0].type==="text"&&(f.tokens[0].tokens[0].text=N+" "+f.tokens[0].tokens[0].text)):f.tokens.unshift({type:"text",text:N+" "}):A+=N+" "}A+=this.parse(f.tokens,l),c+=this.renderer.listitem(A,b,!!m)}n+=this.renderer.list(c,o,u);continue}case"html":{const s=a;n+=this.renderer.html(s.text,s.block);continue}case"paragraph":{const s=a;n+=this.renderer.paragraph(this.parseInline(s.tokens));continue}case"text":{let s=a,o=s.tokens?this.parseInline(s.tokens):s.text;for(;i+1<e.length&&e[i+1].type==="text";)s=e[++i],o+=`
494
+ `+(s.tokens?this.parseInline(s.tokens):s.text);n+=r?this.renderer.paragraph(o):o;continue}default:{const s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}parseInline(e,r){r=r||this.renderer;let n="";for(let i=0;i<e.length;i++){const a=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=s||"";continue}}switch(a.type){case"escape":{const s=a;n+=r.text(s.text);break}case"html":{const s=a;n+=r.html(s.text);break}case"link":{const s=a;n+=r.link(s.href,s.title,this.parseInline(s.tokens,r));break}case"image":{const s=a;n+=r.image(s.href,s.title,s.text);break}case"strong":{const s=a;n+=r.strong(this.parseInline(s.tokens,r));break}case"em":{const s=a;n+=r.em(this.parseInline(s.tokens,r));break}case"codespan":{const s=a;n+=r.codespan(s.text);break}case"br":{n+=r.br();break}case"del":{const s=a;n+=r.del(this.parseInline(s.tokens,r));break}case"text":{const s=a;n+=r.text(s.text);break}default:{const s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}}class Sc{constructor(e){Hr(this,"options"),this.options=e||ho}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}Hr(Sc,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var Lf,am,sm,m1;class g1{constructor(...e){A0(this,Lf),A0(this,sm),Hr(this,"defaults",Yv()),Hr(this,"options",this.setOptions),Hr(this,"parse",yv(this,Lf,am).call(this,Ji.lex,Yi.parse)),Hr(this,"parseInline",yv(this,Lf,am).call(this,Ji.lexInline,Yi.parseInline)),Hr(this,"Parser",Yi),Hr(this,"Renderer",kc),Hr(this,"TextRenderer",im),Hr(this,"Lexer",Ji),Hr(this,"Tokenizer",Of),Hr(this,"Hooks",Sc),this.use(...e)}walkTokens(e,r){var n,i;let a=[];for(const s of e)switch(a=a.concat(r.call(this,s)),s.type){case"table":{const o=s;for(const u of o.header)a=a.concat(this.walkTokens(u.tokens,r));for(const u of o.rows)for(const l of u)a=a.concat(this.walkTokens(l.tokens,r));break}case"list":{const o=s;a=a.concat(this.walkTokens(o.items,r));break}default:{const o=s;(i=(n=this.defaults.extensions)==null?void 0:n.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(u=>{const l=o[u].flat(1/0);a=a.concat(this.walkTokens(l,r))}):o.tokens&&(a=a.concat(this.walkTokens(o.tokens,r)))}}return a}use(...e){const r=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const s=r.renderers[a.name];s?r.renderers[a.name]=function(...o){let u=a.renderer.apply(this,o);return u===!1&&(u=s.apply(this,o)),u}:r.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const s=r[a.level];s?s.unshift(a.tokenizer):r[a.level]=[a.tokenizer],a.start&&(a.level==="block"?r.startBlock?r.startBlock.push(a.start):r.startBlock=[a.start]:a.level==="inline"&&(r.startInline?r.startInline.push(a.start):r.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(r.childTokens[a.name]=a.childTokens)}),i.extensions=r),n.renderer){const a=this.defaults.renderer||new kc(this.defaults);for(const s in n.renderer){if(!(s in a))throw new Error(`renderer '${s}' does not exist`);if(s==="options")continue;const o=s,u=n.renderer[o],l=a[o];a[o]=(...c)=>{let d=u.apply(a,c);return d===!1&&(d=l.apply(a,c)),d||""}}i.renderer=a}if(n.tokenizer){const a=this.defaults.tokenizer||new Of(this.defaults);for(const s in n.tokenizer){if(!(s in a))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;const o=s,u=n.tokenizer[o],l=a[o];a[o]=(...c)=>{let d=u.apply(a,c);return d===!1&&(d=l.apply(a,c)),d}}i.tokenizer=a}if(n.hooks){const a=this.defaults.hooks||new Sc;for(const s in n.hooks){if(!(s in a))throw new Error(`hook '${s}' does not exist`);if(s==="options")continue;const o=s,u=n.hooks[o],l=a[o];Sc.passThroughHooks.has(s)?a[o]=c=>{if(this.defaults.async)return Promise.resolve(u.call(a,c)).then(f=>l.call(a,f));const d=u.call(a,c);return l.call(a,d)}:a[o]=(...c)=>{let d=u.apply(a,c);return d===!1&&(d=l.apply(a,c)),d}}i.hooks=a}if(n.walkTokens){const a=this.defaults.walkTokens,s=n.walkTokens;i.walkTokens=function(o){let u=[];return u.push(s.call(this,o)),a&&(u=u.concat(a.call(this,o))),u}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,r){return Ji.lex(e,r??this.defaults)}parser(e,r){return Yi.parse(e,r??this.defaults)}}Lf=new WeakSet,am=function(t,e){return(r,n)=>{const i={...n},a={...this.defaults,...i};this.defaults.async===!0&&i.async===!1&&(a.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),a.async=!0);const s=yv(this,sm,m1).call(this,!!a.silent,!!a.async);if(typeof r>"u"||r===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(a.hooks&&(a.hooks.options=a),a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(r):r).then(o=>t(o,a)).then(o=>a.hooks?a.hooks.processAllTokens(o):o).then(o=>a.walkTokens?Promise.all(this.walkTokens(o,a.walkTokens)).then(()=>o):o).then(o=>e(o,a)).then(o=>a.hooks?a.hooks.postprocess(o):o).catch(s);try{a.hooks&&(r=a.hooks.preprocess(r));let o=t(r,a);a.hooks&&(o=a.hooks.processAllTokens(o)),a.walkTokens&&this.walkTokens(o,a.walkTokens);let u=e(o,a);return a.hooks&&(u=a.hooks.postprocess(u)),u}catch(o){return s(o)}}},sm=new WeakSet,m1=function(t,e){return r=>{if(r.message+=`
495
+ Please report this to https://github.com/markedjs/marked.`,t){const n="<p>An error occurred:</p><pre>"+Gn(r.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(r);throw r}};const po=new g1;function Ir(t,e){return po.parse(t,e)}Ir.options=Ir.setOptions=function(t){return po.setOptions(t),Ir.defaults=po.defaults,t1(Ir.defaults),Ir},Ir.getDefaults=Yv,Ir.defaults=ho,Ir.use=function(...t){return po.use(...t),Ir.defaults=po.defaults,t1(Ir.defaults),Ir},Ir.walkTokens=function(t,e){return po.walkTokens(t,e)},Ir.parseInline=po.parseInline,Ir.Parser=Yi,Ir.parser=Yi.parse,Ir.Renderer=kc,Ir.TextRenderer=im,Ir.Lexer=Ji,Ir.lexer=Ji.lex,Ir.Tokenizer=Of,Ir.Hooks=Sc,Ir.parse=Ir,Ir.options,Ir.setOptions,Ir.use,Ir.walkTokens,Ir.parseInline,Yi.parse,Ji.lex;const om=new kc;om.link=(t,e,r)=>{const n=document.createElement("a");return n.setAttribute("href",t),n.setAttribute("target","_blank"),n.setAttribute("rel","noopener nofollow"),n.textContent=r,e&&n.setAttribute("title",e),n.outerHTML};const sL=new g1({renderer:om});function oL(t){const e=uL(t);return sL.parse(e,{renderer:om})}function um(t){const e=oL(t);return ar`
496
+ <div class="flex flex-col gap-3">
497
+ ${T4(e)}
498
+ </div>
499
+ `}function uL(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.replace(/[&<>"']/g,r=>e[r])}var lL=Object.defineProperty,cL=Object.getOwnPropertyDescriptor,ii=(t,e,r,n)=>{for(var i=n>1?void 0:n?cL(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&lL(e,r,i),i},y1=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},$c=(t,e,r)=>(y1(t,e,"read from private field"),r?r.call(t):e.get(t)),dL=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},fL=(t,e,r,n)=>(y1(t,e,"write to private field"),e.set(t,r),r),fs;let Dn=class extends Ln{constructor(){super(),dL(this,fs,void 0),this.disableInput=!1,this.showTyping=!1,this.messages=[],this.inputValue="",this.internalShowTyping=!1,this.showPopoverDisclaimer=!1,this.previousThreads=[],this._emitter=$4(),this._emitter.on("*",(t,e)=>this.dispatchEvent(new CustomEvent(`iai-chat-${t.toString()}`,{bubbles:!0,composed:!0,detail:e})))}connectedCallback(){super.connectedCallback(),this.cleanOptions=If.parse(this.options||{});const{assistantId:t,clientId:e,params:r,config:n}=this.cleanOptions;this.checkIfDisclaimerShouldBeShown(),fL(this,fs,new k4(t,{clientId:e,params:r,historyKey:n.historyKey,initialReplyMessage:n.initialReplyMessage,resetEndedChatOnLoad:n.resetEndedChatOnLoad})),this.updateMessages($c(this,fs).messages),this.showTyping=$c(this,fs).isTyping,this.disableInput=$c(this,fs).inputDisabled,this.chatManager.on("functionCall",({id:i,name:a,params:s})=>{const o=this.cleanOptions.handlers.functionCalls[a];if(!o){console.warn(`No function call handler found for ${a}`);return}o.call(this,{id:i,params:s,html:ar,chatWindow:this})}),this.chatManager.on("typing",i=>{this.showTyping=i}),this.chatManager.on("inputDisabled",i=>{this.disableInput=i}),this.chatManager.on("inactivityWarning",()=>{this.addMessage({role:"assistant",content:n.inactivityWarningMessage})}),this.chatManager.on("chatEnded",()=>{this.addMessage({role:"system",content:n.chatEndedMessage}),this.previousThreads.push([...this.messages]),this.chatManager.reset()}),this.chatManager.on("message",i=>{this.updateMessages([...this.messages,i])}),this.chatManager.on("messageRemoved",i=>{this.updateMessages(this.messages.filter(a=>a.id!==i))}),this.chatManager.on("reset",()=>{this.updateMessages([]),this.checkIfDisclaimerShouldBeShown()}),this.chatManager.on("*",this._emitter.emit)}disconnectedCallback(){super.disconnectedCallback(),this._emitter.all.clear(),$c(this,fs).destroy()}updateMessages(t){this.messages=[...t],this.scrollChatToBottom()}render(){const{chatWindow:t,disclaimerMessage:e,disclaimerPopover:r}=this.cleanOptions.config,{header:n,showCloseButton:i}=t;return ar`
500
+ <div class="relative flex flex-col h-full rounded-lg shadow-lg bg-white text-black">
501
+ <div class="header rounded-t-lg text-lg p-2 flex justify-between items-center h-12">
137
502
  <div class="flex flex-row h-full items-center">
138
- ${ct(s.imageSrc,()=>z`
139
- <img src="${s.imageSrc}" alt="Logo" style="max-height: 100%" />
503
+ ${_a(n.imageSrc,()=>ar`
504
+ <img src="${n.imageSrc}" alt="Logo" style="max-height: 100%" />
140
505
  `)}
141
- ${ct(s.text,()=>z`
142
- <span class="text-lg font-semibold ml-2">${s.text}</span>
506
+ ${_a(n.text,()=>ar`
507
+ <span class="text-lg font-semibold ml-2">${n.text}</span>
143
508
  `)}
144
509
  </div>
145
510
 
146
511
  <div class="flex-grow"></div>
147
512
 
148
513
  <button
149
- class="mr-2 h-6 focus:outline-none"
514
+ class="mr-2 h-6 w-6"
150
515
  @click="${this.resetChat}"
151
516
  >
152
- ${Fr}
517
+ ${_M}
153
518
  </button>
154
519
 
155
- ${ct(e,()=>z`
156
- <button class="mr-2 h-6 focus:outline-none" @click="${this.closeChat}">
157
- ${As}
520
+ ${_a(i,()=>ar`
521
+ <button class="mr-2 h-6 w-6" @click="${this.closeChat}">
522
+ ${kM}
158
523
  </button>
159
524
  `)}
160
525
  </div>
526
+
527
+ ${_a(this.showPopoverDisclaimer,()=>ar`
528
+ <div class="absolute top-12 left-0 right-0 bottom-0 bg-white z-10 flex flex-col gap-2 rounded-b-lg">
529
+ <div class="flex-grow overflow-y-auto pt-4 px-4 relative">
530
+ ${um(r.message)}
531
+
532
+ <div class="sticky bottom-[-1px] left-0 right-0 h-12 bg-gradient-to-t from-white to-transparent"></div>
533
+ </div>
161
534
 
535
+ <div class="m-4 text-right">
536
+ <button
537
+ class="button rounded-lg p-2"
538
+ @click="${this.acceptDisclaimer}"
539
+ >
540
+ ${r.agreeButtonText}
541
+ </button>
542
+ </div>
543
+ </div>
544
+ `)}
545
+
162
546
  <div id="chat-container" class="flex-1 overflow-y-auto p-4 flex flex-col gap-2">
163
- ${this.chatMessage({id:"intro-message",role:"assistant",content:this.cleanOptions.config.welcomeMessage})}
547
+ ${Ov(this.previousThreads,(a,s)=>s,(a,s)=>ar`
548
+ ${this.listMessages(a,`${s}`)}
164
549
 
165
- ${Ur(this.messages,t=>t.id,(t,i)=>z`
166
- <div>
167
- ${this.nameLabel(i)}
168
- ${this.chatMessage(t)}
169
- </div>
550
+ ${this.chatMessage({id:`chat-started-message-${s}`,role:"system",content:"Chat Started"})}
170
551
  `)}
552
+
553
+ ${this.listMessages(this.messages,"primary")}
171
554
  </div>
172
555
 
173
- <div class="p-4">
174
- <div class="mb-1 ml-1 ${this.internalShowTyping||this.showTyping?"text-gray-400":"text-white"}">
556
+ <div class="px-4 pt-2 pb-2">
557
+ <div class="mb-1 ml-1 text-sm ${this.internalShowTyping||this.showTyping?"text-gray-400":"text-white"}">
175
558
  Agent is typing...
176
559
  </div>
177
560
 
178
561
  <form @submit="${this.sendUserMessage}">
179
- <div class="flex items-center space-x-2">
180
- <input
562
+ <div class="flex items-end space-x-2">
563
+ <textarea
181
564
  id="message-input"
182
565
  type="text"
183
- class="flex-1 p-2 border rounded-lg focus:outline-none disabled:bg-gray-200"
566
+ class="flex-1 p-2 border rounded-lg disabled:bg-gray-200 max-h-20 bg-white text-black resize-none"
567
+ rows="1"
184
568
  placeholder="Type your message..."
185
569
  autocomplete="off"
186
- .disabled="${this.internalDisableInput||this.disableInput}"
570
+ maxlength="500"
571
+ .disabled="${this.disableInput}"
187
572
  .value="${this.inputValue}"
188
- @input="${t=>this.inputValue=t.target.value}"
189
- >
573
+ @input="${this.handleInput}"
574
+ @keydown="${a=>this.handleKeyDown(a)}"
575
+ ></textarea>
190
576
  <button
191
577
  type="submit"
192
- class="button rounded-lg p-2 disabled:opacity-50 h-9"
193
- .disabled="${!this.inputValue||this.internalDisableInput||this.disableInput}"
578
+ class="button rounded-lg p-2 disabled:opacity-50 h-9 w-9"
579
+ .disabled="${this.isSubmitDisabled}"
194
580
  >
195
- ${Br}
581
+ ${wM}
196
582
  </button>
197
583
  </div>
198
584
  </form>
585
+
586
+ <p class="text-center text-gray-400 text-sm pt-1">
587
+ ${e}
588
+ </p>
199
589
  </div>
200
590
  </div>
201
- `}get chatManager(){return dt(this,Pe)}resetChat(){this.chatManager.reset()}addMessage(s){return this.chatManager.addMessage(s)}removeMessage(s){this.chatManager.removeMessage(s)}setInputDisabled(s=!0){this.chatManager.setInputDisabled(s)}setTypingIndicatorVisible(s=!0){this.chatManager.setTyping(s)}async sendFunctionCallResponse(s,e,t=!1){try{await this.chatManager.respondToFunctionCall(s,e,t)}catch(i){console.error("sendFunctionCallResponse error",i),this.addMessage({role:"assistant",content:"An unexpected error occurred. Please try again later."})}}async sendUserMessage(s){s.preventDefault(),!(this.internalDisableInput||this.disableInput)&&(this.internalDisableInput=!0,this.dispatchEvent(new CustomEvent("iai-chat-send-user-message",{bubbles:!0,composed:!0,detail:{message:this.inputValue},cancelable:!0}))&&(await dt(this,as),Di(this,as,this.chatManager.sendUserMessage(this.inputValue))),this.inputValue="",this.internalDisableInput=!1,setTimeout(()=>{this.focusOnInput()},0))}focusOnInput(){var s;const e=(s=this.shadowRoot)==null?void 0:s.getElementById("message-input");e==null||e.focus()}scrollChatToBottom(){var s;const e=(s=this.shadowRoot)==null?void 0:s.getElementById("chat-container");e==null||e.scrollTo({top:e==null?void 0:e.scrollHeight,behavior:"smooth"})}nameLabel(s){const e=this.messages[s];if(e.role!=="assistant")return null;const t=e.name||"Assistant",i=this.messages[s-1];return((i==null?void 0:i.name)||"Assistant")===t?null:z`
202
- <div class="name text-sm">${e.name||"Assistant"}</div>
203
- `}chatMessage(s){switch(s.role){case"assistant":return z`
591
+ `}get isSubmitDisabled(){return!this.inputValue||this.disableInput}handleKeyDown(t){t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),!this.isSubmitDisabled&&this.sendUserMessage(t))}checkIfDisclaimerShouldBeShown(){const{config:t}=this.cleanOptions,e=localStorage.getItem(`iaiChatWindow-${t.historyKey}-acceptedDisclaimerTime`);this.showPopoverDisclaimer=!!(t.disclaimerPopover.message&&(!e||e1().diff(e,"minutes")>=t.disclaimerPopover.rememberDurationMinutes))}acceptDisclaimer(){localStorage.setItem(`iaiChatWindow-${this.cleanOptions.config.historyKey}-acceptedDisclaimerTime`,e1().toISOString()),this.showPopoverDisclaimer=!1}handleInput(){const{inputElement:t,chatContainer:e}=this;if(!t||!e)return;this.inputValue=t.value;const{scrollTop:r,clientHeight:n,scrollHeight:i}=e,a=r+n>=i;t.style.height="auto",t.style.height=`${t.scrollHeight+2}px`,a&&this.scrollChatToBottom()}get chatManager(){return $c(this,fs)}resetChat(){this.previousThreads=[],this.chatManager.reset("Manually reset by user")}addMessage(t){return this.chatManager.addMessage(t)}removeMessage(t){this.chatManager.removeMessage(t)}setInputDisabled(t=!0){this.chatManager.setInputDisabled(t)}setTypingIndicatorVisible(t=!0){this.chatManager.setTyping(t)}async sendFunctionCallResponse(t,e,r=!1){try{await this.chatManager.respondToFunctionCall(t,e,r)}catch(n){console.error("sendFunctionCallResponse error",n),this.addMessage({role:"assistant",content:"An unexpected error occurred. Please try again later."})}}async sendUserMessage(t){t.preventDefault(),!this.disableInput&&(this.dispatchEvent(new CustomEvent("iai-chat-send-user-message",{bubbles:!0,composed:!0,detail:{message:this.inputValue},cancelable:!0}))&&this.chatManager.sendUserMessage(this.inputValue).then(),this.inputValue="",this.inputElement&&(this.inputElement.style.height="auto"),this.focusOnInput())}focusOnInput(){var t;(t=this.inputElement)==null||t.focus()}scrollChatToBottom(){const{chatContainer:t}=this;t==null||t.scrollTo({top:t==null?void 0:t.scrollHeight,behavior:"smooth"})}listMessages(t,e=Math.random().toString(36).substring(7)){const r=this.chatMessage({id:`intro-message-${e}`,role:"assistant",content:this.cleanOptions.config.welcomeMessage},{disableRatingControls:!0});return ar`
592
+ ${r}
593
+
594
+ ${Ov(t,n=>n.id,(n,i)=>ar`
595
+ <div>
596
+ ${this.nameLabel(t,i)}
597
+ ${this.chatMessage(n)}
598
+ </div>
599
+ `)}`}nameLabel(t,e){const r=t[e];if(r.role!=="assistant")return null;const n=r.name||"Assistant",i=t[e-1];return((i==null?void 0:i.name)||"Assistant")===n?null:ar`
600
+ <div class="name text-sm">${r.name||"Assistant"}</div>
601
+ `}rateMessage(t,e){this.chatManager.rateMessage(t,e).then()}chatMessage(t,e={}){switch(t.role){case"assistant":return ar`
204
602
  <iai-chat-message-assistant
205
- id="message-${s.id}"
206
- .content="${s.content}"
603
+ id="message-${t.id}"
604
+ .content="${t.content}"
605
+ .showRatingControls="${!(this.cleanOptions.config.disableMessageRating||e.disableRatingControls)}"
606
+ rating="${t.userRating||0}"
607
+ @rate-message="${r=>this.rateMessage(t.id,r.detail.rating)}"
207
608
  ></iai-chat-message-assistant>
208
- `;case"user":return z`
609
+ `;case"user":return ar`
209
610
  <iai-chat-message-user
210
- id="message-${s.id}"
211
- .content="${s.content}"
611
+ id="message-${t.id}"
612
+ .content="${t.content}"
212
613
  ></iai-chat-message-user>
213
- `;case"system":return z`
614
+ `;case"system":return ar`
214
615
  <iai-chat-message-system
215
- id="message-${s.id}"
216
- .content="${s.content}"
217
- .enhancedContent="${s.enhancedContent}"
218
- .contentHtmlTemplate="${s.contentHtmlTemplate}"
616
+ id="message-${t.id}"
617
+ .content="${t.content}"
618
+ .enhancedContent="${t.enhancedContent}"
619
+ .contentHtmlTemplate="${t.contentHtmlTemplate}"
219
620
  .options="${this.cleanOptions}"
220
621
  ></iai-chat-message-system>
221
- `;default:return""}}closeChat(){this._emitter.emit("close")}};Pe=new WeakMap,as=new WeakMap,oe.styles=[Ee,Qe`
622
+ `;default:return""}}closeChat(){this._emitter.emit("close")}};fs=new WeakMap,Dn.styles=[Zi,ba`
222
623
  .header {
223
624
  background-color: var(--iai-chat-i-header-bg);
224
625
  color: var(--iai-chat-i-header-fg);
225
- height: 50px;
226
626
  }
227
627
 
228
628
  .button {
@@ -234,119 +634,702 @@
234
634
  .name {
235
635
  color: #8c8c8c;
236
636
  }
237
- `],be([J({type:Object})],oe.prototype,"options",2),be([J()],oe.prototype,"disableInput",2),be([J()],oe.prototype,"showTyping",2),be([it()],oe.prototype,"messages",2),be([it()],oe.prototype,"inputValue",2),be([it()],oe.prototype,"internalDisableInput",2),be([it()],oe.prototype,"internalShowTyping",2),be([$s.debounce(1)],oe.prototype,"scrollChatToBottom",1),oe=be([Ce("iai-chat")],oe);var Ui={exports:{}};(function(s){(function(e){if(typeof window>"u")return;var t=0,i=!1,n=!1,r="message",a=r.length,o="[iFrameSizer]",c=o.length,l=null,h=window.requestAnimationFrame,p=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),d={},b=null,N=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){ce("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function H(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function ee(u,y,M){u.addEventListener(y,M,!1)}function _e(u,y,M){u.removeEventListener(y,M,!1)}function xe(){var u=["moz","webkit","o","ms"],y;for(y=0;y<u.length&&!h;y+=1)h=window[u[y]+"RequestAnimationFrame"];h?h=h.bind(window):O("setup","RequestAnimationFrame not supported")}function te(u){var y="Host page: "+u;return window.top!==window.self&&(y=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+u:"Nested host page: "+u),y}function ut(u){return o+"["+te(u)+"]"}function ke(u){return d[u]?d[u].log:i}function O(u,y){Ms("log",u,y,ke(u))}function qi(u,y){Ms("info",u,y,ke(u))}function ce(u,y){Ms("warn",u,y,!0)}function Ms(u,y,M,x){x===!0&&typeof window.console=="object"&&console[u](ut(y),M)}function xa(u){function y(){function v(){tn(R),Xi($),Ge("onResized",R)}Z("Height"),Z("Width"),sn(v,R,"init")}function M(){var v=le.slice(c).split(":"),A=v[1]?parseInt(v[1],10):0,L=d[v[0]]&&d[v[0]].iframe,D=getComputedStyle(L);return{iframe:L,id:v[0],height:A+x(D)+P(D),width:v[2],type:v[3]}}function x(v){if(v.boxSizing!=="border-box")return 0;var A=v.paddingTop?parseInt(v.paddingTop,10):0,L=v.paddingBottom?parseInt(v.paddingBottom,10):0;return A+L}function P(v){if(v.boxSizing!=="border-box")return 0;var A=v.borderTopWidth?parseInt(v.borderTopWidth,10):0,L=v.borderBottomWidth?parseInt(v.borderBottomWidth,10):0;return A+L}function Z(v){var A=Number(d[$]["max"+v]),L=Number(d[$]["min"+v]),D=v.toLowerCase(),K=Number(R[D]);O($,"Checking "+D+" is in range "+L+"-"+A),K<L&&(K=L,O($,"Set "+D+" to min value")),K>A&&(K=A,O($,"Set "+D+" to max value")),R[D]=""+K}function fe(){function v(){function D(){var X=0,$e=!1;for(O($,"Checking connection is from allowed list of origins: "+L);X<L.length;X++)if(L[X]===A){$e=!0;break}return $e}function K(){var X=d[$]&&d[$].remoteHost;return O($,"Checking connection is from: "+X),A===X}return L.constructor===Array?D():K()}var A=u.origin,L=d[$]&&d[$].checkOrigin;if(L&&""+A!="null"&&!v())throw new Error("Unexpected message received from: "+A+" for "+R.iframe.id+". Message was: "+u.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function Ye(){return o===(""+le).slice(0,c)&&le.slice(c).split(":")[0]in d}function Se(){var v=R.type in{true:1,false:1,undefined:1};return v&&O($,"Ignoring init message from meta parent page"),v}function Te(v){return le.slice(le.indexOf(":")+a+v)}function Ne(v){O($,"onMessage passed: {iframe: "+R.iframe.id+", message: "+v+"}"),Ge("onMessage",{iframe:R.iframe,message:JSON.parse(v)}),O($,"--")}function Ls(){var v=document.body.getBoundingClientRect(),A=R.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:A.height,iframeWidth:A.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(A.top-v.top,10),offsetLeft:parseInt(A.left-v.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function ps(v,A){function L(){me("Send Page Info","pageInfo:"+Ls(),v,A)}Sa(L,32,A)}function zs(){function v(K,X){function $e(){d[D]?ps(d[D].iframe,D):A()}["scroll","resize"].forEach(function(cn){O(D,K+cn+" listener for sendPageInfo"),X(window,cn,$e)})}function A(){v("Remove ",_e)}function L(){v("Add ",ee)}var D=$;L(),d[D]&&(d[D].stopPageInfo=A)}function Ds(){d[$]&&d[$].stopPageInfo&&(d[$].stopPageInfo(),delete d[$].stopPageInfo)}function Us(){var v=!0;return R.iframe===null&&(ce($,"IFrame ("+R.id+") not found"),v=!1),v}function k(v){var A=v.getBoundingClientRect();return Gi($),{x:Math.floor(Number(A.left)+Number(l.x)),y:Math.floor(Number(A.top)+Number(l.y))}}function S(v){function A(){l=X,W(),O($,"--")}function L(){return{x:Number(R.width)+K.x,y:Number(R.height)+K.y}}function D(){window.parentIFrame?window.parentIFrame["scrollTo"+(v?"Offset":"")](X.x,X.y):ce($,"Unable to scroll to requested position, window.parentIFrame not found")}var K=v?k(R.iframe):{x:0,y:0},X=L();O($,"Reposition requested from iFrame (offset x:"+K.x+" y:"+K.y+")"),window.top===window.self?A():D()}function W(){Ge("onScroll",l)===!1?Qi():Xi($)}function Y(v){function A(){var $e=k(X);O($,"Moving to in page link (#"+D+") at x: "+$e.x+" y: "+$e.y),l={x:$e.x,y:$e.y},W(),O($,"--")}function L(){window.parentIFrame?window.parentIFrame.moveToAnchor(D):O($,"In page link #"+D+" not found and window.parentIFrame not found")}var D=v.split("#")[1]||"",K=decodeURIComponent(D),X=document.getElementById(K)||document.getElementsByName(K)[0];X?A():window.top===window.self?O($,"In page link #"+D+" not found"):L()}function de(v){var A={};if(Number(R.width)===0&&Number(R.height)===0){var L=Te(9).split(":");A={x:L[1],y:L[0]}}else A={x:R.width,y:R.height};Ge(v,{iframe:R.iframe,screenX:Number(A.x),screenY:Number(A.y),type:R.type})}function Ge(v,A){return Ps($,v,A)}function Hs(){switch(d[$]&&d[$].firstRun&&Vs(),R.type){case"close":{Ns(R.iframe);break}case"message":{Ne(Te(6));break}case"mouseenter":{de("onMouseEnter");break}case"mouseleave":{de("onMouseLeave");break}case"autoResize":{d[$].autoResize=JSON.parse(Te(9));break}case"scrollTo":{S(!1);break}case"scrollToOffset":{S(!0);break}case"pageInfo":{ps(d[$]&&d[$].iframe,$),zs();break}case"pageInfoStop":{Ds();break}case"inPageLink":{Y(Te(9));break}case"reset":{en(R);break}case"init":{y(),Ge("onInit",R.iframe);break}default:Number(R.width)===0&&Number(R.height)===0?ce("Unsupported message received ("+R.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):y()}}function Bs(v){var A=!0;return d[v]||(A=!1,ce(R.type+" No settings for "+v+". Message was: "+le)),A}function Fs(){for(var v in d)me("iFrame requested init",nn(v),d[v].iframe,v)}function Vs(){d[$]&&(d[$].firstRun=!1)}var le=u.data,R={},$=null;le==="[iFrameResizerChild]Ready"?Fs():Ye()?(R=M(),$=R.id,d[$]&&(d[$].loaded=!0),!Se()&&Bs($)&&(O($,"Received: "+le),Us()&&fe()&&Hs())):qi($,"Ignored: "+le)}function Ps(u,y,M){var x=null,P=null;if(d[u])if(x=d[u][y],typeof x=="function")P=x(M);else throw new TypeError(y+" on iFrame["+u+"] is not a function");return P}function Yi(u){var y=u.id;delete d[y]}function Ns(u){var y=u.id;if(Ps(y,"onClose",y)===!1){O(y,"Close iframe cancelled by onClose event");return}O(y,"Removing iFrame: "+y);try{u.parentNode&&u.parentNode.removeChild(u)}catch(M){ce(M)}Ps(y,"onClosed",y),O(y,"--"),Yi(u)}function Gi(u){l===null&&(l={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},O(u,"Get page position: "+l.x+","+l.y))}function Xi(u){l!==null&&(window.scrollTo(l.x,l.y),O(u,"Set page position: "+l.x+","+l.y),Qi())}function Qi(){l=null}function en(u){function y(){tn(u),me("reset","reset",u.iframe,u.id)}O(u.id,"Size reset requested by "+(u.type==="init"?"host page":"iFrame")),Gi(u.id),sn(y,u,"reset")}function tn(u){function y(Z){if(!u.id){O("undefined","messageData id not set");return}u.iframe.style[Z]=u[Z]+"px",O(u.id,"IFrame ("+P+") "+Z+" set to "+u[Z]+"px")}function M(Z){!n&&u[Z]==="0"&&(n=!0,O(P,"Hidden iFrame detected, creating visibility listener"),Ta())}function x(Z){y(Z),M(Z)}var P=u.iframe.id;d[P]&&(d[P].sizeHeight&&x("height"),d[P].sizeWidth&&x("width"))}function sn(u,y,M){M!==y.type&&h&&!window.jasmine?(O(y.id,"Requesting animation frame"),h(u)):u()}function me(u,y,M,x,P){function Z(){var Ne=d[x]&&d[x].targetOrigin;O(x,"["+u+"] Sending msg to iframe["+x+"] ("+y+") targetOrigin: "+Ne),M.contentWindow.postMessage(o+y,Ne)}function fe(){ce(x,"["+u+"] IFrame("+x+") not found")}function Ye(){M&&"contentWindow"in M&&M.contentWindow!==null?Z():fe()}function Se(){function Ne(){d[x]&&!d[x].loaded&&!Te&&(Te=!0,ce(x,"IFrame has not responded within "+d[x].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}P&&d[x]&&d[x].warningTimeout&&(d[x].msgTimeout=setTimeout(Ne,d[x].warningTimeout))}var Te=!1;x=x||M.id,d[x]&&(Ye(),Se())}function nn(u){return u+":"+d[u].bodyMarginV1+":"+d[u].sizeWidth+":"+d[u].log+":"+d[u].interval+":"+d[u].enablePublicMethods+":"+d[u].autoResize+":"+d[u].bodyMargin+":"+d[u].heightCalculationMethod+":"+d[u].bodyBackground+":"+d[u].bodyPadding+":"+d[u].tolerance+":"+d[u].inPageLinks+":"+d[u].resizeFrom+":"+d[u].widthCalculationMethod+":"+d[u].mouseEvents}function ka(u){return typeof u=="number"}function rn(u,y){function M(){function S(Y){var de=d[k][Y];de!==1/0&&de!==0&&(u.style[Y]=ka(de)?de+"px":de,O(k,"Set "+Y+" = "+u.style[Y]))}function W(Y){if(d[k]["min"+Y]>d[k]["max"+Y])throw new Error("Value for min"+Y+" can not be greater than max"+Y)}W("Height"),W("Width"),S("maxHeight"),S("minHeight"),S("maxWidth"),S("minWidth")}function x(){var S=y&&y.id||N.id+t++;return document.getElementById(S)!==null&&(S+=t++),S}function P(S){if(typeof S!="string")throw new TypeError("Invaild id for iFrame. Expected String");return S===""&&(u.id=S=x(),i=(y||{}).log,O(S,"Added missing iframe ID: "+S+" ("+u.src+")")),S}function Z(){switch(O(k,"IFrame scrolling "+(d[k]&&d[k].scrolling?"enabled":"disabled")+" for "+k),u.style.overflow=(d[k]&&d[k].scrolling)===!1?"hidden":"auto",d[k]&&d[k].scrolling){case"omit":break;case!0:{u.scrolling="yes";break}case!1:{u.scrolling="no";break}default:u.scrolling=d[k]?d[k].scrolling:"no"}}function fe(){(typeof(d[k]&&d[k].bodyMargin)=="number"||(d[k]&&d[k].bodyMargin)==="0")&&(d[k].bodyMarginV1=d[k].bodyMargin,d[k].bodyMargin=""+d[k].bodyMargin+"px")}function Ye(){var S=d[k]&&d[k].firstRun,W=d[k]&&d[k].heightCalculationMethod in p;!S&&W&&en({iframe:u,height:0,width:0,type:"init"})}function Se(){d[k]&&(d[k].iframe.iFrameResizer={close:Ns.bind(null,d[k].iframe),removeListeners:Yi.bind(null,d[k].iframe),resize:me.bind(null,"Window resize","resize",d[k].iframe),moveToAnchor:function(S){me("Move to anchor","moveToAnchor:"+S,d[k].iframe,k)},sendMessage:function(S){S=JSON.stringify(S),me("Send Message","message:"+S,d[k].iframe,k)}})}function Te(S){function W(){me("iFrame.onload",S,u,e,!0),Ye()}function Y(Ge){if(u.parentNode){var Hs=new Ge(function(Bs){Bs.forEach(function(Fs){var Vs=Array.prototype.slice.call(Fs.removedNodes);Vs.forEach(function(le){le===u&&Ns(u)})})});Hs.observe(u.parentNode,{childList:!0})}}var de=H();de&&Y(de),ee(u,"load",W),me("init",S,u,e,!0)}function Ne(S){if(typeof S!="object")throw new TypeError("Options is not an object")}function Ls(S){for(var W in N)Object.prototype.hasOwnProperty.call(N,W)&&(d[k][W]=Object.prototype.hasOwnProperty.call(S,W)?S[W]:N[W])}function ps(S){return S===""||S.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":S}function zs(S){var W=S.split("Callback");if(W.length===2){var Y="on"+W[0].charAt(0).toUpperCase()+W[0].slice(1);this[Y]=this[S],delete this[S],ce(k,"Deprecated: '"+S+"' has been renamed '"+Y+"'. The old method will be removed in the next major version.")}}function Ds(S){S=S||{},d[k]=Object.create(null),d[k].iframe=u,d[k].firstRun=!0,d[k].remoteHost=u.src&&u.src.split("/").slice(0,3).join("/"),Ne(S),Object.keys(S).forEach(zs,S),Ls(S),d[k]&&(d[k].targetOrigin=d[k].checkOrigin===!0?ps(d[k].remoteHost):"*")}function Us(){return k in d&&"iFrameResizer"in u}var k=P(u.id);Us()?ce(k,"Ignored iFrame, already setup."):(Ds(y),Z(),M(),fe(),Te(nn(k)),Se())}function js(u,y){b===null&&(b=setTimeout(function(){b=null,u()},y))}var Rs={};function Sa(u,y,M){Rs[M]||(Rs[M]=setTimeout(function(){Rs[M]=null,u()},y))}function Ta(){function u(){function P(Z){function fe(Se){return(d[Z]&&d[Z].iframe.style[Se])==="0px"}function Ye(Se){return Se.offsetParent!==null}d[Z]&&Ye(d[Z].iframe)&&(fe("height")||fe("width"))&&me("Visibility change","resize",d[Z].iframe,Z)}Object.keys(d).forEach(function(Z){P(Z)})}function y(P){O("window","Mutation observed: "+P[0].target+" "+P[0].type),js(u,16)}function M(){var P=document.querySelector("body"),Z={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},fe=new x(y);fe.observe(P,Z)}var x=H();x&&M()}function $a(u){function y(){on("Window "+u,"resize")}O("window","Trigger event: "+u),js(y,16)}function an(){function u(){on("Tab Visible","resize")}document.visibilityState!=="hidden"&&(O("document","Trigger event: Visibility change"),js(u,16))}function on(u,y){function M(x){return d[x]&&d[x].resizeFrom==="parent"&&d[x].autoResize&&!d[x].firstRun}Object.keys(d).forEach(function(x){M(x)&&me(u,y,d[x].iframe,x)})}function Ea(){ee(window,"message",xa),ee(window,"resize",function(){$a("resize")}),ee(document,"visibilitychange",an),ee(document,"-webkit-visibilitychange",an)}function Zs(){function u(x,P){function Z(){if(P.tagName){if(P.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+P.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}P&&(Z(),rn(P,x),M.push(P))}function y(x){x&&x.enablePublicMethods&&ce("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var M;return xe(),Ea(),function(x,P){switch(M=[],y(x),typeof P){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(P||"iframe"),u.bind(e,x));break}case"object":{u(x,P);break}default:throw new TypeError("Unexpected data type ("+typeof P+")")}return M}}function Ca(u){u.fn?u.fn.iFrameResize||(u.fn.iFrameResize=function(y){function M(x,P){rn(P,y)}return this.filter("iframe").each(M).end()}):qi("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&Ca(window.jQuery),typeof e=="function"&&e.amd?e([],Zs):s.exports=Zs(),window.iFrameResize=window.iFrameResize||Zs()})()})(Ui);var Kr=Ui.exports;const Jr=ji(Kr);var qr=Object.defineProperty,Yr=Object.getOwnPropertyDescriptor,Hi=(s,e,t,i)=>{for(var n=i>1?void 0:i?Yr(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&qr(e,t,n),n};let os=class extends se{constructor(){super(...arguments),this.src=""}async onLoad(s){Jr({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},s.target)}render(){return z`
238
- <iframe
239
- src=${this.src}
240
- width="100%"
241
- @load=${this.onLoad}
242
- ></iframe>
243
- `}};os.styles=[Ee],Hi([J({type:String})],os.prototype,"src",2),os=Hi([Ce("iai-chat-iframe")],os);var Gr=Object.defineProperty,Xr=Object.getOwnPropertyDescriptor,Os=(s,e,t,i)=>{for(var n=i>1?void 0:i?Xr(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Gr(e,t,n),n};let Rt=class extends se{constructor(){super(...arguments),this.title="",this.src=""}async connectedCallback(){super.connectedCallback()}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return z`
637
+ `],ii([jr({type:Object})],Dn.prototype,"options",2),ii([jr()],Dn.prototype,"disableInput",2),ii([jr()],Dn.prototype,"showTyping",2),ii([eo()],Dn.prototype,"messages",2),ii([eo()],Dn.prototype,"inputValue",2),ii([eo()],Dn.prototype,"internalShowTyping",2),ii([eo()],Dn.prototype,"showPopoverDisclaimer",2),ii([eo()],Dn.prototype,"previousThreads",2),ii([df("#chat-container")],Dn.prototype,"chatContainer",2),ii([df("#message-input")],Dn.prototype,"inputElement",2),ii([Hv.debounce(1)],Dn.prototype,"scrollChatToBottom",1),Dn=ii([Wi("iai-chat")],Dn);var b1={exports:{}};(function(t){(function(e){if(typeof window>"u")return;var r=0,n=!1,i=!1,a="message",s=a.length,o="[iFrameSizer]",u=o.length,l=null,c=window.requestAnimationFrame,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),f={},m=null,b=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){V("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function A(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function N(Q,Ue,ot){Q.addEventListener(Ue,ot,!1)}function z(Q,Ue,ot){Q.removeEventListener(Ue,ot,!1)}function X(){var Q=["moz","webkit","o","ms"],Ue;for(Ue=0;Ue<Q.length&&!c;Ue+=1)c=window[Q[Ue]+"RequestAnimationFrame"];c?c=c.bind(window):Oe("setup","RequestAnimationFrame not supported")}function Ee(Q){var Ue="Host page: "+Q;return window.top!==window.self&&(Ue=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+Q:"Nested host page: "+Q),Ue}function Ie(Q){return o+"["+Ee(Q)+"]"}function Fe(Q){return f[Q]?f[Q].log:n}function Oe(Q,Ue){xe("log",Q,Ue,Fe(Q))}function ze(Q,Ue){xe("info",Q,Ue,Fe(Q))}function V(Q,Ue){xe("warn",Q,Ue,!0)}function xe(Q,Ue,ot,Pe){Pe===!0&&typeof window.console=="object"&&console[Q](Ie(Ue),ot)}function _e(Q){function Ue(){function we(){H(ae),q(me),zt("onResized",ae)}ut("Height"),ut("Width"),ye(we,ae,"init")}function ot(){var we=$e.slice(u).split(":"),K=we[1]?parseInt(we[1],10):0,he=f[we[0]]&&f[we[0]].iframe,G=getComputedStyle(he);return{iframe:he,id:we[0],height:K+Pe(G)+St(G),width:we[2],type:we[3]}}function Pe(we){if(we.boxSizing!=="border-box")return 0;var K=we.paddingTop?parseInt(we.paddingTop,10):0,he=we.paddingBottom?parseInt(we.paddingBottom,10):0;return K+he}function St(we){if(we.boxSizing!=="border-box")return 0;var K=we.borderTopWidth?parseInt(we.borderTopWidth,10):0,he=we.borderBottomWidth?parseInt(we.borderBottomWidth,10):0;return K+he}function ut(we){var K=Number(f[me]["max"+we]),he=Number(f[me]["min"+we]),G=we.toLowerCase(),de=Number(ae[G]);Oe(me,"Checking "+G+" is in range "+he+"-"+K),de<he&&(de=he,Oe(me,"Set "+G+" to min value")),de>K&&(de=K,Oe(me,"Set "+G+" to max value")),ae[G]=""+de}function or(){function we(){function G(){var ee=0,Ye=!1;for(Oe(me,"Checking connection is from allowed list of origins: "+he);ee<he.length;ee++)if(he[ee]===K){Ye=!0;break}return Ye}function de(){var ee=f[me]&&f[me].remoteHost;return Oe(me,"Checking connection is from: "+ee),K===ee}return he.constructor===Array?G():de()}var K=Q.origin,he=f[me]&&f[me].checkOrigin;if(he&&""+K!="null"&&!we())throw new Error("Unexpected message received from: "+K+" for "+ae.iframe.id+". Message was: "+Q.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function br(){return o===(""+$e).slice(0,u)&&$e.slice(u).split(":")[0]in f}function et(){var we=ae.type in{true:1,false:1,undefined:1};return we&&Oe(me,"Ignoring init message from meta parent page"),we}function Mr(we){return $e.slice($e.indexOf(":")+s+we)}function Fr(we){Oe(me,"onMessage passed: {iframe: "+ae.iframe.id+", message: "+we+"}"),zt("onMessage",{iframe:ae.iframe,message:JSON.parse(we)}),Oe(me,"--")}function dr(){var we=document.body.getBoundingClientRect(),K=ae.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:K.height,iframeWidth:K.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(K.top-we.top,10),offsetLeft:parseInt(K.left-we.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function fr(we,K){function he(){ke("Send Page Info","pageInfo:"+dr(),we,K)}ce(he,32,K)}function Wt(){function we(de,ee){function Ye(){f[G]?fr(f[G].iframe,G):K()}["scroll","resize"].forEach(function(qe){Oe(G,de+qe+" listener for sendPageInfo"),ee(window,qe,Ye)})}function K(){we("Remove ",z)}function he(){we("Add ",N)}var G=me;he(),f[G]&&(f[G].stopPageInfo=K)}function Ot(){f[me]&&f[me].stopPageInfo&&(f[me].stopPageInfo(),delete f[me].stopPageInfo)}function L(){var we=!0;return ae.iframe===null&&(V(me,"IFrame ("+ae.id+") not found"),we=!1),we}function W(we){var K=we.getBoundingClientRect();return oe(me),{x:Math.floor(Number(K.left)+Number(l.x)),y:Math.floor(Number(K.top)+Number(l.y))}}function ie(we){function K(){l=ee,He(),Oe(me,"--")}function he(){return{x:Number(ae.width)+de.x,y:Number(ae.height)+de.y}}function G(){window.parentIFrame?window.parentIFrame["scrollTo"+(we?"Offset":"")](ee.x,ee.y):V(me,"Unable to scroll to requested position, window.parentIFrame not found")}var de=we?W(ae.iframe):{x:0,y:0},ee=he();Oe(me,"Reposition requested from iFrame (offset x:"+de.x+" y:"+de.y+")"),window.top===window.self?K():G()}function He(){zt("onScroll",l)===!1?ne():q(me)}function ct(we){function K(){var Ye=W(ee);Oe(me,"Moving to in page link (#"+G+") at x: "+Ye.x+" y: "+Ye.y),l={x:Ye.x,y:Ye.y},He(),Oe(me,"--")}function he(){window.parentIFrame?window.parentIFrame.moveToAnchor(G):Oe(me,"In page link #"+G+" not found and window.parentIFrame not found")}var G=we.split("#")[1]||"",de=decodeURIComponent(G),ee=document.getElementById(de)||document.getElementsByName(de)[0];ee?K():window.top===window.self?Oe(me,"In page link #"+G+" not found"):he()}function bt(we){var K={};if(Number(ae.width)===0&&Number(ae.height)===0){var he=Mr(9).split(":");K={x:he[1],y:he[0]}}else K={x:ae.width,y:ae.height};zt(we,{iframe:ae.iframe,screenX:Number(K.x),screenY:Number(K.y),type:ae.type})}function zt(we,K){return se(me,we,K)}function tr(){switch(f[me]&&f[me].firstRun&&pe(),ae.type){case"close":{re(ae.iframe);break}case"message":{Fr(Mr(6));break}case"mouseenter":{bt("onMouseEnter");break}case"mouseleave":{bt("onMouseLeave");break}case"autoResize":{f[me].autoResize=JSON.parse(Mr(9));break}case"scrollTo":{ie(!1);break}case"scrollToOffset":{ie(!0);break}case"pageInfo":{fr(f[me]&&f[me].iframe,me),Wt();break}case"pageInfoStop":{Ot();break}case"inPageLink":{ct(Mr(9));break}case"reset":{Se(ae);break}case"init":{Ue(),zt("onInit",ae.iframe);break}default:Number(ae.width)===0&&Number(ae.height)===0?V("Unsupported message received ("+ae.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):Ue()}}function Re(we){var K=!0;return f[we]||(K=!1,V(ae.type+" No settings for "+we+". Message was: "+$e)),K}function Ne(){for(var we in f)ke("iFrame requested init",M(we),f[we].iframe,we)}function pe(){f[me]&&(f[me].firstRun=!1)}var $e=Q.data,ae={},me=null;$e==="[iFrameResizerChild]Ready"?Ne():br()?(ae=ot(),me=ae.id,f[me]&&(f[me].loaded=!0),!et()&&Re(me)&&(Oe(me,"Received: "+$e),L()&&or()&&tr())):ze(me,"Ignored: "+$e)}function se(Q,Ue,ot){var Pe=null,St=null;if(f[Q])if(Pe=f[Q][Ue],typeof Pe=="function")St=Pe(ot);else throw new TypeError(Ue+" on iFrame["+Q+"] is not a function");return St}function Te(Q){var Ue=Q.id;delete f[Ue]}function re(Q){var Ue=Q.id;if(se(Ue,"onClose",Ue)===!1){Oe(Ue,"Close iframe cancelled by onClose event");return}Oe(Ue,"Removing iFrame: "+Ue);try{Q.parentNode&&Q.parentNode.removeChild(Q)}catch(ot){V(ot)}se(Ue,"onClosed",Ue),Oe(Ue,"--"),Te(Q)}function oe(Q){l===null&&(l={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},Oe(Q,"Get page position: "+l.x+","+l.y))}function q(Q){l!==null&&(window.scrollTo(l.x,l.y),Oe(Q,"Set page position: "+l.x+","+l.y),ne())}function ne(){l=null}function Se(Q){function Ue(){H(Q),ke("reset","reset",Q.iframe,Q.id)}Oe(Q.id,"Size reset requested by "+(Q.type==="init"?"host page":"iFrame")),oe(Q.id),ye(Ue,Q,"reset")}function H(Q){function Ue(ut){if(!Q.id){Oe("undefined","messageData id not set");return}Q.iframe.style[ut]=Q[ut]+"px",Oe(Q.id,"IFrame ("+St+") "+ut+" set to "+Q[ut]+"px")}function ot(ut){!i&&Q[ut]==="0"&&(i=!0,Oe(St,"Hidden iFrame detected, creating visibility listener"),Ke())}function Pe(ut){Ue(ut),ot(ut)}var St=Q.iframe.id;f[St]&&(f[St].sizeHeight&&Pe("height"),f[St].sizeWidth&&Pe("width"))}function ye(Q,Ue,ot){ot!==Ue.type&&c&&!window.jasmine?(Oe(Ue.id,"Requesting animation frame"),c(Q)):Q()}function ke(Q,Ue,ot,Pe,St){function ut(){var Fr=f[Pe]&&f[Pe].targetOrigin;Oe(Pe,"["+Q+"] Sending msg to iframe["+Pe+"] ("+Ue+") targetOrigin: "+Fr),ot.contentWindow.postMessage(o+Ue,Fr)}function or(){V(Pe,"["+Q+"] IFrame("+Pe+") not found")}function br(){ot&&"contentWindow"in ot&&ot.contentWindow!==null?ut():or()}function et(){function Fr(){f[Pe]&&!f[Pe].loaded&&!Mr&&(Mr=!0,V(Pe,"IFrame has not responded within "+f[Pe].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}St&&f[Pe]&&f[Pe].warningTimeout&&(f[Pe].msgTimeout=setTimeout(Fr,f[Pe].warningTimeout))}var Mr=!1;Pe=Pe||ot.id,f[Pe]&&(br(),et())}function M(Q){return Q+":"+f[Q].bodyMarginV1+":"+f[Q].sizeWidth+":"+f[Q].log+":"+f[Q].interval+":"+f[Q].enablePublicMethods+":"+f[Q].autoResize+":"+f[Q].bodyMargin+":"+f[Q].heightCalculationMethod+":"+f[Q].bodyBackground+":"+f[Q].bodyPadding+":"+f[Q].tolerance+":"+f[Q].inPageLinks+":"+f[Q].resizeFrom+":"+f[Q].widthCalculationMethod+":"+f[Q].mouseEvents}function Xe(Q){return typeof Q=="number"}function Ct(Q,Ue){function ot(){function ie(ct){var bt=f[W][ct];bt!==1/0&&bt!==0&&(Q.style[ct]=Xe(bt)?bt+"px":bt,Oe(W,"Set "+ct+" = "+Q.style[ct]))}function He(ct){if(f[W]["min"+ct]>f[W]["max"+ct])throw new Error("Value for min"+ct+" can not be greater than max"+ct)}He("Height"),He("Width"),ie("maxHeight"),ie("minHeight"),ie("maxWidth"),ie("minWidth")}function Pe(){var ie=Ue&&Ue.id||b.id+r++;return document.getElementById(ie)!==null&&(ie+=r++),ie}function St(ie){if(typeof ie!="string")throw new TypeError("Invaild id for iFrame. Expected String");return ie===""&&(Q.id=ie=Pe(),n=(Ue||{}).log,Oe(ie,"Added missing iframe ID: "+ie+" ("+Q.src+")")),ie}function ut(){switch(Oe(W,"IFrame scrolling "+(f[W]&&f[W].scrolling?"enabled":"disabled")+" for "+W),Q.style.overflow=(f[W]&&f[W].scrolling)===!1?"hidden":"auto",f[W]&&f[W].scrolling){case"omit":break;case!0:{Q.scrolling="yes";break}case!1:{Q.scrolling="no";break}default:Q.scrolling=f[W]?f[W].scrolling:"no"}}function or(){(typeof(f[W]&&f[W].bodyMargin)=="number"||(f[W]&&f[W].bodyMargin)==="0")&&(f[W].bodyMarginV1=f[W].bodyMargin,f[W].bodyMargin=""+f[W].bodyMargin+"px")}function br(){var ie=f[W]&&f[W].firstRun,He=f[W]&&f[W].heightCalculationMethod in d;!ie&&He&&Se({iframe:Q,height:0,width:0,type:"init"})}function et(){f[W]&&(f[W].iframe.iFrameResizer={close:re.bind(null,f[W].iframe),removeListeners:Te.bind(null,f[W].iframe),resize:ke.bind(null,"Window resize","resize",f[W].iframe),moveToAnchor:function(ie){ke("Move to anchor","moveToAnchor:"+ie,f[W].iframe,W)},sendMessage:function(ie){ie=JSON.stringify(ie),ke("Send Message","message:"+ie,f[W].iframe,W)}})}function Mr(ie){function He(){ke("iFrame.onload",ie,Q,e,!0),br()}function ct(zt){if(Q.parentNode){var tr=new zt(function(Re){Re.forEach(function(Ne){var pe=Array.prototype.slice.call(Ne.removedNodes);pe.forEach(function($e){$e===Q&&re(Q)})})});tr.observe(Q.parentNode,{childList:!0})}}var bt=A();bt&&ct(bt),N(Q,"load",He),ke("init",ie,Q,e,!0)}function Fr(ie){if(typeof ie!="object")throw new TypeError("Options is not an object")}function dr(ie){for(var He in b)Object.prototype.hasOwnProperty.call(b,He)&&(f[W][He]=Object.prototype.hasOwnProperty.call(ie,He)?ie[He]:b[He])}function fr(ie){return ie===""||ie.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":ie}function Wt(ie){var He=ie.split("Callback");if(He.length===2){var ct="on"+He[0].charAt(0).toUpperCase()+He[0].slice(1);this[ct]=this[ie],delete this[ie],V(W,"Deprecated: '"+ie+"' has been renamed '"+ct+"'. The old method will be removed in the next major version.")}}function Ot(ie){ie=ie||{},f[W]=Object.create(null),f[W].iframe=Q,f[W].firstRun=!0,f[W].remoteHost=Q.src&&Q.src.split("/").slice(0,3).join("/"),Fr(ie),Object.keys(ie).forEach(Wt,ie),dr(ie),f[W]&&(f[W].targetOrigin=f[W].checkOrigin===!0?fr(f[W].remoteHost):"*")}function L(){return W in f&&"iFrameResizer"in Q}var W=St(Q.id);L()?V(W,"Ignored iFrame, already setup."):(Ot(Ue),ut(),ot(),or(),Mr(M(W)),et())}function rt(Q,Ue){m===null&&(m=setTimeout(function(){m=null,Q()},Ue))}var je={};function ce(Q,Ue,ot){je[ot]||(je[ot]=setTimeout(function(){je[ot]=null,Q()},Ue))}function Ke(){function Q(){function St(ut){function or(et){return(f[ut]&&f[ut].iframe.style[et])==="0px"}function br(et){return et.offsetParent!==null}f[ut]&&br(f[ut].iframe)&&(or("height")||or("width"))&&ke("Visibility change","resize",f[ut].iframe,ut)}Object.keys(f).forEach(function(ut){St(ut)})}function Ue(St){Oe("window","Mutation observed: "+St[0].target+" "+St[0].type),rt(Q,16)}function ot(){var St=document.querySelector("body"),ut={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},or=new Pe(Ue);or.observe(St,ut)}var Pe=A();Pe&&ot()}function Be(Q){function Ue(){pt("Window "+Q,"resize")}Oe("window","Trigger event: "+Q),rt(Ue,16)}function be(){function Q(){pt("Tab Visible","resize")}document.visibilityState!=="hidden"&&(Oe("document","Trigger event: Visibility change"),rt(Q,16))}function pt(Q,Ue){function ot(Pe){return f[Pe]&&f[Pe].resizeFrom==="parent"&&f[Pe].autoResize&&!f[Pe].firstRun}Object.keys(f).forEach(function(Pe){ot(Pe)&&ke(Q,Ue,f[Pe].iframe,Pe)})}function Ze(){N(window,"message",_e),N(window,"resize",function(){Be("resize")}),N(document,"visibilitychange",be),N(document,"-webkit-visibilitychange",be)}function Jt(){function Q(Pe,St){function ut(){if(St.tagName){if(St.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+St.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}St&&(ut(),Ct(St,Pe),ot.push(St))}function Ue(Pe){Pe&&Pe.enablePublicMethods&&V("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var ot;return X(),Ze(),function(Pe,St){switch(ot=[],Ue(Pe),typeof St){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(St||"iframe"),Q.bind(e,Pe));break}case"object":{Q(Pe,St);break}default:throw new TypeError("Unexpected data type ("+typeof St+")")}return ot}}function At(Q){Q.fn?Q.fn.iFrameResize||(Q.fn.iFrameResize=function(Ue){function ot(Pe,St){Ct(St,Ue)}return this.filter("iframe").each(ot).end()}):ze("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&At(window.jQuery),t.exports=Jt(),window.iFrameResize=window.iFrameResize||Jt()})()})(b1);var hL=b1.exports;const pL=z_(hL);var vL=Object.defineProperty,mL=Object.getOwnPropertyDescriptor,lm=(t,e,r,n)=>{for(var i=n>1?void 0:n?mL(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&vL(e,r,i),i};let Tc=class extends Ln{constructor(){super(...arguments),this.src="",this.showCloseButton=!1}async onLoad(t){pL({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},t.target)}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return ar`
638
+ <div class="relative">
639
+ ${_a(this.showCloseButton,()=>ar`
640
+ <button class="absolute top-0 right-0 m-2 h-6 text-white focus:outline-none" @click="${this.close}">
641
+ ${Lv}
642
+ </button>
643
+ `)}
644
+
645
+ <iframe
646
+ src=${this.src}
647
+ width="100%"
648
+ @load=${this.onLoad}
649
+ ></iframe>
650
+ </div>
651
+ `}};Tc.styles=[Zi],lm([jr({type:String})],Tc.prototype,"src",2),lm([jr({type:Boolean})],Tc.prototype,"showCloseButton",2),Tc=lm([Wi("iai-chat-iframe")],Tc);var gL=Object.defineProperty,yL=Object.getOwnPropertyDescriptor,wu=(t,e,r,n)=>{for(var i=n>1?void 0:n?yL(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&gL(e,r,i),i};let hs=class extends Ln{constructor(){super(...arguments),this.title="",this.src="",this.width="500px",this.height=null,this.showHeader=!0}async connectedCallback(){super.connectedCallback()}close(){this.dispatchEvent(new CustomEvent("close"))}render(){const t=Ql({width:this.width,height:this.height});return ar`
244
652
  <div class="fixed inset-0 z-50 bg-black bg-opacity-50 flex justify-center items-center">
245
653
  <div
246
654
  class="flex flex-col rounded-lg shadow-lg bg-white mx-auto my-auto max-h-[90vh] max-w-[90vw] overflow-hidden"
655
+ style=${t}
247
656
  part="modal"
248
657
  >
249
- <div class="header text-lg p-2 flex justify-between items-center">
250
- <div class="flex flex-row h-full items-center">
251
- <span class="text-lg font-semibold ml-2">${this.title}</span>
252
- </div>
658
+ ${_a(this.showHeader,()=>ar`
659
+ <div class="header text-lg p-2 flex justify-between items-center">
660
+ <div class="flex flex-row h-full items-center">
661
+ <span class="text-lg font-semibold ml-2">${this.title}</span>
662
+ </div>
253
663
 
254
- <button class="mr-2 focus:outline-none" @click="${this.close}">
255
- <svg class="h-6 w-6 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
256
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
257
- </svg>
258
- </button>
259
- </div>
664
+ <button class="mr-2 h-6 text-white focus:outline-none" @click="${this.close}">
665
+ ${Lv}
666
+ </button>
667
+ </div>
668
+ `)}
260
669
 
261
670
  <div class="overflow-y-auto">
262
671
  <iai-chat-iframe
263
672
  src=${this.src}
673
+ showCloseButton=${!this.showHeader}
674
+ @close=${this.close}
264
675
  ></iai-chat-iframe>
265
676
  </div>
266
677
  </div>
267
678
  </div>
268
- `}};Rt.styles=[Ee,Qe`
679
+ `}};hs.styles=[Zi,ba`
269
680
  .header {
270
681
  background-color: var(--iai-chat-i-iframe-modal-header-bg);
271
682
  color: var(--iai-chat-i-iframe-modal-header-fg);
272
683
  height: 50px;
273
684
  }
274
- `],Os([J({type:String})],Rt.prototype,"title",2),Os([J({type:String})],Rt.prototype,"src",2),Rt=Os([Ce("iai-chat-iframe-modal")],Rt);/**
275
- * @license
276
- * Copyright 2017 Google LLC
277
- * SPDX-License-Identifier: BSD-3-Clause
278
- */class Is extends Vt{constructor(e){if(super(e),this.it=V,e.type!==Bt.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===V||e==null)return this._t=void 0,this.it=e;if(e===ue)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Is.directiveName="unsafeHTML",Is.resultType=1;const Qr=Ft(Is);var Bi={exports:{}};(function(s,e){(function(t,i){s.exports=i()})(Cr,function(){function t(o){return o.replace(/\\([(){}[\]#*+\-.!_\\])/g,function(c,l){return String.fromCharCode(1,n.indexOf(l)+r)}).replace(/(\*\*|__|~~)(\S(?:[\s\S]*?\S)?)\1/g,function(c,l,h){return l==="~~"?"<del>"+h+"</del>":"<b>"+h+"</b>"}).replace(/(\n|^|\W)([_\*])(\S(?:[\s\S]*?\S)?)\2(\W|$|\n)/g,function(c,l,h,p,d){return l+"<i>"+p+"</i>"+d}).replace(/(!?)\[([^\]<>]+)\]\((\+?)([^ \)<>]+)(?: "([^\(\)\"]+)")?\)/g,function(c,l,h,p,d,b){var N=b?' title="'+b+'"':"";return l?'<img src="'+a.href(d)+'" alt="'+h+'"'+N+"/>":(p&&(N+=' target="_blank"'),'<a href="'+a.href(d)+'"'+N+">"+h+"</a>")})}function i(o){return o.replace(/\x01([\x0f-\x1c])/g,function(c,l){return n.charAt(l.charCodeAt(0)-r)})}var n="\\[!]#{()}*+-._",r=16,a=function(o){return o.replace(/.+(?:\n.+)*/g,function(c){var l=/^\s{4}([^]*)$/.exec(c);if(l)return"<pre><code>"+l[1].replace(/\n /g,`
279
- `)+"</code></pre>";for(var h,p=[],d=t(c).split(`
280
- `),b=0,N=d.length;N>b;++b){var H=d[b],ee=/^\s{0,3}(\#{1,6})\s+(.*?)\s*#*\s*$/.exec(H);if(ee)p.push(h=[ee[2],"h",ee[1].length]);else{var _e=/^(\s*)(?:[-*]|(\d[.)])) (.+)$/.exec(H);_e?p.push(h=[_e[3],_e[2]?"ol":"ul",_e[1].length]):/^\s{0,3}([-])(\s*\1){2,}\s*$/.test(H)?p.push(h=["","hr"]):h&&h[1]!=="hr"&&h[1]!=="h"?h[0]+=`
281
- `+H:p.push(h=[H,"p",""])}}var xe="",te=[];for(b=0,N=p.length;N>b;++b){h=p[b];var ut=h[0],ke=h[1],O=h[2];if(ke==="ul"||ke==="ol")!te.length||O>te[0][1]?(te.unshift([ke,O]),xe+="<"+te[0][0]+"><li>"+ut):te.length>1&&O<=te[1][1]?(xe+="</li></"+te.shift()[0]+">",--b):xe+="</li><li>"+ut;else{for(;te.length;)xe+="</li></"+te.shift()[0]+">";xe+=ke==="hr"?"<hr/>":"<"+ke+O+a.headAttrs(O,ut)+">"+ut+"</"+ke+O+">"}}for(;te.length;)xe+="</li></"+te.shift()[0]+">";return i(xe)})};return a.href=function(o){return o},a.headAttrs=function(o,c){return""},a})})(Bi);var ea=Bi.exports;const ta=ji(ea);var sa=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,Fi=(s,e,t,i)=>{for(var n=i>1?void 0:i?ia(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&sa(e,t,n),n};let cs=class extends se{constructor(){super(...arguments),this.content=""}get htmlContent(){return ta(this.content)}render(){return z`
685
+ `],wu([jr({type:String})],hs.prototype,"title",2),wu([jr({type:String})],hs.prototype,"src",2),wu([jr({type:String})],hs.prototype,"width",2),wu([jr({type:String})],hs.prototype,"height",2),wu([jr({type:Boolean})],hs.prototype,"showHeader",2),hs=wu([Wi("iai-chat-iframe-modal")],hs);var bL=Object.defineProperty,wL=Object.getOwnPropertyDescriptor,Df=(t,e,r,n)=>{for(var i=n>1?void 0:n?wL(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&bL(e,r,i),i};let _u=class extends Ln{constructor(){super(...arguments),this.content="",this.showRatingControls=!0,this.rating=0}render(){return ar`
282
686
  <div class="flex items-end mr-20">
283
- <div class="message rounded-lg px-4 py-2 flex flex-col gap-1">
284
- ${Qr(this.htmlContent)}
687
+ <div class="flex flex-col">
688
+ <div class="message rounded-lg px-4 py-2">
689
+ ${um(this.content)}
690
+ </div>
691
+
692
+ ${_a(this.showRatingControls,()=>ar`
693
+ <div class="mt-1 pl-3 text-gray-400 opacity-80">
694
+ <button
695
+ class="h-4 w-4 ${yf({"active-rating":this.rating===1})}"
696
+ @click="${()=>this.rateMessage(1)}"
697
+ >
698
+ ${this.rating===1?SM:TM}
699
+ </button>
700
+
701
+ <button
702
+ class="h-4 w-4 ${yf({"active-rating":this.rating===-1})}"
703
+ @click="${()=>this.rateMessage(-1)}"
704
+ >
705
+ ${this.rating===-1?$M:EM}
706
+ </button>
707
+ </div>
708
+ `)}
285
709
  </div>
286
710
  </div>
287
- `}};cs.styles=[Ee,Qe`
711
+ `}rateMessage(t){const e=this.rating===t?0:t;this.rating=e,this.dispatchEvent(new CustomEvent("rate-message",{detail:{rating:e}}))}};_u.styles=[Zi,ba`
288
712
  .message {
289
713
  background-color: var(--iai-chat-i-message-assistant-bg);
290
714
  color: var(--iai-chat-i-message-assistant-fg);
291
715
  }
292
-
293
- h1 {
294
- font-size: 1.5em;
295
- }
296
-
297
- h2 {
298
- font-size: 1.17em;
299
- }
300
-
301
- h3 {
302
- font-size: 1em;
716
+
717
+ .active-rating {
718
+ color: var(--iai-chat-i-message-assistant-rating-active);
303
719
  }
304
- `],Fi([J({type:String})],cs.prototype,"content",2),cs=Fi([Ce("iai-chat-message-assistant")],cs);async function na(s,e){const{type:t,params:i}=s,n=e[t];if(!n)throw new Error(`No handler for enhanced content type ${t}`);return n({params:i,html:z})}var ra=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,Zt=(s,e,t,i)=>{for(var n=i>1?void 0:i?aa(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&ra(e,t,n),n};let Je=class extends se{constructor(){super(...arguments),this.content=""}async connectedCallback(){if(super.connectedCallback(),this.enhancedContent)try{this.contentHtmlTemplate=await na(this.enhancedContent,this.options.handlers.enhancedContent);return}catch(s){console.warn("Error processing enhanced content",s)}else this.contentHtmlTemplate||(this.contentHtmlTemplate=z`<p class="text-center text-gray-400 text-sm">${this.content}</p>`)}render(){return z`
720
+ `],Df([jr({type:String})],_u.prototype,"content",2),Df([jr({type:Boolean})],_u.prototype,"showRatingControls",2),Df([jr({type:Number})],_u.prototype,"rating",2),_u=Df([Wi("iai-chat-message-assistant")],_u);async function _L(t,e){const{type:r,params:n}=t,i=e[r];if(!i)throw new Error(`No handler for enhanced content type ${r}`);return i({params:n,html:ar})}var kL=Object.defineProperty,SL=Object.getOwnPropertyDescriptor,Ec=(t,e,r,n)=>{for(var i=n>1?void 0:n?SL(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&kL(e,r,i),i};let vo=class extends Ln{constructor(){super(...arguments),this.content=""}async connectedCallback(){if(super.connectedCallback(),this.enhancedContent)try{this.contentHtmlTemplate=await _L(this.enhancedContent,this.options.handlers.enhancedContent)}catch(t){console.warn("Error processing enhanced content",t)}this.contentHtmlTemplate||(this.contentHtmlTemplate=ar`
721
+ <div class="text-center text-gray-400 text-sm">
722
+ ${um(this.content)}
723
+ </div>
724
+ `)}render(){return ar`
305
725
  <div>
306
726
  ${this.contentHtmlTemplate}
307
727
  </div>
308
- `}};Je.styles=[Ee],Zt([J({type:Object})],Je.prototype,"options",2),Zt([J({type:String})],Je.prototype,"content",2),Zt([J({type:Object})],Je.prototype,"enhancedContent",2),Zt([J()],Je.prototype,"contentHtmlTemplate",2),Je=Zt([Ce("iai-chat-message-system")],Je);var oa=Object.defineProperty,ca=Object.getOwnPropertyDescriptor,Vi=(s,e,t,i)=>{for(var n=i>1?void 0:i?ca(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&oa(e,t,n),n};let ds=class extends se{constructor(){super(...arguments),this.content=""}render(){return z`
728
+ `}};vo.styles=[Zi],Ec([jr({type:Object})],vo.prototype,"options",2),Ec([jr({type:String})],vo.prototype,"content",2),Ec([jr({type:Object})],vo.prototype,"enhancedContent",2),Ec([jr()],vo.prototype,"contentHtmlTemplate",2),vo=Ec([Wi("iai-chat-message-system")],vo);var $L=Object.defineProperty,TL=Object.getOwnPropertyDescriptor,w1=(t,e,r,n)=>{for(var i=n>1?void 0:n?TL(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&$L(e,r,i),i};let jf=class extends Ln{constructor(){super(...arguments),this.content=""}render(){return ar`
309
729
  <div class="flex items-end justify-end ml-20">
310
730
  <div class="message rounded-lg px-4 py-2 flex gap-2">
311
- <p>${this.content}</p>
731
+ <p class="whitespace-pre-wrap">${this.content}</p>
312
732
  </div>
313
733
  </div>
314
- `}};ds.styles=[Ee,Qe`
734
+ `}};jf.styles=[Zi,ba`
315
735
  .message {
316
736
  background-color: var(--iai-chat-i-message-user-bg);
317
737
  color: var(--iai-chat-i-message-user-fg);
318
738
  }
319
- `],Vi([J({type:String})],ds.prototype,"content",2),ds=Vi([Ce("iai-chat-message-user")],ds);var da=Object.defineProperty,la=Object.getOwnPropertyDescriptor,ls=(s,e,t,i)=>{for(var n=i>1?void 0:i?la(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&da(e,t,n),n};let lt=class extends se{constructor(){super(...arguments),this.isChatWindowOpen=!1,this.isCtaOpen=!0}render(){const{openChatButton:{width:s,height:e,imageSrc:t,cta:i},placement:n}=this.options.config,r=vt({alignItems:n!=="left"?"end":"start"}),a=vt({width:s,height:e});return z`
320
- <div class="flex flex-col gap-4" style=${r}>
321
- ${ct(i&&this.isCtaOpen&&!this.isChatWindowOpen,()=>z`
322
- <div class="relative rounded-lg p-5 shadow-md bg-white" style="max-width: 350px;">
323
- <button
324
- class="absolute top-0 right-0 w-5 h-5 m-0.5"
325
- @click="${()=>this.isCtaOpen=!1}"
326
- >${As}</button>
327
-
328
- <span>${i}</span>
329
-
330
- <div
331
- class="absolute bottom-0 mx-4 mb-[-8px] w-0 h-0 border-x-8 border-t-8 border-x-transparent border-white"
332
- style=${vt({[n]:0})}
333
- />
739
+ `],w1([jr({type:String})],jf.prototype,"content",2),jf=w1([Wi("iai-chat-message-user")],jf);var EL=Object.defineProperty,CL=Object.getOwnPropertyDescriptor,_1=(t,e,r,n)=>{for(var i=n>1?void 0:n?CL(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&EL(e,r,i),i};let Uf=class extends Ln{render(){const{openChatButton:{width:t,height:e,imageSrc:r}}=this.options.config,n=Ql({width:t,height:e});return ar`
740
+ <button @click="${this.toggleChat}">
741
+ ${_a(r,()=>ar`
742
+ <img src="${r}" alt="Chat Icon" style=${n}/>
743
+ `,()=>ar`
744
+ <div class="button rounded-full flex items-center justify-center" style=${n}>
745
+ <div class="h-3/5 w-3/5">
746
+ ${bM}
334
747
  </div>
335
- `)}
336
-
337
- <button @click="${this.toggleChat}">
338
- ${ct(t,()=>z`<img src="${t}" alt="Chat Icon" style=${a}/>`,()=>z`
339
- <div class="button rounded-full flex items-center justify-center" style=${a}>
340
- <div class="h-3/5 w-3/5">
341
- ${ct(this.isChatWindowOpen,()=>As,()=>Hr)}
342
- </div>
343
- </div>
344
- `)}
345
- </button>
346
- </div>
347
- `}toggleChat(){this.dispatchEvent(new CustomEvent("toggle-chat"))}};lt.styles=[Ee,Qe`
748
+ </div>
749
+ `)}
750
+ </button>
751
+ `}toggleChat(){this.dispatchEvent(new CustomEvent("toggle-chat"))}};Uf.styles=[Zi,ba`
752
+ :host {
753
+ display: inline-block;
754
+ }
755
+
348
756
  .button {
349
757
  background-color: var(--iai-chat-i-ocb-bg);
350
758
  color: var(--iai-chat-i-ocb-fg);
351
759
  }
352
- `],ls([J({type:Object})],lt.prototype,"options",2),ls([J({type:Boolean})],lt.prototype,"isChatWindowOpen",2),ls([it()],lt.prototype,"isCtaOpen",2),lt=ls([Ce("iai-chat-open-chat-button")],lt);function ua(s){return s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Wi(s,e=""){return Object.keys(s).reduce((t,i)=>{const n=ua(i),r=e?`${e}-${n}`:n;return typeof s[i]=="object"&&s[i]!==null?Object.assign(t,Wi(s[i],r)):t[r]=s[i],t},{})}class ha{constructor(e){this.widget=null,this.options=is.parse(e);const t=document.createElement("iai-chat-popup");t.options=this.options;const i=Wi(this.options.config.styles);Object.entries(i).forEach(([n,r])=>{t.style.setProperty(`--iai-chat-${n}`,r)}),document.body.appendChild(t),this.widget=t}get api(){if(!this.widget)throw new Error("Widget has not been initialized");return this.widget}destroy(){var e;(e=this.widget)==null||e.remove(),this.widget=null}}var us;(s=>{(e=>{e.TEXT="TEXT"})(s.MessageType||(s.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(s.AcknowledgeType||(s.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(s.ContentType||(s.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(s.ConversationEventOrigin||(s.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(s.ConversationStatus||(s.ConversationStatus={}))})(us||(us={}));function Ki(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}class pa{constructor(e){this.chatWsUrl=e,this._emitter=Ki(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.reconnectCodes=new Set([1006]),this.reconnectAttempts=0,this.maxReconnectAttempts=10}connect(){const e=new WebSocket(this.chatWsUrl);e.onopen=async()=>{this.reconnectAttempts=0},e.onmessage=t=>{const i=JSON.parse(t.data);this._emitter.emit(i.type,i.data)},e.onclose=t=>{console.log("Disconnected: ",t.code,t.reason||"No reason provided"),this._emitter.emit("disconnected",t),this.reconnectCodes.has(t.code)&&this.reconnectAttempts<this.maxReconnectAttempts&&(console.log("Reconnecting..."),this._emitter.emit("reconnecting"),this.reconnectAttempts++,setTimeout(()=>this.connect(),this.reconnectAttempts*1e3))},e.onerror=t=>{console.log("Error:",t),this._emitter.emit("error",t)},this.ws=e}reconnect(){this.reconnectAttempts=0,this.connect()}disconnect(){var e;(e=this.ws)==null||e.close()}destroy(){this.disconnect(),this._emitter.all.clear()}}const ma=us.AcknowledgeType,fa="Anyone Home",ga="IB Chat Leasing - Development";let ya="https://five9.ah.inhabit.work";const va="https://five9.ah.inhabit.work".replace("http","ws").replace(/\/$/,""),zt=class zt{constructor(){Ws(this,we,void 0);Ws(this,qe,void 0);this._emitter=Ki(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),je(this,we,null),je(this,qe,null),this.conversationStarted=!1}serialize(){return JSON.stringify({sessionToken:this.sessionToken,conversationId:this.conversationId,conversationStarted:this.conversationStarted})}static deserialize(e){const t=JSON.parse(e),i=new zt;return t.sessionToken&&i.setSession(t.sessionToken),t.conversationId&&i.setConversationId(t.conversationId),i.conversationStarted=t.conversationStarted||!1,i}static generateBaseUrl(e){return`https://${e}/appsvcs/rs/svc`}async createSession(){const e=await fetch(`${zt.generateBaseUrl("app-scl.five9.com")}/auth/anon?cookieless=true`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({tenantName:fa})});return je(this,we,await e.json()),ms(this,we)}setSession(e){je(this,we,e)}setConversationId(e){je(this,qe,e),this.five9WebSocket&&(this.five9WebSocket.destroy(),this.five9WebSocket=void 0,e&&this.connectToWebSocket())}connect(){if(!this.sessionToken)throw new Error("Session not created");if(!this.conversationId)throw new Error("Conversation not started");this.connectToWebSocket()}connectToWebSocket(){if(!this.conversationId)throw new Error("Conversation not started");this.five9WebSocket&&this.five9WebSocket.destroy();const e=new pa(`${va}/conversations/${this.conversationId}/ws`);e.on("*",(t,i)=>{this._emitter.emit(t,i)}),e.on("conversationCreated",t=>{this.conversationStarted=!0,console.log("Conversation Created:",t)}),e.on("conversationAccepted",t=>{console.log("Conversation Accepted:",t)}),e.on("agentJoined",t=>{console.log("Agent Joined:",t)}),e.on("agentTransferredConversation",t=>{console.log("Agent Transferred Conversation:",t)}),e.on("conversationTransferredToGroup",t=>{console.log("Conversation Transferred To Group:",t)}),e.on("agentLeftConversation",t=>{console.log("Agent Left Conversation:",t)}),e.on("agentTyping",t=>{console.log("Agent Typing:",t)}),e.on("message",async t=>{console.log("Message:",t),await this.acknowledgeMessage({messages:[{messageId:t.messageId,type:ma.READ}]})}),e.on("conversationTerminated",t=>{console.log("Conversation Terminated:",t)}),e.on("error",t=>{console.log("Error:",t)}),this.five9WebSocket=e,e.connect()}async authenticatedFetch(e,t={}){const{sessionToken:i}=this;if(!i)throw new Error("Session not found");e=e.startsWith("/")?e:`/${e}`;const n=i.metadata.dataCenters[0].apiUrls[0].host,r=await fetch(`${zt.generateBaseUrl(n)}${e}`,{...t,headers:{...t.headers,"Content-Type":"application/json",Accept:"application/json",Authorization:i.tokenId,farmId:i.context.farmId}});return r.status===204?null:r.json()}async getMetadata(){if(!this.sessionToken)throw new Error("Session not created");return await this.authenticatedFetch("/auth/metadata",{method:"GET"})}async createConversation(e){if(!this.sessionToken)throw new Error("Session not created");const t={...e,campaignName:ga,tenantId:this.tenantId,callbackUrl:ya};console.log("body",t);const i=await this.authenticatedFetch("/conversations",{method:"POST",body:JSON.stringify(t)});return this.setConversationId(i.id),i}async sendMessage(e){const{conversationId:t,conversationStarted:i}=this;if(!t||!i)throw new Error("Conversation not started");const n={messageType:us.MessageType.TEXT,message:e};await this.authenticatedFetch(`/conversations/${t}/messages`,{method:"POST",body:JSON.stringify(n)})}async sendTyping(){const{conversationId:e}=this;if(!e)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${e}/messages/typing`,{method:"PUT"})}async acknowledgeMessage(e){const{conversationId:t}=this;if(!t)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${t}/messages/acknowledge`,{method:"PUT",body:JSON.stringify(e)})}async terminateConversation(){const{conversationId:e}=this;if(!e)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${e}/terminate`,{method:"POST"}),this.destroy()}destroy(){this.five9WebSocket&&this.five9WebSocket.destroy(),je(this,we,null),je(this,qe,null)}get sessionToken(){return ms(this,we)}get conversationId(){return ms(this,qe)}get dataCenter(){var e;return(e=this.sessionToken)==null?void 0:e.metadata.dataCenters[0]}get apiUrl(){var e;return(e=this.dataCenter)==null?void 0:e.apiUrls[0].host}get tenantId(){var e;return(e=this.sessionToken)==null?void 0:e.orgId}get tokenId(){var e;return(e=this.sessionToken)==null?void 0:e.tokenId}get farmId(){var e;return(e=this.sessionToken)==null?void 0:e.context.farmId}};we=new WeakMap,qe=new WeakMap;let hs=zt;function Lt(s){return`any-${s||"main"}-chatSession`}async function ba({params:s,chatWindow:e}){e=e,e.setInputDisabled(!0),e.addMessage({role:"system",content:"Please wait while we connect you to a live agent"});const t=new hs;await t.createSession();const{summary:i,subject:n,...r}=s;await t.createConversation({contact:r,attributes:{Question:n,"AI Summary":i}}),localStorage.setItem(Lt(e.cleanOptions.config.historyKey),t.serialize()),Ji(e,t)}function Ji(s,e){e.on("conversationCreated",()=>{s.setInputDisabled(!1),localStorage.setItem(Lt(s.cleanOptions.config.historyKey),e.serialize())}),e.on("conversationAccepted",r=>{s.addMessage({role:"system",content:`${r.displayName} has joined the chat`})}),e.on("agentTyping",()=>{s.setTypingIndicatorVisible(!0)}),e.on("agentJoined",r=>{s.addMessage({role:"system",content:`${r.displayName} has joined the chat`})}),e.on("agentTransferredConversation",r=>{s.addMessage({role:"system",content:`You have been transferred to ${r.toDisplayName}`})}),e.on("conversationTransferredToGroup",r=>{s.addMessage({role:"system",content:`You have been transferred to ${r.groupName}`})}),e.on("agentLeftConversation",r=>{s.addMessage({role:"system",content:`${r.displayName} has left the chat`})}),e.on("conversationTerminated",r=>{s.addMessage({role:"system",content:"The chat has ended"}),s.setInputDisabled(!0),localStorage.removeItem(Lt(s.cleanOptions.config.historyKey))}),e.on("message",r=>{switch(r.from){case"SYSTEM":s.addMessage({role:"system",content:r.text});break;case"USER":s.setTypingIndicatorVisible(!1),s.addMessage({role:"assistant",name:r.displayName,content:r.text});break;default:console.log("unhandled message:",r);break}}),e.connect();const t=async r=>{r.preventDefault(),s.addMessage({role:"user",content:r.detail.message}),await e.sendMessage(r.detail.message)},i=async()=>{console.log("destroyed fired"),e.destroy(),s.removeEventListener("iai-chat-send-user-message",t),s.removeEventListener("iai-chat-reset",n),s.removeEventListener("iai-chat-destroy",i)},n=async()=>{console.log("reset fired"),await e.terminateConversation(),await i(),localStorage.removeItem(Lt(s.cleanOptions.config.historyKey))};s.addEventListener("iai-chat-send-user-message",t),s.addEventListener("iai-chat-reset",n),s.addEventListener("iai-chat-destroy",i)}function wa(s){return async function({id:t,params:i,chatWindow:n}){n.setInputDisabled(!0);const r=document.createElement("iai-chat-iframe-modal");r.title="Schedule a Tour",r.src=`${s}?${new URLSearchParams(i).toString()}`;const a=()=>{r.remove(),window.removeEventListener("beforeunload",l),n.setInputDisabled(!1)},o=async({detail:h})=>{if(h.type!=="tourScheduled")return;const{tourType:p,tourDate:d,tourTime:b}=h;a(),n.addMessage({role:"system",content:"Your tour has been scheduled!"}),await n.sendFunctionCallResponse(t,{status:"scheduled",tourType:p,tourDate:d,tourTime:b},!0)},c=async()=>{a(),n.addMessage({role:"system",content:"Tour Scheduler Closed"}),await n.sendFunctionCallResponse(t,{status:"canceled"},!0)},l=async()=>{a(),n.addMessage({role:"system",content:"Tour Scheduler Closed"})};r.addEventListener("message-received",o),r.addEventListener("close",c),window.addEventListener("beforeunload",l),document.body.appendChild(r),n.addMessage({role:"system",content:"Tour Scheduler Opened"})}}class _a{constructor(e,t){const i=is.parse({assistantId:"7e59c8c1-a4ff-40f1-9a68-86ea294a4e75",...e});i.handlers.functionCalls.transferToLiveAgent=ba,i.handlers.functionCalls.showScheduleTourWidget=wa(t.schedulerUrl),this.chatWidget=new ha(i);const n=localStorage.getItem(Lt(i.config.historyKey));if(n){const r=hs.deserialize(n);setTimeout(()=>{Ji(this.chatWidget.api.chatWindow,r)},0)}}destroy(){this.chatWidget.destroy()}}F.AnyChatWidget=_a,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
760
+ `],_1([jr({type:Object})],Uf.prototype,"options",2),Uf=_1([Wi("iai-chat-open-chat-button")],Uf);function RL(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function k1(t,e=""){return Object.keys(t).reduce((r,n)=>{const i=RL(n),a=e?`${e}-${i}`:i;return typeof t[n]=="object"&&t[n]!==null?Object.assign(r,k1(t[n],a)):r[a]=t[n],r},{})}class xL{constructor(e){this.widget=null,this.options=If.parse(e);const r=document.createElement("iai-chat-popup");r.options=this.options;const n=k1(this.options.config.styles);Object.entries(n).filter(([,i])=>i).forEach(([i,a])=>{r.style.setProperty(`--iai-chat-${i}`,a)}),document.body.appendChild(r),this.widget=r}get api(){if(!this.widget)throw new Error("Widget has not been initialized");return this.widget}destroy(){var e;(e=this.widget)==null||e.remove(),this.widget=null}}function IL({html:t,params:e}){return t`
761
+ <div>
762
+ <iai-chat-carousel>
763
+ ${e.photos.map(r=>{const n=t`<img src="${`${r.url}`}" alt="${r.name||"Property image"}">`;return t`
764
+ <div>
765
+ <h2>${r.name||""}</h2>
766
+ <ul>
767
+ ${r.bed?t`<li>Bedrooms: ${r.bed}</li>`:""}
768
+ ${r.bath?t`<li>Bathrooms: ${r.bath}</li>`:""}
769
+ ${r.sqft?t`<li>SQFT: ${r.sqft}</li>`:""}
770
+ </ul>
771
+ ${n}
772
+ </div>
773
+ `})}
774
+ </iai-chat-carousel>
775
+ </div>
776
+ `}function AL({html:t,params:e}){return t`
777
+ <div>
778
+ <iai-chat-carousel>
779
+ ${e.units.map(r=>{const n=r.floorPlanImage!=="Data not available"?t`<img src="${r.floorPlanImage}" alt="">`:"",i=r.pricing.isVisitForPrice?r.pricing.rentString:`$${r.pricing.rent}/mo for a ${r.pricing.term} Month Lease`;return t`
780
+ <div>
781
+ <h2>Unit ${r.unitName}</h2>
782
+ <ul>
783
+ <li>Bedrooms: ${r.bedroomCount}</li>
784
+ <li>Bathrooms: ${r.bathroomCount}</li>
785
+ <li>SQFT: ${r.squareFeet}</li>
786
+ <li>Rent: ${i}</li>
787
+ ${n}
788
+ </ul>
789
+ </div>
790
+ `})}
791
+ </iai-chat-carousel>
792
+ </div>
793
+ `}var S1={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(ln,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",b="date",A="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,X={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Ee=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Ie={s:Ee,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Ee(Se,2,"0")+":"+Ee(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:b,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Fe="en",Oe={};Oe[Fe]=X;var ze="$isDayjsObject",V=function(oe){return oe instanceof Te||!(!oe||!oe[ze])},xe=function oe(q,ne,Se){var H;if(!q)return Fe;if(typeof q=="string"){var ye=q.toLowerCase();Oe[ye]&&(H=ye),ne&&(Oe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var M=q.name;Oe[M]=q,H=M}return!Se&&H&&(Fe=H),H||!Se&&Fe},_e=function(oe,q){if(V(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Ie;se.l=xe,se.i=V,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=xe(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var M=ke[2]-1||0,Xe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)):new Date(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==A},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),M=function(be,pt){var Ze=se.w(H.$u?Date.UTC(H.$y,pt,be):new Date(H.$y,pt,be),H);return ye?Ze:Ze.endOf(l)},Xe=function(be,pt){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(pt)),H)},Ct=this.$W,rt=this.$M,je=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?M(1,0):M(31,11);case d:return ye?M(1,rt):M(0,rt+1);case c:var Ke=this.$locale().weekStart||0,Be=(Ct<Ke?Ct+7:Ct)-Ke;return M(ye?je-Be:je+(6-Be),rt);case l:case b:return Xe(ce+"Hours",0);case u:return Xe(ce+"Minutes",1);case o:return Xe(ce+"Seconds",2);case s:return Xe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),M=(H={},H[l]=ke+"Date",H[b]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Xe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(b,1);Ct.$d[M](Xe),Ct.init(),this.$d=Ct.set(b,Math.min(this.$D,Ct.daysInMonth())).$d}else M&&this.$d[M](Xe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),M=function(rt){var je=_e(ye);return se.w(je.date(je.date()+Math.round(rt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return M(1);if(ke===c)return M(7);var Xe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Xe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||A;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),M=this.$H,Xe=this.$m,Ct=this.$M,rt=H.weekdays,je=H.months,ce=H.meridiem,Ke=function(pt,Ze,Jt,At){return pt&&(pt[Ze]||pt(Se,ye))||Jt[Ze].slice(0,At)},Be=function(pt){return se.s(M%12||12,pt,"0")},be=ce||function(pt,Ze,Jt){var At=pt<12?"AM":"PM";return Jt?At.toLowerCase():At};return ye.replace(z,function(pt,Ze){return Ze||function(Jt){switch(Jt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ke(H.monthsShort,Ct,je,3);case"MMMM":return Ke(je,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ke(H.weekdaysMin,Se.$W,rt,2);case"ddd":return Ke(H.weekdaysShort,Se.$W,rt,3);case"dddd":return rt[Se.$W];case"H":return String(M);case"HH":return se.s(M,2,"0");case"h":return Be(1);case"hh":return Be(2);case"a":return be(M,Xe,!0);case"A":return be(M,Xe,!1);case"m":return String(Xe);case"mm":return se.s(Xe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(pt)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,M=se.p(Se),Xe=_e(ne),Ct=(Xe.utcOffset()-this.utcOffset())*n,rt=this-Xe,je=function(){return se.m(ke,Xe)};switch(M){case m:ye=je()/12;break;case d:ye=je();break;case f:ye=je()/3;break;case c:ye=(rt-Ct)/6048e5;break;case l:ye=(rt-Ct)/864e5;break;case u:ye=rt/i;break;case o:ye=rt/n;break;case s:ye=rt/r;break;default:ye=rt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Oe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=xe(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),re=Te.prototype;return _e.prototype=re,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",b]].forEach(function(oe){re[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=xe,_e.isDayjs=V,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Oe[Fe],_e.Ls=Oe,_e.p={},_e})})(S1);var OL=S1.exports;const PL=yP(OL);function ML(t){return async function({id:r,params:n,chatWindow:i}){i.setInputDisabled(!0);const a=i.chatManager.registerRecurringKeepAlive(),{threadId:s}=i.chatManager,o={isAIChat:!0,guestCardId:n.guestCardId||null,AIChatSessionTimeout:!1,...s&&{AIChatUniqueSessionId:s},...n.firstName&&{firstName:n.firstName},...n.lastName&&{lastName:n.lastName},...n.email&&{email:n.email},...n.phoneNumber&&{phone:n.phoneNumber},...n.desiredMoveInDate&&{moveInDate:PL(n.desiredMoveInDate).format("MM/DD/YYYY")},...n.AccessWidgetLeadId&&{AccessWidgetLeadId:n.AccessWidgetLeadId}},u=document.createElement("iai-chat-iframe-modal");u.title="Schedule a Tour",u.src=`${t}?${new URLSearchParams(o).toString()}`,u.showHeader=!1;const l=()=>{a(),u.remove(),window.removeEventListener("beforeunload",f),i.removeEventListener("iai-chat-reset",l),i.setInputDisabled(!1)},c=async({detail:m})=>{if(m.type!=="tourScheduled")return;const{tourType:b,tourDate:A,tourTime:N,prospectName:z,guestCardId:X,accessWidgetLeadId:Ee}=m;l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Your tour has been scheduled!"});try{await i.sendFunctionCallResponse(r,{status:"scheduled",tourType:b,tourDate:A,tourTime:N,guestCardId:X,firstName:z,accessWidgetLeadId:Ee},!0)}finally{i.setInputDisabled(!1)}},d=async()=>{l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Tour Scheduler Closed"});try{await i.sendFunctionCallResponse(r,{status:"canceled"},!0)}finally{i.setInputDisabled(!1)}},f=async()=>{l(),i.addMessage({role:"system",content:"Tour Scheduler Closed"})};u.addEventListener("message-received",c),u.addEventListener("close",d),i.addEventListener("iai-chat-reset",l),window.addEventListener("beforeunload",f),document.body.appendChild(u),i.addMessage({role:"system",content:"Tour Scheduler Opened"})}}function $1(t,e){return function(){return t.apply(e,arguments)}}const{toString:NL}=Object.prototype,{getPrototypeOf:cm}=Object,Ff=(t=>e=>{const r=NL.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ci=t=>(t=t.toLowerCase(),e=>Ff(e)===t),Bf=t=>e=>typeof e===t,{isArray:ku}=Array,Cc=Bf("undefined");function LL(t){return t!==null&&!Cc(t)&&t.constructor!==null&&!Cc(t.constructor)&&ai(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const T1=Ci("ArrayBuffer");function DL(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&T1(t.buffer),e}const jL=Bf("string"),ai=Bf("function"),E1=Bf("number"),zf=t=>t!==null&&typeof t=="object",UL=t=>t===!0||t===!1,Hf=t=>{if(Ff(t)!=="object")return!1;const e=cm(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},FL=Ci("Date"),BL=Ci("File"),zL=Ci("Blob"),HL=Ci("FileList"),qL=t=>zf(t)&&ai(t.pipe),VL=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||ai(t.append)&&((e=Ff(t))==="formdata"||e==="object"&&ai(t.toString)&&t.toString()==="[object FormData]"))},WL=Ci("URLSearchParams"),[ZL,GL,KL,JL]=["ReadableStream","Request","Response","Headers"].map(Ci),YL=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Rc(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),ku(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const a=r?Object.getOwnPropertyNames(t):Object.keys(t),s=a.length;let o;for(n=0;n<s;n++)o=a[n],e.call(null,t[o],o,t)}}function C1(t,e){e=e.toLowerCase();const r=Object.keys(t);let n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}const R1=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,x1=t=>!Cc(t)&&t!==R1;function dm(){const{caseless:t}=x1(this)&&this||{},e={},r=(n,i)=>{const a=t&&C1(e,i)||i;Hf(e[a])&&Hf(n)?e[a]=dm(e[a],n):Hf(n)?e[a]=dm({},n):ku(n)?e[a]=n.slice():e[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Rc(arguments[n],r);return e}const QL=(t,e,r,{allOwnKeys:n}={})=>(Rc(e,(i,a)=>{r&&ai(i)?t[a]=$1(i,r):t[a]=i},{allOwnKeys:n}),t),XL=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),e3=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},t3=(t,e,r,n)=>{let i,a,s;const o={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),a=i.length;a-- >0;)s=i[a],(!n||n(s,t,e))&&!o[s]&&(e[s]=t[s],o[s]=!0);t=r!==!1&&cm(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},r3=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},n3=t=>{if(!t)return null;if(ku(t))return t;let e=t.length;if(!E1(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},i3=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&cm(Uint8Array)),a3=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=n.next())&&!i.done;){const a=i.value;e.call(t,a[0],a[1])}},s3=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},o3=Ci("HTMLFormElement"),u3=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),I1=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),l3=Ci("RegExp"),A1=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};Rc(r,(i,a)=>{let s;(s=e(i,a,t))!==!1&&(n[a]=s||i)}),Object.defineProperties(t,n)},c3=t=>{A1(t,(e,r)=>{if(ai(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(ai(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},d3=(t,e)=>{const r={},n=i=>{i.forEach(a=>{r[a]=!0})};return ku(t)?n(t):n(String(t).split(e)),r},f3=()=>{},h3=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,fm="abcdefghijklmnopqrstuvwxyz",O1="0123456789",P1={DIGIT:O1,ALPHA:fm,ALPHA_DIGIT:fm+fm.toUpperCase()+O1},p3=(t=16,e=P1.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r};function v3(t){return!!(t&&ai(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const m3=t=>{const e=new Array(10),r=(n,i)=>{if(zf(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[i]=n;const a=ku(n)?[]:{};return Rc(n,(s,o)=>{const u=r(s,i+1);!Cc(u)&&(a[o]=u)}),e[i]=void 0,a}}return n};return r(t,0)},g3=Ci("AsyncFunction"),De={isArray:ku,isArrayBuffer:T1,isBuffer:LL,isFormData:VL,isArrayBufferView:DL,isString:jL,isNumber:E1,isBoolean:UL,isObject:zf,isPlainObject:Hf,isReadableStream:ZL,isRequest:GL,isResponse:KL,isHeaders:JL,isUndefined:Cc,isDate:FL,isFile:BL,isBlob:zL,isRegExp:l3,isFunction:ai,isStream:qL,isURLSearchParams:WL,isTypedArray:i3,isFileList:HL,forEach:Rc,merge:dm,extend:QL,trim:YL,stripBOM:XL,inherits:e3,toFlatObject:t3,kindOf:Ff,kindOfTest:Ci,endsWith:r3,toArray:n3,forEachEntry:a3,matchAll:s3,isHTMLForm:o3,hasOwnProperty:I1,hasOwnProp:I1,reduceDescriptors:A1,freezeMethods:c3,toObjectSet:d3,toCamelCase:u3,noop:f3,toFiniteNumber:h3,findKey:C1,global:R1,isContextDefined:x1,ALPHABET:P1,generateString:p3,isSpecCompliantForm:v3,toJSONObject:m3,isAsyncFn:g3,isThenable:t=>t&&(zf(t)||ai(t))&&ai(t.then)&&ai(t.catch)};function ir(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}De.inherits(ir,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:De.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const M1=ir.prototype,N1={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{N1[t]={value:t}}),Object.defineProperties(ir,N1),Object.defineProperty(M1,"isAxiosError",{value:!0}),ir.from=(t,e,r,n,i,a)=>{const s=Object.create(M1);return De.toFlatObject(t,s,function(u){return u!==Error.prototype},o=>o!=="isAxiosError"),ir.call(s,t.message,e,r,n,i),s.cause=t,s.name=t.name,a&&Object.assign(s,a),s};const y3=null;function hm(t){return De.isPlainObject(t)||De.isArray(t)}function L1(t){return De.endsWith(t,"[]")?t.slice(0,-2):t}function D1(t,e,r){return t?t.concat(e).map(function(i,a){return i=L1(i),!r&&a?"["+i+"]":i}).join(r?".":""):e}function b3(t){return De.isArray(t)&&!t.some(hm)}const w3=De.toFlatObject(De,{},null,function(e){return/^is[A-Z]/.test(e)});function qf(t,e,r){if(!De.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=De.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,N){return!De.isUndefined(N[A])});const n=r.metaTokens,i=r.visitor||c,a=r.dots,s=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&De.isSpecCompliantForm(e);if(!De.isFunction(i))throw new TypeError("visitor must be a function");function l(b){if(b===null)return"";if(De.isDate(b))return b.toISOString();if(!u&&De.isBlob(b))throw new ir("Blob is not supported. Use a Buffer instead.");return De.isArrayBuffer(b)||De.isTypedArray(b)?u&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function c(b,A,N){let z=b;if(b&&!N&&typeof b=="object"){if(De.endsWith(A,"{}"))A=n?A:A.slice(0,-2),b=JSON.stringify(b);else if(De.isArray(b)&&b3(b)||(De.isFileList(b)||De.endsWith(A,"[]"))&&(z=De.toArray(b)))return A=L1(A),z.forEach(function(Ee,Ie){!(De.isUndefined(Ee)||Ee===null)&&e.append(s===!0?D1([A],Ie,a):s===null?A:A+"[]",l(Ee))}),!1}return hm(b)?!0:(e.append(D1(N,A,a),l(b)),!1)}const d=[],f=Object.assign(w3,{defaultVisitor:c,convertValue:l,isVisitable:hm});function m(b,A){if(!De.isUndefined(b)){if(d.indexOf(b)!==-1)throw Error("Circular reference detected in "+A.join("."));d.push(b),De.forEach(b,function(z,X){(!(De.isUndefined(z)||z===null)&&i.call(e,z,De.isString(X)?X.trim():X,A,f))===!0&&m(z,A?A.concat(X):[X])}),d.pop()}}if(!De.isObject(t))throw new TypeError("data must be an object");return m(t),e}function j1(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function pm(t,e){this._pairs=[],t&&qf(t,this,e)}const U1=pm.prototype;U1.append=function(e,r){this._pairs.push([e,r])},U1.toString=function(e){const r=e?function(n){return e.call(this,n,j1)}:j1;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function _3(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function F1(t,e,r){if(!e)return t;const n=r&&r.encode||_3,i=r&&r.serialize;let a;if(i?a=i(e,r):a=De.isURLSearchParams(e)?e.toString():new pm(e,r).toString(n),a){const s=t.indexOf("#");s!==-1&&(t=t.slice(0,s)),t+=(t.indexOf("?")===-1?"?":"&")+a}return t}class B1{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){De.forEach(this.handlers,function(n){n!==null&&e(n)})}}const z1={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},k3={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:pm,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},vm=typeof window<"u"&&typeof document<"u",S3=(t=>vm&&["ReactNative","NativeScript","NS"].indexOf(t)<0)(typeof navigator<"u"&&navigator.product),$3=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",T3=vm&&window.location.href||"http://localhost",Ri={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:vm,hasStandardBrowserEnv:S3,hasStandardBrowserWebWorkerEnv:$3,origin:T3},Symbol.toStringTag,{value:"Module"})),...k3};function E3(t,e){return qf(t,new Ri.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return Ri.isNode&&De.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},e))}function C3(t){return De.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function R3(t){const e={},r=Object.keys(t);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],e[a]=t[a];return e}function H1(t){function e(r,n,i,a){let s=r[a++];if(s==="__proto__")return!0;const o=Number.isFinite(+s),u=a>=r.length;return s=!s&&De.isArray(i)?i.length:s,u?(De.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!o):((!i[s]||!De.isObject(i[s]))&&(i[s]=[]),e(r,n,i[s],a)&&De.isArray(i[s])&&(i[s]=R3(i[s])),!o)}if(De.isFormData(t)&&De.isFunction(t.entries)){const r={};return De.forEachEntry(t,(n,i)=>{e(C3(n),i,r,0)}),r}return null}function x3(t,e,r){if(De.isString(t))try{return(e||JSON.parse)(t),De.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const xc={transitional:z1,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=De.isObject(e);if(a&&De.isHTMLForm(e)&&(e=new FormData(e)),De.isFormData(e))return i?JSON.stringify(H1(e)):e;if(De.isArrayBuffer(e)||De.isBuffer(e)||De.isStream(e)||De.isFile(e)||De.isBlob(e)||De.isReadableStream(e))return e;if(De.isArrayBufferView(e))return e.buffer;if(De.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return E3(e,this.formSerializer).toString();if((o=De.isFileList(e))||n.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return qf(o?{"files[]":e}:e,u&&new u,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),x3(e)):e}],transformResponse:[function(e){const r=this.transitional||xc.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(De.isResponse(e)||De.isReadableStream(e))return e;if(e&&De.isString(e)&&(n&&!this.responseType||i)){const s=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?ir.from(o,ir.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ri.classes.FormData,Blob:Ri.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};De.forEach(["delete","get","head","post","put","patch"],t=>{xc.headers[t]={}});const I3=De.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),A3=t=>{const e={};let r,n,i;return t&&t.split(`
794
+ `).forEach(function(s){i=s.indexOf(":"),r=s.substring(0,i).trim().toLowerCase(),n=s.substring(i+1).trim(),!(!r||e[r]&&I3[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},q1=Symbol("internals");function Ic(t){return t&&String(t).trim().toLowerCase()}function Vf(t){return t===!1||t==null?t:De.isArray(t)?t.map(Vf):String(t)}function O3(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}const P3=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function mm(t,e,r,n,i){if(De.isFunction(n))return n.call(this,e,r);if(i&&(e=r),!!De.isString(e)){if(De.isString(n))return e.indexOf(n)!==-1;if(De.isRegExp(n))return n.test(e)}}function M3(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function N3(t,e){const r=De.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(i,a,s){return this[n].call(this,e,i,a,s)},configurable:!0})})}class jn{constructor(e){e&&this.set(e)}set(e,r,n){const i=this;function a(o,u,l){const c=Ic(u);if(!c)throw new Error("header name must be a non-empty string");const d=De.findKey(i,c);(!d||i[d]===void 0||l===!0||l===void 0&&i[d]!==!1)&&(i[d||u]=Vf(o))}const s=(o,u)=>De.forEach(o,(l,c)=>a(l,c,u));if(De.isPlainObject(e)||e instanceof this.constructor)s(e,r);else if(De.isString(e)&&(e=e.trim())&&!P3(e))s(A3(e),r);else if(De.isHeaders(e))for(const[o,u]of e.entries())a(u,o,n);else e!=null&&a(r,e,n);return this}get(e,r){if(e=Ic(e),e){const n=De.findKey(this,e);if(n){const i=this[n];if(!r)return i;if(r===!0)return O3(i);if(De.isFunction(r))return r.call(this,i,n);if(De.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=Ic(e),e){const n=De.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||mm(this,this[n],n,r)))}return!1}delete(e,r){const n=this;let i=!1;function a(s){if(s=Ic(s),s){const o=De.findKey(n,s);o&&(!r||mm(n,n[o],o,r))&&(delete n[o],i=!0)}}return De.isArray(e)?e.forEach(a):a(e),i}clear(e){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const a=r[n];(!e||mm(this,this[a],a,e,!0))&&(delete this[a],i=!0)}return i}normalize(e){const r=this,n={};return De.forEach(this,(i,a)=>{const s=De.findKey(n,a);if(s){r[s]=Vf(i),delete r[a];return}const o=e?M3(a):String(a).trim();o!==a&&delete r[a],r[o]=Vf(i),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return De.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=e&&De.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
795
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[q1]=this[q1]={accessors:{}}).accessors,i=this.prototype;function a(s){const o=Ic(s);n[o]||(N3(i,s),n[o]=!0)}return De.isArray(e)?e.forEach(a):a(e),this}}jn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),De.reduceDescriptors(jn.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),De.freezeMethods(jn);function gm(t,e){const r=this||xc,n=e||r,i=jn.from(n.headers);let a=n.data;return De.forEach(t,function(o){a=o.call(r,a,i.normalize(),e?e.status:void 0)}),i.normalize(),a}function V1(t){return!!(t&&t.__CANCEL__)}function Su(t,e,r){ir.call(this,t??"canceled",ir.ERR_CANCELED,e,r),this.name="CanceledError"}De.inherits(Su,ir,{__CANCEL__:!0});function W1(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new ir("Request failed with status code "+r.status,[ir.ERR_BAD_REQUEST,ir.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function L3(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function D3(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i=0,a=0,s;return e=e!==void 0?e:1e3,function(u){const l=Date.now(),c=n[a];s||(s=l),r[i]=u,n[i]=l;let d=a,f=0;for(;d!==i;)f+=r[d++],d=d%t;if(i=(i+1)%t,i===a&&(a=(a+1)%t),l-s<e)return;const m=c&&l-c;return m?Math.round(f*1e3/m):void 0}}function j3(t,e){let r=0;const n=1e3/e;let i=null;return function(){const s=this===!0,o=Date.now();if(s||o-r>n)return i&&(clearTimeout(i),i=null),r=o,t.apply(null,arguments);i||(i=setTimeout(()=>(i=null,r=Date.now(),t.apply(null,arguments)),n-(o-r)))}}const Wf=(t,e,r=3)=>{let n=0;const i=D3(50,250);return j3(a=>{const s=a.loaded,o=a.lengthComputable?a.total:void 0,u=s-n,l=i(u),c=s<=o;n=s;const d={loaded:s,total:o,progress:o?s/o:void 0,bytes:u,rate:l||void 0,estimated:l&&o&&c?(o-s)/l:void 0,event:a,lengthComputable:o!=null};d[e?"download":"upload"]=!0,t(d)},r)},U3=Ri.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function i(a){let s=a;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(s){const o=De.isString(s)?i(s):s;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}(),F3=Ri.hasStandardBrowserEnv?{write(t,e,r,n,i,a){const s=[t+"="+encodeURIComponent(e)];De.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),De.isString(n)&&s.push("path="+n),De.isString(i)&&s.push("domain="+i),a===!0&&s.push("secure"),document.cookie=s.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function B3(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function z3(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Z1(t,e){return t&&!B3(e)?z3(t,e):e}const G1=t=>t instanceof jn?{...t}:t;function mo(t,e){e=e||{};const r={};function n(l,c,d){return De.isPlainObject(l)&&De.isPlainObject(c)?De.merge.call({caseless:d},l,c):De.isPlainObject(c)?De.merge({},c):De.isArray(c)?c.slice():c}function i(l,c,d){if(De.isUndefined(c)){if(!De.isUndefined(l))return n(void 0,l,d)}else return n(l,c,d)}function a(l,c){if(!De.isUndefined(c))return n(void 0,c)}function s(l,c){if(De.isUndefined(c)){if(!De.isUndefined(l))return n(void 0,l)}else return n(void 0,c)}function o(l,c,d){if(d in e)return n(l,c);if(d in t)return n(void 0,l)}const u={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o,headers:(l,c)=>i(G1(l),G1(c),!0)};return De.forEach(Object.keys(Object.assign({},t,e)),function(c){const d=u[c]||i,f=d(t[c],e[c],c);De.isUndefined(f)&&d!==o||(r[c]=f)}),r}const K1=t=>{const e=mo({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:s,auth:o}=e;e.headers=s=jn.from(s),e.url=F1(Z1(e.baseURL,e.url),t.params,t.paramsSerializer),o&&s.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let u;if(De.isFormData(r)){if(Ri.hasStandardBrowserEnv||Ri.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[l,...c]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([l||"multipart/form-data",...c].join("; "))}}if(Ri.hasStandardBrowserEnv&&(n&&De.isFunction(n)&&(n=n(e)),n||n!==!1&&U3(e.url))){const l=i&&a&&F3.read(a);l&&s.set(i,l)}return e},H3=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const i=K1(t);let a=i.data;const s=jn.from(i.headers).normalize();let{responseType:o}=i,u;function l(){i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let c=new XMLHttpRequest;c.open(i.method.toUpperCase(),i.url,!0),c.timeout=i.timeout;function d(){if(!c)return;const m=jn.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),A={data:!o||o==="text"||o==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:m,config:t,request:c};W1(function(z){r(z),l()},function(z){n(z),l()},A),c=null}"onloadend"in c?c.onloadend=d:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(d)},c.onabort=function(){c&&(n(new ir("Request aborted",ir.ECONNABORTED,i,c)),c=null)},c.onerror=function(){n(new ir("Network Error",ir.ERR_NETWORK,i,c)),c=null},c.ontimeout=function(){let b=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const A=i.transitional||z1;i.timeoutErrorMessage&&(b=i.timeoutErrorMessage),n(new ir(b,A.clarifyTimeoutError?ir.ETIMEDOUT:ir.ECONNABORTED,i,c)),c=null},a===void 0&&s.setContentType(null),"setRequestHeader"in c&&De.forEach(s.toJSON(),function(b,A){c.setRequestHeader(A,b)}),De.isUndefined(i.withCredentials)||(c.withCredentials=!!i.withCredentials),o&&o!=="json"&&(c.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&c.addEventListener("progress",Wf(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Wf(i.onUploadProgress)),(i.cancelToken||i.signal)&&(u=m=>{c&&(n(!m||m.type?new Su(null,t,c):m),c.abort(),c=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const f=L3(i.url);if(f&&Ri.protocols.indexOf(f)===-1){n(new ir("Unsupported protocol "+f+":",ir.ERR_BAD_REQUEST,t));return}c.send(a||null)})},q3=(t,e)=>{let r=new AbortController,n;const i=function(u){if(!n){n=!0,s();const l=u instanceof Error?u:this.reason;r.abort(l instanceof ir?l:new Su(l instanceof Error?l.message:l))}};let a=e&&setTimeout(()=>{i(new ir(`timeout ${e} of ms exceeded`,ir.ETIMEDOUT))},e);const s=()=>{t&&(a&&clearTimeout(a),a=null,t.forEach(u=>{u&&(u.removeEventListener?u.removeEventListener("abort",i):u.unsubscribe(i))}),t=null)};t.forEach(u=>u&&u.addEventListener&&u.addEventListener("abort",i));const{signal:o}=r;return o.unsubscribe=s,[o,()=>{a&&clearTimeout(a),a=null}]},V3=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,i;for(;n<r;)i=n+e,yield t.slice(n,i),n=i},W3=async function*(t,e,r){for await(const n of t)yield*V3(ArrayBuffer.isView(n)?n:await r(String(n)),e)},J1=(t,e,r,n,i)=>{const a=W3(t,e,i);let s=0;return new ReadableStream({type:"bytes",async pull(o){const{done:u,value:l}=await a.next();if(u){o.close(),n();return}let c=l.byteLength;r&&r(s+=c),o.enqueue(new Uint8Array(l))},cancel(o){return n(o),a.return()}},{highWaterMark:2})},Y1=(t,e)=>{const r=t!=null;return n=>setTimeout(()=>e({lengthComputable:r,total:t,loaded:n}))},Zf=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Q1=Zf&&typeof ReadableStream=="function",ym=Zf&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),Z3=Q1&&(()=>{let t=!1;const e=new Request(Ri.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),X1=64*1024,bm=Q1&&!!(()=>{try{return De.isReadableStream(new Response("").body)}catch{}})(),Gf={stream:bm&&(t=>t.body)};Zf&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Gf[e]&&(Gf[e]=De.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new ir(`Response type '${e}' is not supported`,ir.ERR_NOT_SUPPORT,n)})})})(new Response);const G3=async t=>{if(t==null)return 0;if(De.isBlob(t))return t.size;if(De.isSpecCompliantForm(t))return(await new Request(t).arrayBuffer()).byteLength;if(De.isArrayBufferView(t))return t.byteLength;if(De.isURLSearchParams(t)&&(t=t+""),De.isString(t))return(await ym(t)).byteLength},K3=async(t,e)=>{const r=De.toFiniteNumber(t.getContentLength());return r??G3(e)},wm={http:y3,xhr:H3,fetch:Zf&&(async t=>{let{url:e,method:r,data:n,signal:i,cancelToken:a,timeout:s,onDownloadProgress:o,onUploadProgress:u,responseType:l,headers:c,withCredentials:d="same-origin",fetchOptions:f}=K1(t);l=l?(l+"").toLowerCase():"text";let[m,b]=i||a||s?q3([i,a],s):[],A,N;const z=()=>{!A&&setTimeout(()=>{m&&m.unsubscribe()}),A=!0};let X;try{if(u&&Z3&&r!=="get"&&r!=="head"&&(X=await K3(c,n))!==0){let Oe=new Request(e,{method:"POST",body:n,duplex:"half"}),ze;De.isFormData(n)&&(ze=Oe.headers.get("content-type"))&&c.setContentType(ze),Oe.body&&(n=J1(Oe.body,X1,Y1(X,Wf(u)),null,ym))}De.isString(d)||(d=d?"cors":"omit"),N=new Request(e,{...f,signal:m,method:r.toUpperCase(),headers:c.normalize().toJSON(),body:n,duplex:"half",withCredentials:d});let Ee=await fetch(N);const Ie=bm&&(l==="stream"||l==="response");if(bm&&(o||Ie)){const Oe={};["status","statusText","headers"].forEach(V=>{Oe[V]=Ee[V]});const ze=De.toFiniteNumber(Ee.headers.get("content-length"));Ee=new Response(J1(Ee.body,X1,o&&Y1(ze,Wf(o,!0)),Ie&&z,ym),Oe)}l=l||"text";let Fe=await Gf[De.findKey(Gf,l)||"text"](Ee,t);return!Ie&&z(),b&&b(),await new Promise((Oe,ze)=>{W1(Oe,ze,{data:Fe,headers:jn.from(Ee.headers),status:Ee.status,statusText:Ee.statusText,config:t,request:N})})}catch(Ee){throw z(),Ee&&Ee.name==="TypeError"&&/fetch/i.test(Ee.message)?Object.assign(new ir("Network Error",ir.ERR_NETWORK,t,N),{cause:Ee.cause||Ee}):ir.from(Ee,Ee&&Ee.code,t,N)}})};De.forEach(wm,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const ek=t=>`- ${t}`,J3=t=>De.isFunction(t)||t===null||t===!1,tk={getAdapter:t=>{t=De.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let a=0;a<e;a++){r=t[a];let s;if(n=r,!J3(r)&&(n=wm[(s=String(r)).toLowerCase()],n===void 0))throw new ir(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+a]=n}if(!n){const a=Object.entries(i).map(([o,u])=>`adapter ${o} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=e?a.length>1?`since :
796
+ `+a.map(ek).join(`
797
+ `):" "+ek(a[0]):"as no adapter specified";throw new ir("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:wm};function _m(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Su(null,t)}function rk(t){return _m(t),t.headers=jn.from(t.headers),t.data=gm.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),tk.getAdapter(t.adapter||xc.adapter)(t).then(function(n){return _m(t),n.data=gm.call(t,t.transformResponse,n),n.headers=jn.from(n.headers),n},function(n){return V1(n)||(_m(t),n&&n.response&&(n.response.data=gm.call(t,t.transformResponse,n.response),n.response.headers=jn.from(n.response.headers))),Promise.reject(n)})}const nk="1.7.2",km={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{km[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const ik={};km.transitional=function(e,r,n){function i(a,s){return"[Axios v"+nk+"] Transitional option '"+a+"'"+s+(n?". "+n:"")}return(a,s,o)=>{if(e===!1)throw new ir(i(s," has been removed"+(r?" in "+r:"")),ir.ERR_DEPRECATED);return r&&!ik[s]&&(ik[s]=!0,console.warn(i(s," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,s,o):!0}};function Y3(t,e,r){if(typeof t!="object")throw new ir("options must be an object",ir.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const a=n[i],s=e[a];if(s){const o=t[a],u=o===void 0||s(o,a,t);if(u!==!0)throw new ir("option "+a+" must be "+u,ir.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ir("Unknown option "+a,ir.ERR_BAD_OPTION)}}const Sm={assertOptions:Y3,validators:km},ps=Sm.validators;class go{constructor(e){this.defaults=e,this.interceptors={request:new B1,response:new B1}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const a=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?a&&!String(n.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(n.stack+=`
798
+ `+a):n.stack=a}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=mo(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:a}=r;n!==void 0&&Sm.assertOptions(n,{silentJSONParsing:ps.transitional(ps.boolean),forcedJSONParsing:ps.transitional(ps.boolean),clarifyTimeoutError:ps.transitional(ps.boolean)},!1),i!=null&&(De.isFunction(i)?r.paramsSerializer={serialize:i}:Sm.assertOptions(i,{encode:ps.function,serialize:ps.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=a&&De.merge(a.common,a[r.method]);a&&De.forEach(["delete","get","head","post","put","patch","common"],b=>{delete a[b]}),r.headers=jn.concat(s,a);const o=[];let u=!0;this.interceptors.request.forEach(function(A){typeof A.runWhen=="function"&&A.runWhen(r)===!1||(u=u&&A.synchronous,o.unshift(A.fulfilled,A.rejected))});const l=[];this.interceptors.response.forEach(function(A){l.push(A.fulfilled,A.rejected)});let c,d=0,f;if(!u){const b=[rk.bind(this),void 0];for(b.unshift.apply(b,o),b.push.apply(b,l),f=b.length,c=Promise.resolve(r);d<f;)c=c.then(b[d++],b[d++]);return c}f=o.length;let m=r;for(d=0;d<f;){const b=o[d++],A=o[d++];try{m=b(m)}catch(N){A.call(this,N);break}}try{c=rk.call(this,m)}catch(b){return Promise.reject(b)}for(d=0,f=l.length;d<f;)c=c.then(l[d++],l[d++]);return c}getUri(e){e=mo(this.defaults,e);const r=Z1(e.baseURL,e.url);return F1(r,e.params,e.paramsSerializer)}}De.forEach(["delete","get","head","options"],function(e){go.prototype[e]=function(r,n){return this.request(mo(n||{},{method:e,url:r,data:(n||{}).data}))}}),De.forEach(["post","put","patch"],function(e){function r(n){return function(a,s,o){return this.request(mo(o||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:a,data:s}))}}go.prototype[e]=r(),go.prototype[e+"Form"]=r(!0)});class $m{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const n=this;this.promise.then(i=>{if(!n._listeners)return;let a=n._listeners.length;for(;a-- >0;)n._listeners[a](i);n._listeners=null}),this.promise.then=i=>{let a;const s=new Promise(o=>{n.subscribe(o),a=o}).then(i);return s.cancel=function(){n.unsubscribe(a)},s},e(function(a,s,o){n.reason||(n.reason=new Su(a,s,o),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}static source(){let e;return{token:new $m(function(i){e=i}),cancel:e}}}function Q3(t){return function(r){return t.apply(null,r)}}function X3(t){return De.isObject(t)&&t.isAxiosError===!0}const Tm={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Tm).forEach(([t,e])=>{Tm[e]=t});function ak(t){const e=new go(t),r=$1(go.prototype.request,e);return De.extend(r,go.prototype,e,{allOwnKeys:!0}),De.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return ak(mo(t,i))},r}const Qr=ak(xc);Qr.Axios=go,Qr.CanceledError=Su,Qr.CancelToken=$m,Qr.isCancel=V1,Qr.VERSION=nk,Qr.toFormData=qf,Qr.AxiosError=ir,Qr.Cancel=Qr.CanceledError,Qr.all=function(e){return Promise.all(e)},Qr.spread=Q3,Qr.isAxiosError=X3,Qr.mergeConfig=mo,Qr.AxiosHeaders=jn,Qr.formToJSON=t=>H1(De.isHTMLForm(t)?new FormData(t):t),Qr.getAdapter=tk.getAdapter,Qr.HttpStatusCode=Tm,Qr.default=Qr;function sk(t,e){let r=!1;e.on("conversationCreated",()=>{t.setInputDisabled(!1),localStorage.setItem(yo(t.cleanOptions.config.historyKey),JSON.stringify(e.getState()))}),e.on("agentJoined",o=>{t.addMessage({role:"system",content:"Agent has joined the chat"})}),e.on("agentLeftConversation",o=>{const u=e.getState().identity;if(o.identity===u){console.log("[transferToTwilio] Customer left (not showing message to self)");return}t.addMessage({role:"system",content:"Agent has left the chat"})}),e.on("agentTyping",o=>{o.identity!==e.getState().identity&&t.setTypingIndicatorVisible(!0)}),e.on("typingEnded",()=>{t.setTypingIndicatorVisible(!1)}),e.on("message",o=>{console.log("[transferToTwilio] Message event received");const u=o.author||o.identity||"unknown",l=o.body||o.message||"",c=e.getState().identity;if(u===c||u==="customer"||u==="user"){console.log("[transferToTwilio] Skipping own message from:",u);return}t.setTypingIndicatorVisible(!1),t.addMessage({role:"assistant",name:"Agent",content:l})}),e.on("conversationClosed",()=>{t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(yo(t.cleanOptions.config.historyKey))}),e.on("conversationLeft",o=>{if(console.log("[transferToTwilio] Conversation left event"),r){console.log("[transferToTwilio] User-initiated reset, skipping end message"),r=!1;return}t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(yo(t.cleanOptions.config.historyKey))}),e.on("error",o=>{console.error("[Twilio Error]:",o),t.addMessage({role:"system",content:`Error: ${o.message||"An error occurred"}`})}),e.on("connected",()=>{console.log("[Twilio] Connected to backend")}),e.on("disconnected",()=>{console.log("[Twilio] Disconnected from backend")}),e.connect();const n=async o=>{o.preventDefault(),t.addMessage({role:"user",content:o.detail.message}),await e.sendMessage({body:o.detail.message,author:"customer",triggerStudioFlow:!1})},i=async()=>{e.destroy(),t.removeEventListener("iai-chat-send-user-message",n),t.removeEventListener("iai-chat-reset",s),t.removeEventListener("iai-chat-destroy",i)},a=t.cleanOptions.config.disclaimerMessage,s=async()=>{r=!0,await e.terminateConversation(),await i(),localStorage.removeItem(yo(t.cleanOptions.config.historyKey)),t.cleanOptions.config.disclaimerMessage=a};t.cleanOptions.config.disclaimerMessage="",t.addEventListener("iai-chat-send-user-message",n),t.addEventListener("iai-chat-reset",s),t.addEventListener("iai-chat-destroy",i)}function eD(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}var Em;(t=>{(e=>{e.TEXT="TEXT"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(t.ContentType||(t.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(t.ConversationEventOrigin||(t.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(t.ConversationStatus||(t.ConversationStatus={}))})(Em||(Em={})),Em.AcknowledgeType;var qr;(t=>{(e=>{e.TEXT="TEXT",e.MEDIA="MEDIA"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.CONNECTING="connecting",e.CONNECTED="connected",e.DISCONNECTING="disconnecting",e.DISCONNECTED="disconnected",e.DENIED="denied",e.ERROR="error"})(t.ConnectionState||(t.ConnectionState={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE",e.CLOSED="CLOSED"})(t.ConversationStatus||(t.ConversationStatus={})),(e=>{e.CHAT="chat",e.SMS="sms",e.WHATSAPP="whatsapp"})(t.ParticipantType||(t.ParticipantType={})),(e=>{e.QUEUED="queued",e.SENT="sent",e.DELIVERED="delivered",e.READ="read",e.FAILED="failed",e.UNDELIVERED="undelivered"})(t.DeliveryStatus||(t.DeliveryStatus={}))})(qr||(qr={}));class Kf{constructor(){this._emitter=eD(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.client=null,this.conversation=null,this.accessToken=null,this.identity=null,this.conversationSid=null,this.conversationStarted=!1,this.connectionState=qr.ConnectionState.DISCONNECTED,this.conversationStatus=qr.ConversationStatus.PENDING,this.config=null,this.messageQueue=[]}serialize(){return JSON.stringify({accessToken:this.accessToken,identity:this.identity,conversationSid:this.conversationSid,conversationStarted:this.conversationStarted,connectionState:this.connectionState,conversationStatus:this.conversationStatus})}static deserialize(e){const r=JSON.parse(e),n=new Kf;return r.accessToken&&r.identity&&(n.accessToken=r.accessToken,n.identity=r.identity),r.conversationSid&&(n.conversationSid=r.conversationSid),n.conversationStarted=r.conversationStarted||!1,n.connectionState=r.connectionState||qr.ConnectionState.DISCONNECTED,n.conversationStatus=r.conversationStatus||qr.ConversationStatus.PENDING,n}setupClientListeners(){this.client&&(this.client.on("connectionStateChanged",e=>{const r=this.connectionState,n=this.mapConnectionState(e);this.connectionState=n,this._emitter.emit("connectionStateChanged",{previous:r,current:n}),n===qr.ConnectionState.CONNECTED&&r!==qr.ConnectionState.CONNECTED&&this.processMessageQueue()}),this.client.on("tokenAboutToExpire",async()=>{console.log("Token about to expire, refreshing..."),await this.refreshToken()}),this.client.on("tokenExpired",async()=>{console.warn("Token expired, refreshing..."),await this.refreshToken()}),this.client.on("conversationJoined",e=>{console.log("Conversation joined"),this._emitter.emit("conversationJoined",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("conversationLeft",e=>{console.log("Conversation left"),this._emitter.emit("conversationLeft",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("connectionError",e=>{console.error("Twilio connection error:",e),this.handleError("Connection error",e)}))}async initialize(e){try{this.config=e,this.accessToken=e.accessToken,this.identity=e.identity,this.tokenRefreshUrl=e.tokenRefreshUrl;const{Client:r}=await Promise.resolve().then(()=>aae);this.client=new r(e.accessToken,{logLevel:e.logLevel||"error"}),this.setupClientListeners(),await this.waitForClientReady(),e.conversationSid&&(this.conversationSid=e.conversationSid,await this.joinConversation(e.conversationSid))}catch(r){throw console.error("Failed to initialize Twilio Manager:",r),this.handleError("Initialization failed",r),r}}async waitForClientReady(){return new Promise((e,r)=>{if(!this.client){r(new Error("Client not initialized"));return}const n=setTimeout(()=>{r(new Error("Client initialization timeout"))},3e4);this.client.on("initialized",()=>{clearTimeout(n),e()}),this.client.on("initFailed",i=>{clearTimeout(n),r(i)})})}mapConnectionState(e){switch(e){case"connecting":return qr.ConnectionState.CONNECTING;case"connected":return qr.ConnectionState.CONNECTED;case"disconnecting":return qr.ConnectionState.DISCONNECTING;case"disconnected":return qr.ConnectionState.DISCONNECTED;case"denied":return qr.ConnectionState.DENIED;case"error":return qr.ConnectionState.ERROR;default:return qr.ConnectionState.DISCONNECTED}}async refreshToken(){try{if(!this.tokenRefreshUrl)throw new Error("Token refresh URL not configured");const e=await fetch(this.tokenRefreshUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:this.identity})});if(!e.ok)throw new Error(`Token refresh failed: ${e.statusText}`);const r=await e.json();this.accessToken=r.token,this.client&&(await this.client.updateToken(r.token),console.log("Token refreshed successfully"),this._emitter.emit("tokenRefreshed",{timestamp:new Date}))}catch(e){throw console.error("Token refresh failed:",e),this.handleError("Token refresh failed",e),e}}async createConversation(e){try{if(!this.client)throw new Error("Client not initialized");const r=await this.client.createConversation({friendlyName:e.friendlyName,uniqueName:e.uniqueName,attributes:e.attributes});this.conversation=r,this.conversationSid=r.sid,await r.join(),this.setupConversationListeners(r);const n={sid:r.sid,friendlyName:r.friendlyName,uniqueName:r.uniqueName,attributes:r.attributes,dateCreated:r.dateCreated,dateUpdated:r.dateUpdated,state:r.state,status:qr.ConversationStatus.ACTIVE};return this.conversationStarted=!0,this.conversationStatus=qr.ConversationStatus.ACTIVE,this._emitter.emit("conversationCreated",n),n}catch(r){throw console.error("Failed to create conversation:",r),this.handleError("Conversation creation failed",r),r}}async joinConversation(e){try{if(!this.client)throw new Error("Client not initialized");console.log("Joining conversation:",e);const r=await this.client.getConversationBySid(e);try{await r.join()}catch(n){if(n.code!==50403)throw n}this.conversation=r,this.conversationSid=e,this.setupConversationListeners(r),this.conversationStarted=!0,this.conversationStatus=qr.ConversationStatus.ACTIVE,this._emitter.emit("conversationJoined",{conversationSid:e,timestamp:new Date})}catch(r){throw console.error("Failed to join conversation:",r),this.handleError("Failed to join conversation",r),r}}async initializeConversation(e){return this.createConversation(e)}setupConversationListeners(e){const r=(n,i)=>{let a;const s=o=>{try{const u=o.replace(/_([0-9A-Fa-f]{2})/g,"%$1");return decodeURIComponent(u)}catch(u){return console.warn("Could not decode Twilio identity:",u),o}};return n&&n.attributes&&(a=n.attributes.public_identity||n.attributes.full_name||n.attributes.friendlyName,a&&(a=s(a))),!a&&i&&(a=s(i)),a};e.on("messageAdded",async n=>{console.log("Message added");let i;try{const s=await e.getParticipantByIdentity(n.author);i=r(s,n.author)}catch(s){console.warn("Could not fetch participant info for friendly name:",s),i=r(null,n.author)}const a={index:n.index,sid:n.sid,body:n.body,author:n.author,authorFriendlyName:i,participantSid:n.participantSid,timestamp:n.dateCreated,attributes:n.attributes,media:n.attachedMedia};this._emitter.emit("message",a),n.author!==this.identity&&await this.acknowledgeMessage(n.index.toString())}),e.on("typingStarted",n=>{console.log("Typing started");const i={identity:n.identity,participantSid:n.sid,isTyping:!0};this._emitter.emit("agentTyping",i)}),e.on("typingEnded",n=>{console.log("Typing ended");const i={identity:n.identity,participantSid:n.sid,isTyping:!1};this._emitter.emit("typingEnded",i)}),e.on("participantJoined",n=>{console.log("Participant joined");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,attributes:n.attributes,timestamp:new Date};this._emitter.emit("agentJoined",a)}),e.on("participantLeft",n=>{console.log("Participant left");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,timestamp:new Date};this._emitter.emit("agentLeftConversation",a)}),e.on("participantUpdated",n=>{console.log("Participant updated"),this._emitter.emit("participantUpdated",n)}),e.on("updated",n=>{console.log("Conversation updated"),this._emitter.emit("conversationUpdated",n)})}async sendMessage(e,r){try{if(!this.conversation||!this.conversationStarted)throw new Error("Conversation not started");let n,i;if(typeof e=="string"?(n=e,i=r):(n=e.body,i=e.attributes),this.connectionState!==qr.ConnectionState.CONNECTED)return new Promise((s,o)=>{this.messageQueue.push({content:n,attributes:i,resolve:s,reject:o})});const a=await this.conversation.sendMessage(n,i);return this._emitter.emit("messageSent",{content:n,attributes:i,index:a,timestamp:new Date}),await Promise.resolve()}catch(n){throw console.error("Failed to send message:",n),this.handleError("Message sending failed",n),n}}async sendTyping(){try{if(!this.conversation)throw new Error("Conversation not started");this.typingTimeout&&clearTimeout(this.typingTimeout),await this.conversation.typing(),this.typingTimeout=setTimeout(()=>{this.typingTimeout=void 0},3e3)}catch(e){console.error("Failed to send typing indicator:",e)}}async acknowledgeMessage(e){try{if(!this.conversation)throw new Error("Conversation not started");const r=parseInt(e,10);if(isNaN(r)){console.warn("Invalid message ID format:",e);return}await this.conversation.updateLastReadMessageIndex(r),this._emitter.emit("messageAcknowledged",{messageId:e,timestamp:new Date})}catch(r){console.error("Failed to acknowledge message:",r)}}async processMessageQueue(){for(;this.messageQueue.length>0;){const e=this.messageQueue.shift();if(e)try{await this.sendMessage(e.content,e.attributes),e.resolve()}catch(r){e.reject(r)}}}async terminateConversation(){try{if(!this.conversation)throw new Error("Conversation not started");await this.conversation.leave(),this._emitter.emit("conversationTerminated",{conversationSid:this.conversationSid,timestamp:new Date}),this.conversation=null,this.conversationSid=null,this.conversationStarted=!1,this.conversationStatus=qr.ConversationStatus.CLOSED}catch(e){throw console.error("Failed to terminate conversation:",e),this.handleError("Conversation termination failed",e),e}}async connect(){if(!this.client)throw new Error("Client not initialized");if(!this.conversationSid)throw new Error("Conversation not started")}async reconnectClient(){try{if(!this.config)throw new Error("Configuration not available");await this.initialize(this.config),await this.processMessageQueue()}catch(e){throw console.error("Failed to reconnect client:",e),e}}async disconnect(){this.client&&(this.client=null),this.connectionState=qr.ConnectionState.DISCONNECTED}async reconnect(){await this.disconnect(),this.config&&await this.initialize(this.config)}destroy(){this.tokenRefreshTimeout&&(clearTimeout(this.tokenRefreshTimeout),this.tokenRefreshTimeout=void 0),this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=void 0),this.client&&(this.client.shutdown(),this.client=null),this.conversation=null,this.conversationSid=null,this.accessToken=null,this.identity=null,this.conversationStarted=!1,this.connectionState=qr.ConnectionState.DISCONNECTED,this.conversationStatus=qr.ConversationStatus.CLOSED,this.messageQueue=[],this._emitter.all.clear()}handleError(e,r){const n={message:e,code:r==null?void 0:r.code,status:r==null?void 0:r.status,details:r,timestamp:new Date};this._emitter.emit("error",n)}get token(){return this.accessToken}get userIdentity(){return this.identity}get currentConversationSid(){return this.conversationSid}getConnectionStatus(){return this.connectionState}getConversationState(){return this.conversationStatus}isConnected(){return this.connectionState===qr.ConnectionState.CONNECTED}getClient(){return this.client}getConversation(){return this.conversation}getState(){return{system:"twilio",conversationSid:this.conversationSid,identity:this.identity,connectionState:this.connectionState,conversationStatus:this.conversationStatus,conversationStarted:this.conversationStarted}}}const tD=Qr.create({baseURL:"https://www.myshowing.com"});function yo(t){return`any-${t||"main"}-chatSession`}const ok=10,rD="1",nD=new Set(["","/null","null","undefined","none","n/a","na"]),uk=new Set(["guest_card_id","guestcardid","guest-card-id"]),Jf=t=>{if(typeof t!="string")return"";const e=t.trim();return nD.has(e.toLowerCase())?"":e},iD=t=>{const e=Jf(t),r=e.toLowerCase(),n=r.replace(/[^a-z0-9]/g,"");if(!(!e||uk.has(r)||uk.has(n)))return e},Yf=(t,e)=>{const r=new Set(e.map(i=>i.toLowerCase())),n=Object.entries(t).find(([i,a])=>r.has(i.toLowerCase())&&Jf(a));return n?Jf(n[1]):""},aD=t=>{const e=Jf(t),r=e.replace(/\D/g,""),n=r.length===ok+1&&r.startsWith(rD)?r.slice(1):r;return n.length!==ok?e:`${n.slice(0,3)}-${n.slice(3,6)}-${n.slice(6)}`};async function sD({id:t,params:e,chatWindow:r,html:n}){const{threadId:i}=r.chatManager;r=r;const a=async()=>{var Oe;const{firstName:d,lastName:f,phoneNumber:m,email:b,propertyId:A}=e,N=(Oe=r.options)==null?void 0:Oe.params,z=A||e.propertyId||(N==null?void 0:N.propertyId),X=e.managementId||(N==null?void 0:N.managementId),Ee=e.sourceId||(N==null?void 0:N.sourceId);if(!X||!z)throw new Error("accountId (managementId) and propertyId are required to create a guest card");const Ie={firstName:d,lastName:f,phoneNumber:m,email:b,threadId:i,sourceId:Ee},Fe=await tD.post(`/${X}/${z}/guestcards/create`,Ie);e.guestCardId=Fe.data.guestCardId},s=async()=>{r.removeMessage("transferMessageId"),r.removeMessage("guestCardFormId"),await r.sendFunctionCallResponse(t,{transfer:"Declined"},!0),r.setInputDisabled(!1)},o=async()=>{r.removeMessage("transferMessageId"),await c()},u=()=>{r.addMessage({id:"waitMessageId",role:"system",content:"Please wait while we connect you to a live agent"}),r.setInputDisabled(!0)},l=async()=>{var Ee,Ie;try{await r.sendFunctionCallResponse(t,{transfer:"Accepted",guestCardId:e.guestCardId,firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phoneNumber,email:e.email},!0)}catch(Fe){console.error("Failed to send function response:",Fe)}await r.chatManager.endChat("Transferred to live agent",!1);const{summary:d,subject:f,guestCardId:m,firstName:b,lastName:A,phoneNumber:N,email:z}=e,X=e.propertyName||((Ie=(Ee=r.options)==null?void 0:Ee.params)==null?void 0:Ie.propertyName);{const Fe="https://five9.ah.inhabit.work",Oe=z||`customer-${Date.now()}`,ze=await fetch(`${Fe}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:Oe})});if(!ze.ok)throw new Error(`Failed to get Twilio token: ${ze.statusText}`);const{token:V}=await ze.json(),xe=new Kf;await xe.initialize({accessToken:V,identity:Oe,tokenRefreshUrl:`${Fe}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),await xe.createConversation({friendlyName:`${b} ${A} - ${f||"Customer Chat"}`,uniqueName:`chat-${Date.now()}-${m}`,attributes:{pre_engagement_data:{gc_id:m,friendlyName:b,last_name:A,phone:N,email:z,question:f,aiSummary:d,propertyName:X}}});const _e="FW490d224a211a6f2bea01c23aaa492122";try{const{conversationSid:se}=xe.getState(),Te=await fetch(`${Fe}/twilio-conversations/${se}/attach-studio-flow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowSid:_e,filters:["onMessageAdded"]})});if(Te.ok){const re=await Te.json()}else console.warn("[TransferToLiveAgent] Failed to attach Studio Flow webhook:",await Te.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching Studio Flow webhook:",se)}try{const{conversationSid:se}=xe.getState(),Te=`${Fe}/twilio-conversations/${se}/webhooks`.replace(/^http:/,"https:"),re=await fetch(`${Fe}/twilio-conversations/${se}/attach-webhook`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webhookUrl:Te,method:"POST",filters:["onMessageAdded","onMessageUpdated","onParticipantAdded","onParticipantRemoved","onConversationUpdated"]})});if(re.ok){const oe=await re.json()}else console.warn("[TransferToLiveAgent] Failed to attach backend webhook:",await re.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching backend webhook:",se)}try{await xe.sendMessage({body:"Customer has been transferred to live agent",attributes:{gc_id:m,friendlyName:b,last_name:A,email:z,phone:N,question:f||"General inquiry",aiSummary:d||"No prior conversation",propertyName:X,messageType:"transfer_trigger"}})}catch(se){console.error("[TransferToLiveAgent] Error sending Studio Flow trigger message:",se)}localStorage.setItem(yo(r.cleanOptions.config.historyKey),JSON.stringify(xe.getState())),r.setInputDisabled(!1),sk(r,xe)}},c=async()=>{const d=iD(e.guestCardId),f=async b=>{e={...e,...b.detail,phoneNumber:b.detail.phone||b.detail.phoneNumber,guestCardId:d},r.removeMessage("guestCardFormId"),u();try{d||await a()}catch(A){console.error("Failed to create guest card before transfer:",A)}await l()},m={firstName:Yf(e,["firstName","customerFirstName"]),lastName:Yf(e,["lastName","last_name","customerLastName"]),email:Yf(e,["email","customerEmail"]),phone:aD(Yf(e,["phoneNumber","phone","customerPhoneNumber"]))};r.addMessage({id:"guestCardFormId",role:"system",contentHtmlTemplate:n`
799
+ <any-contact-form
800
+ .params=${m}
801
+ @submit=${f}
802
+ @cancel=${s}
803
+ ></any-contact-form>
804
+ `})};r.addMessage({id:"transferMessageId",role:"system",contentHtmlTemplate:n`
805
+ <any-transfer-confirmation
806
+ @transfer=${o}
807
+ @cancel=${s}
808
+ ></any-transfer-confirmation>
809
+ `})}class oD{constructor(e,r){const n=If.parse({assistantId:"657acbb4-d23e-487f-9090-4ac9a237b474",...e,config:{...e.config,styles:e.styles||{}}});n.handlers.functionCalls.transferToLiveAgent=sD,n.handlers.functionCalls.showScheduleTourWidget=ML(r.schedulerUrl),n.handlers.enhancedContent.unitList=AL,n.handlers.enhancedContent.photoViewer=IL,this.chatWidget=new xL(n);const i=localStorage.getItem(yo(n.config.historyKey));if(i){const{chatWidget:a}=this;(async()=>{try{const s=JSON.parse(i),o="https://five9.ah.inhabit.work",u=s.identity||`customer-${Date.now()}`,l=await fetch(`${o}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:u})});if(!l.ok)throw new Error("Failed to get Twilio token for session restoration");const{token:c}=await l.json(),d=new Kf;await d.initialize({accessToken:c,identity:u,conversationSid:s.conversationSid,tokenRefreshUrl:`${o}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),sk(a.api.chatWindow,d)}catch(s){console.error("Failed to restore Twilio session:",s),localStorage.removeItem(yo(n.config.historyKey))}})()}}destroy(){this.chatWidget.destroy()}}var lk={},Ac=function(t){return t&&t.Math===Math&&t},cr=Ac(typeof globalThis=="object"&&globalThis)||Ac(typeof window=="object"&&window)||Ac(typeof self=="object"&&self)||Ac(typeof ln=="object"&&ln)||Ac(typeof ln=="object"&&ln)||function(){return this}()||Function("return this")(),Ta={},Vt=function(t){try{return!!t()}catch{return!0}},uD=Vt,Ar=!uD(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),lD=Vt,Oc=!lD(function(){var t=(function(){}).bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),cD=Oc,Qf=Function.prototype.call,Er=cD?Qf.bind(Qf):function(){return Qf.apply(Qf,arguments)},Pc={},ck={}.propertyIsEnumerable,dk=Object.getOwnPropertyDescriptor,dD=dk&&!ck.call({1:2},1);Pc.f=dD?function(e){var r=dk(this,e);return!!r&&r.enumerable}:ck;var bo=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},fk=Oc,hk=Function.prototype,Cm=hk.call,fD=fk&&hk.bind.bind(Cm,Cm),Kt=fk?fD:function(t){return function(){return Cm.apply(t,arguments)}},pk=Kt,hD=pk({}.toString),pD=pk("".slice),Qi=function(t){return pD(hD(t),8,-1)},vD=Kt,mD=Vt,gD=Qi,Rm=Object,yD=vD("".split),Mc=mD(function(){return!Rm("z").propertyIsEnumerable(0)})?function(t){return gD(t)==="String"?yD(t,""):Rm(t)}:Rm,xi=function(t){return t==null},bD=xi,wD=TypeError,Ii=function(t){if(bD(t))throw new wD("Can't call method on "+t);return t},_D=Mc,kD=Ii,Kn=function(t){return _D(kD(t))},xm=typeof document=="object"&&document.all,Cr=typeof xm>"u"&&xm!==void 0?function(t){return typeof t=="function"||t===xm}:function(t){return typeof t=="function"},SD=Cr,Lr=function(t){return typeof t=="object"?t!==null:SD(t)},Im=cr,$D=Cr,TD=function(t){return $D(t)?t:void 0},Ai=function(t,e){return arguments.length<2?TD(Im[t]):Im[t]&&Im[t][e]},ED=Kt,Ea=ED({}.isPrototypeOf),wo=typeof navigator<"u"&&String(navigator.userAgent)||"",vk=cr,Am=wo,mk=vk.process,gk=vk.Deno,yk=mk&&mk.versions||gk&&gk.version,bk=yk&&yk.v8,Oi,Xf;bk&&(Oi=bk.split("."),Xf=Oi[0]>0&&Oi[0]<4?1:+(Oi[0]+Oi[1])),!Xf&&Am&&(Oi=Am.match(/Edge\/(\d+)/),(!Oi||Oi[1]>=74)&&(Oi=Am.match(/Chrome\/(\d+)/),Oi&&(Xf=+Oi[1])));var $u=Xf,wk=$u,CD=Vt,RD=cr,xD=RD.String,Tu=!!Object.getOwnPropertySymbols&&!CD(function(){var t=Symbol("symbol detection");return!xD(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&wk&&wk<41}),ID=Tu,_k=ID&&!Symbol.sham&&typeof Symbol.iterator=="symbol",AD=Ai,OD=Cr,PD=Ea,MD=_k,ND=Object,Eu=MD?function(t){return typeof t=="symbol"}:function(t){var e=AD("Symbol");return OD(e)&&PD(e.prototype,ND(t))},LD=String,_o=function(t){try{return LD(t)}catch{return"Object"}},DD=Cr,jD=_o,UD=TypeError,si=function(t){if(DD(t))return t;throw new UD(jD(t)+" is not a function")},FD=si,BD=xi,ko=function(t,e){var r=t[e];return BD(r)?void 0:FD(r)},Om=Er,Pm=Cr,Mm=Lr,zD=TypeError,HD=function(t,e){var r,n;if(e==="string"&&Pm(r=t.toString)&&!Mm(n=Om(r,t))||Pm(r=t.valueOf)&&!Mm(n=Om(r,t))||e!=="string"&&Pm(r=t.toString)&&!Mm(n=Om(r,t)))return n;throw new zD("Can't convert object to primitive value")},kk={exports:{}},Sk=!1,$k=cr,qD=Object.defineProperty,Nm=function(t,e){try{qD($k,t,{value:e,configurable:!0,writable:!0})}catch{$k[t]=e}return e},VD=cr,WD=Nm,Tk="__core-js_shared__",Ek=kk.exports=VD[Tk]||WD(Tk,{});(Ek.versions||(Ek.versions=[])).push({version:"3.37.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Lm=kk.exports,Ck=Lm,Cu=function(t,e){return Ck[t]||(Ck[t]=e||{})},ZD=Ii,GD=Object,yn=function(t){return GD(ZD(t))},KD=Kt,JD=yn,YD=KD({}.hasOwnProperty),Vr=Object.hasOwn||function(e,r){return YD(JD(e),r)},QD=Kt,XD=0,ej=Math.random(),tj=QD(1 .toString),Nc=function(t){return"Symbol("+(t===void 0?"":t)+")_"+tj(++XD+ej,36)},rj=cr,nj=Cu,Rk=Vr,ij=Nc,aj=Tu,sj=_k,Ru=rj.Symbol,Dm=nj("wks"),oj=sj?Ru.for||Ru:Ru&&Ru.withoutSetter||ij,Rr=function(t){return Rk(Dm,t)||(Dm[t]=aj&&Rk(Ru,t)?Ru[t]:oj("Symbol."+t)),Dm[t]},uj=Er,xk=Lr,Ik=Eu,lj=ko,cj=HD,dj=Rr,fj=TypeError,hj=dj("toPrimitive"),jm=function(t,e){if(!xk(t)||Ik(t))return t;var r=lj(t,hj),n;if(r){if(e===void 0&&(e="default"),n=uj(r,t,e),!xk(n)||Ik(n))return n;throw new fj("Can't convert object to primitive value")}return e===void 0&&(e="number"),cj(t,e)},pj=jm,vj=Eu,eh=function(t){var e=pj(t,"string");return vj(e)?e:e+""},mj=cr,Ak=Lr,Um=mj.document,gj=Ak(Um)&&Ak(Um.createElement),th=function(t){return gj?Um.createElement(t):{}},yj=Ar,bj=Vt,wj=th,Ok=!yj&&!bj(function(){return Object.defineProperty(wj("div"),"a",{get:function(){return 7}}).a!==7}),_j=Ar,kj=Er,Sj=Pc,$j=bo,Tj=Kn,Ej=eh,Cj=Vr,Rj=Ok,Pk=Object.getOwnPropertyDescriptor;Ta.f=_j?Pk:function(e,r){if(e=Tj(e),r=Ej(r),Rj)try{return Pk(e,r)}catch{}if(Cj(e,r))return $j(!kj(Sj.f,e,r),e[r])};var Cn={},xj=Ar,Ij=Vt,Mk=xj&&Ij(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),Aj=Lr,Oj=String,Pj=TypeError,Gr=function(t){if(Aj(t))return t;throw new Pj(Oj(t)+" is not an object")},Mj=Ar,Nj=Ok,Lj=Mk,rh=Gr,Nk=eh,Dj=TypeError,Fm=Object.defineProperty,jj=Object.getOwnPropertyDescriptor,Bm="enumerable",zm="configurable",Hm="writable";Cn.f=Mj?Lj?function(e,r,n){if(rh(e),r=Nk(r),rh(n),typeof e=="function"&&r==="prototype"&&"value"in n&&Hm in n&&!n[Hm]){var i=jj(e,r);i&&i[Hm]&&(e[r]=n.value,n={configurable:zm in n?n[zm]:i[zm],enumerable:Bm in n?n[Bm]:i[Bm],writable:!1})}return Fm(e,r,n)}:Fm:function(e,r,n){if(rh(e),r=Nk(r),rh(n),Nj)try{return Fm(e,r,n)}catch{}if("get"in n||"set"in n)throw new Dj("Accessors not supported");return"value"in n&&(e[r]=n.value),e};var Uj=Ar,Fj=Cn,Bj=bo,Ca=Uj?function(t,e,r){return Fj.f(t,e,Bj(1,r))}:function(t,e,r){return t[e]=r,t},Lk={exports:{}},qm=Ar,zj=Vr,Dk=Function.prototype,Hj=qm&&Object.getOwnPropertyDescriptor,Vm=zj(Dk,"name"),qj=Vm&&(function(){}).name==="something",Vj=Vm&&(!qm||qm&&Hj(Dk,"name").configurable),Lc={EXISTS:Vm,PROPER:qj,CONFIGURABLE:Vj},Wj=Kt,Zj=Cr,Wm=Lm,Gj=Wj(Function.toString);Zj(Wm.inspectSource)||(Wm.inspectSource=function(t){return Gj(t)});var Zm=Wm.inspectSource,Kj=cr,Jj=Cr,jk=Kj.WeakMap,Yj=Jj(jk)&&/native code/.test(String(jk)),Qj=Cu,Xj=Nc,Uk=Qj("keys"),nh=function(t){return Uk[t]||(Uk[t]=Xj(t))},Dc={},eU=Yj,Fk=cr,tU=Lr,rU=Ca,Gm=Vr,Km=Lm,nU=nh,iU=Dc,Bk="Object already initialized",Jm=Fk.TypeError,aU=Fk.WeakMap,ih,jc,ah,sU=function(t){return ah(t)?jc(t):ih(t,{})},oU=function(t){return function(e){var r;if(!tU(e)||(r=jc(e)).type!==t)throw new Jm("Incompatible receiver, "+t+" required");return r}};if(eU||Km.state){var Xi=Km.state||(Km.state=new aU);Xi.get=Xi.get,Xi.has=Xi.has,Xi.set=Xi.set,ih=function(t,e){if(Xi.has(t))throw new Jm(Bk);return e.facade=t,Xi.set(t,e),e},jc=function(t){return Xi.get(t)||{}},ah=function(t){return Xi.has(t)}}else{var xu=nU("state");iU[xu]=!0,ih=function(t,e){if(Gm(t,xu))throw new Jm(Bk);return e.facade=t,rU(t,xu,e),e},jc=function(t){return Gm(t,xu)?t[xu]:{}},ah=function(t){return Gm(t,xu)}}var Jn={set:ih,get:jc,has:ah,enforce:sU,getterFor:oU},Ym=Kt,uU=Vt,lU=Cr,sh=Vr,Qm=Ar,cU=Lc.CONFIGURABLE,dU=Zm,zk=Jn,fU=zk.enforce,hU=zk.get,Hk=String,oh=Object.defineProperty,pU=Ym("".slice),vU=Ym("".replace),mU=Ym([].join),gU=Qm&&!uU(function(){return oh(function(){},"length",{value:8}).length!==8}),yU=String(String).split("String"),bU=Lk.exports=function(t,e,r){pU(Hk(e),0,7)==="Symbol("&&(e="["+vU(Hk(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!sh(t,"name")||cU&&t.name!==e)&&(Qm?oh(t,"name",{value:e,configurable:!0}):t.name=e),gU&&r&&sh(r,"arity")&&t.length!==r.arity&&oh(t,"length",{value:r.arity});try{r&&sh(r,"constructor")&&r.constructor?Qm&&oh(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch{}var n=fU(t);return sh(n,"source")||(n.source=mU(yU,typeof e=="string"?e:"")),t};Function.prototype.toString=bU(function(){return lU(this)&&hU(this).source||dU(this)},"toString");var qk=Lk.exports,wU=Cr,_U=Cn,kU=qk,SU=Nm,Rn=function(t,e,r,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:e;if(wU(r)&&kU(r,a,n),n.global)i?t[e]=r:SU(e,r);else{try{n.unsafe?t[e]&&(i=!0):delete t[e]}catch{}i?t[e]=r:_U.f(t,e,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return t},So={},$U=Math.ceil,TU=Math.floor,EU=Math.trunc||function(e){var r=+e;return(r>0?TU:$U)(r)},CU=EU,ea=function(t){var e=+t;return e!==e||e===0?0:CU(e)},RU=ea,xU=Math.max,IU=Math.min,Iu=function(t,e){var r=RU(t);return r<0?xU(r+e,0):IU(r,e)},AU=ea,OU=Math.min,Ra=function(t){var e=AU(t);return e>0?OU(e,9007199254740991):0},PU=Ra,bn=function(t){return PU(t.length)},MU=Kn,NU=Iu,LU=bn,Vk=function(t){return function(e,r,n){var i=MU(e),a=LU(i);if(a===0)return!t&&-1;var s=NU(n,a),o;if(t&&r!==r){for(;a>s;)if(o=i[s++],o!==o)return!0}else for(;a>s;s++)if((t||s in i)&&i[s]===r)return t||s||0;return!t&&-1}},uh={includes:Vk(!0),indexOf:Vk(!1)},DU=Kt,Xm=Vr,jU=Kn,UU=uh.indexOf,FU=Dc,Wk=DU([].push),Zk=function(t,e){var r=jU(t),n=0,i=[],a;for(a in r)!Xm(FU,a)&&Xm(r,a)&&Wk(i,a);for(;e.length>n;)Xm(r,a=e[n++])&&(~UU(i,a)||Wk(i,a));return i},eg=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],BU=Zk,zU=eg,HU=zU.concat("length","prototype");So.f=Object.getOwnPropertyNames||function(e){return BU(e,HU)};var Uc={};Uc.f=Object.getOwnPropertySymbols;var qU=Ai,VU=Kt,WU=So,ZU=Uc,GU=Gr,KU=VU([].concat),Gk=qU("Reflect","ownKeys")||function(e){var r=WU.f(GU(e)),n=ZU.f;return n?KU(r,n(e)):r},Kk=Vr,JU=Gk,YU=Ta,QU=Cn,tg=function(t,e,r){for(var n=JU(e),i=QU.f,a=YU.f,s=0;s<n.length;s++){var o=n[s];!Kk(t,o)&&!(r&&Kk(r,o))&&i(t,o,a(e,o))}},XU=Vt,e5=Cr,t5=/#|\.prototype\./,Fc=function(t,e){var r=n5[r5(t)];return r===a5?!0:r===i5?!1:e5(e)?XU(e):!!e},r5=Fc.normalize=function(t){return String(t).replace(t5,".").toLowerCase()},n5=Fc.data={},i5=Fc.NATIVE="N",a5=Fc.POLYFILL="P",lh=Fc,ch=cr,s5=Ta.f,o5=Ca,u5=Rn,l5=Nm,c5=tg,d5=lh,er=function(t,e){var r=t.target,n=t.global,i=t.stat,a,s,o,u,l,c;if(n?s=ch:i?s=ch[r]||l5(r,{}):s=ch[r]&&ch[r].prototype,s)for(o in e){if(l=e[o],t.dontCallGetSet?(c=s5(s,o),u=c&&c.value):u=s[o],a=d5(n?o:r+(i?".":"#")+o,t.forced),!a&&u!==void 0){if(typeof l==typeof u)continue;c5(l,u)}(t.sham||u&&u.sham)&&o5(l,"sham",!0),u5(s,o,l,t)}},f5=Cn.f,h5=Vr,p5=Rr,Jk=p5("toStringTag"),ta=function(t,e,r){t&&!r&&(t=t.prototype),t&&!h5(t,Jk)&&f5(t,Jk,{configurable:!0,value:e})},v5=er,m5=cr,g5=ta;v5({global:!0},{Reflect:{}}),g5(m5.Reflect,"Reflect",!0);var y5=Oc,Yk=Function.prototype,Qk=Yk.apply,Xk=Yk.call,$o=typeof Reflect=="object"&&Reflect.apply||(y5?Xk.bind(Qk):function(){return Xk.apply(Qk,arguments)}),b5=Kt,ra=b5([].slice),eS=Kt,w5=si,_5=Lr,k5=Vr,tS=ra,S5=Oc,rS=Function,$5=eS([].concat),T5=eS([].join),rg={},E5=function(t,e,r){if(!k5(rg,e)){for(var n=[],i=0;i<e;i++)n[i]="a["+i+"]";rg[e]=rS("C,a","return new C("+T5(n,",")+")")}return rg[e](t,r)},C5=S5?rS.bind:function(e){var r=w5(this),n=r.prototype,i=tS(arguments,1),a=function(){var o=$5(i,tS(arguments));return this instanceof a?E5(r,o.length,o):r.apply(e,o)};return _5(n)&&(a.prototype=n),a},R5=Rr,x5=R5("toStringTag"),nS={};nS[x5]="z";var ng=String(nS)==="[object z]",I5=ng,A5=Cr,dh=Qi,O5=Rr,P5=O5("toStringTag"),M5=Object,N5=dh(function(){return arguments}())==="Arguments",L5=function(t,e){try{return t[e]}catch{}},xa=I5?dh:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=L5(e=M5(t),P5))=="string"?r:N5?dh(e):(n=dh(e))==="Object"&&A5(e.callee)?"Arguments":n},D5=Kt,j5=Vt,iS=Cr,U5=xa,F5=Ai,B5=Zm,aS=function(){},sS=F5("Reflect","construct"),ig=/^\s*(?:class|function)\b/,z5=D5(ig.exec),H5=!ig.test(aS),Bc=function(e){if(!iS(e))return!1;try{return sS(aS,[],e),!0}catch{return!1}},oS=function(e){if(!iS(e))return!1;switch(U5(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return H5||!!z5(ig,B5(e))}catch{return!0}};oS.sham=!0;var fh=!sS||j5(function(){var t;return Bc(Bc.call)||!Bc(Object)||!Bc(function(){t=!0})||t})?oS:Bc,q5=fh,V5=_o,W5=TypeError,ag=function(t){if(q5(t))return t;throw new W5(V5(t)+" is not a constructor")},sg={},Z5=Zk,G5=eg,zc=Object.keys||function(e){return Z5(e,G5)},K5=Ar,J5=Mk,Y5=Cn,Q5=Gr,X5=Kn,e6=zc;sg.f=K5&&!J5?Object.defineProperties:function(e,r){Q5(e);for(var n=X5(r),i=e6(r),a=i.length,s=0,o;a>s;)Y5.f(e,o=i[s++],n[o]);return e};var t6=Ai,uS=t6("document","documentElement"),r6=Gr,n6=sg,lS=eg,i6=Dc,a6=uS,s6=th,o6=nh,cS=">",dS="<",og="prototype",ug="script",fS=o6("IE_PROTO"),lg=function(){},hS=function(t){return dS+ug+cS+t+dS+"/"+ug+cS},pS=function(t){t.write(hS("")),t.close();var e=t.parentWindow.Object;return t=null,e},u6=function(){var t=s6("iframe"),e="java"+ug+":",r;return t.style.display="none",a6.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(hS("document.F=Object")),r.close(),r.F},hh,ph=function(){try{hh=new ActiveXObject("htmlfile")}catch{}ph=typeof document<"u"?document.domain&&hh?pS(hh):u6():pS(hh);for(var t=lS.length;t--;)delete ph[og][lS[t]];return ph()};i6[fS]=!0;var vs=Object.create||function(e,r){var n;return e!==null?(lg[og]=r6(e),n=new lg,lg[og]=null,n[fS]=e):n=ph(),r===void 0?n:n6.f(n,r)},l6=er,c6=Ai,cg=$o,d6=C5,vS=ag,f6=Gr,mS=Lr,h6=vs,gS=Vt,dg=c6("Reflect","construct"),p6=Object.prototype,v6=[].push,yS=gS(function(){function t(){}return!(dg(function(){},[],t)instanceof t)}),bS=!gS(function(){dg(function(){})}),wS=yS||bS;l6({target:"Reflect",stat:!0,forced:wS,sham:wS},{construct:function(e,r){vS(e),f6(r);var n=arguments.length<3?e:vS(arguments[2]);if(bS&&!yS)return dg(e,r,n);if(e===n){switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3])}var i=[null];return cg(v6,i,r),new(cg(d6,e,i))}var a=n.prototype,s=h6(mS(a)?a:p6),o=cg(e,s,r);return mS(o)?o:s}});var m6=er,g6=yn,_S=zc,y6=Vt,b6=y6(function(){_S(1)});m6({target:"Object",stat:!0,forced:b6},{keys:function(e){return _S(g6(e))}});var w6=xa,_6=String,nn=function(t){if(w6(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return _6(t)},fg={},k6=Qi,S6=Kn,kS=So.f,$6=ra,SS=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],T6=function(t){try{return kS(t)}catch{return $6(SS)}};fg.f=function(e){return SS&&k6(e)==="Window"?T6(e):kS(S6(e))};var $S=qk,E6=Cn,na=function(t,e,r){return r.get&&$S(r.get,e,{getter:!0}),r.set&&$S(r.set,e,{setter:!0}),E6.f(t,e,r)},hg={},C6=Rr;hg.f=C6;var R6=cr,TS=R6,ES=TS,x6=Vr,I6=hg,A6=Cn.f,CS=function(t){var e=ES.Symbol||(ES.Symbol={});x6(e,t)||A6(e,t,{value:I6.f(t)})},O6=Er,P6=Ai,M6=Rr,N6=Rn,L6=function(){var t=P6("Symbol"),e=t&&t.prototype,r=e&&e.valueOf,n=M6("toPrimitive");e&&!e[n]&&N6(e,n,function(i){return O6(r,this)},{arity:1})},D6=Qi,j6=Kt,pg=function(t){if(D6(t)==="Function")return j6(t)},RS=pg,U6=si,F6=Oc,B6=RS(RS.bind),Ia=function(t,e){return U6(t),e===void 0?t:F6?B6(t,e):function(){return t.apply(e,arguments)}},z6=Qi,Hc=Array.isArray||function(e){return z6(e)==="Array"},xS=Hc,H6=fh,q6=Lr,V6=Rr,W6=V6("species"),IS=Array,Z6=function(t){var e;return xS(t)&&(e=t.constructor,H6(e)&&(e===IS||xS(e.prototype))?e=void 0:q6(e)&&(e=e[W6],e===null&&(e=void 0))),e===void 0?IS:e},G6=Z6,vg=function(t,e){return new(G6(t))(e===0?0:e)},K6=Ia,J6=Kt,Y6=Mc,Q6=yn,X6=bn,eF=vg,AS=J6([].push),ms=function(t){var e=t===1,r=t===2,n=t===3,i=t===4,a=t===6,s=t===7,o=t===5||a;return function(u,l,c,d){for(var f=Q6(u),m=Y6(f),b=X6(m),A=K6(l,c),N=0,z=d||eF,X=e?z(u,b):r||s?z(u,0):void 0,Ee,Ie;b>N;N++)if((o||N in m)&&(Ee=m[N],Ie=A(Ee,N,f),t))if(e)X[N]=Ie;else if(Ie)switch(t){case 3:return!0;case 5:return Ee;case 6:return N;case 2:AS(X,Ee)}else switch(t){case 4:return!1;case 7:AS(X,Ee)}return a?-1:n||i?i:X}},Un={forEach:ms(0),map:ms(1),filter:ms(2),some:ms(3),every:ms(4),find:ms(5),findIndex:ms(6),filterReject:ms(7)},vh=er,qc=cr,mg=Er,tF=Kt,Au=Ar,Ou=Tu,rF=Vt,fn=Vr,nF=Ea,gg=Gr,mh=Kn,yg=eh,iF=nn,bg=bo,Pu=vs,OS=zc,aF=So,PS=fg,sF=Uc,MS=Ta,NS=Cn,oF=sg,LS=Pc,wg=Rn,uF=na,_g=Cu,lF=nh,DS=Dc,jS=Nc,cF=Rr,dF=hg,fF=CS,hF=L6,pF=ta,US=Jn,gh=Un.forEach,Fn=lF("hidden"),yh="Symbol",Vc="prototype",vF=US.set,FS=US.getterFor(yh),oi=Object[Vc],To=qc.Symbol,Wc=To&&To[Vc],mF=qc.RangeError,gF=qc.TypeError,kg=qc.QObject,BS=MS.f,Eo=NS.f,zS=PS.f,yF=LS.f,HS=tF([].push),Aa=_g("symbols"),Zc=_g("op-symbols"),bF=_g("wks"),Sg=!kg||!kg[Vc]||!kg[Vc].findChild,qS=function(t,e,r){var n=BS(oi,e);n&&delete oi[e],Eo(t,e,r),n&&t!==oi&&Eo(oi,e,n)},$g=Au&&rF(function(){return Pu(Eo({},"a",{get:function(){return Eo(this,"a",{value:7}).a}})).a!==7})?qS:Eo,Tg=function(t,e){var r=Aa[t]=Pu(Wc);return vF(r,{type:yh,tag:t,description:e}),Au||(r.description=e),r},bh=function(e,r,n){e===oi&&bh(Zc,r,n),gg(e);var i=yg(r);return gg(n),fn(Aa,i)?(n.enumerable?(fn(e,Fn)&&e[Fn][i]&&(e[Fn][i]=!1),n=Pu(n,{enumerable:bg(0,!1)})):(fn(e,Fn)||Eo(e,Fn,bg(1,Pu(null))),e[Fn][i]=!0),$g(e,i,n)):Eo(e,i,n)},Eg=function(e,r){gg(e);var n=mh(r),i=OS(n).concat(ZS(n));return gh(i,function(a){(!Au||mg(Cg,n,a))&&bh(e,a,n[a])}),e},wF=function(e,r){return r===void 0?Pu(e):Eg(Pu(e),r)},Cg=function(e){var r=yg(e),n=mg(yF,this,r);return this===oi&&fn(Aa,r)&&!fn(Zc,r)?!1:n||!fn(this,r)||!fn(Aa,r)||fn(this,Fn)&&this[Fn][r]?n:!0},VS=function(e,r){var n=mh(e),i=yg(r);if(!(n===oi&&fn(Aa,i)&&!fn(Zc,i))){var a=BS(n,i);return a&&fn(Aa,i)&&!(fn(n,Fn)&&n[Fn][i])&&(a.enumerable=!0),a}},WS=function(e){var r=zS(mh(e)),n=[];return gh(r,function(i){!fn(Aa,i)&&!fn(DS,i)&&HS(n,i)}),n},ZS=function(t){var e=t===oi,r=zS(e?Zc:mh(t)),n=[];return gh(r,function(i){fn(Aa,i)&&(!e||fn(oi,i))&&HS(n,Aa[i])}),n};Ou||(To=function(){if(nF(Wc,this))throw new gF("Symbol is not a constructor");var e=!arguments.length||arguments[0]===void 0?void 0:iF(arguments[0]),r=jS(e),n=function(i){var a=this===void 0?qc:this;a===oi&&mg(n,Zc,i),fn(a,Fn)&&fn(a[Fn],r)&&(a[Fn][r]=!1);var s=bg(1,i);try{$g(a,r,s)}catch(o){if(!(o instanceof mF))throw o;qS(a,r,s)}};return Au&&Sg&&$g(oi,r,{configurable:!0,set:n}),Tg(r,e)},Wc=To[Vc],wg(Wc,"toString",function(){return FS(this).tag}),wg(To,"withoutSetter",function(t){return Tg(jS(t),t)}),LS.f=Cg,NS.f=bh,oF.f=Eg,MS.f=VS,aF.f=PS.f=WS,sF.f=ZS,dF.f=function(t){return Tg(cF(t),t)},Au&&(uF(Wc,"description",{configurable:!0,get:function(){return FS(this).description}}),wg(oi,"propertyIsEnumerable",Cg,{unsafe:!0}))),vh({global:!0,constructor:!0,wrap:!0,forced:!Ou,sham:!Ou},{Symbol:To}),gh(OS(bF),function(t){fF(t)}),vh({target:yh,stat:!0,forced:!Ou},{useSetter:function(){Sg=!0},useSimple:function(){Sg=!1}}),vh({target:"Object",stat:!0,forced:!Ou,sham:!Au},{create:wF,defineProperty:bh,defineProperties:Eg,getOwnPropertyDescriptor:VS}),vh({target:"Object",stat:!0,forced:!Ou},{getOwnPropertyNames:WS}),hF(),pF(To,yh),DS[Fn]=!0;var _F=Tu,GS=_F&&!!Symbol.for&&!!Symbol.keyFor,kF=er,SF=Ai,$F=Vr,TF=nn,KS=Cu,EF=GS,Rg=KS("string-to-symbol-registry"),CF=KS("symbol-to-string-registry");kF({target:"Symbol",stat:!0,forced:!EF},{for:function(t){var e=TF(t);if($F(Rg,e))return Rg[e];var r=SF("Symbol")(e);return Rg[e]=r,CF[r]=e,r}});var RF=er,xF=Vr,IF=Eu,AF=_o,OF=Cu,PF=GS,JS=OF("symbol-to-string-registry");RF({target:"Symbol",stat:!0,forced:!PF},{keyFor:function(e){if(!IF(e))throw new TypeError(AF(e)+" is not a symbol");if(xF(JS,e))return JS[e]}});var MF=Kt,YS=Hc,NF=Cr,QS=Qi,LF=nn,XS=MF([].push),DF=function(t){if(NF(t))return t;if(YS(t)){for(var e=t.length,r=[],n=0;n<e;n++){var i=t[n];typeof i=="string"?XS(r,i):(typeof i=="number"||QS(i)==="Number"||QS(i)==="String")&&XS(r,LF(i))}var a=r.length,s=!0;return function(o,u){if(s)return s=!1,u;if(YS(this))return u;for(var l=0;l<a;l++)if(r[l]===o)return u}}},jF=er,e$=Ai,t$=$o,UF=Er,Gc=Kt,r$=Vt,n$=Cr,i$=Eu,a$=ra,FF=DF,BF=Tu,zF=String,gs=e$("JSON","stringify"),wh=Gc(/./.exec),s$=Gc("".charAt),HF=Gc("".charCodeAt),qF=Gc("".replace),VF=Gc(1 .toString),WF=/[\uD800-\uDFFF]/g,o$=/^[\uD800-\uDBFF]$/,u$=/^[\uDC00-\uDFFF]$/,l$=!BF||r$(function(){var t=e$("Symbol")("stringify detection");return gs([t])!=="[null]"||gs({a:t})!=="{}"||gs(Object(t))!=="{}"}),c$=r$(function(){return gs("\uDF06\uD834")!=='"\\udf06\\ud834"'||gs("\uDEAD")!=='"\\udead"'}),ZF=function(t,e){var r=a$(arguments),n=FF(e);if(!(!n$(n)&&(t===void 0||i$(t))))return r[1]=function(i,a){if(n$(n)&&(a=UF(n,this,zF(i),a)),!i$(a))return a},t$(gs,null,r)},GF=function(t,e,r){var n=s$(r,e-1),i=s$(r,e+1);return wh(o$,t)&&!wh(u$,i)||wh(u$,t)&&!wh(o$,n)?"\\u"+VF(HF(t,0),16):t};gs&&jF({target:"JSON",stat:!0,arity:3,forced:l$||c$},{stringify:function(e,r,n){var i=a$(arguments),a=t$(l$?ZF:gs,null,i);return c$&&typeof a=="string"?qF(a,WF,GF):a}});var KF=er,JF=Tu,YF=Vt,d$=Uc,QF=yn,XF=!JF||YF(function(){d$.f(1)});KF({target:"Object",stat:!0,forced:XF},{getOwnPropertySymbols:function(e){var r=d$.f;return r?r(QF(e)):[]}});var eB=Vt,tB=Rr,rB=$u,nB=tB("species"),Kc=function(t){return rB>=51||!eB(function(){var e=[],r=e.constructor={};return r[nB]=function(){return{foo:1}},e[t](Boolean).foo!==1})},iB=er,aB=Un.filter,sB=Kc,oB=sB("filter");iB({target:"Array",proto:!0,forced:!oB},{filter:function(e){return aB(this,e,arguments.length>1?arguments[1]:void 0)}});var uB=er,lB=Vt,cB=Kn,f$=Ta.f,h$=Ar,dB=!h$||lB(function(){f$(1)});uB({target:"Object",stat:!0,forced:dB,sham:!h$},{getOwnPropertyDescriptor:function(e,r){return f$(cB(e),r)}});var fB=Ar,hB=Cn,pB=bo,Jc=function(t,e,r){fB?hB.f(t,e,pB(0,r)):t[e]=r},vB=er,mB=Ar,gB=Gk,yB=Kn,bB=Ta,wB=Jc;vB({target:"Object",stat:!0,sham:!mB},{getOwnPropertyDescriptors:function(e){for(var r=yB(e),n=bB.f,i=gB(r),a={},s=0,o,u;i.length>s;)u=n(r,o=i[s++]),u!==void 0&&wB(a,o,u);return a}});var p$={exports:{}};(function(t){function e(n,i,a,s,o,u,l){try{var c=n[u](l),d=c.value}catch(f){return void a(f)}c.done?i(d):Promise.resolve(d).then(s,o)}function r(n){return function(){var i=this,a=arguments;return new Promise(function(s,o){var u=n.apply(i,a);function l(d){e(u,s,o,l,c,"next",d)}function c(d){e(u,s,o,l,c,"throw",d)}l(void 0)})}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(p$);var Mu=p$.exports,v$={exports:{}};(function(t){function e(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(v$);var ys=v$.exports,m$={exports:{}},g$={exports:{}};(function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,a){return i.__proto__=a,i},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(g$);var xg=g$.exports;(function(t){var e=xg;function r(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&e(n,i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(m$);var ia=m$.exports,y$={exports:{}},b$={exports:{}};(function(t){function e(r){"@babel/helpers - typeof";return t.exports=e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(b$);var ui=b$.exports;(function(t){var e=ui.default,r=ys;function n(i,a){if(a&&(e(a)=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(y$);var aa=y$.exports,w$={exports:{}};(function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(w$);var li=w$.exports,_$={exports:{}},k$={exports:{}},S$={exports:{}};(function(t){var e=ui.default;function r(n,i){if(e(n)!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(e(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(S$);var _B=S$.exports;(function(t){var e=ui.default,r=_B;function n(i){var a=r(i,"string");return e(a)=="symbol"?a:a+""}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(k$);var $$=k$.exports;(function(t){var e=$$;function r(n,i,a){return(i=e(i))in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(_$);var bs=_$.exports,T$={exports:{}};(function(t){var e=$$;function r(i,a){for(var s=0;s<a.length;s++){var o=a[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(i,e(o.key),o)}}function n(i,a,s){return a&&r(i.prototype,a),s&&r(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(T$);var Oa=T$.exports,E$={exports:{}};(function(t){function e(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(E$);var sa=E$.exports,kB=er,SB=Un.map,$B=Kc,TB=$B("map");kB({target:"Array",proto:!0,forced:!TB},{map:function(e){return SB(this,e,arguments.length>1?arguments[1]:void 0)}});var EB=ng,CB=xa,RB=EB?{}.toString:function(){return"[object "+CB(this)+"]"},xB=ng,IB=Rn,AB=RB;xB||IB(Object.prototype,"toString",AB,{unsafe:!0});var C$={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},OB=th,Ig=OB("span").classList,R$=Ig&&Ig.constructor&&Ig.constructor.prototype,x$=R$===Object.prototype?void 0:R$,PB=Vt,_h=function(t,e){var r=[][t];return!!r&&PB(function(){r.call(null,e||function(){return 1},1)})},MB=Un.forEach,NB=_h,LB=NB("forEach"),DB=LB?[].forEach:function(e){return MB(this,e,arguments.length>1?arguments[1]:void 0)},I$=cr,A$=C$,jB=x$,Ag=DB,UB=Ca,O$=function(t){if(t&&t.forEach!==Ag)try{UB(t,"forEach",Ag)}catch{t.forEach=Ag}};for(var Og in A$)A$[Og]&&O$(I$[Og]&&I$[Og].prototype);O$(jB);var FB=cr,BB=Qi,kh=BB(FB.process)==="process",zB=Kt,HB=si,qB=function(t,e,r){try{return zB(HB(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}},VB=Lr,WB=function(t){return VB(t)||t===null},ZB=WB,GB=String,KB=TypeError,JB=function(t){if(ZB(t))return t;throw new KB("Can't set "+GB(t)+" as a prototype")},YB=qB,QB=Lr,XB=Ii,e8=JB,Nu=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=YB(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(i,a){return XB(i),e8(a),QB(i)&&(t?r(i,a):i.__proto__=a),i}}():void 0),t8=Ai,r8=na,n8=Rr,i8=Ar,P$=n8("species"),Sh=function(t){var e=t8(t);i8&&e&&!e[P$]&&r8(e,P$,{configurable:!0,get:function(){return this}})},a8=Ea,s8=TypeError,ws=function(t,e){if(a8(e,t))return t;throw new s8("Incorrect invocation")},M$=Gr,o8=ag,u8=xi,l8=Rr,c8=l8("species"),Pg=function(t,e){var r=M$(t).constructor,n;return r===void 0||u8(n=M$(r)[c8])?e:o8(n)},d8=TypeError,Mg=function(t,e){if(t<e)throw new d8("Not enough arguments");return t},f8=wo,N$=/(?:ipad|iphone|ipod).*applewebkit/i.test(f8),Yn=cr,h8=$o,p8=Ia,L$=Cr,v8=Vr,D$=Vt,j$=uS,m8=ra,U$=th,g8=Mg,y8=N$,b8=kh,Ng=Yn.setImmediate,Lg=Yn.clearImmediate,w8=Yn.process,Dg=Yn.Dispatch,_8=Yn.Function,F$=Yn.MessageChannel,k8=Yn.String,jg=0,Yc={},B$="onreadystatechange",Qc,Co,Ug,Fg;D$(function(){Qc=Yn.location});var Bg=function(t){if(v8(Yc,t)){var e=Yc[t];delete Yc[t],e()}},zg=function(t){return function(){Bg(t)}},z$=function(t){Bg(t.data)},H$=function(t){Yn.postMessage(k8(t),Qc.protocol+"//"+Qc.host)};(!Ng||!Lg)&&(Ng=function(e){g8(arguments.length,1);var r=L$(e)?e:_8(e),n=m8(arguments,1);return Yc[++jg]=function(){h8(r,void 0,n)},Co(jg),jg},Lg=function(e){delete Yc[e]},b8?Co=function(t){w8.nextTick(zg(t))}:Dg&&Dg.now?Co=function(t){Dg.now(zg(t))}:F$&&!y8?(Ug=new F$,Fg=Ug.port2,Ug.port1.onmessage=z$,Co=p8(Fg.postMessage,Fg)):Yn.addEventListener&&L$(Yn.postMessage)&&!Yn.importScripts&&Qc&&Qc.protocol!=="file:"&&!D$(H$)?(Co=H$,Yn.addEventListener("message",z$,!1)):B$ in U$("script")?Co=function(t){j$.appendChild(U$("script"))[B$]=function(){j$.removeChild(this),Bg(t)}}:Co=function(t){setTimeout(zg(t),0)});var q$={set:Ng,clear:Lg},V$=cr,S8=Ar,$8=Object.getOwnPropertyDescriptor,W$=function(t){if(!S8)return V$[t];var e=$8(V$,t);return e&&e.value},Z$=function(){this.head=null,this.tail=null};Z$.prototype={add:function(t){var e={item:t,next:null},r=this.tail;r?r.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t){var e=this.head=t.next;return e===null&&(this.tail=null),t.item}}};var G$=Z$,T8=wo,E8=/ipad|iphone|ipod/i.test(T8)&&typeof Pebble<"u",C8=wo,R8=/web0s(?!.*chrome)/i.test(C8),Lu=cr,x8=W$,K$=Ia,Hg=q$.set,I8=G$,A8=N$,O8=E8,P8=R8,qg=kh,J$=Lu.MutationObserver||Lu.WebKitMutationObserver,Y$=Lu.document,Q$=Lu.process,$h=Lu.Promise,Vg=x8("queueMicrotask"),Du,Wg,Zg,Th,X$;if(!Vg){var Eh=new I8,Ch=function(){var t,e;for(qg&&(t=Q$.domain)&&t.exit();e=Eh.get();)try{e()}catch(r){throw Eh.head&&Du(),r}t&&t.enter()};!A8&&!qg&&!P8&&J$&&Y$?(Wg=!0,Zg=Y$.createTextNode(""),new J$(Ch).observe(Zg,{characterData:!0}),Du=function(){Zg.data=Wg=!Wg}):!O8&&$h&&$h.resolve?(Th=$h.resolve(void 0),Th.constructor=$h,X$=K$(Th.then,Th),Du=function(){X$(Ch)}):qg?Du=function(){Q$.nextTick(Ch)}:(Hg=K$(Hg,Lu),Du=function(){Hg(Ch)}),Vg=function(t){Eh.head||Du(),Eh.add(t)}}var M8=Vg,N8=function(t,e){try{arguments.length===1?console.error(t):console.error(t,e)}catch{}},Gg=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}},L8=cr,Rh=L8.Promise,eT=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",D8=eT,j8=kh,U8=!D8&&!j8&&typeof window=="object"&&typeof document=="object",F8=cr,Xc=Rh,B8=Cr,z8=lh,H8=Zm,q8=Rr,V8=U8,W8=eT,Kg=$u;Xc&&Xc.prototype;var Z8=q8("species"),Jg=!1,tT=B8(F8.PromiseRejectionEvent),G8=z8("Promise",function(){var t=H8(Xc),e=t!==String(Xc);if(!e&&Kg===66)return!0;if(!Kg||Kg<51||!/native code/.test(t)){var r=new Xc(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=r.constructor={};if(i[Z8]=n,Jg=r.then(function(){})instanceof n,!Jg)return!0}return!e&&(V8||W8)&&!tT}),ed={CONSTRUCTOR:G8,REJECTION_EVENT:tT,SUBCLASSING:Jg},ju={},rT=si,K8=TypeError,J8=function(t){var e,r;this.promise=new t(function(n,i){if(e!==void 0||r!==void 0)throw new K8("Bad Promise constructor");e=n,r=i}),this.resolve=rT(e),this.reject=rT(r)};ju.f=function(t){return new J8(t)};var Y8=er,xh=kh,_s=cr,Uu=Er,nT=Rn,iT=Nu,Q8=ta,X8=Sh,e9=si,Ih=Cr,t9=Lr,r9=ws,n9=Pg,aT=q$.set,Yg=M8,i9=N8,a9=Gg,s9=G$,sT=Jn,Ah=Rh,Qg=ed,oT=ju,Oh="Promise",uT=Qg.CONSTRUCTOR,o9=Qg.REJECTION_EVENT,u9=Qg.SUBCLASSING,Xg=sT.getterFor(Oh),l9=sT.set,Fu=Ah&&Ah.prototype,Ro=Ah,Ph=Fu,lT=_s.TypeError,ey=_s.document,ty=_s.process,ry=oT.f,c9=ry,d9=!!(ey&&ey.createEvent&&_s.dispatchEvent),cT="unhandledrejection",f9="rejectionhandled",dT=0,fT=1,h9=2,ny=1,hT=2,Mh,pT,p9,vT,mT=function(t){var e;return t9(t)&&Ih(e=t.then)?e:!1},gT=function(t,e){var r=e.value,n=e.state===fT,i=n?t.ok:t.fail,a=t.resolve,s=t.reject,o=t.domain,u,l,c;try{i?(n||(e.rejection===hT&&m9(e),e.rejection=ny),i===!0?u=r:(o&&o.enter(),u=i(r),o&&(o.exit(),c=!0)),u===t.promise?s(new lT("Promise-chain cycle")):(l=mT(u))?Uu(l,u,a,s):a(u)):s(r)}catch(d){o&&!c&&o.exit(),s(d)}},yT=function(t,e){t.notified||(t.notified=!0,Yg(function(){for(var r=t.reactions,n;n=r.get();)gT(n,t);t.notified=!1,e&&!t.rejection&&v9(t)}))},bT=function(t,e,r){var n,i;d9?(n=ey.createEvent("Event"),n.promise=e,n.reason=r,n.initEvent(t,!1,!0),_s.dispatchEvent(n)):n={promise:e,reason:r},!o9&&(i=_s["on"+t])?i(n):t===cT&&i9("Unhandled promise rejection",r)},v9=function(t){Uu(aT,_s,function(){var e=t.facade,r=t.value,n=wT(t),i;if(n&&(i=a9(function(){xh?ty.emit("unhandledRejection",r,e):bT(cT,e,r)}),t.rejection=xh||wT(t)?hT:ny,i.error))throw i.value})},wT=function(t){return t.rejection!==ny&&!t.parent},m9=function(t){Uu(aT,_s,function(){var e=t.facade;xh?ty.emit("rejectionHandled",e):bT(f9,e,t.value)})},Bu=function(t,e,r){return function(n){t(e,n,r)}},zu=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=h9,yT(t,!0))},iy=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw new lT("Promise can't be resolved itself");var n=mT(e);n?Yg(function(){var i={done:!1};try{Uu(n,e,Bu(iy,i,t),Bu(zu,i,t))}catch(a){zu(i,a,t)}}):(t.value=e,t.state=fT,yT(t,!1))}catch(i){zu({done:!1},i,t)}}};if(uT&&(Ro=function(e){r9(this,Ph),e9(e),Uu(Mh,this);var r=Xg(this);try{e(Bu(iy,r),Bu(zu,r))}catch(n){zu(r,n)}},Ph=Ro.prototype,Mh=function(e){l9(this,{type:Oh,done:!1,notified:!1,parent:!1,reactions:new s9,rejection:!1,state:dT,value:void 0})},Mh.prototype=nT(Ph,"then",function(e,r){var n=Xg(this),i=ry(n9(this,Ro));return n.parent=!0,i.ok=Ih(e)?e:!0,i.fail=Ih(r)&&r,i.domain=xh?ty.domain:void 0,n.state===dT?n.reactions.add(i):Yg(function(){gT(i,n)}),i.promise}),pT=function(){var t=new Mh,e=Xg(t);this.promise=t,this.resolve=Bu(iy,e),this.reject=Bu(zu,e)},oT.f=ry=function(t){return t===Ro||t===p9?new pT(t):c9(t)},Ih(Ah)&&Fu!==Object.prototype)){vT=Fu.then,u9||nT(Fu,"then",function(e,r){var n=this;return new Ro(function(i,a){Uu(vT,n,i,a)}).then(e,r)},{unsafe:!0});try{delete Fu.constructor}catch{}iT&&iT(Fu,Ph)}Y8({global:!0,constructor:!0,wrap:!0,forced:uT},{Promise:Ro}),Q8(Ro,Oh,!1),X8(Oh);var td={},g9=Rr,y9=td,b9=g9("iterator"),w9=Array.prototype,ay=function(t){return t!==void 0&&(y9.Array===t||w9[b9]===t)},_9=xa,_T=ko,k9=xi,S9=td,$9=Rr,T9=$9("iterator"),rd=function(t){if(!k9(t))return _T(t,T9)||_T(t,"@@iterator")||S9[_9(t)]},E9=Er,C9=si,R9=Gr,x9=_o,I9=rd,A9=TypeError,Nh=function(t,e){var r=arguments.length<2?I9(t):e;if(C9(r))return R9(E9(r,t));throw new A9(x9(t)+" is not iterable")},O9=Er,kT=Gr,P9=ko,ST=function(t,e,r){var n,i;kT(t);try{if(n=P9(t,"return"),!n){if(e==="throw")throw r;return r}n=O9(n,t)}catch(a){i=!0,n=a}if(e==="throw")throw r;if(i)throw n;return kT(n),r},M9=Ia,N9=Er,L9=Gr,D9=_o,j9=ay,U9=bn,$T=Ea,F9=Nh,B9=rd,TT=ST,z9=TypeError,Lh=function(t,e){this.stopped=t,this.result=e},ET=Lh.prototype,nd=function(t,e,r){var n=r&&r.that,i=!!(r&&r.AS_ENTRIES),a=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),o=!!(r&&r.INTERRUPTED),u=M9(e,n),l,c,d,f,m,b,A,N=function(X){return l&&TT(l,"normal",X),new Lh(!0,X)},z=function(X){return i?(L9(X),o?u(X[0],X[1],N):u(X[0],X[1])):o?u(X,N):u(X)};if(a)l=t.iterator;else if(s)l=t;else{if(c=B9(t),!c)throw new z9(D9(t)+" is not iterable");if(j9(c)){for(d=0,f=U9(t);f>d;d++)if(m=z(t[d]),m&&$T(ET,m))return m;return new Lh(!1)}l=F9(t,c)}for(b=a?t.next:l.next;!(A=N9(b,l)).done;){try{m=z(A.value)}catch(X){TT(l,"throw",X)}if(typeof m=="object"&&m&&$T(ET,m))return m}return new Lh(!1)},H9=Rr,CT=H9("iterator"),RT=!1;try{var q9=0,xT={next:function(){return{done:!!q9++}},return:function(){RT=!0}};xT[CT]=function(){return this},Array.from(xT,function(){throw 2})}catch{}var Dh=function(t,e){try{if(!e&&!RT)return!1}catch{return!1}var r=!1;try{var n={};n[CT]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch{}return r},V9=Rh,W9=Dh,Z9=ed.CONSTRUCTOR,IT=Z9||!W9(function(t){V9.all(t).then(void 0,function(){})}),G9=er,K9=Er,J9=si,Y9=ju,Q9=Gg,X9=nd,e7=IT;G9({target:"Promise",stat:!0,forced:e7},{all:function(e){var r=this,n=Y9.f(r),i=n.resolve,a=n.reject,s=Q9(function(){var o=J9(r.resolve),u=[],l=0,c=1;X9(e,function(d){var f=l++,m=!1;c++,K9(o,r,d).then(function(b){m||(m=!0,u[f]=b,--c||i(u))},a)}),--c||i(u)});return s.error&&a(s.value),n.promise}});var t7=er,r7=ed.CONSTRUCTOR,sy=Rh,n7=Ai,i7=Cr,a7=Rn,AT=sy&&sy.prototype;if(t7({target:"Promise",proto:!0,forced:r7,real:!0},{catch:function(t){return this.then(void 0,t)}}),i7(sy)){var OT=n7("Promise").prototype.catch;AT.catch!==OT&&a7(AT,"catch",OT,{unsafe:!0})}var s7=er,o7=Er,u7=si,l7=ju,c7=Gg,d7=nd,f7=IT;s7({target:"Promise",stat:!0,forced:f7},{race:function(e){var r=this,n=l7.f(r),i=n.reject,a=c7(function(){var s=u7(r.resolve);d7(e,function(o){o7(s,r,o).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var h7=er,p7=ju,v7=ed.CONSTRUCTOR;h7({target:"Promise",stat:!0,forced:v7},{reject:function(e){var r=p7.f(this),n=r.reject;return n(e),r.promise}});var m7=Gr,g7=Lr,y7=ju,b7=function(t,e){if(m7(t),g7(e)&&e.constructor===t)return e;var r=y7.f(t),n=r.resolve;return n(e),r.promise},w7=er,_7=Ai,k7=ed.CONSTRUCTOR,S7=b7;_7("Promise"),w7({target:"Promise",stat:!0,forced:k7},{resolve:function(e){return S7(this,e)}});var PT={exports:{}},MT={exports:{}};(function(t){function e(r,n){this.v=r,this.k=n}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(MT);var NT=MT.exports,LT={exports:{}},DT={exports:{}};(function(t){function e(r,n,i,a){var s=Object.defineProperty;try{s({},"",{})}catch{s=0}t.exports=e=function(u,l,c,d){function f(m,b){e(u,m,function(A){return this._invoke(m,b,A)})}l?s?s(u,l,{value:c,enumerable:!d,configurable:!d,writable:!d}):u[l]=c:(f("next",0),f("throw",1),f("return",2))},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n,i,a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(DT);var jT=DT.exports;(function(t){var e=jT;function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var n,i,a=typeof Symbol=="function"?Symbol:{},s=a.iterator||"@@iterator",o=a.toStringTag||"@@toStringTag";function u(N,z,X,Ee){var Ie=z&&z.prototype instanceof c?z:c,Fe=Object.create(Ie.prototype);return e(Fe,"_invoke",function(Oe,ze,V){var xe,_e,se,Te=0,re=V||[],oe=!1,q={p:0,n:0,v:n,a:ne,f:ne.bind(n,4),d:function(H,ye){return xe=H,_e=0,se=n,q.n=ye,l}};function ne(Se,H){for(_e=Se,se=H,i=0;!oe&&Te&&!ye&&i<re.length;i++){var ye,ke=re[i],M=q.p,Xe=ke[2];Se>3?(ye=Xe===H)&&(se=ke[(_e=ke[4])?5:(_e=3,3)],ke[4]=ke[5]=n):ke[0]<=M&&((ye=Se<2&&M<ke[1])?(_e=0,q.v=H,q.n=ke[1]):M<Xe&&(ye=Se<3||ke[0]>H||H>Xe)&&(ke[4]=Se,ke[5]=H,q.n=Xe,_e=0))}if(ye||Se>1)return l;throw oe=!0,H}return function(Se,H,ye){if(Te>1)throw TypeError("Generator is already running");for(oe&&H===1&&ne(H,ye),_e=H,se=ye;(i=_e<2?n:se)||!oe;){xe||(_e?_e<3?(_e>1&&(q.n=-1),ne(_e,se)):q.n=se:q.v=se);try{if(Te=2,xe){if(_e||(Se="next"),i=xe[Se]){if(!(i=i.call(xe,se)))throw TypeError("iterator result is not an object");if(!i.done)return i;se=i.value,_e<2&&(_e=0)}else _e===1&&(i=xe.return)&&i.call(xe),_e<2&&(se=TypeError("The iterator does not provide a '"+Se+"' method"),_e=1);xe=n}else if((i=(oe=q.n<0)?se:Oe.call(ze,q))!==l)break}catch(ke){xe=n,_e=1,se=ke}finally{Te=1}}return{value:i,done:oe}}}(N,X,Ee),!0),Fe}var l={};function c(){}function d(){}function f(){}i=Object.getPrototypeOf;var m=[][s]?i(i([][s]())):(e(i={},s,function(){return this}),i),b=f.prototype=c.prototype=Object.create(m);function A(N){return Object.setPrototypeOf?Object.setPrototypeOf(N,f):(N.__proto__=f,e(N,o,"GeneratorFunction")),N.prototype=Object.create(b),N}return d.prototype=f,e(b,"constructor",f),e(f,"constructor",d),d.displayName="GeneratorFunction",e(f,o,"GeneratorFunction"),e(b),e(b,o,"Generator"),e(b,s,function(){return this}),e(b,"toString",function(){return"[object Generator]"}),(t.exports=r=function(){return{w:u,m:A}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(LT);var UT=LT.exports,FT={exports:{}},BT={exports:{}},zT={exports:{}};(function(t){var e=NT,r=jT;function n(i,a){function s(u,l,c,d){try{var f=i[u](l),m=f.value;return m instanceof e?a.resolve(m.v).then(function(b){s("next",b,c,d)},function(b){s("throw",b,c,d)}):a.resolve(m).then(function(b){f.value=b,c(f)},function(b){return s("throw",b,c,d)})}catch(b){d(b)}}var o;this.next||(r(n.prototype),r(n.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(u,l,c){function d(){return new a(function(f,m){s(u,c,f,m)})}return o=o?o.then(d,d):d()},!0)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(zT);var HT=zT.exports;(function(t){var e=UT,r=HT;function n(i,a,s,o,u){return new r(e().w(i,a,s,o),u||Promise)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(BT);var qT=BT.exports;(function(t){var e=qT;function r(n,i,a,s,o){var u=e(n,i,a,s,o);return u.next().then(function(l){return l.done?l.value:u.next()})}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(FT);var $7=FT.exports,VT={exports:{}};(function(t){function e(r){var n=Object(r),i=[];for(var a in n)i.unshift(a);return function s(){for(;i.length;)if((a=i.pop())in n)return s.value=a,s.done=!1,s;return s.done=!0,s}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(VT);var T7=VT.exports,WT={exports:{}};(function(t){var e=ui.default;function r(n){if(n!=null){var i=n[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],a=0;if(i)return i.call(n);if(typeof n.next=="function")return n;if(!isNaN(n.length))return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}}}throw new TypeError(e(n)+" is not iterable")}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(WT);var E7=WT.exports;(function(t){var e=NT,r=UT,n=$7,i=qT,a=HT,s=T7,o=E7;function u(){var l=r(),c=l.m(u),d=(Object.getPrototypeOf?Object.getPrototypeOf(c):c.__proto__).constructor;function f(A){var N=typeof A=="function"&&A.constructor;return!!N&&(N===d||(N.displayName||N.name)==="GeneratorFunction")}var m={throw:1,return:2,break:3,continue:3};function b(A){var N,z;return function(X){N||(N={stop:function(){return z(X.a,2)},catch:function(){return X.v},abrupt:function(Ie,Fe){return z(X.a,m[Ie],Fe)},delegateYield:function(Ie,Fe,Oe){return N.resultName=Fe,z(X.d,o(Ie),Oe)},finish:function(Ie){return z(X.f,Ie)}},z=function(Ie,Fe,Oe){X.p=N.prev,X.n=N.next;try{return Ie(Fe,Oe)}finally{N.next=X.n}}),N.resultName&&(N[N.resultName]=X.v,N.resultName=void 0),N.sent=X.v,N.next=X.n;try{return A.call(this,N)}finally{X.p=N.prev,X.n=N.next}}}return(t.exports=u=function(){return{wrap:function(z,X,Ee,Ie){return l.w(b(z),X,Ee,Ie&&Ie.reverse())},isGeneratorFunction:f,mark:l.m,awrap:function(z,X){return new e(z,X)},AsyncIterator:a,async:function(z,X,Ee,Ie,Fe){return(f(X)?i:n)(b(z),X,Ee,Ie,Fe)},keys:s,values:o}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports})(PT);var C7=PT.exports,jh=C7(),Hu=jh;try{regeneratorRuntime=jh}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=jh:Function("r","regeneratorRuntime = r")(jh)}var R7=TypeError,x7=9007199254740991,ZT=function(t){if(t>x7)throw R7("Maximum allowed index exceeded");return t},I7=er,A7=Vt,O7=Hc,P7=Lr,M7=yn,N7=bn,GT=ZT,KT=Jc,L7=vg,D7=Kc,j7=Rr,U7=$u,JT=j7("isConcatSpreadable"),F7=U7>=51||!A7(function(){var t=[];return t[JT]=!1,t.concat()[0]!==t}),B7=function(t){if(!P7(t))return!1;var e=t[JT];return e!==void 0?!!e:O7(t)},z7=!F7||!D7("concat");I7({target:"Array",proto:!0,arity:1,forced:z7},{concat:function(e){var r=M7(this),n=L7(r,0),i=0,a,s,o,u,l;for(a=-1,o=arguments.length;a<o;a++)if(l=a===-1?r:arguments[a],B7(l))for(u=N7(l),GT(i+u),s=0;s<u;s++,i++)s in l&&KT(n,i,l[s]);else GT(i+1),KT(n,i++,l);return n.length=i,n}});var H7=Gr,q7=ST,V7=function(t,e,r,n){try{return n?e(H7(r)[0],r[1]):e(r)}catch(i){q7(t,"throw",i)}},W7=Ia,Z7=Er,G7=yn,K7=V7,J7=ay,Y7=fh,Q7=bn,YT=Jc,X7=Nh,ez=rd,QT=Array,XT=function(e){var r=G7(e),n=Y7(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=W7(a,i>2?arguments[2]:void 0));var o=ez(r),u=0,l,c,d,f,m,b;if(o&&!(this===QT&&J7(o)))for(c=n?new this:[],f=X7(r,o),m=f.next;!(d=Z7(m,f)).done;u++)b=s?K7(f,a,[d.value,u],!0):d.value,YT(c,u,b);else for(l=Q7(r),c=n?new this(l):QT(l);l>u;u++)b=s?a(r[u],u):r[u],YT(c,u,b);return c.length=u,c},tz=er,rz=XT,nz=Dh,iz=!nz(function(t){Array.from(t)});tz({target:"Array",stat:!0,forced:iz},{from:rz});var oy=Kt,az=ea,sz=nn,oz=Ii,uz=oy("".charAt),eE=oy("".charCodeAt),lz=oy("".slice),tE=function(t){return function(e,r){var n=sz(oz(e)),i=az(r),a=n.length,s,o;return i<0||i>=a?t?"":void 0:(s=eE(n,i),s<55296||s>56319||i+1===a||(o=eE(n,i+1))<56320||o>57343?t?uz(n,i):s:t?lz(n,i,i+2):(s-55296<<10)+(o-56320)+65536)}},uy={codeAt:tE(!1),charAt:tE(!0)},cz=Vt,dz=!cz(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),fz=Vr,hz=Cr,pz=yn,vz=nh,mz=dz,rE=vz("IE_PROTO"),ly=Object,gz=ly.prototype,id=mz?ly.getPrototypeOf:function(t){var e=pz(t);if(fz(e,rE))return e[rE];var r=e.constructor;return hz(r)&&e instanceof r?r.prototype:e instanceof ly?gz:null},yz=Vt,bz=Cr,wz=Lr,nE=id,_z=Rn,kz=Rr,cy=kz("iterator"),iE=!1,xo,dy,fy;[].keys&&(fy=[].keys(),"next"in fy?(dy=nE(nE(fy)),dy!==Object.prototype&&(xo=dy)):iE=!0);var Sz=!wz(xo)||yz(function(){var t={};return xo[cy].call(t)!==t});Sz&&(xo={}),bz(xo[cy])||_z(xo,cy,function(){return this});var aE={IteratorPrototype:xo,BUGGY_SAFARI_ITERATORS:iE},$z=aE.IteratorPrototype,Tz=vs,Ez=bo,Cz=ta,Rz=td,xz=function(){return this},sE=function(t,e,r,n){var i=e+" Iterator";return t.prototype=Tz($z,{next:Ez(+!n,r)}),Cz(t,i,!1),Rz[i]=xz,t},Iz=er,Az=Er,oE=Lc,Oz=Cr,Pz=sE,uE=id,lE=Nu,Mz=ta,Nz=Ca,hy=Rn,Lz=Rr,Dz=td,cE=aE,jz=oE.PROPER,Uz=oE.CONFIGURABLE,dE=cE.IteratorPrototype,Uh=cE.BUGGY_SAFARI_ITERATORS,ad=Lz("iterator"),fE="keys",sd="values",hE="entries",Fz=function(){return this},py=function(t,e,r,n,i,a,s){Pz(r,e,n);var o=function(z){if(z===i&&f)return f;if(!Uh&&z&&z in c)return c[z];switch(z){case fE:return function(){return new r(this,z)};case sd:return function(){return new r(this,z)};case hE:return function(){return new r(this,z)}}return function(){return new r(this)}},u=e+" Iterator",l=!1,c=t.prototype,d=c[ad]||c["@@iterator"]||i&&c[i],f=!Uh&&d||o(i),m=e==="Array"&&c.entries||d,b,A,N;if(m&&(b=uE(m.call(new t)),b!==Object.prototype&&b.next&&(uE(b)!==dE&&(lE?lE(b,dE):Oz(b[ad])||hy(b,ad,Fz)),Mz(b,u,!0))),jz&&i===sd&&d&&d.name!==sd&&(Uz?Nz(c,"name",sd):(l=!0,f=function(){return Az(d,this)})),i)if(A={values:o(sd),keys:a?f:o(fE),entries:o(hE)},s)for(N in A)(Uh||l||!(N in c))&&hy(c,N,A[N]);else Iz({target:e,proto:!0,forced:Uh||l},A);return c[ad]!==f&&hy(c,ad,f,{name:i}),Dz[e]=f,A},Fh=function(t,e){return{value:t,done:e}},Bz=uy.charAt,zz=nn,pE=Jn,Hz=py,vE=Fh,mE="String Iterator",qz=pE.set,Vz=pE.getterFor(mE);Hz(String,"String",function(t){qz(this,{type:mE,string:zz(t),index:0})},function(){var e=Vz(this),r=e.string,n=e.index,i;return n>=r.length?vE(void 0,!0):(i=Bz(r,n),e.index+=i.length,vE(i,!1))});var gE={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(ln,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],a={},s=null;function o(A,N){var z=A[N];if(typeof z.bind=="function")return z.bind(A);try{return Function.prototype.bind.call(z,A)}catch{return function(){return Function.prototype.apply.apply(z,[A,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(A){return A==="debug"&&(A="log"),typeof console===r?!1:A==="trace"&&n?u:console[A]!==void 0?o(console,A):console.log!==void 0?o(console,"log"):e}function c(){for(var A=this.getLevel(),N=0;N<i.length;N++){var z=i[N];this[z]=N<A?e:this.methodFactory(z,A,this.name)}if(this.log=this.debug,typeof console===r&&A<this.levels.SILENT)return"No console available for logging"}function d(A){return function(){typeof console!==r&&(c.call(this),this[A].apply(this,arguments))}}function f(A,N,z){return l(A)||d.apply(this,arguments)}function m(A,N){var z=this,X,Ee,Ie,Fe="loglevel";typeof A=="string"?Fe+=":"+A:typeof A=="symbol"&&(Fe=void 0);function Oe(se){var Te=(i[se]||"silent").toUpperCase();if(!(typeof window===r||!Fe)){try{window.localStorage[Fe]=Te;return}catch{}try{window.document.cookie=encodeURIComponent(Fe)+"="+Te+";"}catch{}}}function ze(){var se;if(!(typeof window===r||!Fe)){try{se=window.localStorage[Fe]}catch{}if(typeof se===r)try{var Te=window.document.cookie,re=encodeURIComponent(Fe),oe=Te.indexOf(re+"=");oe!==-1&&(se=/^([^;]+)/.exec(Te.slice(oe+re.length+1))[1])}catch{}return z.levels[se]===void 0&&(se=void 0),se}}function V(){if(!(typeof window===r||!Fe)){try{window.localStorage.removeItem(Fe)}catch{}try{window.document.cookie=encodeURIComponent(Fe)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function xe(se){var Te=se;if(typeof Te=="string"&&z.levels[Te.toUpperCase()]!==void 0&&(Te=z.levels[Te.toUpperCase()]),typeof Te=="number"&&Te>=0&&Te<=z.levels.SILENT)return Te;throw new TypeError("log.setLevel() called with invalid level: "+se)}z.name=A,z.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},z.methodFactory=N||f,z.getLevel=function(){return Ie??Ee??X},z.setLevel=function(se,Te){return Ie=xe(se),Te!==!1&&Oe(Ie),c.call(z)},z.setDefaultLevel=function(se){Ee=xe(se),ze()||z.setLevel(se,!1)},z.resetLevel=function(){Ie=null,V(),c.call(z)},z.enableAll=function(se){z.setLevel(z.levels.TRACE,se)},z.disableAll=function(se){z.setLevel(z.levels.SILENT,se)},z.rebuild=function(){if(s!==z&&(X=xe(s.getLevel())),c.call(z),s===z)for(var se in a)a[se].rebuild()},X=xe(s?s.getLevel():"WARN");var _e=ze();_e!=null&&(Ie=xe(_e)),c.call(z)}s=new m,s.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=a[N];return z||(z=a[N]=new m(N,s.methodFactory)),z};var b=typeof window!==r?window.log:void 0;return s.noConflict=function(){return typeof window!==r&&window.log===s&&(window.log=b),s},s.getLoggers=function(){return a},s.default=s,s})})(gE);var qu=gE.exports;const Io="\\d+(?:[\\.,]\\d+)?",Wz=`(${Io}W)`,Zz=`(${Io}Y)?(${Io}M)?(${Io}D)?`,Gz=`T(${Io}H)?(${Io}M)?(${Io}S)?`,Kz=`P(?:${Wz}|${Zz}(?:${Gz})?)`,Jz=["weeks","years","months","days","hours","minutes","seconds"],vy=new RegExp(Kz),yE=t=>t.match(vy).slice(1).reduce((e,r,n)=>(e[Jz[n]]=parseFloat(r)||0,e),{}),my=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return n.setFullYear(n.getFullYear()+t.years),n.setMonth(n.getMonth()+t.months),n.setDate(n.getDate()+t.days),n.setHours(n.getHours()+t.hours),n.setMinutes(n.getMinutes()+t.minutes),n.setMilliseconds(n.getMilliseconds()+t.seconds*1e3),n.setDate(n.getDate()+t.weeks*7),n},bE=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return(my(t,n).getTime()-n.getTime())/1e3},Yz=bP(Object.freeze(Object.defineProperty({__proto__:null,default:{end:my,toSeconds:bE,pattern:vy,parse:yE},end:my,parse:yE,pattern:vy,toSeconds:bE},Symbol.toStringTag,{value:"Module"})));var Qz=Rr,Xz=vs,eH=Cn.f,gy=Qz("unscopables"),yy=Array.prototype;yy[gy]===void 0&&eH(yy,gy,{configurable:!0,value:Xz(null)});var by=function(t){yy[gy][t]=!0},tH=Kn,wy=by,wE=td,_E=Jn,rH=Cn.f,nH=py,Bh=Fh,iH=Ar,kE="Array Iterator",aH=_E.set,sH=_E.getterFor(kE),SE=nH(Array,"Array",function(t,e){aH(this,{type:kE,target:tH(t),index:0,kind:e})},function(){var t=sH(this),e=t.target,r=t.index++;if(!e||r>=e.length)return t.target=void 0,Bh(void 0,!0);switch(t.kind){case"keys":return Bh(r,!1);case"values":return Bh(e[r],!1)}return Bh([r,e[r]],!1)},"values"),$E=wE.Arguments=wE.Array;if(wy("keys"),wy("values"),wy("entries"),iH&&$E.name!=="values")try{rH($E,"name",{value:"values"})}catch{}var TE=cr,EE=C$,oH=x$,od=SE,CE=Ca,uH=ta,lH=Rr,_y=lH("iterator"),ky=od.values,RE=function(t,e){if(t){if(t[_y]!==ky)try{CE(t,_y,ky)}catch{t[_y]=ky}if(uH(t,e,!0),EE[e]){for(var r in od)if(t[r]!==od[r])try{CE(t,r,od[r])}catch{t[r]=od[r]}}}};for(var Sy in EE)RE(TE[Sy]&&TE[Sy].prototype,Sy);RE(oH,"DOMTokenList");var cH=Cr,dH=Lr,xE=Nu,zh=function(t,e,r){var n,i;return xE&&cH(n=e.constructor)&&n!==r&&dH(i=n.prototype)&&i!==r.prototype&&xE(t,i),t},fH=Kt,hH=fH(1 .valueOf),pH=`
810
+ \v\f\r                 \u2028\u2029\uFEFF`,vH=Kt,mH=Ii,gH=nn,$y=pH,IE=vH("".replace),yH=RegExp("^["+$y+"]+"),bH=RegExp("(^|[^"+$y+"])["+$y+"]+$"),Ty=function(t){return function(e){var r=gH(mH(e));return t&1&&(r=IE(r,yH,"")),t&2&&(r=IE(r,bH,"$1")),r}},wH={start:Ty(1),end:Ty(2),trim:Ty(3)},_H=er,AE=Sk,kH=Ar,OE=cr,PE=TS,ME=Kt,SH=lh,NE=Vr,$H=zh,TH=Ea,EH=Eu,LE=jm,CH=Vt,RH=So.f,xH=Ta.f,IH=Cn.f,AH=hH,OH=wH.trim,Hh="Number",Vu=OE[Hh];PE[Hh];var Ey=Vu.prototype,PH=OE.TypeError,MH=ME("".slice),qh=ME("".charCodeAt),NH=function(t){var e=LE(t,"number");return typeof e=="bigint"?e:LH(e)},LH=function(t){var e=LE(t,"number"),r,n,i,a,s,o,u,l;if(EH(e))throw new PH("Cannot convert a Symbol value to a number");if(typeof e=="string"&&e.length>2){if(e=OH(e),r=qh(e,0),r===43||r===45){if(n=qh(e,2),n===88||n===120)return NaN}else if(r===48){switch(qh(e,1)){case 66:case 98:i=2,a=49;break;case 79:case 111:i=8,a=55;break;default:return+e}for(s=MH(e,2),o=s.length,u=0;u<o;u++)if(l=qh(s,u),l<48||l>a)return NaN;return parseInt(s,i)}}return+e},Cy=SH(Hh,!Vu(" 0o1")||!Vu("0b1")||Vu("+0x1")),DH=function(t){return TH(Ey,t)&&CH(function(){AH(t)})},Vh=function(e){var r=arguments.length<1?0:Vu(NH(e));return DH(this)?$H(Object(r),this,Vh):r};Vh.prototype=Ey,Cy&&!AE&&(Ey.constructor=Vh),_H({global:!0,constructor:!0,wrap:!0,forced:Cy},{Number:Vh});var jH=function(t,e){for(var r=kH?RH(e):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),n=0,i;r.length>n;n++)NE(e,i=r[n])&&!NE(t,i)&&IH(t,i,xH(e,i))};(Cy||AE)&&jH(PE[Hh],Vu);var UH=Gr,DE=function(){var t=UH(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},Ry=Vt,FH=cr,xy=FH.RegExp,Iy=Ry(function(){var t=xy("a","y");return t.lastIndex=2,t.exec("abcd")!==null}),BH=Iy||Ry(function(){return!xy("a","y").sticky}),zH=Iy||Ry(function(){var t=xy("^r","gy");return t.lastIndex=2,t.exec("str")!==null}),jE={BROKEN_CARET:zH,MISSED_STICKY:BH,UNSUPPORTED_Y:Iy},HH=Vt,qH=cr,VH=qH.RegExp,WH=HH(function(){var t=VH(".","s");return!(t.dotAll&&t.test(`
811
+ `)&&t.flags==="s")}),ZH=Vt,GH=cr,KH=GH.RegExp,JH=ZH(function(){var t=KH("(?<a>b)","g");return t.exec("b").groups.a!=="b"||"b".replace(t,"$<a>c")!=="bc"}),Wu=Er,Wh=Kt,YH=nn,QH=DE,XH=jE,eq=Cu,tq=vs,rq=Jn.get,nq=WH,iq=JH,aq=eq("native-string-replace",String.prototype.replace),Zh=RegExp.prototype.exec,Ay=Zh,sq=Wh("".charAt),oq=Wh("".indexOf),uq=Wh("".replace),Oy=Wh("".slice),Py=function(){var t=/a/,e=/b*/g;return Wu(Zh,t,"a"),Wu(Zh,e,"a"),t.lastIndex!==0||e.lastIndex!==0}(),UE=XH.BROKEN_CARET,My=/()??/.exec("")[1]!==void 0,lq=Py||My||UE||nq||iq;lq&&(Ay=function(e){var r=this,n=rq(r),i=YH(e),a=n.raw,s,o,u,l,c,d,f;if(a)return a.lastIndex=r.lastIndex,s=Wu(Ay,a,i),r.lastIndex=a.lastIndex,s;var m=n.groups,b=UE&&r.sticky,A=Wu(QH,r),N=r.source,z=0,X=i;if(b&&(A=uq(A,"y",""),oq(A,"g")===-1&&(A+="g"),X=Oy(i,r.lastIndex),r.lastIndex>0&&(!r.multiline||r.multiline&&sq(i,r.lastIndex-1)!==`
812
+ `)&&(N="(?: "+N+")",X=" "+X,z++),o=new RegExp("^(?:"+N+")",A)),My&&(o=new RegExp("^"+N+"$(?!\\s)",A)),Py&&(u=r.lastIndex),l=Wu(Zh,b?o:r,X),b?l?(l.input=Oy(l.input,z),l[0]=Oy(l[0],z),l.index=r.lastIndex,r.lastIndex+=l[0].length):r.lastIndex=0:Py&&l&&(r.lastIndex=r.global?l.index+l[0].length:u),My&&l&&l.length>1&&Wu(aq,l[0],o,function(){for(c=1;c<arguments.length-2;c++)arguments[c]===void 0&&(l[c]=void 0)}),l&&m)for(l.groups=d=tq(null),c=0;c<m.length;c++)f=m[c],d[f[0]]=l[f[1]];return l});var Ny=Ay,cq=er,FE=Ny;cq({target:"RegExp",proto:!0,forced:/./.exec!==FE},{exec:FE});var BE=Er,zE=Rn,dq=Ny,HE=Vt,qE=Rr,fq=Ca,hq=qE("species"),Ly=RegExp.prototype,Gh=function(t,e,r,n){var i=qE(t),a=!HE(function(){var l={};return l[i]=function(){return 7},""[t](l)!==7}),s=a&&!HE(function(){var l=!1,c=/a/;return t==="split"&&(c={},c.constructor={},c.constructor[hq]=function(){return c},c.flags="",c[i]=/./[i]),c.exec=function(){return l=!0,null},c[i](""),!l});if(!a||!s||r){var o=/./[i],u=e(i,""[t],function(l,c,d,f,m){var b=c.exec;return b===dq||b===Ly.exec?a&&!m?{done:!0,value:BE(o,c,d,f)}:{done:!0,value:BE(l,d,c,f)}:{done:!1}});zE(String.prototype,t,u[0]),zE(Ly,i,u[1])}n&&fq(Ly[i],"sham",!0)},pq=uy.charAt,Dy=function(t,e,r){return e+(r?pq(t,e).length:1)},jy=Kt,vq=yn,mq=Math.floor,Uy=jy("".charAt),gq=jy("".replace),Fy=jy("".slice),yq=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,bq=/\$([$&'`]|\d{1,2})/g,wq=function(t,e,r,n,i,a){var s=r+t.length,o=n.length,u=bq;return i!==void 0&&(i=vq(i),u=yq),gq(a,u,function(l,c){var d;switch(Uy(c,0)){case"$":return"$";case"&":return t;case"`":return Fy(e,0,r);case"'":return Fy(e,s);case"<":d=i[Fy(c,1,-1)];break;default:var f=+c;if(f===0)return l;if(f>o){var m=mq(f/10);return m===0?l:m<=o?n[m-1]===void 0?Uy(c,1):n[m-1]+Uy(c,1):l}d=n[f-1]}return d===void 0?"":d})},VE=Er,_q=Gr,kq=Cr,Sq=Qi,$q=Ny,Tq=TypeError,Kh=function(t,e){var r=t.exec;if(kq(r)){var n=VE(r,t,e);return n!==null&&_q(n),n}if(Sq(t)==="RegExp")return VE($q,t,e);throw new Tq("RegExp#exec called on incompatible receiver")},Eq=$o,WE=Er,Jh=Kt,Cq=Gh,Rq=Vt,xq=Gr,Iq=Cr,Aq=xi,Oq=ea,Pq=Ra,Zu=nn,Mq=Ii,Nq=Dy,Lq=ko,Dq=wq,jq=Kh,Uq=Rr,By=Uq("replace"),Fq=Math.max,Bq=Math.min,zq=Jh([].concat),zy=Jh([].push),ZE=Jh("".indexOf),GE=Jh("".slice),Hq=function(t){return t===void 0?t:String(t)},qq=function(){return"a".replace(/./,"$0")==="$0"}(),KE=function(){return/./[By]?/./[By]("a","$0")==="":!1}(),Vq=!Rq(function(){var t=/./;return t.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(t,"$<a>")!=="7"});Cq("replace",function(t,e,r){var n=KE?"$":"$0";return[function(a,s){var o=Mq(this),u=Aq(a)?void 0:Lq(a,By);return u?WE(u,a,o,s):WE(e,Zu(o),a,s)},function(i,a){var s=xq(this),o=Zu(i);if(typeof a=="string"&&ZE(a,n)===-1&&ZE(a,"$<")===-1){var u=r(e,s,o,a);if(u.done)return u.value}var l=Iq(a);l||(a=Zu(a));var c=s.global,d;c&&(d=s.unicode,s.lastIndex=0);for(var f=[],m;m=jq(s,o),!(m===null||(zy(f,m),!c));){var b=Zu(m[0]);b===""&&(s.lastIndex=Nq(o,Pq(s.lastIndex),d))}for(var A="",N=0,z=0;z<f.length;z++){m=f[z];for(var X=Zu(m[0]),Ee=Fq(Bq(Oq(m.index),o.length),0),Ie=[],Fe,Oe=1;Oe<m.length;Oe++)zy(Ie,Hq(m[Oe]));var ze=m.groups;if(l){var V=zq([X],Ie,Ee,o);ze!==void 0&&zy(V,ze),Fe=Zu(Eq(a,void 0,V))}else Fe=Dq(X,o,Ee,Ie,ze,a);Ee>=N&&(A+=GE(o,N,Ee)+Fe,N=Ee+X.length)}return A+GE(o,N)}]},!Vq||!qq||KE);var Wq=er,Zq=Kt,Gq=Mc,Kq=Kn,Jq=_h,Yq=Zq([].join),Qq=Gq!==Object,Xq=Qq||!Jq("join",",");Wq({target:"Array",proto:!0,forced:Xq},{join:function(e){return Yq(Kq(this),e===void 0?",":e)}});var an={},eV=Ar,tV=Lc.EXISTS,JE=Kt,rV=na,YE=Function.prototype,nV=JE(YE.toString),QE=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,iV=JE(QE.exec),aV="name";eV&&!tV&&rV(YE,aV,{configurable:!0,get:function(){try{return iV(QE,nV(this))[1]}catch{return""}}});var XE={exports:{}},eC={exports:{}};(function(t){function e(r){if(Array.isArray(r))return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(eC);var sV=eC.exports,tC={exports:{}};(function(t){function e(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var a,s,o,u,l=[],c=!0,d=!1;try{if(o=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;c=!1}else for(;!(c=(a=o.call(i)).done)&&(l.push(a.value),l.length!==n);c=!0);}catch(f){d=!0,s=f}finally{try{if(!c&&i.return!=null&&(u=i.return(),Object(u)!==u))return}finally{if(d)throw s}}return l}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(tC);var oV=tC.exports,rC={exports:{}},nC={exports:{}};(function(t){function e(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,a=Array(n);i<n;i++)a[i]=r[i];return a}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(nC);var iC=nC.exports;(function(t){var e=iC;function r(n,i){if(n){if(typeof n=="string")return e(n,i);var a={}.toString.call(n).slice(8,-1);return a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set"?Array.from(n):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(n,i):void 0}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(rC);var aC=rC.exports,sC={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
813
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(sC);var uV=sC.exports;(function(t){var e=sV,r=oV,n=aC,i=uV;function a(s,o){return e(s)||r(s,o)||n(s,o)||i()}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(XE);var ud=XE.exports,lV=er,oC=Hc,cV=fh,dV=Lr,uC=Iu,fV=bn,hV=Kn,pV=Jc,vV=Rr,mV=Kc,gV=ra,yV=mV("slice"),bV=vV("species"),Hy=Array,wV=Math.max;lV({target:"Array",proto:!0,forced:!yV},{slice:function(e,r){var n=hV(this),i=fV(n),a=uC(e,i),s=uC(r===void 0?i:r,i),o,u,l;if(oC(n)&&(o=n.constructor,cV(o)&&(o===Hy||oC(o.prototype))?o=void 0:dV(o)&&(o=o[bV],o===null&&(o=void 0)),o===Hy||o===void 0))return gV(n,a,s);for(u=new(o===void 0?Hy:o)(wV(s-a,0)),l=0;a<s;a++,l++)a in n&&pV(u,l,n[a]);return u.length=l,u}});var _V=er,lC=Er,kV=Cr,cC=Gr,SV=nn,$V=function(){var t=!1,e=/[ac]/;return e.exec=function(){return t=!0,/./.exec.apply(this,arguments)},e.test("abc")===!0&&t}(),TV=/./.test;_V({target:"RegExp",proto:!0,forced:!$V},{test:function(t){var e=cC(this),r=SV(t),n=e.exec;if(!kV(n))return lC(TV,e,r);var i=lC(n,e,r);return i===null?!1:(cC(i),!0)}});var EV=er,CV=Ar,RV=cr,Yh=Kt,xV=Vr,IV=Cr,AV=Ea,OV=nn,PV=na,MV=tg,Pa=RV.Symbol,Ao=Pa&&Pa.prototype;if(CV&&IV(Pa)&&(!("description"in Ao)||Pa().description!==void 0)){var dC={},Qh=function(){var e=arguments.length<1||arguments[0]===void 0?void 0:OV(arguments[0]),r=AV(Ao,this)?new Pa(e):e===void 0?Pa():Pa(e);return e===""&&(dC[r]=!0),r};MV(Qh,Pa),Qh.prototype=Ao,Ao.constructor=Qh;var NV=String(Pa("description detection"))==="Symbol(description detection)",LV=Yh(Ao.valueOf),DV=Yh(Ao.toString),jV=/^Symbol\((.*)\)[^)]+$/,UV=Yh("".replace),FV=Yh("".slice);PV(Ao,"description",{configurable:!0,get:function(){var e=LV(this);if(xV(dC,e))return"";var r=DV(e),n=NV?FV(r,7,-1):UV(r,jV,"$1");return n===""?void 0:n}}),EV({global:!0,constructor:!0,forced:!0},{Symbol:Qh})}var BV=CS;BV("iterator");var fC={exports:{}},hC={exports:{}};(function(t){var e=iC;function r(n){if(Array.isArray(n))return e(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(hC);var zV=hC.exports,pC={exports:{}};(function(t){function e(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(pC);var HV=pC.exports,vC={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
814
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(vC);var qV=vC.exports;(function(t){var e=zV,r=HV,n=aC,i=qV;function a(s){return e(s)||r(s)||n(s)||i()}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(fC);var ld=fC.exports,VV=er,WV=uh.includes,ZV=Vt,GV=by,KV=ZV(function(){return!Array(1).includes()});VV({target:"Array",proto:!0,forced:KV},{includes:function(e){return WV(this,e,arguments.length>1?arguments[1]:void 0)}}),GV("includes");var JV=Lr,YV=Math.floor,mC=Number.isInteger||function(e){return!JV(e)&&isFinite(e)&&YV(e)===e},QV=er,XV=mC;QV({target:"Number",stat:!0},{isInteger:XV});var gC=Ar,eW=Vt,yC=Kt,tW=id,rW=zc,nW=Kn,iW=Pc.f,bC=yC(iW),aW=yC([].push),sW=gC&&eW(function(){var t=Object.create(null);return t[2]=2,!bC(t,2)}),wC=function(t){return function(e){for(var r=nW(e),n=rW(r),i=sW&&tW(r)===null,a=n.length,s=0,o=[],u;a>s;)u=n[s++],(!gC||(i?u in r:bC(r,u)))&&aW(o,t?[u,r[u]]:r[u]);return o}},oW={entries:wC(!0),values:wC(!1)},uW=er,lW=oW.entries;uW({target:"Object",stat:!0},{entries:function(e){return lW(e)}});/*
815
+ @license
816
+ Copyright (c) 2021 Twilio Inc.
817
+
818
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
819
+
820
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
821
+
822
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
823
+
824
+
825
+ */Object.defineProperty(an,"__esModule",{value:!0});var cW=ui,dW=ud,fW=ld,hW=Oa,pW=sa,vW=ia,mW=aa,gW=li;function ks(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var Gu=ks(cW),Ma=ks(dW),qy=ks(fW),yW=ks(hW),bW=ks(pW),wW=ks(vW),_W=ks(mW),_C=ks(gW),Na=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return{checks:r}},kC=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return Na(function(i){for(var a=!1,s=[],o=0,u=r;o<u.length;o++){var l=u[o];if(typeof l=="string"){a=a||Gu.default(i)===l,s.push("of type ".concat(l));continue}a=a||i instanceof l,s.push("an instance of ".concat(l.name))}return[a,s]})},kW=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return Na(function(i){for(var a=!1,s=[],o=0,u=r;o<u.length;o++){var l=u[o];a=a||i===l,s.push(typeof l=="string"?'"'.concat(l,'"'):"".concat(l))}return[a,s]})};function SW(t){var e=$W();return function(){var n=_C.default(t),i;if(e){var a=_C.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return _W.default(this,i)}}function $W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function cd(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=TW(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
826
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function TW(t,e){if(t){if(typeof t=="string")return SC(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return SC(t,e)}}function SC(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Xh=function(e,r){if(r.length>e.length)throw new Error("Expected at most ".concat(e.length," argument(s), but got ").concat(r.length));for(;r.length<e.length;)r.push(void 0);var n=cd(r.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Ma.default(i.value,2),s=a[0],o=a[1],u=tp(e[s],o),l=Ma.default(u,4),c=l[0],d=l[1],f=l[2],m=l[3];if(!c){var b=s+1;throw new Error("Argument ".concat(b," is expected to be ").concat(f).concat(m," but got ").concat(d))}}}catch(A){n.e(A)}finally{n.f()}},$C=function(e){var r,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(Gu.default(e))&&(n=typeof e=="string"?'"'.concat(e,'"'):"".concat(e)),Gu.default(e)==="object"&&(e==null||(r=e.constructor)===null||r===void 0?void 0:r.name)!=="Object"){var a;n=e===null?"null":"instance of ".concat(e==null||(a=e.constructor)===null||a===void 0?void 0:a.name)}return n||(n=Gu.default(e)),n},EW=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=Vy(r);return function(a){return function(s){wW.default(u,s);var o=SW(u);function u(){bW.default(this,u);for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];return Xh(i,c),o.call.apply(o,[this].concat(c))}return yW.default(u)}(a)}},CW=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=Vy(r);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];return Xh(i,c),u.apply(this,c)}}},RW=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=Vy(r);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];try{Xh(i,c)}catch(f){return Promise.reject(f)}return u.apply(this,c)}}},Vy=function(e){var r=[],n=cd(e),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;r.push(ep(a))}}catch(s){n.e(s)}finally{n.f()}return r},ep=function(e){var r=[],n=Array.isArray(e)?e:[e],i=cd(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){r.push(kC(s));continue}r.push(s)}}catch(o){i.e(o)}finally{i.f()}return r},tp=function(e,r){var n=[],i,a=!1,s=cd(e),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,l=cd(u.checks),c;try{for(l.s();!(c=l.n()).done;){var d=c.value,f=d(r),m=Ma.default(f,3),b=m[0],A=m[1],N=m[2];a=a||b,!i&&N&&(i=N),A&&(n=typeof A=="string"?[].concat(qy.default(n),[A]):[].concat(qy.default(n),qy.default(A)))}}catch(Ie){l.e(Ie)}finally{l.f()}}}catch(Ie){s.e(Ie)}finally{s.f()}if(a)return[!0];var z=i||$C(r),X=n.length-1,Ee=X>0?"".concat(n.slice(0,X).join(", ")," or ").concat(n[X]):n.join(", ");return[!1,z,Ee,X>1?";":","]};function xW(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=IW(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
827
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function IW(t,e){if(t){if(typeof t=="string")return TC(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return TC(t,e)}}function TC(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var AW=function(e,r){return Na(function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(e)];var i=xW(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Ma.default(a.value,2),o=s[0],u=s[1],l=tp(ep(r),u),c=Ma.default(l,3),d=c[0],f=c[1],m=c[2];if(!d)return[!1,"a valid non-empty array of ".concat(e," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(b){i.e(b)}finally{i.f()}return[!0]})},OW=Na(function(t){return[typeof t=="string"&&t.length>0,"a non-empty string"]}),PW=Na(function(t){return[typeof t=="number"&&Number.isInteger(t)&&t>=0,"a non-negative integer"]}),MW=Na(function(t){return[Gu.default(t)==="object"&&t!==null&&!Array.isArray(t),"a pure object (non-null and non-array)"]}),NW=function(e,r){return Na(function(n){if(Gu.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(e," (should be a pure object)")];for(var i=0,a=Object.entries(r);i<a.length;i++){var s=Ma.default(a[i],2),o=s[0],u=s[1],l=tp(ep(u),n[o]),c=Ma.default(l,3),d=c[0],f=c[1],m=c[2];if(!d)return[!1,"valid ".concat(e,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(e,' (key "').concat(o,'" is ').concat(f,")")]}return[!0]})};function LW(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=DW(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
828
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function DW(t,e){if(t){if(typeof t=="string")return EC(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return EC(t,e)}}function EC(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var jW=function(e,r){return Na(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var i=LW(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Ma.default(a.value,2),o=s[0],u=s[1],l=tp(ep(r),u),c=Ma.default(l,3),d=c[0],f=c[1],m=c[2];if(!d)return[!1,"a valid array of ".concat(e," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(b){i.e(b)}finally{i.f()}return[!0]})};an.array=jW,an.custom=Na,an.literal=kW,an.nonEmptyArray=AW,an.nonEmptyString=OW,an.nonNegativeInteger=PW,an.objectSchema=NW,an.pureObject=MW,an.runtimeTypeValidation=Xh,an.stringifyReceivedType=$C,an.type=kC,an.validateConstructorTypes=EW,an.validateTypes=CW,an.validateTypesAsync=RW;var rp={},CC={exports:{}},RC={exports:{}};(function(t){var e=li;function r(n,i){for(;!{}.hasOwnProperty.call(n,i)&&(n=e(n))!==null;);return n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(RC);var UW=RC.exports;(function(t){var e=UW;function r(){return t.exports=r=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,i,a){var s=e(n,i);if(s){var o=Object.getOwnPropertyDescriptor(s,i);return o.get?o.get.call(arguments.length<3?n:a):o.value}},t.exports.__esModule=!0,t.exports.default=t.exports,r.apply(null,arguments)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(CC);var np=CC.exports;/*
829
+ @license
830
+ Copyright (c) 2021 Twilio Inc.
831
+
832
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
833
+
834
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
835
+
836
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
837
+
838
+ */Object.defineProperty(rp,"__esModule",{value:!0});var FW=ld,BW=sa,zW=Oa,HW=ys,qW=np,VW=ia,WW=aa,ZW=li,GW=bs;function La(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var xC=La(FW),KW=La(BW),JW=La(zW),YW=La(HW),Oo=La(qW),QW=La(VW),XW=La(WW),Da=La(ZW),eZ=La(GW),tZ;function Ss(){}Ss.prototype=Object.create(null);function Or(){Or.init.call(this)}Or.EventEmitter=Or,Or.usingDomains=!1,Or.prototype.domain=void 0,Or.prototype._events=void 0,Or.prototype._maxListeners=void 0,Or.defaultMaxListeners=10,Or.init=function(){this.domain=null,Or.usingDomains&&tZ.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new Ss,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Or.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function IC(t){return t._maxListeners===void 0?Or.defaultMaxListeners:t._maxListeners}Or.prototype.getMaxListeners=function(){return IC(this)};function rZ(t,e,r){if(e)t.call(r);else for(var n=t.length,i=dd(t,n),a=0;a<n;++a)i[a].call(r)}function nZ(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=dd(t,i),s=0;s<i;++s)a[s].call(r,n)}function iZ(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=dd(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function aZ(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=dd(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function sZ(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=dd(t,i),s=0;s<i;++s)a[s].apply(r,n)}Or.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:rZ(n,d,this);break;case 2:nZ(n,d,this,arguments[1]);break;case 3:iZ(n,d,this,arguments[1],arguments[2]);break;case 4:aZ(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];sZ(n,d,this,a)}return!0};function AC(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new Ss,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=IC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,oZ(o)}return t}function oZ(t){typeof console.warn=="function"?console.warn(t):console.log(t)}Or.prototype.addListener=function(e,r){return AC(this,e,r,!1)},Or.prototype.on=Or.prototype.addListener,Or.prototype.prependListener=function(e,r){return AC(this,e,r,!0)};function OC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}Or.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,OC(this,e,r)),this},Or.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,OC(this,e,r)),this},Or.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new Ss:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new Ss,this;delete i[e]}else uZ(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},Or.prototype.off=function(t,e){return this.removeListener(t,e)},Or.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new Ss,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new Ss:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new Ss,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},Or.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=lZ(r):n=[]):n=[],n},Or.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):PC.call(t,e)},Or.prototype.listenerCount=PC;function PC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}Or.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function uZ(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function dd(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function lZ(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function cZ(t){var e=dZ();return function(){var n=Da.default(t),i;if(e){var a=Da.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return XW.default(this,i)}}function dZ(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var fZ=function(t){QW.default(r,t);var e=cZ(r);function r(){var n;return KW.default(this,r),n=e.call(this),eZ.default(YW.default(n),"eventHistory",new Map),n}return JW.default(r,[{key:"on",value:function(i,a){return Oo.default(Da.default(r.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return Oo.default(Da.default(r.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return Oo.default(Da.default(r.prototype),"off",this).call(this,i,a)}},{key:"emit",value:function(i){for(var a,s=arguments.length,o=new Array(s>1?s-1:0),u=1;u<s;u++)o[u-1]=arguments[u];return this.eventHistory.set(i,o),(a=Oo.default(Da.default(r.prototype),"emit",this)).call.apply(a,[this,i].concat(o))}},{key:"addListener",value:function(i,a){return Oo.default(Da.default(r.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return Oo.default(Da.default(r.prototype),"removeListener",this).call(this,i,a)}},{key:"addListenerWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0&&a.apply(void 0,xC.default(s)),this.addListener(i,a)}},{key:"onWithReplay",value:function(i,a){return this.addListenerWithReplay(i,a)}},{key:"onceWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0?(a.apply(void 0,xC.default(s)),this):Oo.default(Da.default(r.prototype),"once",this).call(this,i,a)}}]),r}(Or);rp.ReplayEventEmitter=fZ;var ip={exports:{}};ip.exports,function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,o="[object Arguments]",u="[object Array]",l="[object AsyncFunction]",c="[object Boolean]",d="[object Date]",f="[object Error]",m="[object Function]",b="[object GeneratorFunction]",A="[object Map]",N="[object Number]",z="[object Null]",X="[object Object]",Ee="[object Promise]",Ie="[object Proxy]",Fe="[object RegExp]",Oe="[object Set]",ze="[object String]",V="[object Symbol]",xe="[object Undefined]",_e="[object WeakMap]",se="[object ArrayBuffer]",Te="[object DataView]",re="[object Float32Array]",oe="[object Float64Array]",q="[object Int8Array]",ne="[object Int16Array]",Se="[object Int32Array]",H="[object Uint8Array]",ye="[object Uint8ClampedArray]",ke="[object Uint16Array]",M="[object Uint32Array]",Xe=/[\\^$.*+?()[\]{}|]/g,Ct=/^\[object .+?Constructor\]$/,rt=/^(?:0|[1-9]\d*)$/,je={};je[re]=je[oe]=je[q]=je[ne]=je[Se]=je[H]=je[ye]=je[ke]=je[M]=!0,je[o]=je[u]=je[se]=je[c]=je[Te]=je[d]=je[f]=je[m]=je[A]=je[N]=je[X]=je[Fe]=je[Oe]=je[ze]=je[_e]=!1;var ce=typeof ln=="object"&&ln&&ln.Object===Object&&ln,Ke=typeof self=="object"&&self&&self.Object===Object&&self,Be=ce||Ke||Function("return this")(),be=e&&!e.nodeType&&e,pt=be&&!0&&t&&!t.nodeType&&t,Ze=pt&&pt.exports===be,Jt=Ze&&ce.process,At=function(){try{return Jt&&Jt.binding&&Jt.binding("util")}catch{}}(),Q=At&&At.isTypedArray;function Ue(F,ve){for(var We=-1,wt=F==null?0:F.length,Nr=0,Yt=[];++We<wt;){var zr=F[We];ve(zr,We,F)&&(Yt[Nr++]=zr)}return Yt}function ot(F,ve){for(var We=-1,wt=ve.length,Nr=F.length;++We<wt;)F[Nr+We]=ve[We];return F}function Pe(F,ve){for(var We=-1,wt=F==null?0:F.length;++We<wt;)if(ve(F[We],We,F))return!0;return!1}function St(F,ve){for(var We=-1,wt=Array(F);++We<F;)wt[We]=ve(We);return wt}function ut(F){return function(ve){return F(ve)}}function or(F,ve){return F.has(ve)}function br(F,ve){return F==null?void 0:F[ve]}function et(F){var ve=-1,We=Array(F.size);return F.forEach(function(wt,Nr){We[++ve]=[Nr,wt]}),We}function Mr(F,ve){return function(We){return F(ve(We))}}function Fr(F){var ve=-1,We=Array(F.size);return F.forEach(function(wt){We[++ve]=wt}),We}var dr=Array.prototype,fr=Function.prototype,Wt=Object.prototype,Ot=Be["__core-js_shared__"],L=fr.toString,W=Wt.hasOwnProperty,ie=function(){var F=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return F?"Symbol(src)_1."+F:""}(),He=Wt.toString,ct=RegExp("^"+L.call(W).replace(Xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bt=Ze?Be.Buffer:void 0,zt=Be.Symbol,tr=Be.Uint8Array,Re=Wt.propertyIsEnumerable,Ne=dr.splice,pe=zt?zt.toStringTag:void 0,$e=Object.getOwnPropertySymbols,ae=bt?bt.isBuffer:void 0,me=Mr(Object.keys,Object),we=Ve(Be,"DataView"),K=Ve(Be,"Map"),he=Ve(Be,"Promise"),G=Ve(Be,"Set"),de=Ve(Be,"WeakMap"),ee=Ve(Object,"create"),Ye=T(we),qe=T(K),dt=T(he),lt=T(G),ht=T(de),Rt=zt?zt.prototype:void 0,xt=Rt?Rt.valueOf:void 0;function kt(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function $t(){this.__data__=ee?ee(null):{},this.size=0}function It(F){var ve=this.has(F)&&delete this.__data__[F];return this.size-=ve?1:0,ve}function jt(F){var ve=this.__data__;if(ee){var We=ve[F];return We===n?void 0:We}return W.call(ve,F)?ve[F]:void 0}function on(F){var ve=this.__data__;return ee?ve[F]!==void 0:W.call(ve,F)}function _n(F,ve){var We=this.__data__;return this.size+=this.has(F)?0:1,We[F]=ee&&ve===void 0?n:ve,this}kt.prototype.clear=$t,kt.prototype.delete=It,kt.prototype.get=jt,kt.prototype.has=on,kt.prototype.set=_n;function Ut(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function qn(){this.__data__=[],this.size=0}function pa(F){var ve=this.__data__,We=Dr(ve,F);if(We<0)return!1;var wt=ve.length-1;return We==wt?ve.pop():Ne.call(ve,We,1),--this.size,!0}function Za(F){var ve=this.__data__,We=Dr(ve,F);return We<0?void 0:ve[We][1]}function ti(F){return Dr(this.__data__,F)>-1}function va(F,ve){var We=this.__data__,wt=Dr(We,F);return wt<0?(++this.size,We.push([F,ve])):We[wt][1]=ve,this}Ut.prototype.clear=qn,Ut.prototype.delete=pa,Ut.prototype.get=Za,Ut.prototype.has=ti,Ut.prototype.set=va;function ri(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function gi(){this.size=0,this.__data__={hash:new kt,map:new(K||Ut),string:new kt}}function Ga(F){var ve=Ae(this,F).delete(F);return this.size-=ve?1:0,ve}function en(F){return Ae(this,F).get(F)}function ji(F){return Ae(this,F).has(F)}function Ns(F,ve){var We=Ae(this,F),wt=We.size;return We.set(F,ve),this.size+=We.size==wt?0:1,this}ri.prototype.clear=gi,ri.prototype.delete=Ga,ri.prototype.get=en,ri.prototype.has=ji,ri.prototype.set=Ns;function Ui(F){var ve=-1,We=F==null?0:F.length;for(this.__data__=new ri;++ve<We;)this.add(F[ve])}function Ls(F){return this.__data__.set(F,n),this}function zo(F){return this.__data__.has(F)}Ui.prototype.add=Ui.prototype.push=Ls,Ui.prototype.has=zo;function Vn(F){var ve=this.__data__=new Ut(F);this.size=ve.size}function Ds(){this.__data__=new Ut,this.size=0}function Ho(F){var ve=this.__data__,We=ve.delete(F);return this.size=ve.size,We}function qo(F){return this.__data__.get(F)}function hn(F){return this.__data__.has(F)}function js(F,ve){var We=this.__data__;if(We instanceof Ut){var wt=We.__data__;if(!K||wt.length<r-1)return wt.push([F,ve]),this.size=++We.size,this;We=this.__data__=new ri(wt)}return We.set(F,ve),this.size=We.size,this}Vn.prototype.clear=Ds,Vn.prototype.delete=Ho,Vn.prototype.get=qo,Vn.prototype.has=hn,Vn.prototype.set=js;function Pn(F,ve){var We=P(F),wt=!We&&U(F),Nr=!We&&!wt&&Ce(F),Yt=!We&&!wt&&!Nr&&tn(F),zr=We||wt||Nr||Yt,Jr=zr?St(F.length,String):[],un=Jr.length;for(var Nt in F)W.call(F,Nt)&&!(zr&&(Nt=="length"||Nr&&(Nt=="offset"||Nt=="parent")||Yt&&(Nt=="buffer"||Nt=="byteLength"||Nt=="byteOffset")||Nn(Nt,un)))&&Jr.push(Nt);return Jr}function Dr(F,ve){for(var We=F.length;We--;)if($(F[We][0],ve))return We;return-1}function Vo(F,ve,We){var wt=ve(F);return P(F)?wt:ot(wt,We(F))}function ni(F){return F==null?F===void 0?xe:z:pe&&pe in Object(F)?at(F):E(F)}function Mn(F){return Fi(F)&&ni(F)==o}function Us(F,ve,We,wt,Nr){return F===ve?!0:F==null||ve==null||!Fi(F)&&!Fi(ve)?F!==F&&ve!==ve:te(F,ve,We,wt,Us,Nr)}function te(F,ve,We,wt,Nr,Yt){var zr=P(F),Jr=P(ve),un=zr?u:Br(F),Nt=Jr?u:Br(ve);un=un==o?X:un,Nt=Nt==o?X:Nt;var Sn=un==X,$n=Nt==X,pn=un==Nt;if(pn&&Ce(F)){if(!Ce(ve))return!1;zr=!0,Sn=!1}if(pn&&!Sn)return Yt||(Yt=new Vn),zr||tn(F)?R(F,ve,We,wt,Nr,Yt):Z(F,ve,un,We,wt,Nr,Yt);if(!(We&i)){var Wn=Sn&&W.call(F,"__wrapped__"),Zt=$n&&W.call(ve,"__wrapped__");if(Wn||Zt){var ma=Wn?F.value():F,C=Zt?ve.value():ve;return Yt||(Yt=new Vn),Nr(ma,C,We,wt,Yt)}}return pn?(Yt||(Yt=new Vn),j(F,ve,We,wt,Nr,Yt)):!1}function ue(F){if(!vn(F)||D(F))return!1;var ve=it(F)?ct:Ct;return ve.test(T(F))}function I(F){return Fi(F)&&Pt(F.length)&&!!je[ni(F)]}function O(F){if(!B(F))return me(F);var ve=[];for(var We in Object(F))W.call(F,We)&&We!="constructor"&&ve.push(We);return ve}function R(F,ve,We,wt,Nr,Yt){var zr=We&i,Jr=F.length,un=ve.length;if(Jr!=un&&!(zr&&un>Jr))return!1;var Nt=Yt.get(F);if(Nt&&Yt.get(ve))return Nt==ve;var Sn=-1,$n=!0,pn=We&a?new Ui:void 0;for(Yt.set(F,ve),Yt.set(ve,F);++Sn<Jr;){var Wn=F[Sn],Zt=ve[Sn];if(wt)var ma=zr?wt(Zt,Wn,Sn,ve,F,Yt):wt(Wn,Zt,Sn,F,ve,Yt);if(ma!==void 0){if(ma)continue;$n=!1;break}if(pn){if(!Pe(ve,function(C,x){if(!or(pn,x)&&(Wn===C||Nr(Wn,C,We,wt,Yt)))return pn.push(x)})){$n=!1;break}}else if(!(Wn===Zt||Nr(Wn,Zt,We,wt,Yt))){$n=!1;break}}return Yt.delete(F),Yt.delete(ve),$n}function Z(F,ve,We,wt,Nr,Yt,zr){switch(We){case Te:if(F.byteLength!=ve.byteLength||F.byteOffset!=ve.byteOffset)return!1;F=F.buffer,ve=ve.buffer;case se:return!(F.byteLength!=ve.byteLength||!Yt(new tr(F),new tr(ve)));case c:case d:case N:return $(+F,+ve);case f:return F.name==ve.name&&F.message==ve.message;case Fe:case ze:return F==ve+"";case A:var Jr=et;case Oe:var un=wt&i;if(Jr||(Jr=Fr),F.size!=ve.size&&!un)return!1;var Nt=zr.get(F);if(Nt)return Nt==ve;wt|=a,zr.set(F,ve);var Sn=R(Jr(F),Jr(ve),wt,Nr,Yt,zr);return zr.delete(F),Sn;case V:if(xt)return xt.call(F)==xt.call(ve)}return!1}function j(F,ve,We,wt,Nr,Yt){var zr=We&i,Jr=Le(F),un=Jr.length,Nt=Le(ve),Sn=Nt.length;if(un!=Sn&&!zr)return!1;for(var $n=un;$n--;){var pn=Jr[$n];if(!(zr?pn in ve:W.call(ve,pn)))return!1}var Wn=Yt.get(F);if(Wn&&Yt.get(ve))return Wn==ve;var Zt=!0;Yt.set(F,ve),Yt.set(ve,F);for(var ma=zr;++$n<un;){pn=Jr[$n];var C=F[pn],x=ve[pn];if(wt)var w=zr?wt(x,C,pn,ve,F,Yt):wt(C,x,pn,F,ve,Yt);if(!(w===void 0?C===x||Nr(C,x,We,wt,Yt):w)){Zt=!1;break}ma||(ma=pn=="constructor")}if(Zt&&!ma){var p=F.constructor,h=ve.constructor;p!=h&&"constructor"in F&&"constructor"in ve&&!(typeof p=="function"&&p instanceof p&&typeof h=="function"&&h instanceof h)&&(Zt=!1)}return Yt.delete(F),Yt.delete(ve),Zt}function Le(F){return Vo(F,Bi,Tt)}function Ae(F,ve){var We=F.__data__;return kn(ve)?We[typeof ve=="string"?"string":"hash"]:We.map}function Ve(F,ve){var We=br(F,ve);return ue(We)?We:void 0}function at(F){var ve=W.call(F,pe),We=F[pe];try{F[pe]=void 0;var wt=!0}catch{}var Nr=He.call(F);return wt&&(ve?F[pe]=We:delete F[pe]),Nr}var Tt=$e?function(F){return F==null?[]:(F=Object(F),Ue($e(F),function(ve){return Re.call(F,ve)}))}:ev,Br=ni;(we&&Br(new we(new ArrayBuffer(1)))!=Te||K&&Br(new K)!=A||he&&Br(he.resolve())!=Ee||G&&Br(new G)!=Oe||de&&Br(new de)!=_e)&&(Br=function(F){var ve=ni(F),We=ve==X?F.constructor:void 0,wt=We?T(We):"";if(wt)switch(wt){case Ye:return Te;case qe:return A;case dt:return Ee;case lt:return Oe;case ht:return _e}return ve});function Nn(F,ve){return ve=ve??s,!!ve&&(typeof F=="number"||rt.test(F))&&F>-1&&F%1==0&&F<ve}function kn(F){var ve=typeof F;return ve=="string"||ve=="number"||ve=="symbol"||ve=="boolean"?F!=="__proto__":F===null}function D(F){return!!ie&&ie in F}function B(F){var ve=F&&F.constructor,We=typeof ve=="function"&&ve.prototype||Wt;return F===We}function E(F){return He.call(F)}function T(F){if(F!=null){try{return L.call(F)}catch{}try{return F+""}catch{}}return""}function $(F,ve){return F===ve||F!==F&&ve!==ve}var U=Mn(function(){return arguments}())?Mn:function(F){return Fi(F)&&W.call(F,"callee")&&!Re.call(F,"callee")},P=Array.isArray;function Me(F){return F!=null&&Pt(F.length)&&!it(F)}var Ce=ae||Kw;function Qe(F,ve){return Us(F,ve)}function it(F){if(!vn(F))return!1;var ve=ni(F);return ve==m||ve==b||ve==l||ve==Ie}function Pt(F){return typeof F=="number"&&F>-1&&F%1==0&&F<=s}function vn(F){var ve=typeof F;return F!=null&&(ve=="object"||ve=="function")}function Fi(F){return F!=null&&typeof F=="object"}var tn=Q?ut(Q):I;function Bi(F){return Me(F)?Pn(F):O(F)}function ev(){return[]}function Kw(){return!1}t.exports=Qe}(ip,ip.exports);var hZ=ip.exports,MC={exports:{}},pZ=Vt,vZ=pZ(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}),mZ=Vt,gZ=Lr,yZ=Qi,NC=vZ,ap=Object.isExtensible,bZ=mZ(function(){ap(1)}),wZ=bZ||NC?function(e){return!gZ(e)||NC&&yZ(e)==="ArrayBuffer"?!1:ap?ap(e):!0}:ap,_Z=Vt,LC=!_Z(function(){return Object.isExtensible(Object.preventExtensions({}))}),kZ=er,SZ=Kt,$Z=Dc,TZ=Lr,Wy=Vr,EZ=Cn.f,DC=So,CZ=fg,Zy=wZ,RZ=Nc,xZ=LC,jC=!1,ja=RZ("meta"),IZ=0,Gy=function(t){EZ(t,ja,{value:{objectID:"O"+IZ++,weakData:{}}})},AZ=function(t,e){if(!TZ(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!Wy(t,ja)){if(!Zy(t))return"F";if(!e)return"E";Gy(t)}return t[ja].objectID},OZ=function(t,e){if(!Wy(t,ja)){if(!Zy(t))return!0;if(!e)return!1;Gy(t)}return t[ja].weakData},PZ=function(t){return xZ&&jC&&Zy(t)&&!Wy(t,ja)&&Gy(t),t},MZ=function(){NZ.enable=function(){},jC=!0;var t=DC.f,e=SZ([].splice),r={};r[ja]=1,t(r).length&&(DC.f=function(n){for(var i=t(n),a=0,s=i.length;a<s;a++)if(i[a]===ja){e(i,a,1);break}return i},kZ({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:CZ.f}))},NZ=MC.exports={enable:MZ,fastKey:AZ,getWeakData:OZ,onFreeze:PZ};$Z[ja]=!0;var sp=MC.exports,LZ=er,DZ=cr,jZ=Kt,UC=lh,UZ=Rn,FZ=sp,BZ=nd,zZ=ws,HZ=Cr,qZ=xi,Ky=Lr,Jy=Vt,VZ=Dh,WZ=ta,ZZ=zh,Yy=function(t,e,r){var n=t.indexOf("Map")!==-1,i=t.indexOf("Weak")!==-1,a=n?"set":"add",s=DZ[t],o=s&&s.prototype,u=s,l={},c=function(z){var X=jZ(o[z]);UZ(o,z,z==="add"?function(Ie){return X(this,Ie===0?0:Ie),this}:z==="delete"?function(Ee){return i&&!Ky(Ee)?!1:X(this,Ee===0?0:Ee)}:z==="get"?function(Ie){return i&&!Ky(Ie)?void 0:X(this,Ie===0?0:Ie)}:z==="has"?function(Ie){return i&&!Ky(Ie)?!1:X(this,Ie===0?0:Ie)}:function(Ie,Fe){return X(this,Ie===0?0:Ie,Fe),this})},d=UC(t,!HZ(s)||!(i||o.forEach&&!Jy(function(){new s().entries().next()})));if(d)u=r.getConstructor(e,t,n,a),FZ.enable();else if(UC(t,!0)){var f=new u,m=f[a](i?{}:-0,1)!==f,b=Jy(function(){f.has(1)}),A=VZ(function(z){new s(z)}),N=!i&&Jy(function(){for(var z=new s,X=5;X--;)z[a](X,X);return!z.has(-0)});A||(u=e(function(z,X){zZ(z,o);var Ee=ZZ(new s,z,u);return qZ(X)||BZ(X,Ee[a],{that:Ee,AS_ENTRIES:n}),Ee}),u.prototype=o,o.constructor=u),(b||N)&&(c("delete"),c("has"),n&&c("get")),(N||m)&&c(a),i&&o.clear&&delete o.clear}return l[t]=u,LZ({global:!0,constructor:!0,forced:u!==s},l),WZ(u,t),i||r.setStrong(u,t,n),u},GZ=Rn,op=function(t,e,r){for(var n in e)GZ(t,n,e[n],r);return t},FC=vs,KZ=na,BC=op,JZ=Ia,YZ=ws,QZ=xi,XZ=nd,eG=py,up=Fh,tG=Sh,fd=Ar,zC=sp.fastKey,HC=Jn,qC=HC.set,Qy=HC.getterFor,VC={getConstructor:function(t,e,r,n){var i=t(function(l,c){YZ(l,a),qC(l,{type:e,index:FC(null),first:void 0,last:void 0,size:0}),fd||(l.size=0),QZ(c)||XZ(c,l[n],{that:l,AS_ENTRIES:r})}),a=i.prototype,s=Qy(e),o=function(l,c,d){var f=s(l),m=u(l,c),b,A;return m?m.value=d:(f.last=m={index:A=zC(c,!0),key:c,value:d,previous:b=f.last,next:void 0,removed:!1},f.first||(f.first=m),b&&(b.next=m),fd?f.size++:l.size++,A!=="F"&&(f.index[A]=m)),l},u=function(l,c){var d=s(l),f=zC(c),m;if(f!=="F")return d.index[f];for(m=d.first;m;m=m.next)if(m.key===c)return m};return BC(a,{clear:function(){for(var c=this,d=s(c),f=d.first;f;)f.removed=!0,f.previous&&(f.previous=f.previous.next=void 0),f=f.next;d.first=d.last=void 0,d.index=FC(null),fd?d.size=0:c.size=0},delete:function(l){var c=this,d=s(c),f=u(c,l);if(f){var m=f.next,b=f.previous;delete d.index[f.index],f.removed=!0,b&&(b.next=m),m&&(m.previous=b),d.first===f&&(d.first=m),d.last===f&&(d.last=b),fd?d.size--:c.size--}return!!f},forEach:function(c){for(var d=s(this),f=JZ(c,arguments.length>1?arguments[1]:void 0),m;m=m?m.next:d.first;)for(f(m.value,m.key,this);m&&m.removed;)m=m.previous},has:function(c){return!!u(this,c)}}),BC(a,r?{get:function(c){var d=u(this,c);return d&&d.value},set:function(c,d){return o(this,c===0?0:c,d)}}:{add:function(c){return o(this,c=c===0?0:c,c)}}),fd&&KZ(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(t,e,r){var n=e+" Iterator",i=Qy(e),a=Qy(n);eG(t,e,function(s,o){qC(this,{type:n,target:s,state:i(s),kind:o,last:void 0})},function(){for(var s=a(this),o=s.kind,u=s.last;u&&u.removed;)u=u.previous;return!s.target||!(s.last=u=u?u.next:s.state.first)?(s.target=void 0,up(void 0,!0)):up(o==="keys"?u.key:o==="values"?u.value:[u.key,u.value],!1)},r?"entries":"values",!r,!0),tG(e)}},rG=Yy,nG=VC;rG("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},nG);var oa={};/*
839
+ @license
840
+ Copyright (c) 2016, Twilio, Inc.
841
+
842
+ Permission to use, copy, modify, and/or distribute this software for any
843
+ purpose with or without fee is hereby granted, provided that the above
844
+ copyright notice and this permission notice appear in all copies.
845
+
846
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
847
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
848
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
849
+ SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
850
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
851
+ OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
852
+ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
853
+
854
+ */Object.defineProperty(oa,"__esModule",{value:!0});var iG=sa,aG=Oa,sG=ys,oG=ia,uG=aa,lG=li,cG=bs;function Po(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var Xy=Po(iG),eb=Po(aG),Ua=Po(sG),tb=Po(oG),WC=Po(uG),lp=Po(lG),Fa=Po(cG),dG;function $s(){}$s.prototype=Object.create(null);function kr(){kr.init.call(this)}kr.EventEmitter=kr,kr.usingDomains=!1,kr.prototype.domain=void 0,kr.prototype._events=void 0,kr.prototype._maxListeners=void 0,kr.defaultMaxListeners=10,kr.init=function(){this.domain=null,kr.usingDomains&&dG.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new $s,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function ZC(t){return t._maxListeners===void 0?kr.defaultMaxListeners:t._maxListeners}kr.prototype.getMaxListeners=function(){return ZC(this)};function fG(t,e,r){if(e)t.call(r);else for(var n=t.length,i=hd(t,n),a=0;a<n;++a)i[a].call(r)}function hG(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=hd(t,i),s=0;s<i;++s)a[s].call(r,n)}function pG(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=hd(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function vG(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=hd(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function mG(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=hd(t,i),s=0;s<i;++s)a[s].apply(r,n)}kr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:fG(n,d,this);break;case 2:hG(n,d,this,arguments[1]);break;case 3:pG(n,d,this,arguments[1],arguments[2]);break;case 4:vG(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];mG(n,d,this,a)}return!0};function GC(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new $s,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=ZC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,gG(o)}return t}function gG(t){typeof console.warn=="function"?console.warn(t):console.log(t)}kr.prototype.addListener=function(e,r){return GC(this,e,r,!1)},kr.prototype.on=kr.prototype.addListener,kr.prototype.prependListener=function(e,r){return GC(this,e,r,!0)};function KC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}kr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,KC(this,e,r)),this},kr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,KC(this,e,r)),this},kr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new $s:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new $s,this;delete i[e]}else yG(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},kr.prototype.off=function(t,e){return this.removeListener(t,e)},kr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new $s,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new $s:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new $s,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},kr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=bG(r):n=[]):n=[],n},kr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):JC.call(t,e)},kr.prototype.listenerCount=JC;function JC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}kr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function yG(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function hd(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function bG(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function YC(t){var e=wG();return function(){var n=lp.default(t),i;if(e){var a=lp.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return WC.default(this,i)}}function wG(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var QC=function(t){tb.default(r,t);var e=YC(r);function r(n){var i;return Xy.default(this,r),i=e.call(this),Fa.default(Ua.default(i),"timeout",null),Fa.default(Ua.default(i),"startTimestamp",-1),i.minDelay=n.min,i.maxDelay=n.max,i.initialDelay=n.initial||0,i.maxAttemptsCount=n.maxAttemptsCount||0,i.maxAttemptsTime=n.maxAttemptsTime||0,i.randomness=n.randomness||0,i.inProgress=!1,i.attemptNum=0,i.prevDelay=0,i.currDelay=0,i}return eb.default(r,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(i){if(typeof i=="number")return this.prevDelay=0,this.currDelay=i,i;if(this.attemptNum==0)return this.initialDelay;if(this.attemptNum==1)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var a=this.currDelay+this.prevDelay;return this.maxDelay&&a>this.maxDelay&&(this.currDelay=this.maxDelay,a=this.maxDelay),this.currDelay=a,a}},{key:"randomize",value:function(i){var a=i*this.randomness,s=Math.round(Math.random()*a*2-a);return Math.max(0,i+s)}},{key:"scheduleAttempt",value:function(i){var a=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount){this.cleanup(),this.emit("failed",new Error("Maximum attempt count limit reached"));return}var s=this.nextDelay(i);if(s=this.randomize(s),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+s){this.cleanup(),this.emit("failed",new Error("Maximum attempt time limit reached"));return}this.timeout=setTimeout(function(){return a.attempt()},s)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(i){this.emit("succeeded",i)}},{key:"failed",value:function(i,a){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(a)}}]),r}(kr),_G=function(t){tb.default(r,t);var e=YC(r);function r(n){var i;return Xy.default(this,r),i=e.call(this),Fa.default(Ua.default(i),"resolve",function(){}),Fa.default(Ua.default(i),"reject",function(){}),i.retrier=new QC(n),i}return eb.default(r,[{key:"run",value:function(i){var a=this;return this.retrier.on("attempt",function(){i().then(function(s){return a.retrier.succeeded(s)}).catch(function(s){return a.retrier.failed(s)})}),this.retrier.on("succeeded",function(s){return a.resolve(s)}),this.retrier.on("cancelled",function(){return a.reject(new Error("Cancelled"))}),this.retrier.on("failed",function(s){return a.reject(s)}),new Promise(function(s,o){a.resolve=s,a.reject=o,a.retrier.start()})}},{key:"cancel",value:function(){this.retrier.cancel()}}]),r}(kr);function kG(t){var e=SG();return function(){var n=lp.default(t),i;if(e){var a=lp.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return WC.default(this,i)}}function SG(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function cp(t){return t!=null}var $G=function(t){tb.default(r,t);var e=kG(r);function r(n){var i;Xy.default(this,r),i=e.call(this),Fa.default(Ua.default(i),"backoffDelay",0),Fa.default(Ua.default(i),"nextBackoffDelay",0),Fa.default(Ua.default(i),"backoffNumber",0),Fa.default(Ua.default(i),"timeoutID",null),Fa.default(Ua.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,o=a.maxDelay,u=a.randomisationFactor,l=a.factor;if(cp(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(cp(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(cp(u)&&(u<0||u>1))throw new Error("The randomisation factor must be between 0 and 1.");if(cp(l)&&l<=1)throw new Error("Exponential factor should be greater than 1.");if(i.initialDelay=s||100,i.maxDelay=o||1e4,i.maxDelay<=i.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return i.randomisationFactor=u||0,i.factor=l||2,i.reset(),i}return eb.default(r,[{key:"backoff",value:function(i){this.timeoutID==null&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",i),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,i)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(i){if(i<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(i));this.maxNumberOfRetry=i}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var i=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*i))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(i){return new r(i)}}]),r}(kr);oa.AsyncRetrier=_G,oa.Backoff=$G,oa.Retrier=QC;var rb={},TG=Er,EG=Vr,CG=Ea,RG=DE,XC=RegExp.prototype,xG=function(t){var e=t.flags;return e===void 0&&!("flags"in XC)&&!EG(t,"flags")&&CG(XC,t)?TG(RG,t):e},IG=Lc.PROPER,AG=Rn,OG=Gr,eR=nn,PG=Vt,MG=xG,nb="toString",tR=RegExp.prototype,rR=tR[nb],NG=PG(function(){return rR.call({source:"a",flags:"b"})!=="/a/b"}),LG=IG&&rR.name!==nb;(NG||LG)&&AG(tR,nb,function(){var e=OG(this),r=eR(e.source),n=eR(MG(e));return"/"+r+"/"+n},{unsafe:!0});var DG=Yy,jG=VC;DG("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},jG);var nR={exports:{}};(function(t,e){(function(n,i){t.exports=i()})(ln,function(){return function(r){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return r[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=r,i.c=n,i.i=function(a){return a},i.d=function(a,s,o){i.o(a,s)||Object.defineProperty(a,s,{configurable:!1,enumerable:!0,get:o})},i.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return i.d(s,"a",s),s},i.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},i.p="",i(i.s=5)}([function(r,n,i){r.exports=function(a,s){var o,u,l;for(o=1;o<arguments.length;o++){u=arguments[o];for(l in u)u.hasOwnProperty(l)&&(a[l]=u[l])}return a}},function(r,n,i){var a=i(0);r.exports={build:function(s,o){var u,l,c,d=o.plugins;for(u=0,l=d.length;u<l;u++)c=d[u],c.methods&&a(s,c.methods),c.properties&&Object.defineProperties(s,c.properties)},hook:function(s,o,u){var l,c,d,f,m=s.config.plugins,b=[s.context];for(u&&(b=b.concat(u)),l=0,c=m.length;l<c;l++)f=m[l],d=m[l][o],d&&d.apply(f,b)}}},function(r,n,i){function a(s){if(s.length===0)return s;var o,u,l=s.split(/[_-]/);if(l.length===1&&l[0][0].toLowerCase()===l[0][0])return s;for(u=l[0].toLowerCase(),o=1;o<l.length;o++)u=u+l[o].charAt(0).toUpperCase()+l[o].substring(1).toLowerCase();return u}a.prepended=function(s,o){return o=a(o),s+o[0].toUpperCase()+o.substring(1)},r.exports=a},function(r,n,i){var a=i(0),s=i(2);function o(u,l){u=u||{},this.options=u,this.defaults=l.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(u.init),this.data=this.configureData(u.data),this.methods=this.configureMethods(u.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(u.transitions||[]),this.plugins=this.configurePlugins(u.plugins,l.plugin)}a(o.prototype,{addState:function(u){this.map[u]||(this.states.push(u),this.addStateLifecycleNames(u),this.map[u]={})},addStateLifecycleNames:function(u){this.lifecycle.onEnter[u]=s.prepended("onEnter",u),this.lifecycle.onLeave[u]=s.prepended("onLeave",u),this.lifecycle.on[u]=s.prepended("on",u)},addTransition:function(u){this.transitions.indexOf(u)<0&&(this.transitions.push(u),this.addTransitionLifecycleNames(u))},addTransitionLifecycleNames:function(u){this.lifecycle.onBefore[u]=s.prepended("onBefore",u),this.lifecycle.onAfter[u]=s.prepended("onAfter",u),this.lifecycle.on[u]=s.prepended("on",u)},mapTransition:function(u){var l=u.name,c=u.from,d=u.to;return this.addState(c),typeof d!="function"&&this.addState(d),this.addTransition(l),this.map[c][l]=u,u},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(u){return typeof u=="string"?this.mapTransition(a({},this.defaults.init,{to:u,active:!0})):typeof u=="object"?this.mapTransition(a({},this.defaults.init,u,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(u){return typeof u=="function"?u:typeof u=="object"?function(){return u}:function(){return{}}},configureMethods:function(u){return u||{}},configurePlugins:function(u,l){u=u||[];var c,d,f;for(c=0,d=u.length;c<d;c++)f=u[c],typeof f=="function"&&(u[c]=f=f()),f.configure&&f.configure(this);return u},configureTransitions:function(u){var l,c,d,f,m,b=this.defaults.wildcard;for(c=0;c<u.length;c++)for(d=u[c],f=Array.isArray(d.from)?d.from:[d.from||b],m=d.to||b,l=0;l<f.length;l++)this.mapTransition({name:d.name,from:f[l],to:m})},transitionFor:function(u,l){var c=this.defaults.wildcard;return this.map[u][l]||this.map[c][l]},transitionsFor:function(u){var l=this.defaults.wildcard;return Object.keys(this.map[u]).concat(Object.keys(this.map[l]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),r.exports=o},function(r,n,i){var a=i(0),s=i(6),o=i(1),u=[null,[]];function l(c,d){this.context=c,this.config=d,this.state=d.init.from,this.observers=[c]}a(l.prototype,{init:function(c){if(a(this.context,this.config.data.apply(this.context,c)),o.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(c){return Array.isArray(c)?c.indexOf(this.state)>=0:this.state===c},isPending:function(){return this.pending},can:function(c){return!this.isPending()&&!!this.seek(c)},cannot:function(c){return!this.can(c)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(c,d){var f=this.config.defaults.wildcard,m=this.config.transitionFor(this.state,c),b=m&&m.to;return typeof b=="function"?b.apply(this.context,d):b===f?this.state:b},fire:function(c,d){return this.transit(c,this.state,this.seek(c,d),d)},transit:function(c,d,f,m){var b=this.config.lifecycle,A=this.config.options.observeUnchangedState||d!==f;return f?this.isPending()?this.context.onPendingTransition(c,d,f):(this.config.addState(f),this.beginTransit(),m.unshift({transition:c,from:d,to:f,fsm:this.context}),this.observeEvents([this.observersForEvent(b.onBefore.transition),this.observersForEvent(b.onBefore[c]),A?this.observersForEvent(b.onLeave.state):u,A?this.observersForEvent(b.onLeave[d]):u,this.observersForEvent(b.on.transition),A?["doTransit",[this]]:u,A?this.observersForEvent(b.onEnter.state):u,A?this.observersForEvent(b.onEnter[f]):u,A?this.observersForEvent(b.on[f]):u,this.observersForEvent(b.onAfter.transition),this.observersForEvent(b.onAfter[c]),this.observersForEvent(b.on[c])],m)):this.context.onInvalidTransition(c,d,f)},beginTransit:function(){this.pending=!0},endTransit:function(c){return this.pending=!1,c},failTransit:function(c){throw this.pending=!1,c},doTransit:function(c){this.state=c.to},observe:function(c){if(c.length===2){var d={};d[c[0]]=c[1],this.observers.push(d)}else this.observers.push(c[0])},observersForEvent:function(c){for(var d=0,f=this.observers.length,m,b=[];d<f;d++)m=this.observers[d],m[c]&&b.push(m);return[c,b,!0]},observeEvents:function(c,d,f,m){if(c.length===0)return this.endTransit(m===void 0?!0:m);var b=c[0][0],A=c[0][1],N=c[0][2];if(d[0].event=b,b&&N&&b!==f&&o.hook(this,"lifecycle",d),A.length===0)return c.shift(),this.observeEvents(c,d,b,m);var z=A.shift(),X=z[b].apply(z,d);return X&&typeof X.then=="function"?X.then(this.observeEvents.bind(this,c,d,b)).catch(this.failTransit.bind(this)):X===!1?this.endTransit(!1):this.observeEvents(c,d,b,X)},onInvalidTransition:function(c,d,f){throw new s("transition is invalid in current state",c,d,f,this.state)},onPendingTransition:function(c,d,f){throw new s("transition is invalid while previous transition is still in progress",c,d,f,this.state)}}),r.exports=l},function(r,n,i){var a=i(0),s=i(2),o=i(1),u=i(3),l=i(4),c={is:function(N){return this._fsm.is(N)},can:function(N){return this._fsm.can(N)},cannot:function(N){return this._fsm.cannot(N)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(N,z,X){return this._fsm.onInvalidTransition(N,z,X)},onPendingTransition:function(N,z,X){return this._fsm.onPendingTransition(N,z,X)}},d={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(N){throw Error("use transitions to change state")}}};function f(N){return b(this||{},N)}function m(){var N,z;typeof arguments[0]=="function"?(N=arguments[0],z=arguments[1]||{}):(N=function(){this._fsm.apply(this,arguments)},z=arguments[0]||{});var X=new u(z,f);return A(N.prototype,X),N.prototype._fsm.config=X,N}function b(N,z){var X=new u(z,f);return A(N,X),N._fsm(),N}function A(N,z){if(typeof N!="object"||Array.isArray(N))throw Error("StateMachine can only be applied to objects");o.build(N,z),Object.defineProperties(N,d),a(N,c),a(N,z.methods),z.allTransitions().forEach(function(X){N[s(X)]=function(){return this._fsm.fire(X,[].slice.call(arguments))}}),N._fsm=function(){this._fsm=new l(this,z),this._fsm.init(arguments)}}f.version="3.0.1",f.factory=m,f.apply=b,f.defaults={wildcard:"*",init:{name:"init",from:"none"}},r.exports=f},function(r,n,i){r.exports=function(a,s,o,u,l){this.message=a,this.transition=s,this.from=o,this.to=u,this.current=l}}])})})(nR);var iR=nR.exports,ib={exports:{}},aR=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(aR){var sR=new Uint8Array(16);ib.exports=function(){return aR(sR),sR}}else{var oR=new Array(16);ib.exports=function(){for(var e=0,r;e<16;e++)e&3||(r=Math.random()*4294967296),oR[e]=r>>>((e&3)<<3)&255;return oR}}for(var uR=ib.exports,lR=[],dp=0;dp<256;++dp)lR[dp]=(dp+256).toString(16).substr(1);function UG(t,e){var r=e||0,n=lR;return[n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]]].join("")}var cR=UG,FG=uR,BG=cR,dR,ab,sb=0,ob=0;function zG(t,e,r){var n=e&&r||0,i=e||[];t=t||{};var a=t.node||dR,s=t.clockseq!==void 0?t.clockseq:ab;if(a==null||s==null){var o=FG();a==null&&(a=dR=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=ab=(o[6]<<8|o[7])&16383)}var u=t.msecs!==void 0?t.msecs:new Date().getTime(),l=t.nsecs!==void 0?t.nsecs:ob+1,c=u-sb+(l-ob)/1e4;if(c<0&&t.clockseq===void 0&&(s=s+1&16383),(c<0||u>sb)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");sb=u,ob=l,ab=s,u+=122192928e5;var d=((u&268435455)*1e4+l)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=d&255;var f=u/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=f&255,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return e||BG(i)}var HG=zG,qG=uR,VG=cR;function WG(t,e,r){var n=e&&r||0;typeof t=="string"&&(e=t==="binary"?new Array(16):null,t=null),t=t||{};var i=t.random||(t.rng||qG)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e)for(var a=0;a<16;++a)e[n+a]=i[a];return e||VG(i)}var ZG=WG,GG=HG,fR=ZG,ub=fR;ub.v1=GG,ub.v4=fR;var pd=ub,lb={exports:{}},hR=typeof ArrayBuffer<"u"&&typeof DataView<"u",KG=hR,cb=Ar,xn=cr,pR=Cr,fp=Lr,Ts=Vr,db=xa,JG=_o,YG=Ca,fb=Rn,QG=na,XG=Ea,hp=id,Ku=Nu,eK=Rr,tK=Nc,vR=Jn,mR=vR.enforce,rK=vR.get,pp=xn.Int8Array,hb=pp&&pp.prototype,gR=xn.Uint8ClampedArray,yR=gR&&gR.prototype,ua=pp&&hp(pp),Pi=hb&&hp(hb),nK=Object.prototype,pb=xn.TypeError,bR=eK("toStringTag"),vb=tK("TYPED_ARRAY_TAG"),vp="TypedArrayConstructor",Ba=KG&&!!Ku&&db(xn.opera)!=="Opera",wR=!1,Bn,Es,Ju,za={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},mb={BigInt64Array:8,BigUint64Array:8},iK=function(e){if(!fp(e))return!1;var r=db(e);return r==="DataView"||Ts(za,r)||Ts(mb,r)},_R=function(t){var e=hp(t);if(fp(e)){var r=rK(e);return r&&Ts(r,vp)?r[vp]:_R(e)}},kR=function(t){if(!fp(t))return!1;var e=db(t);return Ts(za,e)||Ts(mb,e)},aK=function(t){if(kR(t))return t;throw new pb("Target is not a typed array")},sK=function(t){if(pR(t)&&(!Ku||XG(ua,t)))return t;throw new pb(JG(t)+" is not a typed array constructor")},oK=function(t,e,r,n){if(cb){if(r)for(var i in za){var a=xn[i];if(a&&Ts(a.prototype,t))try{delete a.prototype[t]}catch{try{a.prototype[t]=e}catch{}}}(!Pi[t]||r)&&fb(Pi,t,r?e:Ba&&hb[t]||e,n)}},uK=function(t,e,r){var n,i;if(cb){if(Ku){if(r){for(n in za)if(i=xn[n],i&&Ts(i,t))try{delete i[t]}catch{}}if(!ua[t]||r)try{return fb(ua,t,r?e:Ba&&ua[t]||e)}catch{}else return}for(n in za)i=xn[n],i&&(!i[t]||r)&&fb(i,t,e)}};for(Bn in za)Es=xn[Bn],Ju=Es&&Es.prototype,Ju?mR(Ju)[vp]=Es:Ba=!1;for(Bn in mb)Es=xn[Bn],Ju=Es&&Es.prototype,Ju&&(mR(Ju)[vp]=Es);if((!Ba||!pR(ua)||ua===Function.prototype)&&(ua=function(){throw new pb("Incorrect invocation")},Ba))for(Bn in za)xn[Bn]&&Ku(xn[Bn],ua);if((!Ba||!Pi||Pi===nK)&&(Pi=ua.prototype,Ba))for(Bn in za)xn[Bn]&&Ku(xn[Bn].prototype,Pi);if(Ba&&hp(yR)!==Pi&&Ku(yR,Pi),cb&&!Ts(Pi,bR)){wR=!0,QG(Pi,bR,{configurable:!0,get:function(){return fp(this)?this[vb]:void 0}});for(Bn in za)xn[Bn]&&YG(xn[Bn],vb,Bn)}var Pr={NATIVE_ARRAY_BUFFER_VIEWS:Ba,TYPED_ARRAY_TAG:wR&&vb,aTypedArray:aK,aTypedArrayConstructor:sK,exportTypedArrayMethod:oK,exportTypedArrayStaticMethod:uK,getTypedArrayConstructor:_R,isView:iK,isTypedArray:kR,TypedArray:ua,TypedArrayPrototype:Pi},SR=cr,gb=Vt,lK=Dh,cK=Pr.NATIVE_ARRAY_BUFFER_VIEWS,dK=SR.ArrayBuffer,Mo=SR.Int8Array,fK=!cK||!gb(function(){Mo(1)})||!gb(function(){new Mo(-1)})||!lK(function(t){new Mo,new Mo(null),new Mo(1.5),new Mo(t)},!0)||gb(function(){return new Mo(new dK(2),1,void 0).length!==1}),hK=ea,pK=Ra,vK=RangeError,$R=function(t){if(t===void 0)return 0;var e=hK(t),r=pK(e);if(e!==r)throw new vK("Wrong length or index");return r},mK=Math.sign||function(e){var r=+e;return r===0||r!==r?r:r<0?-1:1},gK=mK,yK=Math.abs,TR=2220446049250313e-31,ER=1/TR,bK=function(t){return t+ER-ER},wK=function(t,e,r,n){var i=+t,a=yK(i),s=gK(i);if(a<n)return s*bK(a/n/e)*n*e;var o=(1+e/TR)*a,u=o-(o-a);return u>r||u!==u?s*(1/0):s*u},_K=wK,kK=11920928955078125e-23,SK=34028234663852886e22,$K=11754943508222875e-54,TK=Math.fround||function(e){return _K(e,kK,SK,$K)},EK=Array,CK=Math.abs,Ha=Math.pow,RK=Math.floor,xK=Math.log,IK=Math.LN2,AK=function(t,e,r){var n=EK(r),i=r*8-e-1,a=(1<<i)-1,s=a>>1,o=e===23?Ha(2,-24)-Ha(2,-77):0,u=t<0||t===0&&1/t<0?1:0,l=0,c,d,f;for(t=CK(t),t!==t||t===1/0?(d=t!==t?1:0,c=a):(c=RK(xK(t)/IK),f=Ha(2,-c),t*f<1&&(c--,f*=2),c+s>=1?t+=o/f:t+=o*Ha(2,1-s),t*f>=2&&(c++,f/=2),c+s>=a?(d=0,c=a):c+s>=1?(d=(t*f-1)*Ha(2,e),c+=s):(d=t*Ha(2,s-1)*Ha(2,e),c=0));e>=8;)n[l++]=d&255,d/=256,e-=8;for(c=c<<e|d,i+=e;i>0;)n[l++]=c&255,c/=256,i-=8;return n[--l]|=u*128,n},OK=function(t,e){var r=t.length,n=r*8-e-1,i=(1<<n)-1,a=i>>1,s=n-7,o=r-1,u=t[o--],l=u&127,c;for(u>>=7;s>0;)l=l*256+t[o--],s-=8;for(c=l&(1<<-s)-1,l>>=-s,s+=e;s>0;)c=c*256+t[o--],s-=8;if(l===0)l=1-a;else{if(l===i)return c?NaN:u?-1/0:1/0;c+=Ha(2,e),l-=a}return(u?-1:1)*c*Ha(2,l-e)},PK={pack:AK,unpack:OK},MK=yn,CR=Iu,NK=bn,RR=function(e){for(var r=MK(this),n=NK(r),i=arguments.length,a=CR(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,o=s===void 0?n:CR(s,n);o>a;)r[a++]=e;return r},mp=cr,yb=Kt,bb=Ar,LK=hR,xR=Lc,DK=Ca,jK=na,IR=op,wb=Vt,gp=ws,UK=ea,FK=Ra,yp=$R,BK=TK,AR=PK,zK=id,OR=Nu,HK=RR,qK=ra,VK=zh,WK=tg,PR=ta,_b=Jn,ZK=xR.PROPER,MR=xR.CONFIGURABLE,Yu="ArrayBuffer",bp="DataView",Qu="prototype",GK="Wrong length",NR="Wrong index",LR=_b.getterFor(Yu),vd=_b.getterFor(bp),DR=_b.set,Mi=mp[Yu],Qn=Mi,Xu=Qn&&Qn[Qu],la=mp[bp],No=la&&la[Qu],jR=Object.prototype,KK=mp.Array,wp=mp.RangeError,JK=yb(HK),YK=yb([].reverse),UR=AR.pack,FR=AR.unpack,BR=function(t){return[t&255]},zR=function(t){return[t&255,t>>8&255]},HR=function(t){return[t&255,t>>8&255,t>>16&255,t>>24&255]},qR=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},QK=function(t){return UR(BK(t),23,4)},XK=function(t){return UR(t,52,8)},_p=function(t,e,r){jK(t[Qu],e,{configurable:!0,get:function(){return r(this)[e]}})},Cs=function(t,e,r,n){var i=vd(t),a=yp(r),s=!!n;if(a+e>i.byteLength)throw new wp(NR);var o=i.bytes,u=a+i.byteOffset,l=qK(o,u,u+e);return s?l:YK(l)},Rs=function(t,e,r,n,i,a){var s=vd(t),o=yp(r),u=n(+i),l=!!a;if(o+e>s.byteLength)throw new wp(NR);for(var c=s.bytes,d=o+s.byteOffset,f=0;f<e;f++)c[d+f]=u[l?f:e-f-1]};if(!LK)Qn=function(e){gp(this,Xu);var r=yp(e);DR(this,{type:Yu,bytes:JK(KK(r),0),byteLength:r}),bb||(this.byteLength=r,this.detached=!1)},Xu=Qn[Qu],la=function(e,r,n){gp(this,No),gp(e,Xu);var i=LR(e),a=i.byteLength,s=UK(r);if(s<0||s>a)throw new wp("Wrong offset");if(n=n===void 0?a-s:FK(n),s+n>a)throw new wp(GK);DR(this,{type:bp,buffer:e,byteLength:n,byteOffset:s,bytes:i.bytes}),bb||(this.buffer=e,this.byteLength=n,this.byteOffset=s)},No=la[Qu],bb&&(_p(Qn,"byteLength",LR),_p(la,"buffer",vd),_p(la,"byteLength",vd),_p(la,"byteOffset",vd)),IR(No,{getInt8:function(e){return Cs(this,1,e)[0]<<24>>24},getUint8:function(e){return Cs(this,1,e)[0]},getInt16:function(e){var r=Cs(this,2,e,arguments.length>1?arguments[1]:!1);return(r[1]<<8|r[0])<<16>>16},getUint16:function(e){var r=Cs(this,2,e,arguments.length>1?arguments[1]:!1);return r[1]<<8|r[0]},getInt32:function(e){return qR(Cs(this,4,e,arguments.length>1?arguments[1]:!1))},getUint32:function(e){return qR(Cs(this,4,e,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(e){return FR(Cs(this,4,e,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(e){return FR(Cs(this,8,e,arguments.length>1?arguments[1]:!1),52)},setInt8:function(e,r){Rs(this,1,e,BR,r)},setUint8:function(e,r){Rs(this,1,e,BR,r)},setInt16:function(e,r){Rs(this,2,e,zR,r,arguments.length>2?arguments[2]:!1)},setUint16:function(e,r){Rs(this,2,e,zR,r,arguments.length>2?arguments[2]:!1)},setInt32:function(e,r){Rs(this,4,e,HR,r,arguments.length>2?arguments[2]:!1)},setUint32:function(e,r){Rs(this,4,e,HR,r,arguments.length>2?arguments[2]:!1)},setFloat32:function(e,r){Rs(this,4,e,QK,r,arguments.length>2?arguments[2]:!1)},setFloat64:function(e,r){Rs(this,8,e,XK,r,arguments.length>2?arguments[2]:!1)}});else{var VR=ZK&&Mi.name!==Yu;!wb(function(){Mi(1)})||!wb(function(){new Mi(-1)})||wb(function(){return new Mi,new Mi(1.5),new Mi(NaN),Mi.length!==1||VR&&!MR})?(Qn=function(e){return gp(this,Xu),VK(new Mi(yp(e)),this,Qn)},Qn[Qu]=Xu,Xu.constructor=Qn,WK(Qn,Mi)):VR&&MR&&DK(Mi,"name",Yu),OR&&zK(No)!==jR&&OR(No,jR);var kp=new la(new Qn(2)),WR=yb(No.setInt8);kp.setInt8(0,2147483648),kp.setInt8(1,2147483649),(kp.getInt8(0)||!kp.getInt8(1))&&IR(No,{setInt8:function(e,r){WR(this,e,r<<24>>24)},setUint8:function(e,r){WR(this,e,r<<24>>24)}},{unsafe:!0})}PR(Qn,Yu),PR(la,bp);var ZR={ArrayBuffer:Qn,DataView:la},eJ=ea,tJ=RangeError,rJ=function(t){var e=eJ(t);if(e<0)throw new tJ("The argument can't be less than 0");return e},nJ=rJ,iJ=RangeError,GR=function(t,e){var r=nJ(t);if(r%e)throw new iJ("Wrong offset");return r},aJ=Math.round,sJ=function(t){var e=aJ(t);return e<0?0:e>255?255:e&255},oJ=xa,uJ=function(t){var e=oJ(t);return e==="BigInt64Array"||e==="BigUint64Array"},lJ=jm,cJ=TypeError,KR=function(t){var e=lJ(t,"number");if(typeof e=="number")throw new cJ("Can't convert number to bigint");return BigInt(e)},dJ=Ia,fJ=Er,hJ=ag,pJ=yn,vJ=bn,mJ=Nh,gJ=rd,yJ=ay,bJ=uJ,wJ=Pr.aTypedArrayConstructor,_J=KR,kJ=function(e){var r=hJ(this),n=pJ(e),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,o=gJ(n),u,l,c,d,f,m,b,A;if(o&&!yJ(o))for(b=mJ(n,o),A=b.next,n=[];!(m=fJ(A,b)).done;)n.push(m.value);for(s&&i>2&&(a=dJ(a,arguments[2])),l=vJ(n),c=new(wJ(r))(l),d=bJ(c),u=0;l>u;u++)f=s?a(n[u],u):n[u],c[u]=d?_J(f):+f;return c},SJ=bn,JR=function(t,e,r){for(var n=0,i=arguments.length>2?r:SJ(e),a=new t(i);i>n;)a[n]=e[n++];return a},YR=er,QR=cr,XR=Er,$J=Ar,TJ=fK,md=Pr,ex=ZR,tx=ws,EJ=bo,gd=Ca,CJ=mC,RJ=Ra,rx=$R,kb=GR,xJ=sJ,nx=eh,yd=Vr,IJ=xa,Sb=Lr,AJ=Eu,OJ=vs,PJ=Ea,Sp=Nu,MJ=So.f,ix=kJ,NJ=Un.forEach,LJ=Sh,DJ=na,ax=Cn,sx=Ta,ox=JR,$b=Jn,jJ=zh,Tb=$b.get,UJ=$b.set,FJ=$b.enforce,ux=ax.f,BJ=sx.f,Eb=QR.RangeError,lx=ex.ArrayBuffer,zJ=lx.prototype,HJ=ex.DataView,$p=md.NATIVE_ARRAY_BUFFER_VIEWS,cx=md.TYPED_ARRAY_TAG,dx=md.TypedArray,bd=md.TypedArrayPrototype,Cb=md.isTypedArray,Tp="BYTES_PER_ELEMENT",Rb="Wrong length",Ep=function(t,e){DJ(t,e,{configurable:!0,get:function(){return Tb(this)[e]}})},fx=function(t){var e;return PJ(zJ,t)||(e=IJ(t))==="ArrayBuffer"||e==="SharedArrayBuffer"},hx=function(t,e){return Cb(t)&&!AJ(e)&&e in t&&CJ(+e)&&e>=0},px=function(e,r){return r=nx(r),hx(e,r)?EJ(2,e[r]):BJ(e,r)},vx=function(e,r,n){return r=nx(r),hx(e,r)&&Sb(n)&&yd(n,"value")&&!yd(n,"get")&&!yd(n,"set")&&!n.configurable&&(!yd(n,"writable")||n.writable)&&(!yd(n,"enumerable")||n.enumerable)?(e[r]=n.value,e):ux(e,r,n)};$J?($p||(sx.f=px,ax.f=vx,Ep(bd,"buffer"),Ep(bd,"byteOffset"),Ep(bd,"byteLength"),Ep(bd,"length")),YR({target:"Object",stat:!0,forced:!$p},{getOwnPropertyDescriptor:px,defineProperty:vx}),lb.exports=function(t,e,r){var n=t.match(/\d+/)[0]/8,i=t+(r?"Clamped":"")+"Array",a="get"+t,s="set"+t,o=QR[i],u=o,l=u&&u.prototype,c={},d=function(A,N){var z=Tb(A);return z.view[a](N*n+z.byteOffset,!0)},f=function(A,N,z){var X=Tb(A);X.view[s](N*n+X.byteOffset,r?xJ(z):z,!0)},m=function(A,N){ux(A,N,{get:function(){return d(this,N)},set:function(z){return f(this,N,z)},enumerable:!0})};$p?TJ&&(u=e(function(A,N,z,X){return tx(A,l),jJ(function(){return Sb(N)?fx(N)?X!==void 0?new o(N,kb(z,n),X):z!==void 0?new o(N,kb(z,n)):new o(N):Cb(N)?ox(u,N):XR(ix,u,N):new o(rx(N))}(),A,u)}),Sp&&Sp(u,dx),NJ(MJ(o),function(A){A in u||gd(u,A,o[A])}),u.prototype=l):(u=e(function(A,N,z,X){tx(A,l);var Ee=0,Ie=0,Fe,Oe,ze;if(!Sb(N))ze=rx(N),Oe=ze*n,Fe=new lx(Oe);else if(fx(N)){Fe=N,Ie=kb(z,n);var V=N.byteLength;if(X===void 0){if(V%n)throw new Eb(Rb);if(Oe=V-Ie,Oe<0)throw new Eb(Rb)}else if(Oe=RJ(X)*n,Oe+Ie>V)throw new Eb(Rb);ze=Oe/n}else return Cb(N)?ox(u,N):XR(ix,u,N);for(UJ(A,{buffer:Fe,byteOffset:Ie,byteLength:Oe,length:ze,view:new HJ(Fe)});Ee<ze;)m(A,Ee++)}),Sp&&Sp(u,dx),l=u.prototype=OJ(bd)),l.constructor!==u&&gd(l,"constructor",u),FJ(l).TypedArrayConstructor=u,cx&&gd(l,cx,i);var b=u!==o;c[i]=u,YR({global:!0,constructor:!0,forced:b,sham:!$p},c),Tp in u||gd(u,Tp,n),Tp in l||gd(l,Tp,n),LJ(i)}):lb.exports=function(){};var qJ=lb.exports,VJ=qJ;VJ("Uint8",function(t){return function(r,n,i){return t(this,r,n,i)}});var mx=Pr,WJ=bn,ZJ=ea,GJ=mx.aTypedArray,KJ=mx.exportTypedArrayMethod;KJ("at",function(e){var r=GJ(this),n=WJ(r),i=ZJ(e),a=i>=0?i:n+i;return a<0||a>=n?void 0:r[a]});var gx=_o,JJ=TypeError,xb=function(t,e){if(!delete t[e])throw new JJ("Cannot delete property "+gx(e)+" of "+gx(t))},YJ=yn,Ib=Iu,QJ=bn,XJ=xb,eY=Math.min,tY=[].copyWithin||function(e,r){var n=YJ(this),i=QJ(n),a=Ib(e,i),s=Ib(r,i),o=arguments.length>2?arguments[2]:void 0,u=eY((o===void 0?i:Ib(o,i))-s,i-a),l=1;for(s<a&&a<s+u&&(l=-1,s+=u-1,a+=u-1);u-- >0;)s in n?n[a]=n[s]:XJ(n,a),a+=l,s+=l;return n},rY=Kt,yx=Pr,nY=tY,iY=rY(nY),aY=yx.aTypedArray,sY=yx.exportTypedArrayMethod;sY("copyWithin",function(e,r){return iY(aY(this),e,r,arguments.length>2?arguments[2]:void 0)});var bx=Pr,oY=Un.every,uY=bx.aTypedArray,lY=bx.exportTypedArrayMethod;lY("every",function(e){return oY(uY(this),e,arguments.length>1?arguments[1]:void 0)});var wx=Pr,cY=RR,dY=KR,fY=xa,hY=Er,pY=Kt,vY=Vt,mY=wx.aTypedArray,gY=wx.exportTypedArrayMethod,yY=pY("".slice),bY=vY(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),t!==1});gY("fill",function(e){var r=arguments.length;mY(this);var n=yY(fY(this),0,3)==="Big"?dY(e):+e;return hY(cY,this,n,r>1?arguments[1]:void 0,r>2?arguments[2]:void 0)},bY);var _x=Pr,wY=Pg,_Y=_x.aTypedArrayConstructor,kY=_x.getTypedArrayConstructor,Cp=function(t){return _Y(wY(t,kY(t)))},SY=JR,$Y=Cp,TY=function(t,e){return SY($Y(t),e)},kx=Pr,EY=Un.filter,CY=TY,RY=kx.aTypedArray,xY=kx.exportTypedArrayMethod;xY("filter",function(e){var r=EY(RY(this),e,arguments.length>1?arguments[1]:void 0);return CY(this,r)});var Sx=Pr,IY=Un.find,AY=Sx.aTypedArray,OY=Sx.exportTypedArrayMethod;OY("find",function(e){return IY(AY(this),e,arguments.length>1?arguments[1]:void 0)});var $x=Pr,PY=Un.findIndex,MY=$x.aTypedArray,NY=$x.exportTypedArrayMethod;NY("findIndex",function(e){return PY(MY(this),e,arguments.length>1?arguments[1]:void 0)});var Tx=Pr,LY=Un.forEach,DY=Tx.aTypedArray,jY=Tx.exportTypedArrayMethod;jY("forEach",function(e){LY(DY(this),e,arguments.length>1?arguments[1]:void 0)});var Ex=Pr,UY=uh.includes,FY=Ex.aTypedArray,BY=Ex.exportTypedArrayMethod;BY("includes",function(e){return UY(FY(this),e,arguments.length>1?arguments[1]:void 0)});var Cx=Pr,zY=uh.indexOf,HY=Cx.aTypedArray,qY=Cx.exportTypedArrayMethod;qY("indexOf",function(e){return zY(HY(this),e,arguments.length>1?arguments[1]:void 0)});var VY=cr,WY=Vt,Ab=Kt,Rx=Pr,Ob=SE,ZY=Rr,Pb=ZY("iterator"),xx=VY.Uint8Array,GY=Ab(Ob.values),KY=Ab(Ob.keys),JY=Ab(Ob.entries),Mb=Rx.aTypedArray,Rp=Rx.exportTypedArrayMethod,el=xx&&xx.prototype,xp=!WY(function(){el[Pb].call([1])}),Ix=!!el&&el.values&&el[Pb]===el.values&&el.values.name==="values",Ax=function(){return GY(Mb(this))};Rp("entries",function(){return JY(Mb(this))},xp),Rp("keys",function(){return KY(Mb(this))},xp),Rp("values",Ax,xp||!Ix,{name:"values"}),Rp(Pb,Ax,xp||!Ix,{name:"values"});var Ox=Pr,YY=Kt,QY=Ox.aTypedArray,XY=Ox.exportTypedArrayMethod,eQ=YY([].join);XY("join",function(e){return eQ(QY(this),e)});var tQ=$o,rQ=Kn,nQ=ea,iQ=bn,aQ=_h,sQ=Math.min,Nb=[].lastIndexOf,Px=!!Nb&&1/[1].lastIndexOf(1,-0)<0,oQ=aQ("lastIndexOf"),uQ=Px||!oQ,lQ=uQ?function(e){if(Px)return tQ(Nb,this,arguments)||0;var r=rQ(this),n=iQ(r);if(n===0)return-1;var i=n-1;for(arguments.length>1&&(i=sQ(i,nQ(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in r&&r[i]===e)return i||0;return-1}:Nb,Mx=Pr,cQ=$o,dQ=lQ,fQ=Mx.aTypedArray,hQ=Mx.exportTypedArrayMethod;hQ("lastIndexOf",function(e){var r=arguments.length;return cQ(dQ,fQ(this),r>1?[e,arguments[1]]:[e])});var Nx=Pr,pQ=Un.map,vQ=Cp,mQ=Nx.aTypedArray,gQ=Nx.exportTypedArrayMethod;gQ("map",function(e){return pQ(mQ(this),e,arguments.length>1?arguments[1]:void 0,function(r,n){return new(vQ(r))(n)})});var yQ=si,bQ=yn,wQ=Mc,_Q=bn,Lx=TypeError,Dx="Reduce of empty array with no initial value",jx=function(t){return function(e,r,n,i){var a=bQ(e),s=wQ(a),o=_Q(a);if(yQ(r),o===0&&n<2)throw new Lx(Dx);var u=t?o-1:0,l=t?-1:1;if(n<2)for(;;){if(u in s){i=s[u],u+=l;break}if(u+=l,t?u<0:o<=u)throw new Lx(Dx)}for(;t?u>=0:o>u;u+=l)u in s&&(i=r(i,s[u],u,a));return i}},Ux={left:jx(!1),right:jx(!0)},Fx=Pr,kQ=Ux.left,SQ=Fx.aTypedArray,$Q=Fx.exportTypedArrayMethod;$Q("reduce",function(e){var r=arguments.length;return kQ(SQ(this),e,r,r>1?arguments[1]:void 0)});var Bx=Pr,TQ=Ux.right,EQ=Bx.aTypedArray,CQ=Bx.exportTypedArrayMethod;CQ("reduceRight",function(e){var r=arguments.length;return TQ(EQ(this),e,r,r>1?arguments[1]:void 0)});var zx=Pr,RQ=zx.aTypedArray,xQ=zx.exportTypedArrayMethod,IQ=Math.floor;xQ("reverse",function(){for(var e=this,r=RQ(e).length,n=IQ(r/2),i=0,a;i<n;)a=e[i],e[i++]=e[--r],e[r]=a;return e});var Hx=cr,qx=Er,Lb=Pr,AQ=bn,OQ=GR,PQ=yn,Vx=Vt,MQ=Hx.RangeError,Db=Hx.Int8Array,Wx=Db&&Db.prototype,Zx=Wx&&Wx.set,NQ=Lb.aTypedArray,LQ=Lb.exportTypedArrayMethod,jb=!Vx(function(){var t=new Uint8ClampedArray(2);return qx(Zx,t,{length:1,0:3},1),t[1]!==3}),DQ=jb&&Lb.NATIVE_ARRAY_BUFFER_VIEWS&&Vx(function(){var t=new Db(2);return t.set(1),t.set("2",1),t[0]!==0||t[1]!==2});LQ("set",function(e){NQ(this);var r=OQ(arguments.length>1?arguments[1]:void 0,1),n=PQ(e);if(jb)return qx(Zx,this,n,r);var i=this.length,a=AQ(n),s=0;if(a+r>i)throw new MQ("Wrong length");for(;s<a;)this[r+s]=n[s++]},!jb||DQ);var Gx=Pr,jQ=Cp,UQ=Vt,FQ=ra,BQ=Gx.aTypedArray,zQ=Gx.exportTypedArrayMethod,HQ=UQ(function(){new Int8Array(1).slice()});zQ("slice",function(e,r){for(var n=FQ(BQ(this),e,r),i=jQ(this),a=0,s=n.length,o=new i(s);s>a;)o[a]=n[a++];return o},HQ);var Kx=Pr,qQ=Un.some,VQ=Kx.aTypedArray,WQ=Kx.exportTypedArrayMethod;WQ("some",function(e){return qQ(VQ(this),e,arguments.length>1?arguments[1]:void 0)});var Jx=ra,ZQ=Math.floor,Ub=function(t,e){var r=t.length;if(r<8)for(var n=1,i,a;n<r;){for(a=n,i=t[n];a&&e(t[a-1],i)>0;)t[a]=t[--a];a!==n++&&(t[a]=i)}else for(var s=ZQ(r/2),o=Ub(Jx(t,0,s),e),u=Ub(Jx(t,s),e),l=o.length,c=u.length,d=0,f=0;d<l||f<c;)t[d+f]=d<l&&f<c?e(o[d],u[f])<=0?o[d++]:u[f++]:d<l?o[d++]:u[f++];return t},Fb=Ub,GQ=wo,Yx=GQ.match(/firefox\/(\d+)/i),Qx=!!Yx&&+Yx[1],KQ=wo,Xx=/MSIE|Trident/.test(KQ),JQ=wo,eI=JQ.match(/AppleWebKit\/(\d+)\./),tI=!!eI&&+eI[1],YQ=cr,QQ=pg,Bb=Vt,XQ=si,eX=Fb,rI=Pr,nI=Qx,tX=Xx,iI=$u,aI=tI,rX=rI.aTypedArray,nX=rI.exportTypedArrayMethod,wd=YQ.Uint16Array,tl=wd&&QQ(wd.prototype.sort),iX=!!tl&&!(Bb(function(){tl(new wd(2),null)})&&Bb(function(){tl(new wd(2),{})})),sI=!!tl&&!Bb(function(){if(iI)return iI<74;if(nI)return nI<67;if(tX)return!0;if(aI)return aI<602;var t=new wd(516),e=Array(516),r,n;for(r=0;r<516;r++)n=r%4,t[r]=515-r,e[r]=r-2*n+3;for(tl(t,function(i,a){return(i/4|0)-(a/4|0)}),r=0;r<516;r++)if(t[r]!==e[r])return!0}),aX=function(t){return function(e,r){return t!==void 0?+t(e,r)||0:r!==r?-1:e!==e?1:e===0&&r===0?1/e>0&&1/r<0?1:-1:e>r}};nX("sort",function(e){return e!==void 0&&XQ(e),sI?tl(this,e):eX(rX(this),aX(e))},!sI||iX);var oI=Pr,sX=Ra,uI=Iu,oX=Cp,uX=oI.aTypedArray,lX=oI.exportTypedArrayMethod;lX("subarray",function(e,r){var n=uX(this),i=n.length,a=uI(e,i),s=oX(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,sX((r===void 0?i:uI(r,i))-a))});var cX=cr,dX=$o,lI=Pr,zb=Vt,cI=ra,Ip=cX.Int8Array,dI=lI.aTypedArray,fX=lI.exportTypedArrayMethod,fI=[].toLocaleString,hX=!!Ip&&zb(function(){fI.call(new Ip(1))}),pX=zb(function(){return[1,2].toLocaleString()!==new Ip([1,2]).toLocaleString()})||!zb(function(){Ip.prototype.toLocaleString.call([1,2])});fX("toLocaleString",function(){return dX(fI,hX?cI(dI(this)):dI(this),cI(arguments))},pX);var vX=Pr.exportTypedArrayMethod,mX=Vt,gX=cr,yX=Kt,hI=gX.Uint8Array,bX=hI&&hI.prototype||{},Ap=[].toString,wX=yX([].join);mX(function(){Ap.call({})})&&(Ap=function(){return wX(this)});var _X=bX.toString!==Ap;vX("toString",Ap,_X);var Hb=Er,pI=Kt,kX=Gh,SX=Gr,$X=xi,TX=Ii,EX=Pg,CX=Dy,RX=Ra,vI=nn,xX=ko,mI=Kh,IX=jE,AX=Vt,rl=IX.UNSUPPORTED_Y,OX=4294967295,PX=Math.min,qb=pI([].push),Vb=pI("".slice),MX=!AX(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var r="ab".split(t);return r.length!==2||r[0]!=="a"||r[1]!=="b"}),gI="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;kX("split",function(t,e,r){var n="0".split(void 0,0).length?function(i,a){return i===void 0&&a===0?[]:Hb(e,this,i,a)}:e;return[function(a,s){var o=TX(this),u=$X(a)?void 0:xX(a,t);return u?Hb(u,a,o,s):Hb(n,vI(o),a,s)},function(i,a){var s=SX(this),o=vI(i);if(!gI){var u=r(n,s,o,a,n!==e);if(u.done)return u.value}var l=EX(s,RegExp),c=s.unicode,d=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(rl?"g":"y"),f=new l(rl?"^(?:"+s.source+")":s,d),m=a===void 0?OX:a>>>0;if(m===0)return[];if(o.length===0)return mI(f,o)===null?[o]:[];for(var b=0,A=0,N=[];A<o.length;){f.lastIndex=rl?0:A;var z=mI(f,rl?Vb(o,A):o),X;if(z===null||(X=PX(RX(f.lastIndex+(rl?A:0)),o.length))===b)A=CX(o,A,c);else{if(qb(N,Vb(o,b,A)),N.length===m)return N;for(var Ee=1;Ee<=z.length-1;Ee++)if(qb(N,z[Ee]),N.length===m)return N;A=b=X}}return qb(N,Vb(o,b)),N}]},gI||!MX,rl);var yI={exports:{}},bI={exports:{}};(function(t){function e(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(bI);var NX=bI.exports,wI={exports:{}},_I={exports:{}};(function(t){function e(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(t.exports=e=function(){return!!r},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(_I);var LX=_I.exports;(function(t){var e=LX,r=xg;function n(i,a,s){if(e())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,a);var u=new(i.bind.apply(i,o));return s&&r(u,s.prototype),u}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(wI);var DX=wI.exports;(function(t){var e=li,r=xg,n=NX,i=DX;function a(s){var o=typeof Map=="function"?new Map:void 0;return t.exports=a=function(l){if(l===null||!n(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(l))return o.get(l);o.set(l,c)}function c(){return i(l,arguments,e(this).constructor)}return c.prototype=Object.create(l.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),r(c,l)},t.exports.__esModule=!0,t.exports.default=t.exports,a(s)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(yI);var _d=yI.exports,Op={exports:{}};/*!
855
+ * Platform.js v1.3.6
856
+ * Copyright 2014-2020 Benjamin Tan
857
+ * Copyright 2011-2013 John-David Dalton
858
+ * Available under MIT license
859
+ */Op.exports,function(t,e){(function(){var r={function:!0,object:!0},n=r[typeof window]&&window||this,i=e,a=t&&!t.nodeType&&t,s=i&&a&&typeof ln=="object"&&ln;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var o=Math.pow(2,53)-1,u=/\bOpera/,l=Object.prototype,c=l.hasOwnProperty,d=l.toString;function f(V){return V=String(V),V.charAt(0).toUpperCase()+V.slice(1)}function m(V,xe,_e){var se={"10.0":"10","6.4":"10 Technical Preview","6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return xe&&_e&&/^Win/i.test(V)&&!/^Windows Phone /i.test(V)&&(se=se[/[\d.]+$/.exec(V)])&&(V="Windows "+se),V=String(V),xe&&_e&&(V=V.replace(RegExp(xe,"i"),_e)),V=A(V.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0]),V}function b(V,xe){var _e=-1,se=V?V.length:0;if(typeof se=="number"&&se>-1&&se<=o)for(;++_e<se;)xe(V[_e],_e,V);else N(V,xe)}function A(V){return V=Fe(V),/^(?:webOS|i(?:OS|P))/.test(V)?V:f(V)}function N(V,xe){for(var _e in V)c.call(V,_e)&&xe(V[_e],_e,V)}function z(V){return V==null?f(V):d.call(V).slice(8,-1)}function X(V,xe){var _e=V!=null?typeof V[xe]:"number";return!/^(?:boolean|number|string|undefined)$/.test(_e)&&(_e=="object"?!!V[xe]:!0)}function Ee(V){return String(V).replace(/([ -])(?!$)/g,"$1?")}function Ie(V,xe){var _e=null;return b(V,function(se,Te){_e=xe(_e,se,Te,V)}),_e}function Fe(V){return String(V).replace(/^ +| +$/g,"")}function Oe(V){var xe=n,_e=V&&typeof V=="object"&&z(V)!="String";_e&&(xe=V,V=null);var se=xe.navigator||{},Te=se.userAgent||"";V||(V=Te);var re=_e?!!se.likeChrome:/\bChrome\b/.test(V)&&!/internal|\n/i.test(d.toString()),oe="Object",q=_e?oe:"ScriptBridgingProxyObject",ne=_e?oe:"Environment",Se=_e&&xe.java?"JavaPackage":z(xe.java),H=_e?oe:"RuntimeObject",ye=/\bJava/.test(Se)&&xe.java,ke=ye&&z(xe.environment)==ne,M=ye?"a":"α",Xe=ye?"b":"β",Ct=xe.document||{},rt=xe.operamini||xe.opera,je=u.test(je=_e&&rt?rt["[[Class]]"]:z(rt))?je:rt=null,ce,Ke=V,Be=[],be=null,pt=V==Te,Ze=pt&&rt&&typeof rt.version=="function"&&rt.version(),Jt,At=St([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),Q=or(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),Ue=et([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),ot=ut({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),Pe=br(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function St(fr){return Ie(fr,function(Wt,Ot){return Wt||RegExp("\\b"+(Ot.pattern||Ee(Ot))+"\\b","i").exec(V)&&(Ot.label||Ot)})}function ut(fr){return Ie(fr,function(Wt,Ot,L){return Wt||(Ot[Ue]||Ot[/^[a-z]+(?: +[a-z]+\b)*/i.exec(Ue)]||RegExp("\\b"+Ee(L)+"(?:\\b|\\w*\\d)","i").exec(V))&&L})}function or(fr){return Ie(fr,function(Wt,Ot){return Wt||RegExp("\\b"+(Ot.pattern||Ee(Ot))+"\\b","i").exec(V)&&(Ot.label||Ot)})}function br(fr){return Ie(fr,function(Wt,Ot){var L=Ot.pattern||Ee(Ot);return!Wt&&(Wt=RegExp("\\b"+L+"(?:/[\\d.]+|[ \\w.]*)","i").exec(V))&&(Wt=m(Wt,L,Ot.label||Ot)),Wt})}function et(fr){return Ie(fr,function(Wt,Ot){var L=Ot.pattern||Ee(Ot);return!Wt&&(Wt=RegExp("\\b"+L+" *\\d+[.\\w_]*","i").exec(V)||RegExp("\\b"+L+" *\\w+-[\\w]*","i").exec(V)||RegExp("\\b"+L+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(V))&&((Wt=String(Ot.label&&!RegExp(L,"i").test(Ot.label)?Ot.label:Wt).split("/"))[1]&&!/[\d.]+/.test(Wt[0])&&(Wt[0]+=" "+Wt[1]),Ot=Ot.label||Ot,Wt=A(Wt[0].replace(RegExp(L,"i"),Ot).replace(RegExp("; *(?:"+Ot+"[_-])?","i")," ").replace(RegExp("("+Ot+")[-_.]?(\\w)","i"),"$1 $2"))),Wt})}function Mr(fr){return Ie(fr,function(Wt,Ot){return Wt||(RegExp(Ot+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(V)||0)[1]||null})}function Fr(){return this.description||""}if(At&&(At=[At]),/\bAndroid\b/.test(Pe)&&!Ue&&(ce=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(V))&&(Ue=Fe(ce[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),ot&&!Ue?Ue=et([ot]):ot&&Ue&&(Ue=Ue.replace(RegExp("^("+Ee(ot)+")[-_.\\s]","i"),ot+" ").replace(RegExp("^("+Ee(ot)+")[-_.]?(\\w)","i"),ot+" $2")),(ce=/\bGoogle TV\b/.exec(Ue))&&(Ue=ce[0]),/\bSimulator\b/i.test(V)&&(Ue=(Ue?Ue+" ":"")+"Simulator"),Q=="Opera Mini"&&/\bOPiOS\b/.test(V)&&Be.push("running in Turbo/Uncompressed mode"),Q=="IE"&&/\blike iPhone OS\b/.test(V)?(ce=Oe(V.replace(/like iPhone OS/,"")),ot=ce.manufacturer,Ue=ce.product):/^iP/.test(Ue)?(Q||(Q="Safari"),Pe="iOS"+((ce=/ OS ([\d_]+)/i.exec(V))?" "+ce[1].replace(/_/g,"."):"")):Q=="Konqueror"&&/^Linux\b/i.test(Pe)?Pe="Kubuntu":ot&&ot!="Google"&&(/Chrome/.test(Q)&&!/\bMobile Safari\b/i.test(V)||/\bVita\b/.test(Ue))||/\bAndroid\b/.test(Pe)&&/^Chrome/.test(Q)&&/\bVersion\//i.test(V)?(Q="Android Browser",Pe=/\bAndroid\b/.test(Pe)?Pe:"Android"):Q=="Silk"?(/\bMobi/i.test(V)||(Pe="Android",Be.unshift("desktop mode")),/Accelerated *= *true/i.test(V)&&Be.unshift("accelerated")):Q=="UC Browser"&&/\bUCWEB\b/.test(V)?Be.push("speed mode"):Q=="PaleMoon"&&(ce=/\bFirefox\/([\d.]+)\b/.exec(V))?Be.push("identifying as Firefox "+ce[1]):Q=="Firefox"&&(ce=/\b(Mobile|Tablet|TV)\b/i.exec(V))?(Pe||(Pe="Firefox OS"),Ue||(Ue=ce[1])):!Q||(ce=!/\bMinefield\b/i.test(V)&&/\b(?:Firefox|Safari)\b/.exec(Q))?(Q&&!Ue&&/[\/,]|^[^(]+?\)/.test(V.slice(V.indexOf(ce+"/")+8))&&(Q=null),(ce=Ue||ot||Pe)&&(Ue||ot||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(Pe))&&(Q=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(Pe)?Pe:ce)+" Browser")):Q=="Electron"&&(ce=(/\bChrome\/([\d.]+)\b/.exec(V)||0)[1])&&Be.push("Chromium "+ce),Ze||(Ze=Mr(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",Ee(Q),"(?:Firefox|Minefield|NetFront)"])),(ce=At=="iCab"&&parseFloat(Ze)>3&&"WebKit"||/\bOpera\b/.test(Q)&&(/\bOPR\b/.test(V)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(V)&&!/^(?:Trident|EdgeHTML)$/.test(At)&&"WebKit"||!At&&/\bMSIE\b/i.test(V)&&(Pe=="Mac OS"?"Tasman":"Trident")||At=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(Q)&&"NetFront")&&(At=[ce]),Q=="IE"&&(ce=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(V)||0)[1])?(Q+=" Mobile",Pe="Windows Phone "+(/\+$/.test(ce)?ce:ce+".x"),Be.unshift("desktop mode")):/\bWPDesktop\b/i.test(V)?(Q="IE Mobile",Pe="Windows Phone 8.x",Be.unshift("desktop mode"),Ze||(Ze=(/\brv:([\d.]+)/.exec(V)||0)[1])):Q!="IE"&&At=="Trident"&&(ce=/\brv:([\d.]+)/.exec(V))&&(Q&&Be.push("identifying as "+Q+(Ze?" "+Ze:"")),Q="IE",Ze=ce[1]),pt){if(X(xe,"global"))if(ye&&(ce=ye.lang.System,Ke=ce.getProperty("os.arch"),Pe=Pe||ce.getProperty("os.name")+" "+ce.getProperty("os.version")),ke){try{Ze=xe.require("ringo/engine").version.join("."),Q="RingoJS"}catch{(ce=xe.system)&&ce.global.system==xe.system&&(Q="Narwhal",Pe||(Pe=ce[0].os||null))}Q||(Q="Rhino")}else typeof xe.process=="object"&&!xe.process.browser&&(ce=xe.process)&&(typeof ce.versions=="object"&&(typeof ce.versions.electron=="string"?(Be.push("Node "+ce.versions.node),Q="Electron",Ze=ce.versions.electron):typeof ce.versions.nw=="string"&&(Be.push("Chromium "+Ze,"Node "+ce.versions.node),Q="NW.js",Ze=ce.versions.nw)),Q||(Q="Node.js",Ke=ce.arch,Pe=ce.platform,Ze=/[\d.]+/.exec(ce.version),Ze=Ze?Ze[0]:null));else z(ce=xe.runtime)==q?(Q="Adobe AIR",Pe=ce.flash.system.Capabilities.os):z(ce=xe.phantom)==H?(Q="PhantomJS",Ze=(ce=ce.version||null)&&ce.major+"."+ce.minor+"."+ce.patch):typeof Ct.documentMode=="number"&&(ce=/\bTrident\/(\d+)/i.exec(V))?(Ze=[Ze,Ct.documentMode],(ce=+ce[1]+4)!=Ze[1]&&(Be.push("IE "+Ze[1]+" mode"),At&&(At[1]=""),Ze[1]=ce),Ze=Q=="IE"?String(Ze[1].toFixed(1)):Ze[0]):typeof Ct.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(Q)&&(Be.push("masking as "+Q+" "+Ze),Q="IE",Ze="11.0",At=["Trident"],Pe="Windows");Pe=Pe&&A(Pe)}if(Ze&&(ce=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Ze)||/(?:alpha|beta)(?: ?\d)?/i.exec(V+";"+(pt&&se.appMinorVersion))||/\bMinefield\b/i.test(V)&&"a")&&(be=/b/i.test(ce)?"beta":"alpha",Ze=Ze.replace(RegExp(ce+"\\+?$"),"")+(be=="beta"?Xe:M)+(/\d+\+?/.exec(ce)||"")),Q=="Fennec"||Q=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(Pe))Q="Firefox Mobile";else if(Q=="Maxthon"&&Ze)Ze=Ze.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(Ue))Ue=="Xbox 360"&&(Pe=null),Ue=="Xbox 360"&&/\bIEMobile\b/.test(V)&&Be.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(Q)||Q&&!Ue&&!/Browser|Mobi/.test(Q))&&(Pe=="Windows CE"||/Mobi/i.test(V)))Q+=" Mobile";else if(Q=="IE"&&pt)try{xe.external===null&&Be.unshift("platform preview")}catch{Be.unshift("embedded")}else(/\bBlackBerry\b/.test(Ue)||/\bBB10\b/.test(V))&&(ce=(RegExp(Ue.replace(/ +/g," *")+"/([.\\d]+)","i").exec(V)||0)[1]||Ze)?(ce=[ce,/BB10/.test(V)],Pe=(ce[1]?(Ue=null,ot="BlackBerry"):"Device Software")+" "+ce[0],Ze=null):this!=N&&Ue!="Wii"&&(pt&&rt||/Opera/.test(Q)&&/\b(?:MSIE|Firefox)\b/i.test(V)||Q=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(Pe)||Q=="IE"&&(Pe&&!/^Win/.test(Pe)&&Ze>5.5||/\bWindows XP\b/.test(Pe)&&Ze>8||Ze==8&&!/\bTrident\b/.test(V)))&&!u.test(ce=Oe.call(N,V.replace(u,"")+";"))&&ce.name&&(ce="ing as "+ce.name+((ce=ce.version)?" "+ce:""),u.test(Q)?(/\bIE\b/.test(ce)&&Pe=="Mac OS"&&(Pe=null),ce="identify"+ce):(ce="mask"+ce,je?Q=A(je.replace(/([a-z])([A-Z])/g,"$1 $2")):Q="Opera",/\bIE\b/.test(ce)&&(Pe=null),pt||(Ze=null)),At=["Presto"],Be.push(ce));(ce=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(V)||0)[1])&&(ce=[parseFloat(ce.replace(/\.(\d)$/,".0$1")),ce],Q=="Safari"&&ce[1].slice(-1)=="+"?(Q="WebKit Nightly",be="alpha",Ze=ce[1].slice(0,-1)):(Ze==ce[1]||Ze==(ce[2]=(/\bSafari\/([\d.]+\+?)/i.exec(V)||0)[1]))&&(Ze=null),ce[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(V)||0)[1],ce[0]==537.36&&ce[2]==537.36&&parseFloat(ce[1])>=28&&At=="WebKit"&&(At=["Blink"]),!pt||!re&&!ce[1]?(At&&(At[1]="like Safari"),ce=(ce=ce[0],ce<400?1:ce<500?2:ce<526?3:ce<533?4:ce<534?"4+":ce<535?5:ce<537?6:ce<538?7:ce<601?8:ce<602?9:ce<604?10:ce<606?11:ce<608?12:"12")):(At&&(At[1]="like Chrome"),ce=ce[1]||(ce=ce[0],ce<530?1:ce<532?2:ce<532.05?3:ce<533?4:ce<534.03?5:ce<534.07?6:ce<534.1?7:ce<534.13?8:ce<534.16?9:ce<534.24?10:ce<534.3?11:ce<535.01?12:ce<535.02?"13+":ce<535.07?15:ce<535.11?16:ce<535.19?17:ce<536.05?18:ce<536.1?19:ce<537.01?20:ce<537.11?"21+":ce<537.13?23:ce<537.18?24:ce<537.24?25:ce<537.36?26:At!="Blink"?"27":"28")),At&&(At[1]+=" "+(ce+=typeof ce=="number"?".x":/[.+]/.test(ce)?"":"+")),Q=="Safari"&&(!Ze||parseInt(Ze)>45)?Ze=ce:Q=="Chrome"&&/\bHeadlessChrome/i.test(V)&&Be.unshift("headless")),Q=="Opera"&&(ce=/\bzbov|zvav$/.exec(Pe))?(Q+=" ",Be.unshift("desktop mode"),ce=="zvav"?(Q+="Mini",Ze=null):Q+="Mobile",Pe=Pe.replace(RegExp(" *"+ce+"$"),"")):Q=="Safari"&&/\bChrome\b/.exec(At&&At[1])?(Be.unshift("desktop mode"),Q="Chrome Mobile",Ze=null,/\bOS X\b/.test(Pe)?(ot="Apple",Pe="iOS 4.3+"):Pe=null):/\bSRWare Iron\b/.test(Q)&&!Ze&&(Ze=Mr("Chrome")),Ze&&Ze.indexOf(ce=/[\d.]+$/.exec(Pe))==0&&V.indexOf("/"+ce+"-")>-1&&(Pe=Fe(Pe.replace(ce,""))),Pe&&Pe.indexOf(Q)!=-1&&!RegExp(Q+" OS").test(Pe)&&(Pe=Pe.replace(RegExp(" *"+Ee(Q)+" *"),"")),At&&!/\b(?:Avant|Nook)\b/.test(Q)&&(/Browser|Lunascape|Maxthon/.test(Q)||Q!="Safari"&&/^iOS/.test(Pe)&&/\bSafari\b/.test(At[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(Q)&&At[1])&&(ce=At[At.length-1])&&Be.push(ce),Be.length&&(Be=["("+Be.join("; ")+")"]),ot&&Ue&&Ue.indexOf(ot)<0&&Be.push("on "+ot),Ue&&Be.push((/^on /.test(Be[Be.length-1])?"":"on ")+Ue),Pe&&(ce=/ ([\d.+]+)$/.exec(Pe),Jt=ce&&Pe.charAt(Pe.length-ce[0].length-1)=="/",Pe={architecture:32,family:ce&&!Jt?Pe.replace(ce[0],""):Pe,version:ce?ce[1]:null,toString:function(){var fr=this.version;return this.family+(fr&&!Jt?" "+fr:"")+(this.architecture==64?" 64-bit":"")}}),(ce=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(Ke))&&!/\bi686\b/i.test(Ke)?(Pe&&(Pe.architecture=64,Pe.family=Pe.family.replace(RegExp(" *"+ce),"")),Q&&(/\bWOW64\b/i.test(V)||pt&&/\w(?:86|32)$/.test(se.cpuClass||se.platform)&&!/\bWin64; x64\b/i.test(V))&&Be.unshift("32-bit")):Pe&&/^OS X/.test(Pe.family)&&Q=="Chrome"&&parseFloat(Ze)>=39&&(Pe.architecture=64),V||(V=null);var dr={};return dr.description=V,dr.layout=At&&At[0],dr.manufacturer=ot,dr.name=Q,dr.prerelease=be,dr.product=Ue,dr.ua=V,dr.version=Q&&Ze,dr.os=Pe||{architecture:null,family:null,version:null,toString:function(){return"null"}},dr.parse=Oe,dr.toString=Fr,dr.version&&Be.unshift(Ze),dr.name&&Be.unshift(Q),Pe&&Q&&!(Pe==String(Pe).split(" ")[0]&&(Pe==Q.split(" ")[0]||Ue))&&Be.push(Ue?"("+Pe+")":"on "+Pe),Be.length&&(dr.description=Be.join(" ")),dr}var ze=Oe();i&&a?N(ze,function(V,xe){i[xe]=V}):n.platform=ze}).call(ln)}(Op,Op.exports);var Wb=Op.exports,jX=Er,UX=Gh,FX=Gr,BX=xi,zX=Ra,Zb=nn,HX=Ii,qX=ko,VX=Dy,kI=Kh;UX("match",function(t,e,r){return[function(i){var a=HX(this),s=BX(i)?void 0:qX(i,t);return s?jX(s,i,a):new RegExp(i)[t](Zb(a))},function(n){var i=FX(this),a=Zb(n),s=r(e,i,a);if(s.done)return s.value;if(!i.global)return kI(i,a);var o=i.unicode;i.lastIndex=0;for(var u=[],l=0,c;(c=kI(i,a))!==null;){var d=Zb(c[0]);u[l]=d,d===""&&(i.lastIndex=VX(a,zX(i.lastIndex),o)),l++}return l===0?null:u}]});var WX=Object.is||function(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r},ZX=Er,GX=Gh,KX=Gr,JX=xi,YX=Ii,SI=WX,$I=nn,QX=ko,XX=Kh;GX("search",function(t,e,r){return[function(i){var a=YX(this),s=JX(i)?void 0:QX(i,t);return s?ZX(s,i,a):new RegExp(i)[t]($I(a))},function(n){var i=KX(this),a=$I(n),s=r(e,i,a);if(s.done)return s.value;var o=i.lastIndex;SI(o,0)||(i.lastIndex=0);var u=XX(i,a);return SI(i.lastIndex,o)||(i.lastIndex=o),u===null?-1:u.index}]});var eee=Ar,tee=Hc,ree=TypeError,nee=Object.getOwnPropertyDescriptor,iee=eee&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}(),aee=iee?function(t,e){if(tee(t)&&!nee(t,"length").writable)throw new ree("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e},see=er,oee=yn,uee=Iu,lee=ea,cee=bn,dee=aee,fee=ZT,hee=vg,pee=Jc,Gb=xb,vee=Kc,mee=vee("splice"),gee=Math.max,yee=Math.min;see({target:"Array",proto:!0,forced:!mee},{splice:function(e,r){var n=oee(this),i=cee(n),a=uee(e,i),s=arguments.length,o,u,l,c,d,f;for(s===0?o=u=0:s===1?(o=0,u=i-a):(o=s-2,u=yee(gee(lee(r),0),i-a)),fee(i+o-u),l=hee(n,u),c=0;c<u;c++)d=a+c,d in n&&pee(l,c,n[d]);if(l.length=u,o<u){for(c=a;c<i-u;c++)d=c+u,f=c+o,d in n?n[f]=n[d]:Gb(n,f);for(c=i;c>i-u+o;c--)Gb(n,c-1)}else if(o>u)for(c=i-u;c>a;c--)d=c+u-1,f=c+o-1,d in n?n[f]=n[d]:Gb(n,f);for(c=0;c<o;c++)n[c+a]=arguments[c+2];return dee(n,i-u+o),l}});/*
860
+ @license
861
+ The following license applies to all parts of this software except as
862
+ documented below.
863
+
864
+ Copyright (c) 2016, Twilio, inc.
865
+ All rights reserved.
866
+
867
+ Redistribution and use in source and binary forms, with or without
868
+ modification, are permitted provided that the following conditions are
869
+ met:
870
+
871
+ 1. Redistributions of source code must retain the above copyright
872
+ notice, this list of conditions and the following disclaimer.
873
+
874
+ 2. Redistributions in binary form must reproduce the above copyright
875
+ notice, this list of conditions and the following disclaimer in
876
+ the documentation and/or other materials provided with the
877
+ distribution.
878
+
879
+ 3. Neither the name of Twilio nor the names of its contributors may
880
+ be used to endorse or promote products derived from this software
881
+ without specific prior written permission.
882
+
883
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
884
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
885
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
886
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
887
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
888
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
889
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
890
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
891
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
892
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
893
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
894
+
895
+ This software includes javascript-state-machine under the following license.
896
+
897
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
898
+
899
+ Permission is hereby granted, free of charge, to any person obtaining a copy
900
+ of this software and associated documentation files (the "Software"), to deal
901
+ in the Software without restriction, including without limitation the rights
902
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
903
+ copies of the Software, and to permit persons to whom the Software is
904
+ furnished to do so, subject to the following conditions:
905
+
906
+ The above copyright notice and this permission notice shall be included in all
907
+ copies or substantial portions of the Software.
908
+
909
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
910
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
911
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
912
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
913
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
914
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
915
+
916
+ This software includes loglevel under the following license.
917
+
918
+ Copyright (c) 2013 Tim Perry
919
+
920
+ Permission is hereby granted, free of charge, to any person
921
+ obtaining a copy of this software and associated documentation
922
+ files (the "Software"), to deal in the Software without
923
+ restriction, including without limitation the rights to use,
924
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
925
+ copies of the Software, and to permit persons to whom the
926
+ Software is furnished to do so, subject to the following
927
+ conditions:
928
+
929
+ The above copyright notice and this permission notice shall be
930
+ included in all copies or substantial portions of the Software.
931
+
932
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
933
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
934
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
935
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
936
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
937
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
938
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
939
+ OTHER DEALINGS IN THE SOFTWARE.
940
+
941
+
942
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Mu,n=ys,i=np,a=ia,s=aa,o=li,u=Oa,l=sa,c=bs,d=Hu,f=ui,m=an,b=qu,A=iR,N=pd,z=_d,X=oa,Ee=rp,Ie=Wb;function Fe(te){return te&&typeof te=="object"&&"default"in te?te:{default:te}}function Oe(te){if(te&&te.__esModule)return te;var ue=Object.create(null);return te&&Object.keys(te).forEach(function(I){if(I!=="default"){var O=Object.getOwnPropertyDescriptor(te,I);Object.defineProperty(ue,I,O.get?O:{enumerable:!0,get:function(){return te[I]}})}}),ue.default=te,Object.freeze(ue)}var ze=Fe(r),V=Fe(n),xe=Fe(i),_e=Fe(a),se=Fe(s),Te=Fe(o),re=Fe(u),oe=Fe(l),q=Fe(c),ne=Fe(d),Se=Fe(f),H=Oe(b),ye=Oe(A),ke=Fe(z),M=Oe(Ie);function Xe(te,ue,I,O){var R=arguments.length,Z=R<3?ue:O===null?O=Object.getOwnPropertyDescriptor(ue,I):O,j;if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Z=Reflect.decorate(te,ue,I,O);else for(var Le=te.length-1;Le>=0;Le--)(j=te[Le])&&(Z=(R<3?j(Z):R>3?j(ue,I,Z):j(ue,I))||Z);return R>3&&Z&&Object.defineProperty(ue,I,Z),Z}function Ct(te,ue){if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(te,ue)}var rt=H.getLogger("twilsock");function je(te,ue){return["".concat(new Date().toISOString()," Twilsock ").concat(te,":")].concat(Array.from(ue))}var ce=function(){function te(ue){oe.default(this,te),q.default(this,"prefix",""),this.prefix=ue!=null&&ue.length>0?" "+ue+":":""}return re.default(te,[{key:"setLevel",value:function(I){rt.setLevel(I)}},{key:"trace",value:function(){if(rt.getLevel()==rt.levels.TRACE){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("T",O))}}},{key:"debug",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("D",O))}},{key:"info",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.info.apply(null,je("I",O))}},{key:"warn",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.warn.apply(null,je("W",O))}},{key:"error",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.error.apply(null,je("E",O))}}],[{key:"setLevel",value:function(I){rt.setLevel(I)}},{key:"trace",value:function(){if(rt.getLevel()==rt.levels.TRACE){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("T",O))}}},{key:"debug",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("D",O))}},{key:"info",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.info.apply(null,je("I",O))}},{key:"warn",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.warn.apply(null,je("W",O))}},{key:"error",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.error.apply(null,je("E",O))}}]),te}(),Ke=new ce(""),Be="0.13.12",be=function(){function te(ue,I,O){oe.default(this,te),q.default(this,"confirmedCapabilities",new Set),this.activeGrant=I,this._token=ue;var R=O.region||"us1",Z="wss://tsock.".concat(R,".twilio.com/v3/wsconnect"),j=O.twilsock||O.Twilsock||{};this.url=j.uri||Z,this._continuationToken=O.continuationToken?O.continuationToken:null,this.logLevel=O.logLevel?O.logLevel:"error",this.retryPolicy=O.retryPolicy?O.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=O.clientMetadata?O.clientMetadata:{},this.clientMetadata.ver=Be,this.initRegistrations=O.initRegistrations?O.initRegistrations:null,this.tweaks=O.tweaks?O.tweaks:null}return re.default(te,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(I){this._token=I}},{key:"updateContinuationToken",value:function(I){this._continuationToken=I}}]),te}(),pt=re.default(function te(ue){oe.default(this,te),this.id=ue||"TM".concat(N.v4())});function Ze(te){var ue=Jt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Jt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At=function(te){_e.default(I,te);var ue=Ze(I);function I(O,R,Z,j,Le){var Ae;return oe.default(this,I),Ae=ue.call(this),q.default(V.default(Ae),"method","init"),Ae.token=O,Ae.continuation_token=R,Ae.metadata=Z,Ae.registrations=j,Ae.tweaks=Le,Ae.capabilities=["client_update","offline_storage","telemetry.v1"],Ae}return re.default(I)}(pt);function Q(te){var ue=Ue();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Ue(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ot=function(te){_e.default(I,te);var ue=Q(I);function I(O,R,Z,j,Le,Ae,Ve){var at;return oe.default(this,I),at=ue.call(this,O),at.continuationToken=R,at.continuationTokenStatus=j,at.offlineStorage=Le,at.initRegistrations=Ae,at.debugInfo=Ve,at.confirmedCapabilities=Z,at}return re.default(I)}(pt);function Pe(te){var ue=St();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function St(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ut=function(te){_e.default(I,te);var ue=Pe(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"method","update"),R.token=O,R}return re.default(I)}(pt);function or(te){var ue=br();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var et=function(te){_e.default(I,te);var ue=or(I);function I(O,R,Z){var j;return oe.default(this,I),j=ue.call(this),q.default(V.default(j),"method","message"),j.active_grant=O,j.payload_type=R,j.http_request=Z,j}return re.default(I)}(pt);function Mr(te){var ue=Fr();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Fr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var dr=function(te){_e.default(I,te);var ue=Mr(I);function I(O){var R;return oe.default(this,I),R=ue.call(this,O),q.default(V.default(R),"method","reply"),q.default(V.default(R),"payload_type","application/json"),q.default(V.default(R),"status",{code:200,status:"OK"}),R}return re.default(I)}(pt);function fr(te){var ue=Wt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot=function(te){_e.default(I,te);var ue=fr(I);function I(){var O;return oe.default(this,I),O=ue.call(this),q.default(V.default(O),"method","close"),O}return re.default(I)}(pt);function L(te){var ue=W();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=re.default(function te(ue,I,O,R,Z,j){oe.default(this,te),this.start=ue,this.end=I,this.title=O,this.details=R,this.id=Z,this.type=j}),He=function(te){_e.default(I,te);var ue=L(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"method","telemetry.v1"),R.events=O,R}return re.default(I)}(pt);function ct(te){var ue=encodeURIComponent(te),I=ue.replace(/%([0-9A-F]{2})/g,function(O,R){return String.fromCharCode(+("0x"+R))});return I.length}function bt(te){var ue=encodeURIComponent(te),I=ue.replace(/%([0-9A-F]{2})/g,function(R,Z){return String.fromCharCode(+("0x"+Z))}),O=new Uint8Array(I.length);return Array.prototype.forEach.call(I,function(R,Z){O[Z]=R.charCodeAt(0)}),O}function zt(te){var ue=Array.prototype.map.call(te,function(O){return String.fromCharCode(O)}).join(""),I=ue.replace(/(.)/g,function(O,R){var Z=R.charCodeAt(0).toString(16).toUpperCase();return Z.length<2&&(Z="0"+Z),"%"+Z});return decodeURIComponent(I)}function tr(te){return JSON.parse(zt(te))}function Re(te){for(var ue="",I=0;I<te.length;++I){var O=String.fromCharCode(te[I]);if(ue+=O,O==="\r"){I+=2;break}}var R=ue.split(" ");return{size:I,protocol:R[0],version:R[1],headerSize:Number(R[2])}}var Ne=function(){function te(){oe.default(this,te)}return re.default(te,null,[{key:"parse",value:function(I){var O=2,R=new Uint8Array(I),Z=Re(R);if(Z.protocol!=="TWILSOCK"||Z.version!=="V3.0")return Ke.error("unsupported protocol: ".concat(Z.protocol," ver ").concat(Z.version)),null;var j;try{j=tr(R.subarray(Z.size,Z.size+Z.headerSize))}catch(at){return Ke.error("failed to parse message header",at,I),null}Ke.debug("message received:",j.method);var Le;if(j.payload_size>0){var Ae=O+Z.size+Z.headerSize,Ve=j.payload_size;if(!j.hasOwnProperty("payload_type")||j.payload_type.indexOf("application/json")===0)try{Le=tr(R.subarray(Ae,Ae+Ve))}catch(at){return Ke.error("failed to parse message body",at,I),null}else j.payload_type.indexOf("text/plain")===0&&(Le=zt(R.subarray(Ae,Ae+Ve)))}return{method:j.method,header:j,payload:Le}}},{key:"createPacket",value:function(I){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";I.payload_size=ct(O);var R=JSON.stringify(I),Z="TWILSOCK V3.0 "+ct(R);Ke.debug("send request:",Z+R+O);var j=bt(Z+`\r
943
+ `+R+`\r
944
+ `+O);return j.buffer}}]),te}();function pe(te){var ue=$e();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function $e(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ae=function(te){_e.default(I,te);var ue=pe(I);function I(O){return oe.default(this,I),ue.call(this,O)}return re.default(I)}(ke.default(Error));function me(te){var ue=we();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function we(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var K=function(te){_e.default(I,te);var ue=me(I);function I(O,R){var Z;return oe.default(this,I),Z=ue.call(this,O),Z.reply=R,Z}return re.default(I)}(ae);function he(te,ue){var I=Object.keys(te);if(Object.getOwnPropertySymbols){var O=Object.getOwnPropertySymbols(te);ue&&(O=O.filter(function(R){return Object.getOwnPropertyDescriptor(te,R).enumerable})),I.push.apply(I,O)}return I}function G(te){for(var ue=1;ue<arguments.length;ue++){var I=arguments[ue]!=null?arguments[ue]:{};ue%2?he(Object(I),!0).forEach(function(O){q.default(te,O,I[O])}):Object.getOwnPropertyDescriptors?Object.defineProperties(te,Object.getOwnPropertyDescriptors(I)):he(Object(I)).forEach(function(O){Object.defineProperty(te,O,Object.getOwnPropertyDescriptor(I,O))})}return te}function de(te){var ue=ee();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=function(te){_e.default(I,te);var ue=de(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"newBackoff",null),q.default(V.default(R),"usedBackoff",null),q.default(V.default(R),"retrier",null),R.options=O?G({},O):{},R}return re.default(I,[{key:"inProgress",get:function(){return!!this.retrier}},{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function(R){this.newBackoff=R}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var R=!this.usedBackoff||this.usedBackoff<this.newBackoff;if(R)this.createRetrier();else{var Z;(Z=this.retrier)===null||Z===void 0||Z.failed(new Error)}}else{var j;(j=this.retrier)===null||j===void 0||j.failed(new Error)}}},{key:"cancel",value:function(){var R;(R=this.retrier)===null||R===void 0||R.cancel()}},{key:"cleanRetrier",value:function(){var R,Z;(R=this.retrier)===null||R===void 0||R.removeAllListeners(),(Z=this.retrier)===null||Z===void 0||Z.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var R=G({},this.options);return this.newBackoff&&(R.min=this.newBackoff,R.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),R.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,R}},{key:"createRetrier",value:function(){var R=this;this.cleanRetrier();var Z=this.getRetryPolicy();this.retrier=new X.Retrier(Z),this.retrier.once("attempt",function(){var j,Le;(j=R.retrier)===null||j===void 0||j.on("attempt",function(){return R.emit("attempt")}),(Le=R.retrier)===null||Le===void 0||Le.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(j){return R.emit("failed",j)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),I}(Ee.ReplayEventEmitter);function qe(te){var ue=dt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function dt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var lt=3e3;function ht(te){setTimeout(te,0)}var Rt=function(te){_e.default(I,te);var ue=qe(I);function I(O,R,Z){var j;oe.default(this,I),j=ue.call(this),q.default(V.default(j),"disconnectingTimer",null),q.default(V.default(j),"disconnectedPromiseResolve",null),q.default(V.default(j),"terminalStates",["disconnected","rejected"]),q.default(V.default(j),"tokenExpiredSasCode",20104),q.default(V.default(j),"terminationReason","Connection is not initialized"),j.websocket=O,j.websocket.on("connected",function(){return j.fsm.socketConnected()}),j.websocket.on("disconnected",function(){return j.fsm.socketClosed()}),j.websocket.on("message",function(Ae){return j.onIncomingMessage(Ae)}),j.websocket.on("socketError",function(Ae){j.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(Ae.message),httpStatusCode:null,errorCode:null}),j.emit("stateChanged","retrying")}),j.transport=R,j.config=Z,j.retrier=new Ye(Z.retryPolicy),j.retrier.on("attempt",function(){return j.retry()}),j.retrier.on("failed",function(Ae){Ke.warn("Retrying failed: ".concat(Ae.message)),j.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){Ke.debug("Browser reported connectivity state: online"),j.resetBackoff(),j.fsm.systemOnline()}),window.addEventListener("offline",function(){Ke.debug("Browser reported connectivity state: offline"),j.websocket.close(),j.fsm.socketClosed()}));var Le=ye.factory({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){j.setupSocket(),j.emit("connecting")},onEnterInitialising:function(){j.sendInit()},onLeaveInitialising:function(){j.cancelInit()},onEnterUpdating:function(){j.sendUpdate()},onLeaveUpdating:function(){j.cancelUpdate()},onEnterRetrying:function(){j.initRetry(),j.emit("connecting")},onEnterConnected:function(){j.resetBackoff(),j.onConnected()},onUserUpdateToken:function(){j.resetBackoff()},onTokenRejected:function(){j.resetBackoff(),j.closeSocket(!0),j.finalizeSocket()},onUserDisconnect:function(){j.closeSocket(!0)},onEnterDisconnecting:function(){j.startDisconnectTimer()},onLeaveDisconnecting:function(){j.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){j.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){j.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){j.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){j.cancelDisconnectTimer()},onDisconnected:function(){j.resetBackoff(),j.finalizeSocket()},onReceiveClose:function(){j.onCloseReceived()},onReceiveOffload:function(Ve,at){Ke.debug("onreceiveoffload: ",at),j.modifyBackoff(at.body),j.onCloseReceived()},onUnsupported:function(){j.closeSocket(!0),j.finalizeSocket()},onError:function(Ve,at){j.closeSocket(at),j.finalizeSocket()},onEnterState:function(Ve){Ve.from!=="none"&&j.changeState(Ve)},onInvalidTransition:function(Ve,at,Tt){Ke.warn("FSM: unexpected transition",at,Tt)}}});return j.fsm=new Le,j}return re.default(I,[{key:"changeState",value:function(R){Ke.debug("FSM: ".concat(R.transition,": ").concat(R.from," --> ").concat(R.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){Ke.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(R){Ke.trace("modifyBackoff",R);var Z=R?R.backoff_policy:null;Z&&typeof Z.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(Z.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var R=this;Ke.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){Ke.debug("disconnecting is timed out"),R.closeSocket(!0)},lt)}},{key:"cancelDisconnectTimer",value:function(){Ke.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return this.state==="connected"&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"denied";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"initRetry",value:function(){Ke.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(Ke.trace("retry"),this.websocket.close(),this.fsm.userRetry()):Ke.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){Ke.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){Ke.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(R){var Z=Ne.parse(R);if(Z){var j=Z.method,Le=Z.header,Ae=Z.payload;if(j!=="reply"&&this.confirmReceiving(Le),j==="notification")this.emit("message",Le.message_type,Ae);else if(Le.method==="reply")this.transport.processReply({id:Le.id,status:Le.status,header:Le,body:Ae});else if(Le.method==="client_update")Le.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(Le.method==="close")if(Le.status.code===308)Ke.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:Le.status.status,body:Ae});else if(Le.status.code===406){var Ve="Server closed connection because can't parse protocol: ".concat(JSON.stringify(Le.status));this.emitReplyConnectionError(Ve,Le,!0),Ke.error(Ve),this.fsm.receiveFatalClose()}else Le.status.code===417?(Ke.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(Le.status))),this.fsm.receiveFatalClose(Le.status.status)):Le.status.code===410?(Ke.warn("Server closed connection: ".concat(JSON.stringify(Le.status))),this.fsm.receiveClose(Le.status.status),this.emit("tokenExpired")):Le.status.code===401?(Ke.error("Server closed connection: ".concat(JSON.stringify(Le.status))),this.fsm.receiveClose(Le.status.status)):(Ke.warn("unexpected message: ",Le.status),this.fsm.receiveOffload({status:Le.status.status,body:null}))}}},{key:"sendInit",value:function(){var O=ze.default(ne.default.mark(function Z(){var j,Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ke.trace("sendInit"),Ve.prev=1,this.emit("beforeSendInit"),Ve.next=5,this.transport.sendInit();case 5:j=Ve.sent,this.config.updateContinuationToken(j.continuationToken),this.config.confirmedCapabilities=j.confirmedCapabilities,this.fsm.initSuccess(j),this.emit("initialized",j),this.emit("tokenUpdated"),Ve.next=17;break;case 13:Ve.prev=13,Ve.t0=Ve.catch(1),Ve.t0 instanceof K?(Le=!1,Ke.warn("Init rejected by server: ".concat(JSON.stringify(Ve.t0.reply.status))),this.emit("sendInitFailed"),Ve.t0.reply.status.code===401||Ve.t0.reply.status.code===403?(Le=!0,this.fsm.tokenRejected(Ve.t0.reply.status),Ve.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Ve.t0.reply.status.code===429?(this.modifyBackoff(Ve.t0.reply.body),this.fsm.initError(!0)):Ve.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(Ve.t0.message,Ve.t0.reply,Le)):(this.terminationReason=Ve.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(Ve.t0.message,`
945
+ `).concat(JSON.stringify(Ve.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Ve.t0);case 17:case"end":return Ve.stop()}},Z,this,[[1,13]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"sendUpdate",value:function(){var O=ze.default(ne.default.mark(function Z(){var j,Le,Ae;return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ke.trace("sendUpdate"),j=new ut(this.config.token),at.prev=2,at.next=5,this.transport.sendWithReply(j);case 5:Le=at.sent,this.fsm.updateSuccess(Le.body),this.emit("tokenUpdated"),at.next=14;break;case 10:at.prev=10,at.t0=at.catch(2),at.t0 instanceof K?(Ae=!1,Ke.warn("Token update rejected by server: ".concat(JSON.stringify(at.t0.reply.status))),at.t0.reply.status.code===401||at.t0.reply.status.code===403?(Ae=!0,this.fsm.tokenRejected(at.t0.reply.status),at.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):at.t0.reply.status.code===429?(this.modifyBackoff(at.t0.reply.body),this.fsm.updateError(at.t0.reply.status)):this.fsm.updateError(at.t0.reply.status),this.emitReplyConnectionError(at.t0.message,at.t0.reply,Ae)):(this.emit("error",!1,at.t0.message,null,null),this.fsm.updateError(at.t0)),this.emit("tokenUpdated",at.t0);case 14:case"end":return at.stop()}},Z,this,[[2,10]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"emitReplyConnectionError",value:function(R,Z,j){var Le=Z.status&&Z.status.description?Z.status.description:R,Ae=Z.status.code,Ve=Z.status&&Z.status.errorCode?Z.status.errorCode:null;j&&(this.terminationReason=Le),this.emit("connectionError",{terminal:j,message:"Connection error: ".concat(Le),httpStatusCode:Ae,errorCode:Ve})}},{key:"cancelInit",value:function(){Ke.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Ke.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(R){Ke.trace("confirmReceiving");try{this.transport.send(new dr(R.id))}catch(Z){Ke.debug("failed to confirm packet receiving",Z)}}},{key:"closeSocket",value:function(R){var Z=this;Ke.trace("closeSocket (graceful: ".concat(R,")")),R&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),ht(function(){return Z.fsm.socketClosed()})}},{key:"connect",value:function(){Ke.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var R=this;return Ke.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(Z){R.disconnectedPromiseResolve=Z,R.fsm.userDisconnect()})}},{key:"updateToken",value:function(R){var Z=this;return Ke.trace("updateToken:",R),new Promise(function(j,Le){Z.once("tokenUpdated",function(Ae){Ae?Le(Ae):j()}),Z.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),I}(Ee.ReplayEventEmitter),xt=function(){function te(){oe.default(this,te)}return re.default(te,null,[{key:"getMetadata",value:function(I){var O,R,Z,j,Le,Ae,Ve,at,Tt=I&&I.clientMetadata?I.clientMetadata:{},Br=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Nn={env:(O=M.name)!==null&&O!==void 0?O:"unknown",envv:(R=M.version)!==null&&R!==void 0?R:"unknown",os:(Z=(j=M.os)===null||j===void 0?void 0:j.family)!==null&&Z!==void 0?Z:"unknown",osv:(Le=(Ae=M.os)===null||Ae===void 0?void 0:Ae.version)!==null&&Le!==void 0?Le:"unknown",osa:(Ve=(at=M.os)===null||at===void 0?void 0:at.architecture)!==null&&Ve!==void 0?Ve:"unknown",sdk:"js-default"},kn={};return Br.filter(function(D){return D in Tt||D in Nn}).forEach(function(D){return kn[D]=D in Tt?Tt[D]:Nn[D]}),kn}}]),te}(),kt=3e4;function $t(te){return te>=200&&te<300}function It(te){switch(Se.default(te)){case"undefined":return"";case"object":return JSON.stringify(te);default:return te}}var jt=function(){function te(ue,I){var O=this;oe.default(this,te),this.config=I,this.activeRequests=new Map,this.channel=ue,this.channel.on("reply",function(R){return O.processReply(R)}),this.channel.on("disconnected",function(){O.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new ae("disconnected"))}),O.activeRequests.clear()})}return re.default(te,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(I){var O=this.activeRequests.get(I.id);O&&(clearTimeout(O.timeout),this.activeRequests.delete(I.id),$t(I.status.code)?O.resolve(I):(O.reject(new K("Transport failure: "+I.status.status,I)),Ke.trace("message rejected")))}},{key:"storeRequest",value:function(I,O,R){var Z={resolve:O,reject:R,timeout:setTimeout(function(){Ke.trace("request",I,"is timed out"),R(new ae("Twilsock: request timeout: "+I))},kt)};this.activeRequests.set(I,Z)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(I){clearTimeout(I.timeout),I.reject(new ae("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var ue=ze.default(ne.default.mark(function O(){var R,Z,j;return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ke.trace("sendInit"),R=xt.getMetadata(this.config),Z=new At(this.config.token,this.config.continuationToken,R,this.config.initRegistrations,this.config.tweaks),Ae.next=5,this.sendWithReply(Z);case 5:return j=Ae.sent,Ae.abrupt("return",new ot(j.id,j.header.continuation_token,new Set(j.header.capabilities),j.header.continuation_token_status,j.header.offline_storage,j.header.init_registrations,j.header.debug_info));case 7:case"end":return Ae.stop()}},O,this)}));function I(){return ue.apply(this,arguments)}return I}()},{key:"sendClose",value:function(){var I=new Ot;this.send(I)}},{key:"sendWithReply",value:function(I,O){var R=this;return new Promise(function(Z,j){var Le=R.send(I,O);R.storeRequest(Le,Z,j)})}},{key:"send",value:function(I,O){I.id=I.id||"TM".concat(N.v4());var R=Ne.createPacket(I,It(O));try{return this.channel.send(R),I.id}catch(Z){throw Ke.debug("failed to send ",I,Z),Ke.trace(Z.stack),Z}}}]),te}();function on(te){var ue=_n();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function _n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ut=function(te){_e.default(I,te);var ue=on(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"socket",null),R.url=O,R.url=O,R.WebSocket=e.WebSocket||e.MozWebSocket||{},R}return re.default(I,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var R=this;Ke.trace("connecting to socket");var Z;try{Z=new this.WebSocket(this.url)}catch(j){Ke.debug("Socket error: ".concat(this.url)),this.emit("socketError",j);return}Z.binaryType="arraybuffer",Z.onopen=function(){Ke.debug("socket opened ".concat(R.url)),R.emit("connected")},Z.onclose=function(j){Ke.debug("socket closed",j),R.emit("disconnected",j)},Z.onerror=function(j){Ke.debug("Socket error:",j),R.emit("socketError",j)},Z.onmessage=function(j){R.emit("message",j.data)},this.socket=Z}},{key:"send",value:function(R){return this.socket&&this.socket.send(R)}},{key:"close",value:function(){if(Ke.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),I}(Ee.ReplayEventEmitter);function qn(te){var ue=pa();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function pa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Za=function(te){_e.default(I,te);var ue=qn(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),R.transport=O,R.registrations=new Map,R.registrationsInProgress=new Map,R}return re.default(I,[{key:"putNotificationContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){var Ae;return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ae={method:"put_notification_ctx",notification_ctx_id:j},at.next=3,this.transport.sendWithReply(Ae,Le);case 3:case"end":return at.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"deleteNotificationContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){var Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Le={method:"delete_notification_ctx",notification_ctx_id:j},Ve.next=3,this.transport.sendWithReply(Le);case 3:case"end":return Ve.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"updateRegistration",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){var Ae,Ve;return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return Ke.debug("update registration for context",j),Ae=this.registrationsInProgress.get(j),Ae||(Ae=new Set,this.registrationsInProgress.set(j,Ae)),Ve=N.v4(),Ae.add(Ve),Tt.prev=5,Tt.next=8,this.putNotificationContext(j,Le);case 8:Ke.debug("registration attempt succeeded for context",Le),Ae.delete(Ve),Ae.size===0&&(this.registrationsInProgress.delete(j),this.emit("registered",j)),Tt.next=19;break;case 13:Tt.prev=13,Tt.t0=Tt.catch(5),Ke.warn("registration attempt failed for context",Le),Ke.debug(Tt.t0),Ae.delete(Ve),Ae.size===0&&(this.registrationsInProgress.delete(j),this.emit("registrationFailed",j,Tt.t0));case 19:case"end":return Tt.stop()}},Z,this,[[5,13]])}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"updateRegistrations",value:function(){var O=ze.default(ne.default.mark(function Z(){var j=this,Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ke.trace("refreshing ".concat(this.registrations.size," registrations")),Le=[],this.registrations.forEach(function(at,Tt){Le.push(j.updateRegistration(Tt,at))}),Ve.next=5,Promise.all(Le);case 5:case"end":return Ve.stop()}},Z,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:if(!(!j||!Le)){Ve.next=2;break}throw new ae("Invalid arguments provided");case 2:return this.registrations.set(j,Le),Ve.next=5,this.updateRegistration(j,Le);case 5:return Ve.abrupt("return",Ve.sent);case 6:case"end":return Ve.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:if(this.registrations.has(j)){Ae.next=2;break}return Ae.abrupt("return");case 2:return Ae.next=4,this.deleteNotificationContext(j);case 4:this.transport.isConnected&&this.registrations.delete(j);case 5:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()}]),I}(Ee.ReplayEventEmitter);function ti(te){var ue=va();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function va(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ri=function(te){_e.default(I,te);var ue=ti(I);function I(O,R,Z){var j;return oe.default(this,I),j=ue.call(this,R),j.status=O,j.description=R,j.body=Z,j}return re.default(I)}(ae);function gi(te){var ue=Ga();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Ga(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var en=function(te){_e.default(I,te);var ue=gi(I);function I(O){return oe.default(this,I),ue.call(this,O)}return re.default(I)}(ae),ji=2e4;function Ns(te){return te>=200&&te<300}function Ui(te){return te&&te.header&&te.header.http_status}function Ls(te){var ue=te.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(ue){var I={protocol:ue[1],host:ue[2],hostname:ue[3],port:ue[4],pathname:ue[5],search:ue[6],hash:ue[7],params:{}};if(I.search.length>0){var O=I.search.substring(1);I.params=O.split("&").map(function(R){return R.split("=")}).reduce(function(R,Z){return R.hasOwnProperty(Z[0])?Array.isArray(R[Z[0]])?R[Z[0]].push(Z[1]):R[Z[0]]=[R[Z[0]],Z[1]]:R[Z[0]]=Z[1],R},{})}return I}throw new ae("Incorrect URI: "+te)}function zo(te,ue){var I=Ls(ue),O={method:te,host:I.host,path:I.pathname};return I.params&&(O.params=I.params),O}function Vn(te,ue,I,O,R){return{to:zo(te,ue),headers:I,body:O,grant:R}}var Ds=function(){function te(ue,I,O){oe.default(this,te),this.config=O,this.transport=ue,this.pendingMessages=[],this.twilsock=I}return re.default(te,[{key:"saveMessage",value:function(I){var O=this;return new Promise(function(R,Z){var j={message:I,resolve:R,reject:Z,alreadyRejected:!1,timeout:setTimeout(function(){Ke.debug("request is timed out"),Z(new ae("request '".concat(I.to.method,"' to '").concat(I.to.host,"' timed out"))),j.alreadyRejected=!0},ji)};O.pendingMessages.push(j)})}},{key:"sendPendingMessages",value:function(){for(var I=this,O=function(){var j=I.pendingMessages[0];if(!j.alreadyRejected)try{var Le=j.message;I.actualSend(Le).then(function(Ae){return j.resolve(Ae)}).catch(function(Ae){return j.reject(Ae)}),clearTimeout(j.timeout)}catch(Ae){return Ke.debug("Failed to send pending message",Ae),"break"}I.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var R=O();if(R==="break")break}}},{key:"rejectPendingMessages",value:function(){var I=this;this.pendingMessages.forEach(function(O){O.reject(new en("Unable to connect: "+I.twilsock.getTerminationReason)),O.alreadyRejected=!0,clearTimeout(O.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var ue=ze.default(ne.default.mark(function O(R){var Z,j,Le,Ae,Ve,at,Tt,Br;return ne.default.wrap(function(kn){for(;;)switch(kn.prev=kn.next){case 0:return j=R.to,Le=R.headers,Ae=R.body,Ve=(Z=R.grant)!==null&&Z!==void 0?Z:this.config.activeGrant,at={host:j.host,path:j.path,method:j.method,params:j.params,headers:Le},Tt=new et(Ve,Le["Content-Type"]||"application/json",at),Ke.trace("Sending upstream message",Tt),kn.next=9,this.transport.sendWithReply(Tt,Ae);case 9:if(Br=kn.sent,Ke.trace("Received upstream message response",Br),!(Ui(Br)&&!Ns(Br.header.http_status.code))){kn.next=13;break}throw new ri(Br.header.http_status.code,Br.header.http_status.status,Br.body);case 13:return kn.abrupt("return",{status:Br.header.http_status,headers:Br.header.http_headers,body:Br.body});case 14:case"end":return kn.stop()}},O,this)}));function I(O){return ue.apply(this,arguments)}return I}()},{key:"send",value:function(I,O){var R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},Z=arguments.length>3?arguments[3]:void 0,j=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new en("Unable to connect: "+this.twilsock.getTerminationReason));var Le=Vn(I,O,R,Z,j);return this.twilsock.isConnected?this.actualSend(Le):this.saveMessage(Le)}}]),te}(),Ho=function(){function te(){var ue=this;oe.default(this,te),this._promise=new Promise(function(I,O){ue._resolve=I,ue._reject=O})}return re.default(te,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(I){this._resolve(I)}},{key:"set",value:function(I){this._resolve(I)}},{key:"fail",value:function(I){this._reject(I)}}]),te}(),qo=function(){function te(ue){oe.default(this,te),this.id=ue}return re.default(te,null,[{key:"create",value:function(I){if(I instanceof Object&&"storage_id"in I)return new te(I.storage_id);throw new ae('Field "storage_id" is missing')}}]),te}(),hn=function(){function te(){return oe.default(this,te),q.default(this,"initializedFlag","twilio_twilsock_token_storage"),q.default(this,"tokenStoragePrefix","twilio_continuation_token_"),te._instance||(this.initialize(),te._instance=this),te._instance}return re.default(te,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(I,O){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(O),I)}},{key:"getStoredToken",value:function(I){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(I)):null}},{key:"initialize",value:function(){var I=this;if(this.canStore()){var O=this.sessionStorage.getItem(this.initializedFlag);O&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var R=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){R(I.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var I=[],O=0;O<this.sessionStorage.length;O++){var R=this.sessionStorage.key(O);R&&R.indexOf(this.tokenStoragePrefix)===0&&I.push(R)}var Z=this.sessionStorage.removeItem;I.forEach(function(j){return Z(j)}),Z(this.initializedFlag)}}},{key:"getKeyName",value:function(I){return"".concat(this.tokenStoragePrefix).concat(I)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),te}();q.default(hn,"_instance",null);var js=new hn,Pn=function(){function te(ue,I,O,R,Z,j){oe.default(this,te),this.title=ue,this.details=I,this.start=O,this.type=Z,this.id=j,this.end=R}return re.default(te,[{key:"toTelemetryEvent",value:function(){var I=new Date,O=this.start,R=this.end?this.end:I;if(R<O){var Z=R;R=O,O=Z}var j=O.getTime()-I.getTime(),Le=R.getTime()-I.getTime(),Ae=new ie(j,Le,this.title,this.details,this.id,this.type);return Ae}}]),te}();t.TelemetryPoint=void 0,function(te){te[te.Start=0]="Start",te[te.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(te){te[te.MinEventsPortion=0]="MinEventsPortion",te[te.AnyEvents=1]="AnyEvents",te[te.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var Dr=function(){function te(ue,I){oe.default(this,te),q.default(this,"minEventsPortionToSend",50),q.default(this,"maxEventsPortionToSend",100),q.default(this,"pendingEvents",new Map),q.default(this,"readyEvents",[]),q.default(this,"hasInitializationFinished",!1),q.default(this,"_canSendTelemetry",!1),this.config=ue,this.packetInterface=I}return re.default(te,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(I){Ke.debug("TelemetryTracker.canSendTelemetry: ".concat(I," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!I&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=I,I&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),I&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(I){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(I)}},{key:"addPartialEvent",value:function(I,O,R){Ke.debug("Adding ".concat(R===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(O,"' event"));var Z=this.pendingEvents.has(O);if(R===t.TelemetryPoint.Start)Z&&Ke.debug("Overwriting starting point for '".concat(O,"' event")),this.pendingEvents.set(O,I);else{if(!Z){Ke.info("Could not find started event for '".concat(O,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(O),I)),this.pendingEvents.delete(O)}}},{key:"getTelemetryToSend",value:function(I){return!this.canSendTelemetry||this.readyEvents.length==0?[]:I==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(I==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(I){var O=this,R=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),Z=this.readyEvents.splice(0,R);return I&&Z.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(j,Le){if(!(Z.length>=O.maxEventsPortionToSend)){var Ae=O.pendingEvents.get(Le);O.pendingEvents.delete(Le),Z.push(new Pn("[UNFINISHED] ".concat(Ae.title),Ae.details,Ae.start,null,Ae.type,Ae.id))}}),Z}},{key:"merge",value:function(I,O){return new Pn(O.title?O.title:I.title,O.details?O.details:I.details,I.start,O.end,O.type?O.type:I.type,O.id?O.id:I.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(I){var O=this.getTelemetryToSend(I);if(O.length!==0)try{this.packetInterface.send(new He(O.map(function(R){return R.toTelemetryEvent()})))}catch(R){Ke.debug("Error while sending ".concat(O.length," telemetry events due to ").concat(R,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(O)}}}]),te}();function Vo(te){var ue=ni();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function ni(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Mn=re.default(function te(){oe.default(this,te)});q.default(Mn,"TWILSOCK_CONNECT","twilsock.sdk.connect"),q.default(Mn,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(te){_e.default(I,te);var ue=Vo(I);function I(O,R,Z){var j;oe.default(this,I),j=ue.call(this),q.default(V.default(j),"version",Be),q.default(V.default(j),"offlineStorageDeferred",new Ho),Z.continuationToken=Z.continuationToken?Z.continuationToken:js.getStoredToken(R);var Le=j.config=new be(O,R,Z);Ke.setLevel(Le.logLevel);var Ae=new Ut(Le.url),Ve=new jt(Ae,Le);return j.channel=new Rt(Ae,Ve,Le),j.registrations=new Za(Ve),j.upstream=new Ds(Ve,j.channel,Le),j.telemetryTracker=new Dr(Le,Ve),j.channel.on("initialized",function(){return j.telemetryTracker.canSendTelemetry=!0}),Ae.on("disconnected",function(){return j.telemetryTracker.canSendTelemetry=!1}),j.registrations.on("registered",function(at){return j.emit("registered",at)}),j.channel.on("message",function(at,Tt){return setTimeout(function(){return j.emit("message",at,Tt)},0)}),j.channel.on("stateChanged",function(at){return setTimeout(function(){return j.emit("stateChanged",at)},0)}),j.channel.on("connectionError",function(at){return setTimeout(function(){return j.emit("connectionError",at)},0)}),j.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return j.emit("tokenAboutToExpire")},0)}),j.channel.on("tokenExpired",function(){return setTimeout(function(){return j.emit("tokenExpired")},0)}),j.channel.on("connected",function(){return j.registrations.updateRegistrations()}),j.channel.on("connected",function(){return j.upstream.sendPendingMessages()}),j.channel.on("connected",function(){return setTimeout(function(){return j.emit("connected")},0)}),j.channel.on("beforeConnect",function(){return j.telemetryTracker.addPartialEvent(new Pn("Establish WebSocket connection","",new Date),Mn.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),j.channel.on("connected",function(){return j.telemetryTracker.addPartialEvent(new Pn("Establish WebSocket connection","",new Date,new Date),Mn.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),j.channel.on("beforeSendInit",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","",new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.Start)}),j.channel.on("initialized",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","Succeeded",new Date,new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("sendInitFailed",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","Failed",new Date,new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("initialized",function(at){j.handleStorageId(R,at),js.storeToken(at.continuationToken,R),setTimeout(function(){return j.emit("initialized",at)},0)}),j.channel.on("disconnected",function(){return setTimeout(function(){return j.emit("disconnected")},0)}),j.channel.on("disconnected",function(){return j.upstream.rejectPendingMessages()}),j.channel.on("disconnected",function(){return j.offlineStorageDeferred.fail(new ae("Client disconnected"))}),j.offlineStorageDeferred.promise.catch(function(){}),j}return re.default(I,[{key:"emit",value:function(R){for(var Z,j=arguments.length,Le=new Array(j>1?j-1:0),Ae=1;Ae<j;Ae++)Le[Ae-1]=arguments[Ae];return Ke.debug("Emitting ".concat(R.toString(),"(").concat(Le.map(function(Ve){return JSON.stringify(Ve)}).join(", "),")")),(Z=xe.default(Te.default(I.prototype),"emit",this)).call.apply(Z,[this,R].concat(Le))}},{key:"handleStorageId",value:function(R,Z){if(!Z.offlineStorage)this.offlineStorageDeferred.fail(new ae("No offline storage id"));else if(Z.offlineStorage.hasOwnProperty(R))try{this.offlineStorageDeferred.set(qo.create(Z.offlineStorage[R])),Ke.debug("Offline storage for '".concat(R,"' product: ").concat(JSON.stringify(Z.offlineStorage[R]),"."))}catch(j){this.offlineStorageDeferred.fail(new ae("Failed to parse offline storage for ".concat(R," ").concat(JSON.stringify(Z.offlineStorage[R]),". ").concat(j,".")))}else this.offlineStorageDeferred.fail(new ae("No offline storage id for '".concat(R,"' product: ").concat(JSON.stringify(Z.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:if(Ke.trace("updating token '".concat(j,"'")),this.config.token!==j){Ae.next=3;break}return Ae.abrupt("return");case 3:return this.config.updateToken(j),Ae.next=6,this.channel.updateToken(j);case 6:return Ae.abrupt("return",Ae.sent);case 7:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ve.next=2,this.registrations.setNotificationsContext(j,Le);case 2:case"end":return Ve.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ae.next=2,this.registrations.removeNotificationsContext(j);case 2:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var O=ze.default(ne.default.mark(function Z(){return ne.default.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Le.next=3,this.channel.disconnect();case 3:return Le.abrupt("return",Le.sent);case 4:case"end":return Le.stop()}},Z,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"get",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae){return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),at.next=3,this.upstream.send("GET",j,Le,void 0,Ae);case 3:return at.abrupt("return",at.sent);case 4:case"end":return at.stop()}},Z,this)}));function R(Z,j,Le){return O.apply(this,arguments)}return R}()},{key:"post",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("POST",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"put",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("PUT",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"delete",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("DELETE",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"addTelemetryEvent",value:function(R){this.telemetryTracker.addTelemetryEvent(R),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(R,Z,j){this.telemetryTracker.addPartialEvent(R,Z,j),j===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),I}(Ee.ReplayEventEmitter),t.TwilsockClient=Xe([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Ct("design:paramtypes",[String,String,Object])],t.TwilsockClient);var Us=function(){function te(ue){oe.default(this,te),this.product=ue,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return re.default(te,[{key:"populateInitRegistrations",value:function(I){var O=new Set(this.message_types);for(var R in I)O.add(I[R]);this.message_types=Array.from(O)}}]),te}();t.InitRegistration=Us,t.TelemetryEventDescription=Pn,t.TelemetryTracker=Dr,t.TransportUnavailableError=en,t.Twilsock=t.TwilsockClient,t.TwilsockError=ae})(rb);var TI={},EI=Ar,bee=Kt,wee=Er,_ee=Vt,Kb=zc,kee=Uc,See=Pc,$ee=yn,Tee=Mc,nl=Object.assign,CI=Object.defineProperty,Eee=bee([].concat),RI=!nl||_ee(function(){if(EI&&nl({b:1},nl(CI({},"a",{enumerable:!0,get:function(){CI(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var t={},e={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return t[r]=7,n.split("").forEach(function(i){e[i]=i}),nl({},t)[r]!==7||Kb(nl({},e)).join("")!==n})?function(e,r){for(var n=$ee(e),i=arguments.length,a=1,s=kee.f,o=See.f;i>a;)for(var u=Tee(arguments[a++]),l=s?Eee(Kb(u),s(u)):Kb(u),c=l.length,d=0,f;c>d;)f=l[d++],(!EI||wee(o,u,f))&&(n[f]=u[f]);return n}:nl,Cee=er,xI=RI;Cee({target:"Object",stat:!0,arity:2,forced:Object.assign!==xI},{assign:xI});/*
946
+ @license
947
+ The MIT License (MIT)
948
+
949
+ Copyright (c) 2016 Twilio Inc.
950
+
951
+ Permission is hereby granted, free of charge, to any person obtaining a copy
952
+ of this software and associated documentation files (the "Software"), to deal
953
+ in the Software without restriction, including without limitation the rights
954
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
955
+ copies of the Software, and to permit persons to whom the Software is
956
+ furnished to do so, subject to the following conditions:
957
+
958
+ The above copyright notice and this permission notice shall be included in all
959
+ copies or substantial portions of the Software.
960
+
961
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
962
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
963
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
964
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
965
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
966
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
967
+ SOFTWARE.
968
+
969
+ */(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Mu,r=sa,n=Oa,i=ia,a=aa,s=li,o=Hu,u=ui,l=rb,c=ys,d=bs,f=oa,m=ud,b=ld,A=qu,N=pd,z=an;function X(Re){return Re&&typeof Re=="object"&&"default"in Re?Re:{default:Re}}function Ee(Re){if(Re&&Re.__esModule)return Re;var Ne=Object.create(null);return Re&&Object.keys(Re).forEach(function(pe){if(pe!=="default"){var $e=Object.getOwnPropertyDescriptor(Re,pe);Object.defineProperty(Ne,pe,$e.get?$e:{enumerable:!0,get:function(){return Re[pe]}})}}),Ne.default=Re,Object.freeze(Ne)}var Ie=X(e),Fe=X(r),Oe=X(n),ze=X(i),V=X(a),xe=X(s),_e=X(o),se=X(u),Te=X(c),re=X(d),oe=X(m),q=X(b),ne=Ee(A),Se=Ee(N);function H(Re,Ne,pe,$e){var ae=arguments.length,me=ae<3?Ne:$e===null?$e=Object.getOwnPropertyDescriptor(Ne,pe):$e,we;if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")me=Reflect.decorate(Re,Ne,pe,$e);else for(var K=Re.length-1;K>=0;K--)(we=Re[K])&&(me=(ae<3?we(me):ae>3?we(Ne,pe,me):we(Ne,pe))||me);return ae>3&&me&&Object.defineProperty(Ne,pe,me),me}function ye(Re,Ne){if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Re,Ne)}var ke;function M(){}M.prototype=Object.create(null);function Xe(){Xe.init.call(this)}Xe.EventEmitter=Xe,Xe.usingDomains=!1,Xe.prototype.domain=void 0,Xe.prototype._events=void 0,Xe.prototype._maxListeners=void 0,Xe.defaultMaxListeners=10,Xe.init=function(){this.domain=null,Xe.usingDomains&&ke.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new M,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Xe.prototype.setMaxListeners=function(Ne){if(typeof Ne!="number"||Ne<0||isNaN(Ne))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=Ne,this};function Ct(Re){return Re._maxListeners===void 0?Xe.defaultMaxListeners:Re._maxListeners}Xe.prototype.getMaxListeners=function(){return Ct(this)};function rt(Re,Ne,pe){if(Ne)Re.call(pe);else for(var $e=Re.length,ae=Q(Re,$e),me=0;me<$e;++me)ae[me].call(pe)}function je(Re,Ne,pe,$e){if(Ne)Re.call(pe,$e);else for(var ae=Re.length,me=Q(Re,ae),we=0;we<ae;++we)me[we].call(pe,$e)}function ce(Re,Ne,pe,$e,ae){if(Ne)Re.call(pe,$e,ae);else for(var me=Re.length,we=Q(Re,me),K=0;K<me;++K)we[K].call(pe,$e,ae)}function Ke(Re,Ne,pe,$e,ae,me){if(Ne)Re.call(pe,$e,ae,me);else for(var we=Re.length,K=Q(Re,we),he=0;he<we;++he)K[he].call(pe,$e,ae,me)}function Be(Re,Ne,pe,$e){if(Ne)Re.apply(pe,$e);else for(var ae=Re.length,me=Q(Re,ae),we=0;we<ae;++we)me[we].apply(pe,$e)}Xe.prototype.emit=function(Ne){var pe,$e,ae,me,we,K,he,G=Ne==="error";if(K=this._events,K)G=G&&K.error==null;else if(!G)return!1;if(he=this.domain,G){if(pe=arguments[1],he)pe||(pe=new Error('Uncaught, unspecified "error" event')),pe.domainEmitter=this,pe.domain=he,pe.domainThrown=!1,he.emit("error",pe);else{if(pe instanceof Error)throw pe;var de=new Error('Uncaught, unspecified "error" event. ('+pe+")");throw de.context=pe,de}return!1}if($e=K[Ne],!$e)return!1;var ee=typeof $e=="function";switch(ae=arguments.length,ae){case 1:rt($e,ee,this);break;case 2:je($e,ee,this,arguments[1]);break;case 3:ce($e,ee,this,arguments[1],arguments[2]);break;case 4:Ke($e,ee,this,arguments[1],arguments[2],arguments[3]);break;default:for(me=new Array(ae-1),we=1;we<ae;we++)me[we-1]=arguments[we];Be($e,ee,this,me)}return!0};function be(Re,Ne,pe,$e){var ae,me,we;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(me=Re._events,me?(me.newListener&&(Re.emit("newListener",Ne,pe.listener?pe.listener:pe),me=Re._events),we=me[Ne]):(me=Re._events=new M,Re._eventsCount=0),!we)we=me[Ne]=pe,++Re._eventsCount;else if(typeof we=="function"?we=me[Ne]=$e?[pe,we]:[we,pe]:$e?we.unshift(pe):we.push(pe),!we.warned&&(ae=Ct(Re),ae&&ae>0&&we.length>ae)){we.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+we.length+" "+Ne+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=Re,K.type=Ne,K.count=we.length,pt(K)}return Re}function pt(Re){typeof console.warn=="function"?console.warn(Re):console.log(Re)}Xe.prototype.addListener=function(Ne,pe){return be(this,Ne,pe,!1)},Xe.prototype.on=Xe.prototype.addListener,Xe.prototype.prependListener=function(Ne,pe){return be(this,Ne,pe,!0)};function Ze(Re,Ne,pe){var $e=!1;function ae(){Re.removeListener(Ne,ae),$e||($e=!0,pe.apply(Re,arguments))}return ae.listener=pe,ae}Xe.prototype.once=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.on(Ne,Ze(this,Ne,pe)),this},Xe.prototype.prependOnceListener=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(Ne,Ze(this,Ne,pe)),this},Xe.prototype.removeListener=function(Ne,pe){var $e,ae,me,we,K;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(ae=this._events,!ae)return this;if($e=ae[Ne],!$e)return this;if($e===pe||$e.listener&&$e.listener===pe)--this._eventsCount===0?this._events=new M:(delete ae[Ne],ae.removeListener&&this.emit("removeListener",Ne,$e.listener||pe));else if(typeof $e!="function"){for(me=-1,we=$e.length;we-- >0;)if($e[we]===pe||$e[we].listener&&$e[we].listener===pe){K=$e[we].listener,me=we;break}if(me<0)return this;if($e.length===1){if($e[0]=void 0,--this._eventsCount===0)return this._events=new M,this;delete ae[Ne]}else At($e,me);ae.removeListener&&this.emit("removeListener",Ne,K||pe)}return this},Xe.prototype.off=function(Re,Ne){return this.removeListener(Re,Ne)},Xe.prototype.removeAllListeners=function(Ne){var pe,$e;if($e=this._events,!$e)return this;if(!$e.removeListener)return arguments.length===0?(this._events=new M,this._eventsCount=0):$e[Ne]&&(--this._eventsCount===0?this._events=new M:delete $e[Ne]),this;if(arguments.length===0){for(var ae=Object.keys($e),me=0,we;me<ae.length;++me)we=ae[me],we!=="removeListener"&&this.removeAllListeners(we);return this.removeAllListeners("removeListener"),this._events=new M,this._eventsCount=0,this}if(pe=$e[Ne],typeof pe=="function")this.removeListener(Ne,pe);else if(pe)do this.removeListener(Ne,pe[pe.length-1]);while(pe[0]);return this},Xe.prototype.listeners=function(Ne){var pe,$e,ae=this._events;return ae?(pe=ae[Ne],pe?typeof pe=="function"?$e=[pe.listener||pe]:$e=Ue(pe):$e=[]):$e=[],$e},Xe.listenerCount=function(Re,Ne){return typeof Re.listenerCount=="function"?Re.listenerCount(Ne):Jt.call(Re,Ne)},Xe.prototype.listenerCount=Jt;function Jt(Re){var Ne=this._events;if(Ne){var pe=Ne[Re];if(typeof pe=="function")return 1;if(pe)return pe.length}return 0}Xe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function At(Re,Ne){for(var pe=Ne,$e=pe+1,ae=Re.length;$e<ae;pe+=1,$e+=1)Re[pe]=Re[$e];Re.pop()}function Q(Re,Ne){for(var pe=new Array(Ne);Ne--;)pe[Ne]=Re[Ne];return pe}function Ue(Re){for(var Ne=new Array(Re.length),pe=0;pe<Ne.length;++pe)Ne[pe]=Re[pe].listener||Re[pe];return Ne}var ot=ne.getLogger("twilio-notificatiions");function Pe(Re,Ne){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(Re,":")].concat(Array.from(Ne))}var St=function(){function Re(){Fe.default(this,Re)}return Oe.default(Re,[{key:"setLevel",value:function(pe){ot.setLevel(pe)}},{key:"trace",value:function(){if(ot.getLevel()==ot.levels.TRACE){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.debug.apply(null,Pe("T",$e))}}},{key:"debug",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.debug.apply(null,Pe("D",$e))}},{key:"info",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.info.apply(null,Pe("I",$e))}},{key:"warn",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.warn.apply(null,Pe("W",$e))}},{key:"error",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.error.apply(null,Pe("E",$e))}}]),Re}(),ut=new St;function or(Re){var Ne=br();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var et=Oe.default(function Re(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",$e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;Fe.default(this,Re),this.token=Ne,this.notificationId=pe,this.messageTypes=$e});function Mr(Re,Ne){return[].concat(q.default(q.default(Re).filter(function(pe){return!Ne.has(pe)})),q.default(q.default(Ne).filter(function(pe){return!Re.has(pe)})))}function Fr(Re,Ne){var pe=new Set;return Re.notificationId!==Ne.notificationId&&pe.add("notificationId"),Re.token!==Ne.token&&pe.add("token"),Mr(Re.messageTypes,Ne.messageTypes).length>0&&pe.add("messageType"),[pe.size>0,pe]}var dr=function(Re){ze.default(pe,Re);var Ne=or(pe);function pe($e){var ae;return Fe.default(this,pe),ae=Ne.call(this),re.default(Te.default(ae),"desiredState",new et),re.default(Te.default(ae),"currentState",new et),re.default(Te.default(ae),"_hasActiveAttempt",!1),ae.channelType=$e,ae}return Oe.default(pe,[{key:"setNotificationId",value:function(ae){this.desiredState.notificationId=ae}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(ae){if(this.desiredState.messageTypes.has(ae)){ut.debug("message type '".concat(ae,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(ae)}},{key:"unsubscribe",value:function(ae){this.desiredState.messageTypes.has(ae)&&this.desiredState.messageTypes.delete(ae)}},{key:"updateToken",value:function(ae){this.desiredState.token=ae}},{key:"commitChanges",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we,K,he,G,de,ee;return _e.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:if(!this._hasActiveAttempt){qe.next=3;break}throw ut.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(we=Fr(this.desiredState,this.currentState),K=oe.default(we,2),he=K[0],G=K[1],he){qe.next=6;break}return qe.abrupt("return");case 6:if(this.currentState.notificationId||G.delete("notificationId"),ut.trace("Persisting ".concat(this.channelType," registration"),G,this.desiredState),qe.prev=8,this._hasActiveAttempt=!0,de=new et,de.token=this.desiredState.token,de.notificationId=this.desiredState.notificationId,de.messageTypes=new Set(this.desiredState.messageTypes),!(de.messageTypes.size>0)){qe.next=24;break}return qe.next=17,this.updateRegistration(de,G);case 17:ee=qe.sent,this.currentState.token=ee.token,this.currentState.notificationId=ee.notificationId,this.currentState.messageTypes=new Set(ee.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),qe.next=30;break;case 24:return qe.next=26,this.removeRegistration();case 26:this.currentState.token=de.token,this.currentState.notificationId=de.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:qe.next=35;break;case 32:throw qe.prev=32,qe.t0=qe.catch(8),qe.t0;case 35:return qe.prev=35,this._hasActiveAttempt=!1,qe.finish(35);case 38:case"end":return qe.stop()}},me,this,[[8,32,35,38]])}));function ae(){return $e.apply(this,arguments)}return ae}()}]),pe}(Xe);function fr(Re){var Ne=Wt();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot={min:2e3,max:12e4,randomness:.2},L=function(Re){ze.default(pe,Re);var Ne=fr(pe);function pe($e,ae,me,we){var K;return Fe.default(this,pe),K=Ne.call(this,$e),re.default(Te.default(K),"registrationId",null),K.context=ae,K.twilsock=me,K.registrarUrl=we,K}return Oe.default(pe,[{key:"updateRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){var he=this,G,de,ee,Ye,qe;return _e.default.wrap(function(lt){for(;;)switch(lt.prev=lt.next){case 0:if(!K.has("notificationId")){lt.next=3;break}return lt.next=3,this.removeRegistration();case 3:if(!(!we.notificationId||!we.notificationId.length)){lt.next=6;break}throw ut.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return ut.trace("Registering",this.channelType,we),G={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(we.messageTypes),data:{registration_id:we.notificationId}},de=this.context.productId,ee="".concat(this.registrarUrl,"?productId=").concat(de),Ye={"Content-Type":"application/json"},ut.trace("Creating registration for channel ".concat(this.channelType)),lt.prev=12,lt.next=15,new f.AsyncRetrier(Ot).run(function(){return he.twilsock.post(ee,Ye,G,de)});case 15:qe=lt.sent,this.registrationId=qe.body.id,ut.debug("Registration created: ",qe),lt.next=24;break;case 20:throw lt.prev=20,lt.t0=lt.catch(12),ut.error("Registration failed: ",lt.t0),lt.t0;case 24:return lt.abrupt("return",we);case 25:case"end":return lt.stop()}},me,this,[[12,20]])}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we=this,K,he,G;return _e.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(this.registrationId){ee.next=2;break}return ee.abrupt("return");case 2:return K=this.context.productId,he="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(K),G={"Content-Type":"application/json"},ut.trace("Removing registration for ".concat(this.channelType)),ee.prev=6,ee.next=9,new f.AsyncRetrier(Object.assign(Ot,{maxAttemptsCount:3})).run(function(){return we.twilsock.delete(he,G,{},K)});case 9:this.registrationId=null,this.currentState.notificationId="",ut.debug("Registration removed for ".concat(this.channelType)),ee.next=18;break;case 14:throw ee.prev=14,ee.t0=ee.catch(6),ut.error("Failed to remove registration ",this.channelType,ee.t0),ee.t0;case 18:case"end":return ee.stop()}},me,this,[[6,14]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Ie.default(_e.default.mark(function me(we){var K=this,he,G,de,ee;return _e.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:if(we!==""){qe.next=2;break}throw new Error("Empty registration ID");case 2:return he=this.context.productId,G="".concat(this.registrarUrl,"?productId=").concat(he),de={"Content-Type":"application/json"},ee={binding_type:this.channelType,address:we},qe.prev=6,ut.trace("Removing old registrations for ".concat(this.channelType)),qe.next=10,new f.AsyncRetrier(Object.assign(Ot,{maxAttemptsCount:3})).run(function(){return K.twilsock.delete(G,de,ee,he)});case 10:this.registrationId=null,this.currentState.notificationId="",ut.debug("Registration removed for ".concat(this.channelType)),qe.next=19;break;case 15:throw qe.prev=15,qe.t0=qe.catch(6),ut.error("Failed to remove registration ",this.channelType,qe.t0),qe.t0;case 19:case"end":return qe.stop()}},me,this,[[6,15]])}));function ae(me){return $e.apply(this,arguments)}return ae}()}]),pe}(dr);function W(Re){var Ne=ie();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function ie(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var He=function(Re){ze.default(pe,Re);var Ne=W(pe);function pe($e,ae,me){var we;return Fe.default(this,pe),we=Ne.call(this,"twilsock"),re.default(Te.default(we),"contextId",Se.v4()),we.productId=$e,we.platform=ae,we.twilsock=me,we}return Oe.default(pe,[{key:"updateRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){var he,G;return _e.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(K.has("messageType")){ee.next=2;break}return ee.abrupt("return",we);case 2:return he=Array.from(we.messageTypes),G={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:he},ee.prev=4,ee.next=7,this.twilsock.setNotificationsContext(this.contextId,G);case 7:ee.next=13;break;case 9:throw ee.prev=9,ee.t0=ee.catch(4),ut.error("Failed to update twilsock notification context: ".concat(ee.t0)),ee.t0;case 13:return ee.abrupt("return",we);case 14:case"end":return ee.stop()}},me,this,[[4,9]])}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.prev=0,K.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:K.next=9;break;case 5:throw K.prev=5,K.t0=K.catch(0),ut.error("Failed to remove twilsock notification context: ".concat(K.t0)),K.t0;case 9:case"end":return K.stop()}},me,this,[[0,5]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Ie.default(_e.default.mark(function me(we){return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:case"end":return he.stop()}},me)}));function ae(me){return $e.apply(this,arguments)}return ae}()}]),pe}(dr);function ct(Re){var Ne=bt();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function bt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var zt,tr=z.literal("apn","fcm","twilsock");t.Notifications=zt=function(Re){ze.default(pe,Re);var Ne=ct(pe);function pe($e){var ae,me,we,K,he,G,de,ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Fe.default(this,pe),de=Ne.call(this),ee.logLevel=(ae=ee.logLevel)!==null&&ae!==void 0?ae:"error",ut.setLevel(ee.logLevel);var Ye=(me=ee.productId)!==null&&me!==void 0?me:"notifications",qe=!ee.twilsockClient,dt=ee.twilsockClient=(we=ee.twilsockClient)!==null&&we!==void 0?we:new l.TwilsockClient($e,Ye,ee),lt=(K=ee.notifications)!==null&&K!==void 0?K:{},ht=(he=(G=lt.region)!==null&&G!==void 0?G:ee.region)!==null&&he!==void 0?he:"us1",Rt="https://ers.".concat(ht,".twilio.com/v1/registrations"),xt=lt.ersUrl||Rt;de.connectors=new Map;var kt=zt._detectPlatform();return de.connectors.set("apn",new L("apn",{protocolVersion:4,productId:Ye,platform:kt},dt,xt)),de.connectors.set("fcm",new L("fcm",{protocolVersion:3,productId:Ye,platform:kt},dt,xt)),de.connectors.set("twilsock",new He(Ye,kt,dt)),dt.on("stateChanged",function($t){return de.emit("transportState",$t)}),de._connector("twilsock").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),de._connector("apn").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),de._connector("fcm").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),dt.on("message",function($t,It){return de._routeMessage($t,It)}),de.updateToken($e),qe&&(dt.connect(),de.twilsock=dt),de}return Oe.default(pe,[{key:"shutdown",value:function(){var $e=Ie.default(_e.default.mark(function me(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.connectors.clear(),!this.twilsock){K.next=4;break}return K.next=4,this.twilsock.disconnect();case 4:case"end":return K.stop()}},me,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"setPushRegistrationId",value:function(ae,me){ut.debug("Set ".concat(ae," push registration id '").concat(me,"'")),this._connector(ae).setNotificationId(me)}},{key:"subscribe",value:function(ae,me){ut.debug("Add ".concat(ae," subscriptions for message type ").concat(me)),this._connector(ae).subscribe(me)}},{key:"unsubscribe",value:function(ae,me){ut.debug("Remove ".concat(ae," subscriptions for message type ").concat(me)),this._connector(ae).unsubscribe(me)}},{key:"updateToken",value:function(ae){this.connectors.forEach(function(me){return me.updateToken(ae)})}},{key:"commitChanges",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we;return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:return we=[],this.connectors.forEach(function(G){G.isActive()&&we.push(G.commitChanges())}),he.next=4,Promise.all(we);case 4:case"end":return he.stop()}},me,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistrations",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){return _e.default.wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return G.next=2,this._connector(we).sendDeviceRemoveRequest(K);case 2:case"end":return G.stop()}},me,this)}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"handlePushNotification",value:function(ae){return{messageType:ae.twi_message_type,payload:ae.payload}}},{key:"_routeMessage",value:function(ae,me){ut.debug("Notification message arrived: ",ae,me),this.emit("message",ae,me)}},{key:"_connector",value:function(ae){var me=this.connectors.get(ae);if(!me)throw new Error("Unknown channel type: ".concat(ae));return me}}],[{key:"_detectPlatform",value:function(){var ae="";return typeof navigator<"u"?(ae="unknown",typeof navigator.product<"u"&&(ae=navigator.product),typeof navigator.userAgent<"u"&&(ae=navigator.userAgent)):ae="web",ae.substring(0,128)}}]),pe}(Xe),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"setPushRegistrationId",null),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"subscribe",null),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"unsubscribe",null),H([z.validateTypes(z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String]),ye("design:returntype",void 0)],t.Notifications.prototype,"updateToken",null),H([z.validateTypesAsync(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",Promise)],t.Notifications.prototype,"removeRegistrations",null),t.Notifications=zt=H([z.validateConstructorTypes(z.nonEmptyString,[z.pureObject,"undefined",z.literal(null)]),ye("design:paramtypes",[String,Object])],t.Notifications)})(TI);var zn={},wn={};/*
970
+ @license
971
+ Copyright (c) 2021 Twilio Inc.
972
+
973
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
974
+
975
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
976
+
977
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
978
+
979
+
980
+ */Object.defineProperty(wn,"__esModule",{value:!0});var Ree=ui,xee=ud,Iee=ld,Aee=sa,Oee=ia,Pee=aa,Mee=li;function Lo(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var il=Lo(Ree),Do=Lo(xee),Jb=Lo(Iee),Nee=Lo(Aee),Lee=Lo(Oee),Dee=Lo(Pee),II=Lo(Mee),xs=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return{checks:r}};function jee(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Uee(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
981
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Uee(t,e){if(t){if(typeof t=="string")return AI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return AI(t,e)}}function AI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var OI=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return xs(function(i){var a=!1,s=[],o=jee(r),u;try{for(o.s();!(u=o.n()).done;){var l=u.value;if(typeof l=="string"){a=a||il.default(i)===l,s.push("of type ".concat(l));continue}a=a||i instanceof l,s.push("an instance of ".concat(l.name))}}catch(c){o.e(c)}finally{o.f()}return[a,s]})};function Fee(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Bee(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
982
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Bee(t,e){if(t){if(typeof t=="string")return PI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return PI(t,e)}}function PI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var zee=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return xs(function(i){var a=!1,s=[],o=Fee(r),u;try{for(o.s();!(u=o.n()).done;){var l=u.value;a=a||i===l,s.push(typeof l=="string"?'"'.concat(l,'"'):"".concat(l))}}catch(c){o.e(c)}finally{o.f()}return[a,s]})},Hee=xs(function(t){return[typeof t=="string"&&t.length>0,"a non-empty string"]}),qee=xs(function(t){return[typeof t=="number"&&Number.isInteger(t)&&t>=0,"a non-negative integer"]}),Vee=xs(function(t){return[il.default(t)==="object"&&t!==null&&!Array.isArray(t),"a pure object (non-null and non-array)"]});function Wee(t){var e=Zee();return function(){var n=II.default(t),i;if(e){var a=II.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Dee.default(this,i)}}function Zee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function kd(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Gee(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
983
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Gee(t,e){if(t){if(typeof t=="string")return MI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return MI(t,e)}}function MI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Pp=function(e,r){if(r.length>e.length)throw new Error("Expected at most ".concat(e.length," argument(s), but got ").concat(r.length));for(;r.length<e.length;)r.push(void 0);var n=kd(r.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Do.default(i.value,2),s=a[0],o=a[1],u=Xb(e[s],o),l=Do.default(u,4),c=l[0],d=l[1],f=l[2],m=l[3];if(!c){var b=s+1;throw new Error("Argument ".concat(b," is expected to be ").concat(f).concat(m," but got ").concat(d))}}}catch(A){n.e(A)}finally{n.f()}},NI=function(e){var r,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(il.default(e))&&(n=typeof e=="string"?'"'.concat(e,'"'):"".concat(e)),il.default(e)==="object"&&(e==null||(r=e.constructor)===null||r===void 0?void 0:r.name)!=="Object"){var a;n=e===null?"null":"instance of ".concat(e==null||(a=e.constructor)===null||a===void 0?void 0:a.name)}return n||(n=il.default(e)),n},Kee=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=Yb(r);return function(a){return function(s){Lee.default(u,s);var o=Wee(u);function u(){Nee.default(this,u);for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];return Pp(i,c),o.call.apply(o,[this].concat(c))}return u}(a)}},Jee=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=Yb(r);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];return Pp(i,c),u.apply(this,c)}}},Yee=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=Yb(r);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];try{Pp(i,c)}catch(f){return Promise.reject(f)}return u.apply(this,c)}}},Yb=function(e){var r=[],n=kd(e),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;r.push(Qb(a))}}catch(s){n.e(s)}finally{n.f()}return r},Qb=function(e){var r=[],n=Array.isArray(e)?e:[e],i=kd(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){r.push(OI(s));continue}r.push(s)}}catch(o){i.e(o)}finally{i.f()}return r},Xb=function(e,r){var n=[],i,a=!1,s=kd(e),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,l=kd(u.checks),c;try{for(l.s();!(c=l.n()).done;){var d=c.value,f=d(r),m=Do.default(f,3),b=m[0],A=m[1],N=m[2];a=a||b,!i&&N&&(i=N),A&&(n=typeof A=="string"?[].concat(Jb.default(n),[A]):[].concat(Jb.default(n),Jb.default(A)))}}catch(Ie){l.e(Ie)}finally{l.f()}}}catch(Ie){s.e(Ie)}finally{s.f()}if(a)return[!0];var z=i||NI(r),X=n.length-1,Ee=X>0?"".concat(n.slice(0,X).join(", ")," or ").concat(n[X]):n.join(", ");return[!1,z,Ee,X>1?";":","]},Qee=function(e,r){return xs(function(n){if(il.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(e," (should be a pure object)")];for(var i=0,a=Object.entries(r);i<a.length;i++){var s=Do.default(a[i],2),o=s[0],u=s[1],l=Xb(Qb(u),n[o]),c=Do.default(l,3),d=c[0],f=c[1],m=c[2];if(!d)return[!1,"valid ".concat(e,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(e,' (key "').concat(o,'" is ').concat(f,")")]}return[!0]})};function Xee(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ete(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
984
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function ete(t,e){if(t){if(typeof t=="string")return LI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return LI(t,e)}}function LI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var tte=function(e,r){return xs(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var i=Xee(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Do.default(a.value,2),o=s[0],u=s[1],l=Xb(Qb(r),u),c=Do.default(l,3),d=c[0],f=c[1],m=c[2];if(!d)return[!1,"a valid array of ".concat(e," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(b){i.e(b)}finally{i.f()}return[!0]})};wn.array=tte,wn.custom=xs,wn.literal=zee,wn.nonEmptyString=Hee,wn.nonNegativeInteger=qee,wn.objectSchema=Qee,wn.pureObject=Vee,wn.runtimeTypeValidation=Pp,wn.stringifyReceivedType=NI,wn.type=OI,wn.validateConstructorTypes=Kee,wn.validateTypes=Jee,wn.validateTypesAsync=Yee;var DI={};/*
985
+ @license
986
+ The following license applies to all parts of this software except as
987
+ documented below.
988
+
989
+ Copyright (c) 2016, Twilio, inc.
990
+ All rights reserved.
991
+
992
+ Redistribution and use in source and binary forms, with or without
993
+ modification, are permitted provided that the following conditions are
994
+ met:
995
+
996
+ 1. Redistributions of source code must retain the above copyright
997
+ notice, this list of conditions and the following disclaimer.
998
+
999
+ 2. Redistributions in binary form must reproduce the above copyright
1000
+ notice, this list of conditions and the following disclaimer in
1001
+ the documentation and/or other materials provided with the
1002
+ distribution.
1003
+
1004
+ 3. Neither the name of Twilio nor the names of its contributors may
1005
+ be used to endorse or promote products derived from this software
1006
+ without specific prior written permission.
1007
+
1008
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1009
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1010
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1011
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1012
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1013
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1014
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1015
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1016
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1017
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1018
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1019
+
1020
+ This software includes javascript-state-machine under the following license.
1021
+
1022
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
1023
+
1024
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1025
+ of this software and associated documentation files (the "Software"), to deal
1026
+ in the Software without restriction, including without limitation the rights
1027
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1028
+ copies of the Software, and to permit persons to whom the Software is
1029
+ furnished to do so, subject to the following conditions:
1030
+
1031
+ The above copyright notice and this permission notice shall be included in all
1032
+ copies or substantial portions of the Software.
1033
+
1034
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1035
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1036
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1037
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1038
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1039
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1040
+
1041
+ This software includes loglevel under the following license.
1042
+
1043
+ Copyright (c) 2013 Tim Perry
1044
+
1045
+ Permission is hereby granted, free of charge, to any person
1046
+ obtaining a copy of this software and associated documentation
1047
+ files (the "Software"), to deal in the Software without
1048
+ restriction, including without limitation the rights to use,
1049
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
1050
+ copies of the Software, and to permit persons to whom the
1051
+ Software is furnished to do so, subject to the following
1052
+ conditions:
1053
+
1054
+ The above copyright notice and this permission notice shall be
1055
+ included in all copies or substantial portions of the Software.
1056
+
1057
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1058
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
1059
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1060
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1061
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1062
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1063
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1064
+ OTHER DEALINGS IN THE SOFTWARE.
1065
+
1066
+
1067
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Mu,n=Oa,i=ys,a=np,s=ia,o=aa,u=li,l=sa,c=bs,d=Hu,f=ui,m=wn,b=qu,A=iR,N=pd,z=_d,X=oa,Ee=Wb;function Ie(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}function Fe(D){if(D&&D.__esModule)return D;var B=Object.create(null);return D&&Object.keys(D).forEach(function(E){if(E!=="default"){var T=Object.getOwnPropertyDescriptor(D,E);Object.defineProperty(B,E,T.get?T:{enumerable:!0,get:function(){return D[E]}})}}),B.default=D,Object.freeze(B)}var Oe=Ie(r),ze=Ie(n),V=Ie(i),xe=Ie(a),_e=Ie(s),se=Ie(o),Te=Ie(u),re=Ie(l),oe=Ie(c),q=Ie(d),ne=Ie(f),Se=Fe(b),H=Fe(A),ye=Ie(z),ke=Fe(Ee);function M(D,B,E,T){var $=arguments.length,U=$<3?B:T===null?T=Object.getOwnPropertyDescriptor(B,E):T,P;if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(D,B,E,T);else for(var Me=D.length-1;Me>=0;Me--)(P=D[Me])&&(U=($<3?P(U):$>3?P(B,E,U):P(B,E))||U);return $>3&&U&&Object.defineProperty(B,E,U),U}function Xe(D,B){if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(D,B)}var Ct;function rt(){}rt.prototype=Object.create(null);function je(){je.init.call(this)}je.EventEmitter=je,je.usingDomains=!1,je.prototype.domain=void 0,je.prototype._events=void 0,je.prototype._maxListeners=void 0,je.defaultMaxListeners=10,je.init=function(){this.domain=null,je.usingDomains&&Ct.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new rt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},je.prototype.setMaxListeners=function(B){if(typeof B!="number"||B<0||isNaN(B))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=B,this};function ce(D){return D._maxListeners===void 0?je.defaultMaxListeners:D._maxListeners}je.prototype.getMaxListeners=function(){return ce(this)};function Ke(D,B,E){if(B)D.call(E);else for(var T=D.length,$=Pe(D,T),U=0;U<T;++U)$[U].call(E)}function Be(D,B,E,T){if(B)D.call(E,T);else for(var $=D.length,U=Pe(D,$),P=0;P<$;++P)U[P].call(E,T)}function be(D,B,E,T,$){if(B)D.call(E,T,$);else for(var U=D.length,P=Pe(D,U),Me=0;Me<U;++Me)P[Me].call(E,T,$)}function pt(D,B,E,T,$,U){if(B)D.call(E,T,$,U);else for(var P=D.length,Me=Pe(D,P),Ce=0;Ce<P;++Ce)Me[Ce].call(E,T,$,U)}function Ze(D,B,E,T){if(B)D.apply(E,T);else for(var $=D.length,U=Pe(D,$),P=0;P<$;++P)U[P].apply(E,T)}je.prototype.emit=function(B){var E,T,$,U,P,Me,Ce,Qe=B==="error";if(Me=this._events,Me)Qe=Qe&&Me.error==null;else if(!Qe)return!1;if(Ce=this.domain,Qe){if(E=arguments[1],Ce)E||(E=new Error('Uncaught, unspecified "error" event')),E.domainEmitter=this,E.domain=Ce,E.domainThrown=!1,Ce.emit("error",E);else{if(E instanceof Error)throw E;var it=new Error('Uncaught, unspecified "error" event. ('+E+")");throw it.context=E,it}return!1}if(T=Me[B],!T)return!1;var Pt=typeof T=="function";switch($=arguments.length,$){case 1:Ke(T,Pt,this);break;case 2:Be(T,Pt,this,arguments[1]);break;case 3:be(T,Pt,this,arguments[1],arguments[2]);break;case 4:pt(T,Pt,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array($-1),P=1;P<$;P++)U[P-1]=arguments[P];Ze(T,Pt,this,U)}return!0};function Jt(D,B,E,T){var $,U,P;if(typeof E!="function")throw new TypeError('"listener" argument must be a function');if(U=D._events,U?(U.newListener&&(D.emit("newListener",B,E.listener?E.listener:E),U=D._events),P=U[B]):(U=D._events=new rt,D._eventsCount=0),!P)P=U[B]=E,++D._eventsCount;else if(typeof P=="function"?P=U[B]=T?[E,P]:[P,E]:T?P.unshift(E):P.push(E),!P.warned&&($=ce(D),$&&$>0&&P.length>$)){P.warned=!0;var Me=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+B+" listeners added. Use emitter.setMaxListeners() to increase limit");Me.name="MaxListenersExceededWarning",Me.emitter=D,Me.type=B,Me.count=P.length,At(Me)}return D}function At(D){typeof console.warn=="function"?console.warn(D):console.log(D)}je.prototype.addListener=function(B,E){return Jt(this,B,E,!1)},je.prototype.on=je.prototype.addListener,je.prototype.prependListener=function(B,E){return Jt(this,B,E,!0)};function Q(D,B,E){var T=!1;function $(){D.removeListener(B,$),T||(T=!0,E.apply(D,arguments))}return $.listener=E,$}je.prototype.once=function(B,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.on(B,Q(this,B,E)),this},je.prototype.prependOnceListener=function(B,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(B,Q(this,B,E)),this},je.prototype.removeListener=function(B,E){var T,$,U,P,Me;if(typeof E!="function")throw new TypeError('"listener" argument must be a function');if($=this._events,!$)return this;if(T=$[B],!T)return this;if(T===E||T.listener&&T.listener===E)--this._eventsCount===0?this._events=new rt:(delete $[B],$.removeListener&&this.emit("removeListener",B,T.listener||E));else if(typeof T!="function"){for(U=-1,P=T.length;P-- >0;)if(T[P]===E||T[P].listener&&T[P].listener===E){Me=T[P].listener,U=P;break}if(U<0)return this;if(T.length===1){if(T[0]=void 0,--this._eventsCount===0)return this._events=new rt,this;delete $[B]}else ot(T,U);$.removeListener&&this.emit("removeListener",B,Me||E)}return this},je.prototype.off=function(D,B){return this.removeListener(D,B)},je.prototype.removeAllListeners=function(B){var E,T;if(T=this._events,!T)return this;if(!T.removeListener)return arguments.length===0?(this._events=new rt,this._eventsCount=0):T[B]&&(--this._eventsCount===0?this._events=new rt:delete T[B]),this;if(arguments.length===0){for(var $=Object.keys(T),U=0,P;U<$.length;++U)P=$[U],P!=="removeListener"&&this.removeAllListeners(P);return this.removeAllListeners("removeListener"),this._events=new rt,this._eventsCount=0,this}if(E=T[B],typeof E=="function")this.removeListener(B,E);else if(E)do this.removeListener(B,E[E.length-1]);while(E[0]);return this},je.prototype.listeners=function(B){var E,T,$=this._events;return $?(E=$[B],E?typeof E=="function"?T=[E.listener||E]:T=St(E):T=[]):T=[],T},je.listenerCount=function(D,B){return typeof D.listenerCount=="function"?D.listenerCount(B):Ue.call(D,B)},je.prototype.listenerCount=Ue;function Ue(D){var B=this._events;if(B){var E=B[D];if(typeof E=="function")return 1;if(E)return E.length}return 0}je.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function ot(D,B){for(var E=B,T=E+1,$=D.length;T<$;E+=1,T+=1)D[E]=D[T];D.pop()}function Pe(D,B){for(var E=new Array(B);B--;)E[B]=D[B];return E}function St(D){for(var B=new Array(D.length),E=0;E<B.length;++E)B[E]=D[E].listener||D[E];return B}var ut=Se.getLogger("twilsock");function or(D,B){return["".concat(new Date().toISOString()," Twilsock ").concat(D,":")].concat(Array.from(B))}var br=function(){function D(B){re.default(this,D),oe.default(this,"prefix",""),this.prefix=B!=null&&B.length>0?" "+B+":":""}return ze.default(D,[{key:"setLevel",value:function(E){ut.setLevel(E)}},{key:"trace",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.trace.apply(null,or("T",T))}},{key:"debug",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.debug.apply(null,or("D",T))}},{key:"info",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.info.apply(null,or("I",T))}},{key:"warn",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.warn.apply(null,or("W",T))}},{key:"error",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.error.apply(null,or("E",T))}}],[{key:"setLevel",value:function(E){ut.setLevel(E)}},{key:"trace",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.trace.apply(null,or("T",T))}},{key:"debug",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.debug.apply(null,or("D",T))}},{key:"info",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.info.apply(null,or("I",T))}},{key:"warn",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.warn.apply(null,or("W",T))}},{key:"error",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.error.apply(null,or("E",T))}}]),D}(),et=new br(""),Mr="0.12.2",Fr=function(){function D(B,E,T){re.default(this,D),oe.default(this,"confirmedCapabilities",new Set),this.activeGrant=E,this._token=B;var $=T.region||"us1",U="wss://tsock.".concat($,".twilio.com/v3/wsconnect"),P=T.twilsock||T.Twilsock||{};this.url=P.uri||U,this._continuationToken=T.continuationToken?T.continuationToken:null,this.logLevel=T.logLevel?T.logLevel:"error",this.retryPolicy=T.retryPolicy?T.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=T.clientMetadata?T.clientMetadata:{},this.clientMetadata.ver=Mr,this.initRegistrations=T.initRegistrations?T.initRegistrations:null,this.tweaks=T.tweaks?T.tweaks:null}return ze.default(D,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(E){this._token=E}},{key:"updateContinuationToken",value:function(E){this._continuationToken=E}}]),D}(),dr=function D(B){re.default(this,D),this.id=B||"TM".concat(N.v4())};function fr(D){var B=Wt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot=function(D){_e.default(E,D);var B=fr(E);function E(T,$,U,P,Me){var Ce;return re.default(this,E),Ce=B.call(this),oe.default(V.default(Ce),"method","init"),Ce.token=T,Ce.continuation_token=$,Ce.metadata=U,Ce.registrations=P,Ce.tweaks=Me,Ce.capabilities=["client_update","offline_storage","telemetry.v1"],Ce}return E}(dr);function L(D){var B=W();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=function(D){_e.default(E,D);var B=L(E);function E(T,$,U,P,Me,Ce,Qe){var it;return re.default(this,E),it=B.call(this,T),it.continuationToken=$,it.continuationTokenStatus=P,it.offlineStorage=Me,it.initRegistrations=Ce,it.debugInfo=Qe,it.confirmedCapabilities=U,it}return E}(dr);function He(D){var B=ct();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function ct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var bt=function(D){_e.default(E,D);var B=He(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"method","update"),$.token=T,$}return E}(dr);function zt(D){var B=tr();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function tr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Re=function(D){_e.default(E,D);var B=zt(E);function E(T,$,U){var P;return re.default(this,E),P=B.call(this),oe.default(V.default(P),"method","message"),P.active_grant=T,P.payload_type=$,P.http_request=U,P}return E}(dr);function Ne(D){var B=pe();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $e=function(D){_e.default(E,D);var B=Ne(E);function E(T){var $;return re.default(this,E),$=B.call(this,T),oe.default(V.default($),"method","reply"),oe.default(V.default($),"payload_type","application/json"),oe.default(V.default($),"status",{code:200,status:"OK"}),$}return E}(dr);function ae(D){var B=me();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function me(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var we=function(D){_e.default(E,D);var B=ae(E);function E(){var T;return re.default(this,E),T=B.call(this),oe.default(V.default(T),"method","close"),T}return E}(dr);function K(D){var B=he();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function he(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var G=function D(B,E,T,$,U,P){re.default(this,D),this.start=B,this.end=E,this.title=T,this.details=$,this.id=U,this.type=P},de=function(D){_e.default(E,D);var B=K(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"method","telemetry.v1"),$.events=T,$}return E}(dr);function ee(D){var B=encodeURIComponent(D),E=B.replace(/%([0-9A-F]{2})/g,function(T,$){return String.fromCharCode(+("0x"+$))});return E.length}function Ye(D){var B=encodeURIComponent(D),E=B.replace(/%([0-9A-F]{2})/g,function($,U){return String.fromCharCode(+("0x"+U))}),T=new Uint8Array(E.length);return Array.prototype.forEach.call(E,function($,U){T[U]=$.charCodeAt(0)}),T}function qe(D){var B=Array.prototype.map.call(D,function(T){return String.fromCharCode(T)}).join(""),E=B.replace(/(.)/g,function(T,$){var U=$.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(E)}function dt(D){return JSON.parse(qe(D))}function lt(D){for(var B="",E=0;E<D.length;++E){var T=String.fromCharCode(D[E]);if(B+=T,T==="\r"){E+=2;break}}var $=B.split(" ");return{size:E,protocol:$[0],version:$[1],headerSize:Number($[2])}}var ht=function(){function D(){re.default(this,D)}return ze.default(D,null,[{key:"parse",value:function(E){var T=2,$=new Uint8Array(E),U=lt($);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return et.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var P;try{P=dt($.subarray(U.size,U.size+U.headerSize))}catch(it){return et.error("failed to parse message header",it,E),null}et.debug("message received: ",P.method),et.trace("message received: ",P);var Me;if(P.payload_size>0){var Ce=T+U.size+U.headerSize,Qe=P.payload_size;if(!P.hasOwnProperty("payload_type")||P.payload_type.indexOf("application/json")===0)try{Me=dt($.subarray(Ce,Ce+Qe))}catch(it){return et.error("failed to parse message body",it,E),null}else P.payload_type.indexOf("text/plain")===0&&(Me=qe($.subarray(Ce,Ce+Qe)))}return{method:P.method,header:P,payload:Me}}},{key:"createPacket",value:function(E){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";E.payload_size=ee(T);var $=JSON.stringify(E),U="TWILSOCK V3.0 "+ee($);et.debug("send request:",U+$+T);var P=Ye(U+`\r
1068
+ `+$+`\r
1069
+ `+T);return P.buffer}}]),D}();function Rt(D){var B=xt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function xt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var kt=function(D){_e.default(E,D);var B=Rt(E);function E(T){return re.default(this,E),B.call(this,T)}return E}(ye.default(Error));function $t(D){var B=It();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function It(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var jt=function(D){_e.default(E,D);var B=$t(E);function E(T,$){var U;return re.default(this,E),U=B.call(this,T),U.reply=$,U}return E}(kt);function on(D,B){var E=Object.keys(D);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(D);B&&(T=T.filter(function($){return Object.getOwnPropertyDescriptor(D,$).enumerable})),E.push.apply(E,T)}return E}function _n(D){for(var B=1;B<arguments.length;B++){var E=arguments[B]!=null?arguments[B]:{};B%2?on(Object(E),!0).forEach(function(T){oe.default(D,T,E[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(E)):on(Object(E)).forEach(function(T){Object.defineProperty(D,T,Object.getOwnPropertyDescriptor(E,T))})}return D}function Ut(D){var B=qn();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function qn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var pa=function(D){_e.default(E,D);var B=Ut(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"newBackoff",null),oe.default(V.default($),"usedBackoff",null),oe.default(V.default($),"retrier",null),$.options=T?_n({},T):{},$}return ze.default(E,[{key:"inProgress",get:function(){return!!this.retrier}},{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function($){this.newBackoff=$}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var $=!this.usedBackoff||this.usedBackoff<this.newBackoff;if($)this.createRetrier();else{var U;(U=this.retrier)===null||U===void 0||U.failed(new Error)}}else{var P;(P=this.retrier)===null||P===void 0||P.failed(new Error)}}},{key:"cancel",value:function(){var $;($=this.retrier)===null||$===void 0||$.cancel()}},{key:"cleanRetrier",value:function(){var $,U;($=this.retrier)===null||$===void 0||$.removeAllListeners(),(U=this.retrier)===null||U===void 0||U.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var $=_n({},this.options);return this.newBackoff&&($.min=this.newBackoff,$.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),$.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,$}},{key:"createRetrier",value:function(){var $=this;this.cleanRetrier();var U=this.getRetryPolicy();this.retrier=new X.Retrier(U),this.retrier.once("attempt",function(){var P,Me;(P=$.retrier)===null||P===void 0||P.on("attempt",function(){return $.emit("attempt")}),(Me=$.retrier)===null||Me===void 0||Me.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(P){return $.emit("failed",P)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),E}(je);function Za(D){var B=ti();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function ti(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var va=3e3;function ri(D){setTimeout(D,0)}var gi=function(D){_e.default(E,D);var B=Za(E);function E(T,$,U){var P;re.default(this,E),P=B.call(this),oe.default(V.default(P),"disconnectingTimer",null),oe.default(V.default(P),"disconnectedPromiseResolve",null),oe.default(V.default(P),"terminalStates",["disconnected","rejected"]),oe.default(V.default(P),"tokenExpiredSasCode",20104),oe.default(V.default(P),"terminationReason","Connection is not initialized"),P.websocket=T,P.websocket.on("connected",function(){return P.fsm.socketConnected()}),P.websocket.on("disconnected",function(){return P.fsm.socketClosed()}),P.websocket.on("message",function(Ce){return P.onIncomingMessage(Ce)}),P.websocket.on("socketError",function(Ce){return P.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(Ce.message),httpStatusCode:null,errorCode:null})}),P.transport=$,P.config=U,P.retrier=new pa(U.retryPolicy),P.retrier.on("attempt",function(){return P.retry()}),P.retrier.on("failed",function(Ce){et.warn("Retrying failed: ".concat(Ce.message)),P.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){et.debug("Browser reported connectivity state: online"),P.resetBackoff(),P.fsm.systemOnline()}),window.addEventListener("offline",function(){et.debug("Browser reported connectivity state: offline"),P.websocket.close(),P.fsm.socketClosed()}));var Me=H.factory({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){P.setupSocket(),P.emit("connecting")},onEnterInitialising:function(){P.sendInit()},onLeaveInitialising:function(){P.cancelInit()},onEnterUpdating:function(){P.sendUpdate()},onLeaveUpdating:function(){P.cancelUpdate()},onEnterRetrying:function(){P.initRetry(),P.emit("connecting")},onEnterConnected:function(){P.resetBackoff(),P.onConnected()},onUserUpdateToken:function(){P.resetBackoff()},onTokenRejected:function(){P.resetBackoff(),P.closeSocket(!0),P.finalizeSocket()},onUserDisconnect:function(){P.closeSocket(!0)},onEnterDisconnecting:function(){P.startDisconnectTimer()},onLeaveDisconnecting:function(){P.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){P.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){P.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){P.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){P.cancelDisconnectTimer()},onDisconnected:function(){P.resetBackoff(),P.finalizeSocket()},onReceiveClose:function(){P.onCloseReceived()},onReceiveOffload:function(Qe,it){et.debug("onreceiveoffload: ",it),P.modifyBackoff(it.body),P.onCloseReceived()},onUnsupported:function(){P.closeSocket(!0),P.finalizeSocket()},onError:function(Qe,it){P.closeSocket(it),P.finalizeSocket()},onEnterState:function(Qe){Qe.from!=="none"&&P.changeState(Qe)},onInvalidTransition:function(Qe,it,Pt){et.warn("FSM: unexpected transition",it,Pt)}}});return P.fsm=new Me,P}return ze.default(E,[{key:"changeState",value:function($){et.debug("FSM: ".concat($.transition,": ").concat($.from," --> ").concat($.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){et.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function($){et.trace("modifyBackoff",$);var U=$?$.backoff_policy:null;U&&typeof U.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(U.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var $=this;et.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){et.debug("disconnecting is timed out"),$.closeSocket(!0)},va)}},{key:"cancelDisconnectTimer",value:function(){et.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return this.state==="connected"&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"denied";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"initRetry",value:function(){et.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(et.trace("retry"),this.websocket.close(),this.fsm.userRetry()):et.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){et.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){et.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function($){var U=ht.parse($);if(U){var P=U.method,Me=U.header,Ce=U.payload;if(P!=="reply"&&this.confirmReceiving(Me),P==="notification")this.emit("message",Me.message_type,Ce);else if(Me.method==="reply")this.transport.processReply({id:Me.id,status:Me.status,header:Me,body:Ce});else if(Me.method==="client_update")Me.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(Me.method==="close")if(Me.status.code===308)et.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:Me.status.status,body:Ce});else if(Me.status.code===406){var Qe="Server closed connection because can't parse protocol: ".concat(JSON.stringify(Me.status));this.emitReplyConnectionError(Qe,Me,!0),et.error(Qe),this.fsm.receiveFatalClose()}else Me.status.code===417?(et.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(Me.status))),this.fsm.receiveFatalClose(Me.status.status)):Me.status.code===410?(et.warn("Server closed connection: ".concat(JSON.stringify(Me.status))),this.fsm.receiveClose(Me.status.status),this.emit("tokenExpired")):Me.status.code===401?(et.error("Server closed connection: ".concat(JSON.stringify(Me.status))),this.fsm.receiveClose(Me.status.status)):(et.warn("unexpected message: ",Me.status),this.fsm.receiveOffload({status:Me.status.status,body:null}))}}},{key:"sendInit",value:function(){var T=Oe.default(q.default.mark(function U(){var P,Me;return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return et.trace("sendInit"),Qe.prev=1,this.emit("beforeSendInit"),Qe.next=5,this.transport.sendInit();case 5:P=Qe.sent,this.config.updateContinuationToken(P.continuationToken),this.config.confirmedCapabilities=P.confirmedCapabilities,this.fsm.initSuccess(P),this.emit("initialized",P),this.emit("tokenUpdated"),Qe.next=17;break;case 13:Qe.prev=13,Qe.t0=Qe.catch(1),Qe.t0 instanceof jt?(Me=!1,et.warn("Init rejected by server: ".concat(JSON.stringify(Qe.t0.reply.status))),this.emit("sendInitFailed"),Qe.t0.reply.status.code===401||Qe.t0.reply.status.code===403?(Me=!0,this.fsm.tokenRejected(Qe.t0.reply.status),Qe.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Qe.t0.reply.status.code===429?(this.modifyBackoff(Qe.t0.reply.body),this.fsm.initError(!0)):Qe.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(Qe.t0.message,Qe.t0.reply,Me)):(this.terminationReason=Qe.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(Qe.t0.message,`
1070
+ `).concat(JSON.stringify(Qe.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Qe.t0);case 17:case"end":return Qe.stop()}},U,this,[[1,13]])}));function $(){return T.apply(this,arguments)}return $}()},{key:"sendUpdate",value:function(){var T=Oe.default(q.default.mark(function U(){var P,Me,Ce;return q.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return et.trace("sendUpdate"),P=new bt(this.config.token),it.prev=2,it.next=5,this.transport.sendWithReply(P);case 5:Me=it.sent,this.fsm.updateSuccess(Me.body),this.emit("tokenUpdated"),it.next=14;break;case 10:it.prev=10,it.t0=it.catch(2),it.t0 instanceof jt?(Ce=!1,et.warn("Token update rejected by server: ".concat(JSON.stringify(it.t0.reply.status))),it.t0.reply.status.code===401||it.t0.reply.status.code===403?(Ce=!0,this.fsm.tokenRejected(it.t0.reply.status),it.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):it.t0.reply.status.code===429?(this.modifyBackoff(it.t0.reply.body),this.fsm.updateError(it.t0.reply.status)):this.fsm.updateError(it.t0.reply.status),this.emitReplyConnectionError(it.t0.message,it.t0.reply,Ce)):(this.emit("error",!1,it.t0.message,null,null),this.fsm.updateError(it.t0)),this.emit("tokenUpdated",it.t0);case 14:case"end":return it.stop()}},U,this,[[2,10]])}));function $(){return T.apply(this,arguments)}return $}()},{key:"emitReplyConnectionError",value:function($,U,P){var Me=U.status&&U.status.description?U.status.description:$,Ce=U.status.code,Qe=U.status&&U.status.errorCode?U.status.errorCode:null;P&&(this.terminationReason=Me),this.emit("connectionError",{terminal:P,message:"Connection error: ".concat(Me),httpStatusCode:Ce,errorCode:Qe})}},{key:"cancelInit",value:function(){et.trace("cancelInit")}},{key:"cancelUpdate",value:function(){et.trace("cancelUpdate")}},{key:"confirmReceiving",value:function($){et.trace("confirmReceiving");try{this.transport.send(new $e($.id))}catch(U){et.debug("failed to confirm packet receiving",U)}}},{key:"closeSocket",value:function($){var U=this;et.trace("closeSocket (graceful: ".concat($,")")),$&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),ri(function(){return U.fsm.socketClosed()})}},{key:"connect",value:function(){et.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var $=this;return et.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(U){$.disconnectedPromiseResolve=U,$.fsm.userDisconnect()})}},{key:"updateToken",value:function($){var U=this;return et.trace("updateToken:",$),new Promise(function(P,Me){U.once("tokenUpdated",function(Ce){Ce?Me(Ce):P()}),U.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),E}(je),Ga=function(){function D(){re.default(this,D)}return ze.default(D,null,[{key:"getMetadata",value:function(E){var T,$,U,P,Me,Ce,Qe,it,Pt=E&&E.clientMetadata?E.clientMetadata:{},vn=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Fi={env:(T=ke.name)!==null&&T!==void 0?T:"unknown",envv:($=ke.version)!==null&&$!==void 0?$:"unknown",os:(U=(P=ke.os)===null||P===void 0?void 0:P.family)!==null&&U!==void 0?U:"unknown",osv:(Me=(Ce=ke.os)===null||Ce===void 0?void 0:Ce.version)!==null&&Me!==void 0?Me:"unknown",osa:(Qe=(it=ke.os)===null||it===void 0?void 0:it.architecture)!==null&&Qe!==void 0?Qe:"unknown",sdk:"js-default"},tn={};return vn.filter(function(Bi){return Bi in Pt||Bi in Fi}).forEach(function(Bi){return tn[Bi]=Bi in Pt?Pt[Bi]:Fi[Bi]}),tn}}]),D}(),en=3e4;function ji(D){return D>=200&&D<300}function Ns(D){switch(ne.default(D)){case"undefined":return"";case"object":return JSON.stringify(D);default:return D}}var Ui=function(){function D(B,E){var T=this;re.default(this,D),this.config=E,this.activeRequests=new Map,this.channel=B,this.channel.on("reply",function($){return T.processReply($)}),this.channel.on("disconnected",function(){T.activeRequests.forEach(function($){clearTimeout($.timeout),$.reject(new kt("disconnected"))}),T.activeRequests.clear()})}return ze.default(D,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(E){var T=this.activeRequests.get(E.id);T&&(clearTimeout(T.timeout),this.activeRequests.delete(E.id),ji(E.status.code)?T.resolve(E):(T.reject(new jt("Transport failure: "+E.status.status,E)),et.trace("message rejected")))}},{key:"storeRequest",value:function(E,T,$){var U={resolve:T,reject:$,timeout:setTimeout(function(){et.trace("request",E,"is timed out"),$(new kt("Twilsock: request timeout: "+E))},en)};this.activeRequests.set(E,U)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(E){clearTimeout(E.timeout),E.reject(new kt("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var B=Oe.default(q.default.mark(function T(){var $,U,P;return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:return et.trace("sendInit"),$=Ga.getMetadata(this.config),U=new Ot(this.config.token,this.config.continuationToken,$,this.config.initRegistrations,this.config.tweaks),Ce.next=5,this.sendWithReply(U);case 5:return P=Ce.sent,Ce.abrupt("return",new ie(P.id,P.header.continuation_token,new Set(P.header.capabilities),P.header.continuation_token_status,P.header.offline_storage,P.header.init_registrations,P.header.debug_info));case 7:case"end":return Ce.stop()}},T,this)}));function E(){return B.apply(this,arguments)}return E}()},{key:"sendClose",value:function(){var E=new we;this.send(E)}},{key:"sendWithReply",value:function(E,T){var $=this;return new Promise(function(U,P){var Me=$.send(E,T);$.storeRequest(Me,U,P)})}},{key:"send",value:function(E,T){E.id=E.id||"TM".concat(N.v4());var $=ht.createPacket(E,Ns(T));try{return this.channel.send($),E.id}catch(U){throw et.debug("failed to send ",E,U),et.trace(U.stack),U}}}]),D}();function Ls(D){var B=zo();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function zo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Vn=function(D){_e.default(E,D);var B=Ls(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"socket",null),$.url=T,$.url=T,$.WebSocket=e.WebSocket||e.MozWebSocket||{},$}return ze.default(E,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var $=this;et.trace("connecting to socket");var U;try{U=new this.WebSocket(this.url)}catch(P){et.debug("Socket error: ".concat(this.url)),this.emit("socketError",P);return}U.binaryType="arraybuffer",U.onopen=function(){et.debug("socket opened ".concat($.url)),$.emit("connected")},U.onclose=function(P){et.debug("socket closed",P),$.emit("disconnected",P)},U.onerror=function(P){et.debug("Socket error:",P),$.emit("socketError",P)},U.onmessage=function(P){$.emit("message",P.data)},this.socket=U}},{key:"send",value:function($){return this.socket&&this.socket.send($)}},{key:"close",value:function(){if(et.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),E}(je);function Ds(D){var B=Ho();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Ho(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var qo=function(D){_e.default(E,D);var B=Ds(E);function E(T){var $;return re.default(this,E),$=B.call(this),$.transport=T,$.registrations=new Map,$.registrationsInProgress=new Map,$}return ze.default(E,[{key:"putNotificationContext",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){var Ce;return q.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return Ce={method:"put_notification_ctx",notification_ctx_id:P},it.next=3,this.transport.sendWithReply(Ce,Me);case 3:case"end":return it.stop()}},U,this)}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"deleteNotificationContext",value:function(){var T=Oe.default(q.default.mark(function U(P){var Me;return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Me={method:"delete_notification_ctx",notification_ctx_id:P},Qe.next=3,this.transport.sendWithReply(Me);case 3:case"end":return Qe.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"updateRegistration",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){var Ce,Qe;return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return et.debug("update registration for context",P),Ce=this.registrationsInProgress.get(P),Ce||(Ce=new Set,this.registrationsInProgress.set(P,Ce)),Qe=N.v4(),Ce.add(Qe),Pt.prev=5,Pt.next=8,this.putNotificationContext(P,Me);case 8:et.debug("registration attempt succeeded for context",Me),Ce.delete(Qe),Ce.size===0&&(this.registrationsInProgress.delete(P),this.emit("registered",P)),Pt.next=19;break;case 13:Pt.prev=13,Pt.t0=Pt.catch(5),et.warn("registration attempt failed for context",Me),et.debug(Pt.t0),Ce.delete(Qe),Ce.size===0&&(this.registrationsInProgress.delete(P),this.emit("registrationFailed",P,Pt.t0));case 19:case"end":return Pt.stop()}},U,this,[[5,13]])}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"updateRegistrations",value:function(){var T=Oe.default(q.default.mark(function U(){var P=this,Me;return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return et.trace("refreshing ".concat(this.registrations.size," registrations")),Me=[],this.registrations.forEach(function(it,Pt){Me.push(P.updateRegistration(Pt,it))}),Qe.next=5,Promise.all(Me);case 5:case"end":return Qe.stop()}},U,this)}));function $(){return T.apply(this,arguments)}return $}()},{key:"setNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:if(!(!P||!Me)){Qe.next=2;break}throw new kt("Invalid arguments provided");case 2:return this.registrations.set(P,Me),Qe.next=5,this.updateRegistration(P,Me);case 5:return Qe.abrupt("return",Qe.sent);case 6:case"end":return Qe.stop()}},U,this)}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"removeNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(this.registrations.has(P)){Ce.next=2;break}return Ce.abrupt("return");case 2:return Ce.next=4,this.deleteNotificationContext(P);case 4:this.transport.isConnected&&this.registrations.delete(P);case 5:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()}]),E}(je);function hn(D){var B=js();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function js(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Pn=function(D){_e.default(E,D);var B=hn(E);function E(T,$,U){var P;return re.default(this,E),P=B.call(this,$),P.status=T,P.description=$,P.body=U,P}return E}(kt);function Dr(D){var B=Vo();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Vo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ni=function(D){_e.default(E,D);var B=Dr(E);function E(T){return re.default(this,E),B.call(this,T)}return E}(kt),Mn=2e4;function Us(D){return D>=200&&D<300}function te(D){return D&&D.header&&D.header.http_status}function ue(D){var B=D.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(B){var E={protocol:B[1],host:B[2],hostname:B[3],port:B[4],pathname:B[5],search:B[6],hash:B[7],params:{}};if(E.search.length>0){var T=E.search.substring(1);E.params=T.split("&").map(function($){return $.split("=")}).reduce(function($,U){return $.hasOwnProperty(U[0])?Array.isArray($[U[0]])?$[U[0]].push(U[1]):$[U[0]]=[$[U[0]],U[1]]:$[U[0]]=U[1],$},{})}return E}throw new kt("Incorrect URI: "+D)}function I(D,B){var E=ue(B),T={method:D,host:E.host,path:E.pathname};return E.params&&(T.params=E.params),T}function O(D,B,E,T,$){return{to:I(D,B),headers:E,body:T,grant:$}}var R=function(){function D(B,E,T){re.default(this,D),this.config=T,this.transport=B,this.pendingMessages=[],this.twilsock=E}return ze.default(D,[{key:"saveMessage",value:function(E){var T=this;return new Promise(function($,U){var P={message:E,resolve:$,reject:U,alreadyRejected:!1,timeout:setTimeout(function(){et.debug("request is timed out"),U(new kt("request '".concat(E.to.method,"' to '").concat(E.to.host,"' timed out"))),P.alreadyRejected=!0},Mn)};T.pendingMessages.push(P)})}},{key:"sendPendingMessages",value:function(){for(var E=this,T=function(){var P=E.pendingMessages[0];if(!P.alreadyRejected)try{var Me=P.message;E.actualSend(Me).then(function(Ce){return P.resolve(Ce)}).catch(function(Ce){return P.reject(Ce)}),clearTimeout(P.timeout)}catch(Ce){return et.debug("Failed to send pending message",Ce),"break"}E.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var $=T();if($==="break")break}}},{key:"rejectPendingMessages",value:function(){var E=this;this.pendingMessages.forEach(function(T){T.reject(new ni("Unable to connect: "+E.twilsock.getTerminationReason)),T.alreadyRejected=!0,clearTimeout(T.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var B=Oe.default(q.default.mark(function T($){var U,P,Me,Ce,Qe,it,Pt,vn;return q.default.wrap(function(tn){for(;;)switch(tn.prev=tn.next){case 0:return P=$.to,Me=$.headers,Ce=$.body,Qe=(U=$.grant)!==null&&U!==void 0?U:this.config.activeGrant,it={host:P.host,path:P.path,method:P.method,params:P.params,headers:Me},Pt=new Re(Qe,Me["Content-Type"]||"application/json",it),et.trace("Sending upstream message",Pt),tn.next=9,this.transport.sendWithReply(Pt,Ce);case 9:if(vn=tn.sent,et.trace("Received upstream message response",vn),!(te(vn)&&!Us(vn.header.http_status.code))){tn.next=13;break}throw new Pn(vn.header.http_status.code,vn.header.http_status.status,vn.body);case 13:return tn.abrupt("return",{status:vn.header.http_status,headers:vn.header.http_headers,body:vn.body});case 14:case"end":return tn.stop()}},T,this)}));function E(T){return B.apply(this,arguments)}return E}()},{key:"send",value:function(E,T){var $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},U=arguments.length>3?arguments[3]:void 0,P=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new ni("Unable to connect: "+this.twilsock.getTerminationReason));var Me=O(E,T,$,U,P);return this.twilsock.isConnected?this.actualSend(Me):this.saveMessage(Me)}}]),D}(),Z=function(){function D(){var B=this;re.default(this,D),this._promise=new Promise(function(E,T){B._resolve=E,B._reject=T})}return ze.default(D,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(E){this._resolve(E)}},{key:"set",value:function(E){this._resolve(E)}},{key:"fail",value:function(E){this._reject(E)}}]),D}(),j=function(){function D(B){re.default(this,D),this.id=B}return ze.default(D,null,[{key:"create",value:function(E){if(E instanceof Object&&"storage_id"in E)return new D(E.storage_id);throw new kt('Field "storage_id" is missing')}}]),D}(),Le=function(){function D(){return re.default(this,D),oe.default(this,"initializedFlag","twilio_twilsock_token_storage"),oe.default(this,"tokenStoragePrefix","twilio_continuation_token_"),D._instance||(this.initialize(),D._instance=this),D._instance}return ze.default(D,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(E,T){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(T),E)}},{key:"getStoredToken",value:function(E){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(E)):null}},{key:"initialize",value:function(){var E=this;if(this.canStore()){var T=this.sessionStorage.getItem(this.initializedFlag);T&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var $=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){$(E.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var E=[],T=0;T<this.sessionStorage.length;T++){var $=this.sessionStorage.key(T);$&&$.indexOf(this.tokenStoragePrefix)===0&&E.push($)}var U=this.sessionStorage.removeItem;E.forEach(function(P){return U(P)}),U(this.initializedFlag)}}},{key:"getKeyName",value:function(E){return"".concat(this.tokenStoragePrefix).concat(E)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),D}();oe.default(Le,"_instance",null);var Ae=new Le,Ve=function(){function D(B,E,T,$,U,P){re.default(this,D),this.title=B,this.details=E,this.start=T,this.type=U,this.id=P,this.end=$}return ze.default(D,[{key:"toTelemetryEvent",value:function(){var E=new Date,T=this.start,$=this.end?this.end:E;if($<T){var U=$;$=T,T=U}var P=T.getTime()-E.getTime(),Me=$.getTime()-E.getTime(),Ce=new G(P,Me,this.title,this.details,this.id,this.type);return Ce}}]),D}();t.TelemetryPoint=void 0,function(D){D[D.Start=0]="Start",D[D.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(D){D[D.MinEventsPortion=0]="MinEventsPortion",D[D.AnyEvents=1]="AnyEvents",D[D.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var at=function(){function D(B,E){re.default(this,D),oe.default(this,"minEventsPortionToSend",50),oe.default(this,"maxEventsPortionToSend",100),oe.default(this,"pendingEvents",new Map),oe.default(this,"readyEvents",[]),oe.default(this,"hasInitializationFinished",!1),oe.default(this,"_canSendTelemetry",!1),this.config=B,this.packetInterface=E}return ze.default(D,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(E){et.debug("TelemetryTracker.canSendTelemetry: ".concat(E," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!E&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=E,E&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),E&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(E){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(E)}},{key:"addPartialEvent",value:function(E,T,$){et.debug("Adding ".concat($===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(T,"' event"));var U=this.pendingEvents.has(T);if($===t.TelemetryPoint.Start)U&&et.debug("Overwriting starting point for '".concat(T,"' event")),this.pendingEvents.set(T,E);else{if(!U){et.info("Could not find started event for '".concat(T,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(T),E)),this.pendingEvents.delete(T)}}},{key:"getTelemetryToSend",value:function(E){return!this.canSendTelemetry||this.readyEvents.length==0?[]:E==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(E==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(E){var T=this,$=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),U=this.readyEvents.splice(0,$);return E&&U.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(P,Me){if(!(U.length>=T.maxEventsPortionToSend)){var Ce=T.pendingEvents.get(Me);T.pendingEvents.delete(Me),U.push(new Ve("[UNFINISHED] ".concat(Ce.title),Ce.details,Ce.start,null,Ce.type,Ce.id))}}),U}},{key:"merge",value:function(E,T){return new Ve(T.title?T.title:E.title,T.details?T.details:E.details,E.start,T.end,T.type?T.type:E.type,T.id?T.id:E.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(E){var T=this.getTelemetryToSend(E);if(T.length!==0)try{this.packetInterface.send(new de(T.map(function($){return $.toTelemetryEvent()})))}catch($){et.debug("Error while sending ".concat(T.length," telemetry events due to ").concat($,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(T)}}}]),D}();function Tt(D){var B=Br();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Nn=function D(){re.default(this,D)};oe.default(Nn,"TWILSOCK_CONNECT","twilsock.sdk.connect"),oe.default(Nn,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(D){_e.default(E,D);var B=Tt(E);function E(T,$,U){var P;re.default(this,E),P=B.call(this),oe.default(V.default(P),"version",Mr),oe.default(V.default(P),"offlineStorageDeferred",new Z),U.continuationToken=U.continuationToken?U.continuationToken:Ae.getStoredToken($);var Me=P.config=new Fr(T,$,U);et.setLevel(Me.logLevel);var Ce=new Vn(Me.url),Qe=new Ui(Ce,Me);return P.channel=new gi(Ce,Qe,Me),P.registrations=new qo(Qe),P.upstream=new R(Qe,P.channel,Me),P.telemetryTracker=new at(Me,Qe),P.channel.on("initialized",function(){return P.telemetryTracker.canSendTelemetry=!0}),Ce.on("disconnected",function(){return P.telemetryTracker.canSendTelemetry=!1}),P.registrations.on("registered",function(it){return P.emit("registered",it)}),P.channel.on("message",function(it,Pt){return setTimeout(function(){return P.emit("message",it,Pt)},0)}),P.channel.on("stateChanged",function(it){return setTimeout(function(){return P.emit("stateChanged",it)},0)}),P.channel.on("connectionError",function(it){return setTimeout(function(){return P.emit("connectionError",it)},0)}),P.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return P.emit("tokenAboutToExpire")},0)}),P.channel.on("tokenExpired",function(){return setTimeout(function(){return P.emit("tokenExpired")},0)}),P.channel.on("connected",function(){return P.registrations.updateRegistrations()}),P.channel.on("connected",function(){return P.upstream.sendPendingMessages()}),P.channel.on("connected",function(){return setTimeout(function(){return P.emit("connected")},0)}),P.channel.on("beforeConnect",function(){return P.telemetryTracker.addPartialEvent(new Ve("Establish WebSocket connection","",new Date),Nn.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),P.channel.on("connected",function(){return P.telemetryTracker.addPartialEvent(new Ve("Establish WebSocket connection","",new Date,new Date),Nn.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),P.channel.on("beforeSendInit",function(){return P.telemetryTracker.addPartialEvent(new Ve("Send Twilsock init","",new Date),Nn.TWILSOCK_INIT,t.TelemetryPoint.Start)}),P.channel.on("initialized",function(){return P.telemetryTracker.addPartialEvent(new Ve("Send Twilsock init","Succeeded",new Date,new Date),Nn.TWILSOCK_INIT,t.TelemetryPoint.End)}),P.channel.on("sendInitFailed",function(){return P.telemetryTracker.addPartialEvent(new Ve("Send Twilsock init","Failed",new Date,new Date),Nn.TWILSOCK_INIT,t.TelemetryPoint.End)}),P.channel.on("initialized",function(it){P.handleStorageId($,it),Ae.storeToken(it.continuationToken,$),setTimeout(function(){return P.emit("initialized",it)},0)}),P.channel.on("disconnected",function(){return setTimeout(function(){return P.emit("disconnected")},0)}),P.channel.on("disconnected",function(){return P.upstream.rejectPendingMessages()}),P.channel.on("disconnected",function(){return P.offlineStorageDeferred.fail(new kt("Client disconnected"))}),P.offlineStorageDeferred.promise.catch(function(){}),P}return ze.default(E,[{key:"emit",value:function($){for(var U,P=arguments.length,Me=new Array(P>1?P-1:0),Ce=1;Ce<P;Ce++)Me[Ce-1]=arguments[Ce];return et.debug("Emitting ".concat($.toString(),"(").concat(Me.map(function(Qe){return JSON.stringify(Qe)}).join(", "),")")),(U=xe.default(Te.default(E.prototype),"emit",this)).call.apply(U,[this,$].concat(Me))}},{key:"handleStorageId",value:function($,U){if(!U.offlineStorage)this.offlineStorageDeferred.fail(new kt("No offline storage id"));else if(U.offlineStorage.hasOwnProperty($))try{this.offlineStorageDeferred.set(j.create(U.offlineStorage[$])),et.debug("Offline storage for '".concat($,"' product: ").concat(JSON.stringify(U.offlineStorage[$]),"."))}catch(P){this.offlineStorageDeferred.fail(new kt("Failed to parse offline storage for ".concat($," ").concat(JSON.stringify(U.offlineStorage[$]),". ").concat(P,".")))}else this.offlineStorageDeferred.fail(new kt("No offline storage id for '".concat($,"' product: ").concat(JSON.stringify(U.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var T=Oe.default(q.default.mark(function U(P){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(et.trace("updating token '".concat(P,"'")),this.config.token!==P){Ce.next=3;break}return Ce.abrupt("return");case 3:return this.config.updateToken(P),Ce.next=6,this.channel.updateToken(P);case 6:return Ce.abrupt("return",Ce.sent);case 7:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"setNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Qe.next=2,this.registrations.setNotificationsContext(P,Me);case 2:case"end":return Qe.stop()}},U,this)}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"removeNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:return Ce.next=2,this.registrations.removeNotificationsContext(P);case 2:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var T=Oe.default(q.default.mark(function U(){return q.default.wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Me.next=3,this.channel.disconnect();case 3:return Me.abrupt("return",Me.sent);case 4:case"end":return Me.stop()}},U,this)}));function $(){return T.apply(this,arguments)}return $}()},{key:"get",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce){return q.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),it.next=3,this.upstream.send("GET",P,Me,void 0,Ce);case 3:return it.abrupt("return",it.sent);case 4:case"end":return it.stop()}},U,this)}));function $(U,P,Me){return T.apply(this,arguments)}return $}()},{key:"post",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce,Qe){return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Pt.next=3,this.upstream.send("POST",P,Me,Ce,Qe);case 3:return Pt.abrupt("return",Pt.sent);case 4:case"end":return Pt.stop()}},U,this)}));function $(U,P,Me,Ce){return T.apply(this,arguments)}return $}()},{key:"put",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce,Qe){return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Pt.next=3,this.upstream.send("PUT",P,Me,Ce,Qe);case 3:return Pt.abrupt("return",Pt.sent);case 4:case"end":return Pt.stop()}},U,this)}));function $(U,P,Me,Ce){return T.apply(this,arguments)}return $}()},{key:"delete",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce,Qe){return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Pt.next=3,this.upstream.send("DELETE",P,Me,Ce,Qe);case 3:return Pt.abrupt("return",Pt.sent);case 4:case"end":return Pt.stop()}},U,this)}));function $(U,P,Me,Ce){return T.apply(this,arguments)}return $}()},{key:"addTelemetryEvent",value:function($){this.telemetryTracker.addTelemetryEvent($),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function($,U,P){this.telemetryTracker.addPartialEvent($,U,P),P===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),E}(je),t.TwilsockClient=M([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Xe("design:paramtypes",[String,String,Object])],t.TwilsockClient);var kn=function(){function D(B){re.default(this,D),this.product=B,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return ze.default(D,[{key:"populateInitRegistrations",value:function(E){var T=new Set(this.message_types);for(var $ in E)T.add(E[$]);this.message_types=Array.from(T)}}]),D}();t.InitRegistration=kn,t.TelemetryEventDescription=Ve,t.TelemetryTracker=at,t.TransportUnavailableError=ni,t.Twilsock=t.TwilsockClient,t.TwilsockError=kt})(DI);/*
1071
+ @license
1072
+ The following license applies to all parts of this software except as
1073
+ documented below.
1074
+
1075
+ Copyright (c) 2016, Twilio, inc.
1076
+ All rights reserved.
1077
+
1078
+ Redistribution and use in source and binary forms, with or without
1079
+ modification, are permitted provided that the following conditions are
1080
+ met:
1081
+
1082
+ 1. Redistributions of source code must retain the above copyright
1083
+ notice, this list of conditions and the following disclaimer.
1084
+
1085
+ 2. Redistributions in binary form must reproduce the above copyright
1086
+ notice, this list of conditions and the following disclaimer in
1087
+ the documentation and/or other materials provided with the
1088
+ distribution.
1089
+
1090
+ 3. Neither the name of Twilio nor the names of its contributors may
1091
+ be used to endorse or promote products derived from this software
1092
+ without specific prior written permission.
1093
+
1094
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1095
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1096
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1097
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1098
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1099
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1100
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1101
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1102
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1103
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1104
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1105
+
1106
+ This software includes loglevel under the following license.
1107
+
1108
+ Copyright (c) 2013 Tim Perry
1109
+
1110
+ Permission is hereby granted, free of charge, to any person
1111
+ obtaining a copy of this software and associated documentation
1112
+ files (the "Software"), to deal in the Software without
1113
+ restriction, including without limitation the rights to use,
1114
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
1115
+ copies of the Software, and to permit persons to whom the
1116
+ Software is furnished to do so, subject to the following
1117
+ conditions:
1118
+
1119
+ The above copyright notice and this permission notice shall be
1120
+ included in all copies or substantial portions of the Software.
1121
+
1122
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1123
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
1124
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1125
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1126
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1127
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1128
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1129
+ OTHER DEALINGS IN THE SOFTWARE.
1130
+
1131
+ This software includes Backoff library under the following license
1132
+
1133
+ Copyright (C) 2012 Mathieu Turcotte
1134
+
1135
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
1136
+ this software and associated documentation files (the "Software"), to deal in
1137
+ the Software without restriction, including without limitation the rights to
1138
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
1139
+ of the Software, and to permit persons to whom the Software is furnished to do
1140
+ so, subject to the following conditions:
1141
+
1142
+ The above copyright notice and this permission notice shall be included in all
1143
+ copies or substantial portions of the Software.
1144
+
1145
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1146
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1147
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1148
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1149
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1150
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1151
+ SOFTWARE.
1152
+
1153
+ This software includes Event-to-Promise library under the following license
1154
+
1155
+ Copyright (c) 2014, Julien Fontanet <julien.fontanet@isonoe.net>.
1156
+
1157
+ Permission to use, copy, modify, and/or distribute this software for any purpose
1158
+ with or without fee is hereby granted, provided that the above copyright notice
1159
+ and this permission notice appear in all copies.
1160
+
1161
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1162
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
1163
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1164
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1165
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1166
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
1167
+ THIS SOFTWARE.
1168
+
1169
+ */Object.defineProperty(zn,"__esModule",{value:!0});var rte=Mu,nte=sa,ite=Oa,ate=ys,ste=ia,ote=aa,ute=li,lte=bs,cte=Hu,dte=ui,Ge=wn,Mp=DI,fte=_d,hte=qu,pte=ud,jI=oa,UI=pd,vte=np,mte=Wb;function Xn(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}function ew(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var tt=Xn(rte),hr=Xn(nte),wr=Xn(ite),ca=Xn(ate),In=Xn(ste),Is=Xn(ote),Kr=Xn(ute),Sr=Xn(lte),fe=Xn(cte),FI=Xn(dte),gte=Xn(fte),yte=ew(hte),BI=Xn(pte),bte=ew(UI),Sd=Xn(vte),Np=ew(mte);function vr(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,s;if((typeof Reflect>"u"?"undefined":FI.default(Reflect))==="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(s=t[o])&&(a=(i<3?s(a):i>3?s(e,r,a):s(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function Je(t,e){if((typeof Reflect>"u"?"undefined":FI.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}var wte;function As(){}As.prototype=Object.create(null);function $r(){$r.init.call(this)}$r.EventEmitter=$r,$r.usingDomains=!1,$r.prototype.domain=void 0,$r.prototype._events=void 0,$r.prototype._maxListeners=void 0,$r.defaultMaxListeners=10,$r.init=function(){this.domain=null,$r.usingDomains&&wte.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new As,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},$r.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function zI(t){return t._maxListeners===void 0?$r.defaultMaxListeners:t._maxListeners}$r.prototype.getMaxListeners=function(){return zI(this)};function _te(t,e,r){if(e)t.call(r);else for(var n=t.length,i=$d(t,n),a=0;a<n;++a)i[a].call(r)}function kte(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=$d(t,i),s=0;s<i;++s)a[s].call(r,n)}function Ste(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=$d(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function $te(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=$d(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function Tte(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=$d(t,i),s=0;s<i;++s)a[s].apply(r,n)}$r.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:_te(n,d,this);break;case 2:kte(n,d,this,arguments[1]);break;case 3:Ste(n,d,this,arguments[1],arguments[2]);break;case 4:$te(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];Tte(n,d,this,a)}return!0};function HI(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new As,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=zI(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,Ete(o)}return t}function Ete(t){typeof console.warn=="function"?console.warn(t):console.log(t)}$r.prototype.addListener=function(e,r){return HI(this,e,r,!1)},$r.prototype.on=$r.prototype.addListener,$r.prototype.prependListener=function(e,r){return HI(this,e,r,!0)};function qI(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}$r.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,qI(this,e,r)),this},$r.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,qI(this,e,r)),this},$r.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new As:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new As,this;delete i[e]}else Cte(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},$r.prototype.off=function(t,e){return this.removeListener(t,e)},$r.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new As,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new As:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new As,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},$r.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=Rte(r):n=[]):n=[],n},$r.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):VI.call(t,e)},$r.prototype.listenerCount=VI;function VI(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}$r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function Cte(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function $d(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function Rte(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}var al=function(){function t(e){hr.default(this,t),this.base=e,this.args=new Array,this.paths=new Array}return wr.default(t,[{key:"pathSegment",value:function(r){return this.paths.push(encodeURIComponent(r)),this}},{key:"queryParam",value:function(r,n){return typeof n<"u"&&this.args.push(encodeURIComponent(r)+"="+encodeURIComponent(n)),this}},{key:"build",value:function(){var r=this.base;return this.paths.length&&(r+="/"+this.paths.join("/")),this.args.length&&(r+="?"+this.args.join("&")),r}}]),t}();function WI(t){var e=xte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function xte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Hn=function(t){In.default(r,t);var e=WI(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return hr.default(this,r),i=e.call(this),i.name=i.constructor.name,i.message="".concat(n," (status: ").concat(a,", code: ").concat(s,")"),i.status=a,i.code=s,i}return r}(gte.default(Error)),Ite=function(t){In.default(r,t);var e=WI(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return hr.default(this,r),i=e.call(this,n,a,s),i.body=o,i}return r}(Hn);function Ni(t){return JSON.parse(JSON.stringify(t))}function ZI(t){var e=t===void 0||tw(t);if(!e)throw new Hn("Invalid pageSize parameter. Expected a positive integer, was '".concat(t,"'."),400,20007)}function Ate(t){return!isNaN(parseInt(t))&&isFinite(t)}function tw(t){return Ate(t)&&t>0}var sl=yte.getLogger("twilio-sync");function Td(t,e){return["".concat(new Date().toISOString()," Sync ").concat(t,":")].concat(Array.from(e))}var gr={setLevel:function(e){sl.setLevel(e)},trace:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];sl.trace.apply(null,Td("T",r))},debug:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];sl.debug.apply(null,Td("D",r))},info:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];sl.info.apply(null,Td("I",r))},warn:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];sl.warn.apply(null,Td("W",r))},error:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];sl.error.apply(null,Td("E",r))}},Ote="/v4/Subscriptions",Pte="/v3/Maps",Mte="/v3/Lists",Nte="/v3/Documents",Lte="/v3/Streams",Dte="/v3/Insights";function jte(t,e,r){return t&&typeof t[e]<"u"?t[e]:r}var Ute=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hr.default(this,t);var r=e.region||"us1",n="https://cds.".concat(r,".twilio.com"),i=e.cdsUri||n;this.settings={subscriptionsUri:i+Ote,documentsUri:i+Nte,listsUri:i+Mte,mapsUri:i+Pte,streamsUri:i+Lte,insightsUri:i+Dte,sessionStorageEnabled:jte(e.Sync,"enableSessionStorage",!0),productId:e.productId}}return wr.default(t,[{key:"subscriptionsUri",get:function(){return this.settings.subscriptionsUri}},{key:"documentsUri",get:function(){return this.settings.documentsUri}},{key:"listsUri",get:function(){return this.settings.listsUri}},{key:"mapsUri",get:function(){return this.settings.mapsUri}},{key:"streamsUri",get:function(){return this.settings.streamsUri}},{key:"insightsUri",get:function(){return this.settings.insightsUri}},{key:"backoffConfig",get:function(){return this.settings.backoffConfig||{}}},{key:"sessionStorageEnabled",get:function(){return this.settings.sessionStorageEnabled}},{key:"productId",get:function(){return this.settings.productId}}]),t}();function Ed(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Fte(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1170
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Fte(t,e){if(t){if(typeof t=="string")return GI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return GI(t,e)}}function GI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Bte=function(){function t(e){hr.default(this,t),this.localObject=e,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return wr.default(t,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(r,n){this.localObject._update(r,n)}},{key:"updatePending",value:function(r,n){this.pendingAction=r,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(r){this.rejectedWithError=r.error,this.updatePending(null,null),this.localObject.reportFailure(new Hn("Failed to subscribe on service events: ".concat(r.error.message),r.error.status,r.error.code))}},{key:"complete",value:function(r){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(r)}},{key:"setSubscriptionState",value:function(r){this.localObject._setSubscriptionState(r)}}]),t}(),zte=function(){function t(e){var r=this;hr.default(this,t),Sr.default(this,"isConnected",!1),Sr.default(this,"maxBatchSize",100),Sr.default(this,"subscriptionTtlTimer",null),Sr.default(this,"pendingPokeReason",null),this.services=e,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=jI.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=r.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?r.applyNewSubscriptionUpdateBatch(a,s):(r.backoff.reset(),gr.debug("All subscriptions resolved."))})}return wr.default(t,[{key:"getSubscriptionUpdateBatch",value:function(){function r(a,s,o,u){var l=[],c=Ed(a),d;try{for(c.s();!(d=c.n()).done;){var f=BI.default(d.value,2),m=f[0],b=f[1],A=s.get(m);if(!A&&o!==b.pendingAction&&!b.rejectedWithError&&(l.push(b),u&&l.length>=u))break}}catch(N){c.e(N)}finally{c.f()}return l}var n=r(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=r(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return i.length>0?{action:"cancel",subscriptions:i}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:function(){var e=tt.default(fe.default.mark(function n(i,a){var s=this,o,u,l,c,d,f,m,b,A,N,z,X,Ee,Ie,Fe,Oe;return fe.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(this.isConnected){V.next=4;break}return gr.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),V.abrupt("return");case 4:a=this.processLocalActions(i,a),o=new Date().getTime(),u=Ed(a);try{for(u.s();!(l=u.n()).done;)c=l.value,this.recordActionAttemptOn(c,i,o)}catch(xe){u.e(xe)}finally{u.f()}return d=this.pendingPokeReason,this.pendingPokeReason=null,V.prev=10,V.next=13,this.request(i,o,d,a);case 13:f=V.sent,m=f.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(b=f.body.ttl_in_s,A=!isNaN(parseFloat(b))&&isFinite(b),N=A&&b>0,N&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},b*1e3))),i==="establish"&&(z=f.body.estimated_delivery_in_ms,X=!isNaN(parseFloat(z))&&isFinite(z),Ee=X&&z>0,Ee?setTimeout(function(){return s.verifyPokeDelivery(o,z,a)},z):gr.error("Invalid timeout: ".concat(z)),a.filter(function(xe){return xe.pendingCorrelationId===o}).forEach(function(xe){return xe.setSubscriptionState("response_in_flight")})),this.backoff.reset(),V.next=26;break;case 21:V.prev=21,V.t0=V.catch(10),Ie=Ed(a);try{for(Ie.s();!(Fe=Ie.n()).done;)Oe=Fe.value,this.recordActionFailureOn(Oe,i)}catch(xe){Ie.e(xe)}finally{Ie.f()}V.t0 instanceof Mp.TransportUnavailableError?(gr.debug("Twilsock connection (required for subscription) not ready (c:".concat(o,"); waiting…")),this.backoff.reset()):(gr.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(o,"); retrying"),V.t0),this.persist());case 26:case"end":return V.stop()}},n,this,[[10,21]])}));function r(n,i){return e.apply(this,arguments)}return r}()},{key:"verifyPokeDelivery",value:function(r,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(r),o=s?new Date().getTime()-s:n;if(o>=n)i.filter(function(l){return l.pendingCorrelationId===r}).forEach(function(l){l.updatePending(null,null),l.retryCount++,a.persisted.delete(l.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(r);else{var u=n-o;setTimeout(function(){return a.verifyPokeDelivery(r,n,i)},u)}}},{key:"processLocalActions",value:function(r,n){return r==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(r,n,i){if(r.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(r.sid,r),r.updatePending(n,i);else{var a=this.persisted.get(r.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(r,n){r.setSubscriptionState("none"),r.updatePending(null,null),n==="establish"&&this.persisted.delete(r.sid)}},{key:"request",value:function(r,n,i,a){var s=a.map(function(l){return{object_sid:l.sid,object_type:l.type,last_event_id:r==="establish"?l.lastEventId:void 0,index_name:r==="establish"?l.indexName:void 0,query_string:r==="establish"?l.queryString:void 0}}),o=a.filter(function(l){return l.retryCount>0}).length;gr.debug("Attempting '".concat(r,"' request (c:").concat(n,"):"),s);var u={event_protocol_version:4,action:r,correlation_id:n,retried_requests:o,ttl_in_s:-1,requests:s};return i==="ttl"&&(u.reason=i),this.services.network.post(this.services.config.subscriptionsUri,u)}},{key:"add",value:function(r,n){gr.debug("Establishing intent to subscribe to ".concat(r));var i=this.subscriptions.get(r);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(r),this.subscriptions.set(r,new Bte(n)),this.persist())}},{key:"remove",value:function(r){gr.debug("Establishing intent to unsubscribe from ".concat(r));var n=this.subscriptions.delete(r);n&&this.persist()}},{key:"acceptMessage",value:function(r,n){gr.trace("Subscriptions received",r);var i=r.event_type,a=typeof r.events<"u"?r.events:[r.event],s=r.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var o=Ed(a),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,c=void 0;switch(r.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(l,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(l,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(l,s);break;case(c=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var d=void 0;switch(c[0]){case"map_":d=l.map_sid;break;case"list_":d=l.list_sid;break;case"document_":d=l.document_sid;break;case"stream_":d=l.stream_sid;break;case"live_query_":d=l.query_id,n=!1,r.strictly_ordered===!0&&(n=!0);break;default:d=void 0}this.applyEventToSubscribedEntity(d,l,i,n);break}default:gr.debug("Dropping unknown message type ".concat(i));break}}}catch(f){o.e(f)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(r,n){var i=r.object_sid,a=this.persisted.get(r.object_sid);a&&a.pendingCorrelationId===n?r.replay_status==="interrupted"?(gr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") interrupted; continuing eagerly.")),a.updatePending(null,null),this.persisted.delete(a.sid),this.backoff.reset()):r.replay_status==="completed"&&(gr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(r.last_event_id),this.persisted.set(r.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):gr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(r,n){var i=this.persisted.get(r.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(r.object_sid)):gr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(r,n){var i=r.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(gr.error("Failed to subscribe on ".concat(s.sid),r.error),s.markAsFailed(r),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(r,n,i,a){var s=this;if(r){a=a||function(){var u=s.persisted.get(r);return u&&u.isEstablished}();var o=this.subscriptions.get(r);o?(n.type=i,o.update(n,a)):gr.debug("Message dropped for SID '".concat(r,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(r){this.isConnected=r,r&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(r){gr.debug("Triggering event replay for all subscriptions, reason=".concat(r)),this.pendingPokeReason=r,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=Ed(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(c){i.e(c)}finally{i.f()}this.persisted.clear();for(var o=0,u=n;o<u.length;o++){var l=u[o];this.persisted.set(l.sid,l)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),t}(),Hte=4e3,qte=6e4,Vte=9e4,Wte=.2;function KI(t){if(t.body&&t.body.message)return t.body.message;switch(t.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function JI(t){return t.body?t.body.code:0}function Cd(t){return t.status===409?new Ite(KI(t),t.status,JI(t),t.body):t.status?new Hn(KI(t),t.status,JI(t)):t instanceof Mp.TransportUnavailableError?t:new Hn(t.message,0,0)}var Zte=function(){function t(e,r,n){hr.default(this,t),this.clientInfo=e,this.config=r,this.transport=n}return wr.default(t,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+bte.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:Hte,max:qte,maxAttemptsTime:Vte,randomness:Wte},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(r){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return new Promise(function(a,s){var o=[502,503,504];i&&o.push(429);var u=new jI.Retrier(n.backoffConfig());u.on("attempt",function(){r().then(function(l){return u.succeeded(l)}).catch(function(l){if(o.includes(l.status)){var c=parseInt(l.headers?l.headers["Retry-After"]:null);u.failed(Cd(l),isNaN(c)?null:c*1e3)}else l.message==="Twilsock disconnected"?u.failed(Cd(l)):(u.removeAllListeners(),u.cancel(),s(Cd(l)))})}),u.on("succeeded",function(l){a(l)}),u.on("cancelled",function(l){return s(Cd(l))}),u.on("failed",function(l){return s(Cd(l))}),u.start()})}},{key:"get",value:function(r){var n=this,i=this.createHeaders();return gr.debug("GET",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(r,i,n.config.productId)},!0)}},{key:"post",value:function(r,n,i){var a=this,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=this.createHeaders();return typeof i<"u"&&i!==null&&(o["If-Match"]=i),gr.debug("POST",r,"ID:",o["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(r,o,n,a.config.productId)},s)}},{key:"put",value:function(r,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),gr.debug("PUT",r,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(r,s,n,a.config.productId)},!1)}},{key:"delete",value:function(r){var n=this,i=this.createHeaders();return gr.debug("DELETE",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(r,i,n.config.productId)},!1)}}]),t}(),Gte=function(){function t(e,r){hr.default(this,t),this.config=e,this.storageId=null;try{this.storage=r||sessionStorage}catch{}}return wr.default(t,[{key:"storageKey",value:function(r,n){return"".concat(this.storageId,"::").concat(r,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(r){this.storageId=r}},{key:"store",value:function(r,n,i){return this.isReady?this._store(this.storageKey(r,n),i):null}},{key:"read",value:function(r,n){return this.isReady?this._read(this.storageKey(r,n)):null}},{key:"remove",value:function(r,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(r,n)),i&&this.storage.removeItem(this.storageKey(r,i))}catch{}}},{key:"update",value:function(r,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(r,n),a),i&&this._apply(this.storageKey(r,i),a)}},{key:"_store",value:function(r,n){try{this.storage.setItem(r,JSON.stringify(n))}catch{}}},{key:"_read",value:function(r){try{var n=this.storage.getItem(r);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(r,n){var i=this._read(r);if(!i)return!1;this._store(r,Object.assign(i,n))}}]),t}();function Kte(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Jte(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1171
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Jte(t,e){if(t){if(typeof t=="string")return YI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return YI(t,e)}}function YI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Rd=function(){function t(e,r){hr.default(this,t),this.services=e,this.removalHandler=r,this.subscriptionState="none",this._attachedListeners=new Map}return wr.default(t,[{key:"_advanceLastEventId",value:function(r,n){}},{key:"reportFailure",value:function(r){r.status===404?this.onRemoved(!1):this.broadcastEventToListeners("failure",r)}},{key:"_subscribe",value:function(){this.services.router._subscribe(this.sid,this)}},{key:"_unsubscribe",value:function(){this.services.router._unsubscribe(this.sid)}},{key:"_setSubscriptionState",value:function(r){this.subscriptionState=r,this.broadcastEventToListeners("_subscriptionStateChanged",r)}},{key:"close",value:function(){this._unsubscribe(),this.removalHandler!=null&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(r){var n=r.listenerUuid,i=this._attachedListeners.get(n);i||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(n,r))}},{key:"detach",value:function(r){this._attachedListeners.delete(r),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(r,n){var i=Kte(this._attachedListeners.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.emit(r,n)}}catch(o){i.e(o)}finally{i.f()}}}]),t}(),QI=function(){function t(e){hr.default(this,t),Sr.default(this,"queuedRequests",[]),Sr.default(this,"isRequestInFlight",!1),this.inputMergingFunction=e}return wr.default(t,[{key:"add",value:function(r,n){var i=this,a=new Promise(function(s,o){return i.queuedRequests.push({input:r,requestFunction:n,resolve:s,reject:o})});return this.wakeupQueue(),a}},{key:"squashAndAdd",value:function(r,n){var i=this.queuedRequests;this.queuedRequests=[];var a;i.length>0?(a=i.map(function(o){return o.input}).reduce(this.inputMergingFunction),a=this.inputMergingFunction(a,r)):a=r;var s=this.add(a,n);return i.forEach(function(o){return s.then(o.resolve,o.reject)}),s}},{key:"isEmpty",value:function(){return this.queuedRequests.length===0&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var r=this;if(!(this.queuedRequests.length===0||this.isRequestInFlight)){var n=this.queuedRequests.shift();this.isRequestInFlight=!0,n.requestFunction(n.input).then(n.resolve,n.reject).then(function(i){r.isRequestInFlight=!1,r.wakeupQueue()})}}}]),t}(),XI=function(){function t(e){hr.default(this,t),Sr.default(this,"queueByNamespaceKey",new Map),this.inputReducer=e}return wr.default(t,[{key:"add",value:function(){var e=tt.default(fe.default.mark(function n(i,a,s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(l){return l.add(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function r(n,i,a){return e.apply(this,arguments)}return r}()},{key:"squashAndAdd",value:function(){var e=tt.default(fe.default.mark(function n(i,a,s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(l){return l.squashAndAdd(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function r(n,i,a){return e.apply(this,arguments)}return r}()},{key:"invokeQueueMethod",value:function(){var e=tt.default(fe.default.mark(function n(i,a){var s,o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.queueByNamespaceKey.has(i)||this.queueByNamespaceKey.set(i,new QI(this.inputReducer)),s=this.queueByNamespaceKey.get(i),o=a(s),this.queueByNamespaceKey.get(i).isEmpty()&&this.queueByNamespaceKey.delete(i),l.abrupt("return",o);case 5:case"end":return l.stop()}},n,this)}));function r(n,i){return e.apply(this,arguments)}return r}()}]),t}();function Yte(t){var e=Qte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function Qte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var xd=function(t){In.default(r,t);var e=Yte(r);function r(){var n;return hr.default(this,r),n=e.call(this),n.closed=!1,n.uuid=UI.v4(),n}return wr.default(r,[{key:"listenerUuid",get:function(){return this.uuid}},{key:"close",value:function(){this.removeAllListeners(),this.closed=!0}},{key:"ensureNotClosed",value:function(){if(this.closed)throw new Error("Invalid operation on closed object")}}]),r}($r);function eA(t){var e=Xte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function Xte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var rw=function(t){In.default(r,t);var e=eA(r);function r(n,i,a){var s;hr.default(this,r),s=e.call(this,n,a),Sr.default(ca.default(s),"isDeleted",!1);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new QI(o),s.descriptor=i,s.descriptor.data=s.descriptor.data||{},s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"document"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"_update",value:function(i){switch(i.date_created=new Date(i.date_created),i.type){case"document_updated":if(i.id<=this.lastEventId){gr.trace("Document update skipped, current:",this.lastEventId,", remote:",i.id);break}var a=this.descriptor.data!==void 0?Ni(this.descriptor.data):null;this.descriptor.last_event_id=i.id,this.descriptor.revision=i.document_revision,this.descriptor.date_updated=i.date_created,this.descriptor.data=i.document_data,this.broadcastEventToListeners("updated",{data:i.document_data,isLocal:!1,previousData:a}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.id,revision:i.document_revision,date_updated:i.date_created,data:i.document_data});break;case"document_removed":this.onRemoved(!1);break}}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u=this,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.squashAndAdd(l,function(f){return u._setUnconditionally(s,f.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u=this,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.add(l,function(f){return u._setWithIfMatch(s,f.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(function(c){return Object.assign(c,s)},o));case 1:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this._postUpdateToServer({ttl:s});case 2:o=l.sent,this.descriptor.date_expires=o.date_expires;case 4:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_setUnconditionally",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this._postUpdateToServer({data:s,revision:void 0,ttl:o});case 2:return u=c.sent,this._handleSuccessfulUpdateResult(u),c.abrupt("return",this.descriptor.data);case 5:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_setWithIfMatch",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(u=s(Ni(this.descriptor.data)),!u){f.next=22;break}return l=this.revision,f.prev=3,f.next=6,this._postUpdateToServer({data:u,revision:l,ttl:o});case 6:return c=f.sent,this._handleSuccessfulUpdateResult(c),f.abrupt("return",this.descriptor.data);case 11:if(f.prev=11,f.t0=f.catch(3),f.t0.status!==412){f.next=19;break}return f.next=16,this._softSync();case 16:return f.abrupt("return",this._setWithIfMatch(s));case 19:throw f.t0;case 20:f.next=23;break;case 22:return f.abrupt("return",this.descriptor.data);case 23:case"end":return f.stop()}},a,this,[[3,11]])}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_handleSuccessfulUpdateResult",value:function(i){if(!(i.last_event_id<=this.descriptor.last_event_id)){var a=this.descriptor.data!==void 0?Ni(this.descriptor.data):null;this.descriptor.revision=i.revision,this.descriptor.data=i.data,this.descriptor.last_event_id=i.last_event_id,this.descriptor.date_expires=i.date_expires,this.descriptor.date_updated=new Date(i.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.last_event_id,revision:i.revision,date_updated:i.date_updated,data:i.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:a})}}},{key:"_postUpdateToServer",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.isDeleted){d.next=17;break}return o={data:s.data},s.ttl!==void 0&&(o.ttl=s.ttl),u=s.revision,d.prev=4,d.next=7,this.services.network.post(this.uri,o,u);case 7:return l=d.sent,d.abrupt("return",{revision:l.body.revision,data:s.data,last_event_id:l.body.last_event_id,date_updated:l.body.date_updated,date_expires:l.body.date_expires});case 11:throw d.prev=11,d.t0=d.catch(4),d.t0.status===404&&this.onRemoved(!1),d.t0;case 15:d.next=18;break;case 17:return d.abrupt("return",Promise.reject(new Hn("The Document has been removed",404,54100)));case 18:case"end":return d.stop()}},a,this,[[4,11]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_softSync",value:function(){var n=tt.default(fe.default.mark(function a(){var s=this;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.network.get(this.uri).then(function(l){var c={type:"document_updated",id:l.body.last_event_id,document_revision:l.body.revision,document_data:l.body.data,date_created:l.body.date_updated};return s._update(c),s}).catch(function(l){l.status===404?s.onRemoved(!1):gr.error("Can't get updates for ".concat(s.sid,":"),l)}));case 1:case"end":return u.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){if(!this.isDeleted){var a=this.descriptor.data!==void 0?Ni(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i,previousData:a})}}},{key:"removeDocument",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.isDeleted){o.next=6;break}return o.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),o.next=7;break;case 6:return o.abrupt("return",Promise.reject(new Hn("The Document has been removed",404,54100)));case 7:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"document"}}]),r}(Rd),ci=function(t){In.default(r,t);var e=eA(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncDocumentImpl=n,i.syncDocumentImpl.attach(ca.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncDocumentImpl.uri}},{key:"revision",get:function(){return this.syncDocumentImpl.revision}},{key:"lastEventId",get:function(){return this.syncDocumentImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncDocumentImpl.dateExpires}},{key:"type",get:function(){return rw.type}},{key:"sid",get:function(){return this.syncDocumentImpl.sid}},{key:"data",get:function(){return this.syncDocumentImpl.data}},{key:"dateUpdated",get:function(){return this.syncDocumentImpl.dateUpdated}},{key:"uniqueName",get:function(){return this.syncDocumentImpl.uniqueName}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.set(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.mutate(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.update(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncDocumentImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeDocument",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Sd.default(Kr.default(r.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return rw.type}}]),r}(xd);Sr.default(ci,"removed","removed"),Sr.default(ci,"updated","updated"),vr([Ge.validateTypesAsync(Ge.pureObject,["undefined",Ge.objectSchema("document metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object,Object]),Je("design:returntype",Promise)],ci.prototype,"set",null),vr([Ge.validateTypesAsync("function",["undefined",Ge.objectSchema("document metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Function,Object]),Je("design:returntype",Promise)],ci.prototype,"mutate",null),vr([Ge.validateTypesAsync(Ge.pureObject,["undefined",Ge.objectSchema("document metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object,Object]),Je("design:returntype",Promise)],ci.prototype,"update",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],ci.prototype,"setTtl",null);var nw=function(){function t(e){hr.default(this,t),this.descriptor=e}return wr.default(t,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(r,n,i,a){return this.descriptor.lastEventId=r,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.dateUpdated=a,this}},{key:"updateDateExpires",value:function(r){this.descriptor.dateExpires=r}}]),t}(),iw=function(){function t(e,r,n,i){hr.default(this,t),this.prevToken=n,this.nextToken=i,this.items=e,this.source=r}return wr.default(t,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:function(){var e=tt.default(fe.default.mark(function n(){return fe.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasNextPage){a.next=2;break}throw new Error("No next page");case 2:return a.abrupt("return",this.source(this.nextToken));case 3:case"end":return a.stop()}},n,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"prevPage",value:function(){var e=tt.default(fe.default.mark(function n(){return fe.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasPrevPage){a.next=2;break}throw new Error("No previous page");case 2:return a.abrupt("return",this.source(this.prevToken));case 3:case"end":return a.stop()}},n,this)}));function r(){return e.apply(this,arguments)}return r}()}]),t}();function ere(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=tre(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1172
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function tre(t,e){if(t){if(typeof t=="string")return tA(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return tA(t,e)}}function tA(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var rre=function(){function t(e,r){hr.default(this,t),this.balanceFactor=0,this.key=e,this.value=r,this.parent=null,this.left=null,this.right=null}return wr.default(t,[{key:"isRoot",get:function(){return this.parent===null}},{key:"isLeaf",get:function(){return this.left===null&&this.right===null}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(r){this.value=r}},{key:"replace",value:function(r,n){r&&(this.left===n?this.left=n:this.right===n&&(this.right=n))}}]),t}(),nre=function(){function t(e,r){hr.default(this,t),this.isLessThan=e||function(n,i){return n<i},this.isEqual=r||function(n,i){return n===i},this.root=null,this.count=null}return wr.default(t,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(r,n){var i=this.getNode(r);i?i.update(n):this.insert(r,n)}},{key:"insert",value:function(r,n){var i=new rre(r,n);if(this.count++,!this.root){this.root=i;return}for(var a=this.root;;)if(this.isLessThan(r,a.key))if(a.left)a=a.left;else{a.left=i;break}else if(a.right)a=a.right;else{a.right=i;break}for(i.parent=a,a=i;a.parent;){var s=a.parent,o=s.balanceFactor;if(a.isLeftChild?s.balanceFactor++:s.balanceFactor--,Math.abs(s.balanceFactor)<Math.abs(o))break;if(s.balanceFactor<-1||s.balanceFactor>1){this.rebalance(s);break}a=s}}},{key:"get",value:function(r){for(var n=this.root;n;){if(this.isEqual(r,n.key))return n.value;this.isLessThan(r,n.key)?n=n.left:n=n.right}return null}},{key:"delete",value:function(r){var n=this.getNode(r);if(!n||n.key!==r)return null;var i=n.parent,a=n.left,s=n.right;if(!!a!=!!s){var o=a||s;!i&&!o?this.root=null:i&&!o?this.root=o:(i.replace(n,null),this.rebalance(i))}else{for(var u=n.left;u.right;)u=u.right;if(n.left===u)n.isRoot?(this.root=u,u.parent=null):(n.isLeftChild?n.parent.left=u:n.parent.right=u,u.parent=n.parent),u.right=n.right,u.right.parent=u,u.balanceFactor=n.balanceFactor,n={parent:u,isLeftChild:!0};else{var l=u.parent,c=u.left;l.right=c,c&&(c.parent=l),n.isRoot?(this.root=u,u.parent=null):(n.isLeftChild?n.parent.left=u:n.parent.right=u,u.parent=n.parent),u.right=n.right,u.right.parent=u,u.left=n.left,u.left.parent=u,u.balanceFactor=n.balanceFactor,n={parent:l,isLeftChild:!1}}}for(this.count--;n.parent;){var d=n.parent,f=d.balanceFactor;if(n.isLeftChild?d.balanceFactor-=1:d.balanceFactor+=1,Math.abs(d.balanceFactor)>Math.abs(f))if(d.balanceFactor<-1||d.balanceFactor>1)if(this.rebalance(d),d.parent.balanceFactor===0)n=d.parent;else break;else break;else n=d}return null}},{key:"getNode",value:function(r){for(var n=this.root;n;){if(this.isEqual(r,n.key))return n;this.isLessThan(r,n.key)?n=n.left:n=n.right}return null}},{key:"rebalance",value:function(r){r.balanceFactor<0?r.right.balanceFactor>0?(this.rotateRight(r.right),this.rotateLeft(r)):this.rotateLeft(r):r.balanceFactor>0&&(r.left.balanceFactor<0?(this.rotateLeft(r.left),this.rotateRight(r)):this.rotateRight(r))}},{key:"rotateLeft",value:function(r){var n=r.right;r.right=n.left,n.left!==null&&(n.left.parent=r),n.parent=r.parent,n.parent===null?this.root=n:r.isLeftChild?n.parent.left=n:n.parent.right=n,n.left=r,r.parent=n,r.balanceFactor=r.balanceFactor+1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor+1-Math.max(r.balanceFactor,0)}},{key:"rotateRight",value:function(r){var n=r.left;r.left=n.right,n.right!==null&&(n.right.parent=r),n.parent=r.parent,n.parent===null?this.root=n:r.isLeftChild?n.parent.left=n:n.parent.right=n,n.right=r,r.parent=n,r.balanceFactor=r.balanceFactor-1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor-1-Math.max(r.balanceFactor,0)}},{key:Symbol.iterator,value:fe.default.mark(function e(){var r,n,i;return fe.default.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:r=ere(this.getIterator()),s.prev=1,r.s();case 3:if((n=r.n()).done){s.next=9;break}return i=n.value,s.next=7,i;case 7:s.next=3;break;case 9:s.next=14;break;case 11:s.prev=11,s.t0=s.catch(1),r.e(s.t0);case 14:return s.prev=14,r.f(),s.finish(14);case 17:case"end":return s.stop()}},e,this,[[1,11,14,17]])})},{key:"getIterator",value:fe.default.mark(function e(){var r,n,i,a=arguments;return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:r=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(r,n.key)||r===null&&!n.left)){o.next=5;break}return o.abrupt("break",8);case 5:this.isLessThan(r,n.key)||r===null?n=n.left:n=n.right,o.next=2;break;case 8:if(n){o.next=10;break}return o.abrupt("return",null);case 10:i=!0;case 11:if(!i){o.next=29;break}return o.next=14,[n.key,n.value];case 14:if(i=!1,!n.right){o.next=21;break}for(n=n.right;n.left;)n=n.left;i=!0,o.next=27;break;case 21:if(!n.parent){o.next=26;break}i=n.parent.left===n,n=n.parent,o.next=27;break;case 26:return o.abrupt("break",37);case 27:o.next=35;break;case 29:if(!n.parent){o.next=34;break}i=n.parent.left===n,n=n.parent,o.next=35;break;case 34:return o.abrupt("break",37);case 35:o.next=11;break;case 37:return o.abrupt("return",null);case 38:case"end":return o.stop()}},e,this)})},{key:"getReverseIterator",value:fe.default.mark(function e(){var r,n,i,a=arguments;return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:r=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(r,n.key)||r===null&&!n.right)){o.next=5;break}return o.abrupt("break",8);case 5:!this.isLessThan(r,n.key)||r===null?n=n.right:n=n.left,o.next=2;break;case 8:if(n){o.next=10;break}return o.abrupt("return",null);case 10:i=!0;case 11:if(!i){o.next=29;break}return o.next=14,[n.key,n.value];case 14:if(i=!1,!n.left){o.next=21;break}for(n=n.left;n.right;)n=n.right;i=!0,o.next=27;break;case 21:if(!n.parent){o.next=26;break}i=n.parent.right===n,n=n.parent,o.next=27;break;case 26:return o.abrupt("break",37);case 27:o.next=35;break;case 29:if(!n.parent){o.next=34;break}i=n.parent.right===n,n=n.parent,o.next=35;break;case 34:return o.abrupt("break",37);case 35:o.next=11;break;case 37:return o.abrupt("return",null);case 38:case"end":return o.stop()}},e,this)})}]),t}();function ire(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=are(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1173
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function are(t,e){if(t){if(typeof t=="string")return rA(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return rA(t,e)}}function rA(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var sre=function(){function t(e,r){hr.default(this,t),this.value=e,this.revision=r||0}return wr.default(t,[{key:"isValid",get:function(){return!0}}]),t}(),ore=function(){function t(e){hr.default(this,t),this.revision=e}return wr.default(t,[{key:"isValid",get:function(){return!1}}]),t}(),aw=function(){function t(){hr.default(this,t),this.items=new nre}return wr.default(t,[{key:"store",value:function(r,n,i){var a=this.items.get(r);return a&&a.revision>i?a.isValid?a.value:null:(this.items.set(r,new sre(n,i)),n)}},{key:"delete",value:function(r,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=this.items.get(r);(!a||a.revision<n||a&&i===!0)&&this.items.set(r,new ore(n))}},{key:"isKnown",value:function(r,n){var i=this.items.get(r);return i&&i.revision>=n}},{key:"get",value:function(r){var n=this.items.get(r);return n&&n.isValid?n.value:null}},{key:"has",value:function(r){var n=this.items.get(r);return n&&n.isValid}},{key:"forEach",value:function(r){if(this.items){var n=ire(this.items),i;try{for(n.s();!(i=n.n()).done;){var a=BI.default(i.value,2),s=a[0],o=a[1];o.isValid&&r(s,o.value)}}catch(u){n.e(u)}finally{n.f()}}}}]),t}();function nA(t){var e=ure();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function ure(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var sw=function(t){In.default(r,t);var e=nA(r);function r(n,i,a){var s;hr.default(this,r),s=e.call(this,n,a);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new XI(o),s.cache=new aw,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"list"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"_addOrUpdateItemOnServer",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u,l){var c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return c={data:o},l!==void 0&&(c.ttl=l),m.next=4,this.services.network.post(s,c,u);case 4:return d=m.sent,d.body.data=o,d.body.date_updated=new Date(d.body.date_updated),m.abrupt("return",d.body);case 8:case"end":return m.stop()}},a,this)}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"push",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return u=(o||{}).ttl,f.next=3,this._addOrUpdateItemOnServer(this.links.items,s,void 0,u);case 3:return l=f.sent,c=Number(l.index),this._handleItemMutated(c,l.url,l.last_event_id,l.revision,s,l.date_updated,l.date_expires,!0,!1),f.abrupt("return",this.cache.get(c));case 7:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.squashAndAdd(s,c,function(m){return l._updateItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemUnconditionally",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return l=f.sent,f.next=5,this._addOrUpdateItemOnServer(l.uri,o,void 0,u);case 5:return c=f.sent,this._handleItemMutated(s,c.url,c.last_event_id,c.revision,c.data,c.date_updated,c.date_expires,!1,!1),f.abrupt("return",this.cache.get(s));case 8:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemWithIfMatch",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c,d,f;return fe.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.get(s);case 2:if(l=b.sent,c=o(Ni(l.data)),!c){b.next=25;break}return d=l.revision,b.prev=6,b.next=9,this._addOrUpdateItemOnServer(l.uri,c,d,u);case 9:return f=b.sent,this._handleItemMutated(s,f.url,f.last_event_id,f.revision,f.data,f.date_updated,f.date_expires,!1,!1),b.abrupt("return",this.cache.get(s));case 14:if(b.prev=14,b.t0=b.catch(6),b.t0.status!==412){b.next=22;break}return b.next=19,this._getItemFromServer(s);case 19:return b.abrupt("return",this._updateItemWithIfMatch(s,o,u));case 22:throw b.t0;case 23:b.next=26;break;case 25:return b.abrupt("return",l);case 26:case"end":return b.stop()}},a,this,[[6,14]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.add(s,c,function(m){return l._updateItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(s,function(d){return Object.assign(d,o)},u));case 1:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u=Ni(o.data),d.next=6,this.services.network.delete(o.uri);case 6:l=d.sent,this._handleItemRemoved(s,l.body.last_event_id,u,new Date(l.body.date_updated),!1);case 8:case"end":return d.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o=this.cache.get(s),!o){l.next=5;break}return l.abrupt("return",o);case 5:return l.abrupt("return",this._getItemFromServer(s));case 6:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.queryItems({index:s});case 2:if(o=l.sent,!(o.items.length<1)){l.next=7;break}throw new Hn("No item with index ".concat(s," found"),404,54151);case 7:return l.abrupt("return",o.items[0]);case 8:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new al(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Index",s.index).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),m.next=4,this.services.network.get(u);case 4:return l=m.sent,c=l.body.items.map(function(b){b.date_updated=new Date(b.date_updated);var A=o.cache.get(b.index);return A?o._handleItemMutated(b.index,b.url,b.last_event_id,b.revision,b.data,b.date_updated,b.date_expires,!1,!0):o.cache.store(Number(b.index),new nw({index:Number(b.index),uri:b.url,revision:b.revision,lastEventId:b.last_event_id,dateUpdated:b.date_updated,dateExpires:b.date_expires,data:b.data}),b.last_event_id),o.cache.get(b.index)}),d=l.body.meta,m.abrupt("return",new iw(c,function(b){return o.queryItems({pageToken:b})},d.previous_token,d.next_token));case 8:case"end":return m.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},ZI(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",u.abrupt("return",this.queryItems(s));case 5:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=tt.default(fe.default.mark(function a(){var s;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.context){u.next=5;break}return u.next=3,this.services.network.get(this.links.context);case 3:s=u.sent,this._updateContextIfRequired(s.body.data,s.body.last_event_id);case 5:return u.abrupt("return",this.context);case 6:case"end":return u.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return u=f.sent,l={ttl:o},f.next=6,this.services.network.post(u.uri,l);case 6:c=f.sent,u.updateDateExpires(c.body.date_expires);case 8:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){var s=Number(i.item_index);switch(i.date_created=new Date(i.date_created),i.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(s,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="list_item_added",!0);break;case"list_item_removed":this._handleItemRemoved(s,i.id,i.item_data,i.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(i.context_data,i.id,i.date_created);break;case"list_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.list_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,o,u,l,c,d,f){if(this.shouldIgnoreEvent(i,s)){gr.trace("Item ".concat(i," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(s));return}this._updateRootDateUpdated(l);var m=this.cache.get(i);if(!m){var b=new nw({index:i,uri:a,lastEventId:s,revision:o,data:u,dateUpdated:l,dateExpires:c});this.cache.store(i,b,s),this.emitItemMutationEvent(b,f,d);return}var A=Ni(m.data);m.update(s,o,u,l),this.cache.store(i,m,s),c!==void 0&&m.updateDateExpires(c),this.emitItemMutationEvent(m,f,!1,A)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",l={item:i,isLocal:!a};s||(l.previousItemData=o),this.broadcastEventToListeners(u,l)}},{key:"_handleItemRemoved",value:function(i,a,s,o,u){this._updateRootDateUpdated(o),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{index:i,isLocal:!u,previousItemData:s})}},{key:"_handleContextUpdate",value:function(i,a,s){this._updateRootDateUpdated(s),this._updateContextIfRequired(i,a)&&this.broadcastEventToListeners("contextUpdated",{context:i,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(i,a){return!this.contextEventId||a>this.contextEventId?(this.context=i,this.contextEventId=a,!0):(gr.trace("Context update skipped, current:",this.lastEventId,", remote:",a),!1)}}],[{key:"type",get:function(){return"list"}}]),r}(Rd),Xr=function(t){In.default(r,t);var e=nA(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncListImpl=n,i.syncListImpl.attach(ca.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncListImpl.uri}},{key:"revision",get:function(){return this.syncListImpl.revision}},{key:"lastEventId",get:function(){return this.syncListImpl.lastEventId}},{key:"links",get:function(){return this.syncListImpl.links}},{key:"dateExpires",get:function(){return this.syncListImpl.dateExpires}},{key:"type",get:function(){return sw.type}},{key:"sid",get:function(){return this.syncListImpl.sid}},{key:"uniqueName",get:function(){return this.syncListImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncListImpl.dateUpdated}},{key:"push",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.push(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.set(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.mutate(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.update(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.remove(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.get(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.getItems(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.setItemTtl(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Sd.default(Kr.default(r.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return sw.type}}]),r}(xd);Sr.default(Xr,"itemAdded","itemAdded"),Sr.default(Xr,"itemUpdated","itemUpdated"),Sr.default(Xr,"itemRemoved","itemRemoved"),Sr.default(Xr,"removed","removed"),vr([Ge.validateTypesAsync(Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object,Object]),Je("design:returntype",Promise)],Xr.prototype,"push",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Number,Object,Object]),Je("design:returntype",Promise)],Xr.prototype,"set",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,"function",["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Number,Function,Object]),Je("design:returntype",Promise)],Xr.prototype,"mutate",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Number,Object,Object]),Je("design:returntype",Promise)],Xr.prototype,"update",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Xr.prototype,"remove",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Xr.prototype,"get",null),vr([Ge.validateTypesAsync(["undefined",Ge.objectSchema("query options",{from:[Ge.nonNegativeInteger,"undefined"],pageSize:[Ge.custom(function(t){return[tw(t),"a positive integer"]}),"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],Xr.prototype,"getItems",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Xr.prototype,"setTtl",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number,Number]),Je("design:returntype",Promise)],Xr.prototype,"setItemTtl",null);var Id=function(){function t(e){hr.default(this,t),this.descriptor=e}return wr.default(t,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"key",get:function(){return this.descriptor.key}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"update",value:function(r,n,i,a){return this.descriptor.last_event_id=r,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.date_updated=a,this}},{key:"updateDateExpires",value:function(r){this.descriptor.date_expires=r}}]),t}();function iA(t){var e=lre();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function lre(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ow=function(t){In.default(r,t);var e=iA(r);function r(n,i,a){var s;hr.default(this,r),s=e.call(this,n,a);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new XI(o),s.cache=new aw,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),i.items&&i.items.forEach(function(u){u.date_updated=new Date(u.date_updated),s.cache.store(u.key,new Id(u),u.last_event_id)}),s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"map"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.squashAndAdd(s,c,function(m){return l._putItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(s!=null){u.next=2;break}throw new Hn("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(s)){u.next=6;break}return u.abrupt("return",this.cache.get(s));case 6:return u.abrupt("return",this._getItemFromServer(s));case 7:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.queryItems({key:s});case 2:if(o=l.sent,!(o.items.length<1)){l.next=7;break}throw new Hn("The specified Map Item does not exist",404,54201);case 7:return l.abrupt("return",o.items[0]);case 8:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.add(s,c,function(m){return l._putItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(s,function(d){return Object.assign(d,o)},u));case 1:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemUnconditionally",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this._putItemToServer(s,o,void 0,u);case 2:return l=f.sent,c=l.item,this._handleItemMutated(c.key,c.url,c.last_event_id,c.revision,c.data,c.date_updated,c.date_expires,l.added,!1),f.abrupt("return",this.cache.get(c.key));case 6:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemWithIfMatch",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c,d,f,m;return fe.default.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,this.get(s).catch(function(N){if(N.status===404)return new Id({key:s,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw N});case 2:if(l=A.sent,c=o(Ni(l.data)),!c){A.next=26;break}return d=l.revision,A.prev=6,A.next=9,this._putItemToServer(s,c,d,u);case 9:return f=A.sent,m=f.item,this._handleItemMutated(m.key,m.url,m.last_event_id,m.revision,m.data,m.date_updated,m.date_expires,f.added,!1),A.abrupt("return",this.cache.get(m.key));case 15:if(A.prev=15,A.t0=A.catch(6),A.t0.status!==412){A.next=23;break}return A.next=20,this._getItemFromServer(s);case 20:return A.abrupt("return",this._putItemWithIfMatch(s,o,u));case 23:throw A.t0;case 24:A.next=27;break;case 26:return A.abrupt("return",l);case 27:case"end":return A.stop()}},a,this,[[6,15]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemToServer",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u,l){var c,d,f,m,b;return fe.default.wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return c=new al(this.links.items).pathSegment(s).build(),d={data:o},l!==void 0&&(d.ttl=l),N.prev=3,N.next=6,this.services.network.put(c,d,u);case 6:return f=N.sent,m=f.body,m.data=o,m.date_updated=new Date(m.date_updated),b=f.status.code===201,N.abrupt("return",{added:b,item:m});case 14:throw N.prev=14,N.t0=N.catch(3),N.t0.status===404&&this.onRemoved(!1),N.t0;case 18:case"end":return N.stop()}},a,this,[[3,14]])}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u=Ni(o.data),d.next=6,this.services.network.delete(o.uri);case 6:l=d.sent,this._handleItemRemoved(s,l.body.last_event_id,u,new Date(l.body.date_updated),!1);case 8:case"end":return d.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new al(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Key",s.key).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),m.next=4,this.services.network.get(u);case 4:return l=m.sent,c=l.body.items.map(function(b){b.date_updated=new Date(b.date_updated);var A=o.cache.get(b.key);return A?o._handleItemMutated(b.key,b.url,b.last_event_id,b.revision,b.data,b.date_updated,b.date_expires,!1,!0):o.cache.store(b.key,new Id(b),b.last_event_id),o.cache.get(b.key)}),d=l.body.meta,m.abrupt("return",new iw(c,function(b){return o.queryItems({pageToken:b})},d.previous_token,d.next_token));case 8:case"end":return m.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},ZI(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",u.abrupt("return",this.queryItems(s));case 5:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){switch(i.date_created=new Date(i.date_created),i.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(i.item_key,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="map_item_added",!0);break;case"map_item_removed":this._handleItemRemoved(i.item_key,i.id,i.item_data,i.date_created,!0);break;case"map_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.map_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,o,u,l,c,d,f){if(this.shouldIgnoreEvent(i,s)){gr.trace("SyncMapItem ",i," update skipped, current:",this.lastEventId,", remote:",s);return}this._updateRootDateUpdated(l);var m=this.cache.get(i);if(!m){var b=new Id({key:i,url:a,last_event_id:s,revision:o,data:u,date_updated:l,date_expires:c});this.cache.store(i,b,s),this.emitItemMutationEvent(b,f,d);return}var A=Ni(m.data);m.update(s,o,u,l),this.cache.store(i,m,s),c!==void 0&&m.updateDateExpires(c),this.emitItemMutationEvent(m,f,!1,A)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",l={item:i,isLocal:!a};s||(l.previousItemData=o),this.broadcastEventToListeners(u,l)}},{key:"_handleItemRemoved",value:function(i,a,s,o,u){this._updateRootDateUpdated(o),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{key:i,isLocal:!u,previousItemData:s})}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return u=f.sent,l={ttl:o},f.next=6,this.services.network.post(u.uri,l);case 6:c=f.sent,u.updateDateExpires(c.body.date_expires);case 8:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"map"}}]),r}(Rd),sn=function(t){In.default(r,t);var e=iA(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncMapImpl=n,i.syncMapImpl.attach(ca.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncMapImpl.uri}},{key:"links",get:function(){return this.syncMapImpl.links}},{key:"revision",get:function(){return this.syncMapImpl.revision}},{key:"lastEventId",get:function(){return this.syncMapImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncMapImpl.dateExpires}},{key:"type",get:function(){return ow.type}},{key:"sid",get:function(){return this.syncMapImpl.sid}},{key:"uniqueName",get:function(){return this.syncMapImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncMapImpl.dateUpdated}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.set(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.get(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.mutate(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.update(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.remove(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.getItems(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.setItemTtl(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.next=3,this.syncMapImpl.removeMap();case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Sd.default(Kr.default(r.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return ow.type}}]),r}(xd);Sr.default(sn,"itemAdded","itemAdded"),Sr.default(sn,"itemUpdated","itemUpdated"),Sr.default(sn,"itemRemoved","itemRemoved"),Sr.default(sn,"removed","removed"),vr([Ge.validateTypesAsync("string",Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[String,Object,Object]),Je("design:returntype",Promise)],sn.prototype,"set",null),vr([Ge.validateTypesAsync("string"),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],sn.prototype,"get",null),vr([Ge.validateTypesAsync("string","function",["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[String,Function,Object]),Je("design:returntype",Promise)],sn.prototype,"mutate",null),vr([Ge.validateTypesAsync("string",Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[String,Object,Object]),Je("design:returntype",Promise)],sn.prototype,"update",null),vr([Ge.validateTypesAsync("string"),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],sn.prototype,"remove",null),vr([Ge.validateTypesAsync(["undefined",Ge.objectSchema("query options",{from:["string","undefined"],pageSize:[Ge.custom(function(t){return[tw(t),"a positive integer"]}),"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],sn.prototype,"getItems",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],sn.prototype,"setTtl",null),vr([Ge.validateTypesAsync("string",Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[String,Number]),Je("design:returntype",Promise)],sn.prototype,"setItemTtl",null);function aA(t){var e=cre();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function cre(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ad=function(t){In.default(r,t);var e=aA(r);function r(n,i,a){var s;return hr.default(this,r),s=e.call(this,n,a),s.descriptor=i,s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"stream"}},{key:"lastEventId",get:function(){return null}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"publishMessage",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return o={data:s},f.next=3,this.services.network.post(this.links.messages,o);case 3:return u=f.sent,l=u.body,c=this._handleMessagePublished(l.sid,s,!1),f.abrupt("return",c);case 7:case"end":return f.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"_update",value:function(i){switch(i.type){case"stream_message_published":{this._handleMessagePublished(i.message_sid,i.message_data,!0);break}case"stream_removed":{this.onRemoved(!1);break}}}},{key:"_handleMessagePublished",value:function(i,a,s){var o={sid:i,data:a};return this.broadcastEventToListeners("messagePublished",{message:o,isLocal:!s}),o}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}}],[{key:"type",get:function(){return"stream"}}]),r}(Rd);vr([Ge.validateTypesAsync(Ge.pureObject),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],Ad.prototype,"publishMessage",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Ad.prototype,"setTtl",null);var da=function(t){In.default(r,t);var e=aA(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncStreamImpl=n,i.syncStreamImpl.attach(ca.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncStreamImpl.uri}},{key:"links",get:function(){return this.syncStreamImpl.links}},{key:"dateExpires",get:function(){return this.syncStreamImpl.dateExpires}},{key:"type",get:function(){return Ad.type}},{key:"lastEventId",get:function(){return null}},{key:"sid",get:function(){return this.syncStreamImpl.sid}},{key:"uniqueName",get:function(){return this.syncStreamImpl.uniqueName}},{key:"publishMessage",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncStreamImpl.publishMessage(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncStreamImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Sd.default(Kr.default(r.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Ad.type}}]),r}(xd);Sr.default(da,"messagePublished","messagePublished"),Sr.default(da,"removed","removed"),vr([Ge.validateTypesAsync(Ge.pureObject),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],da.prototype,"publishMessage",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],da.prototype,"setTtl",null);var dre=function t(e){hr.default(this,t),this.sdk="js",this.sdkVer=e,this.os=Np.os.family,this.osVer=Np.os.version,this.pl=Np.name,this.plVer=Np.version},fre=function(){function t(){hr.default(this,t),this.names=new Map,this.entities=new Map}return wr.default(t,[{key:"store",value:function(r){var n=this.entities.get(r.sid);return n||(this.entities.set(r.sid,r),r.uniqueName&&this.names.set(r.type+"::"+r.uniqueName,r.sid),r)}},{key:"getResolved",value:function(r,n){var i=this.names.get(n+"::"+r);return i?this.entities.get(i):null}},{key:"get",value:function(r,n){return this.entities.get(r)||this.getResolved(r,n)||null}},{key:"remove",value:function(r){var n=this.entities.get(r);n&&(this.entities.delete(r),n.uniqueName&&this.names.delete(n.type+"::"+n.uniqueName))}}]),t}();function uw(t){var e=hre();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function hre(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var pre=function t(){hr.default(this,t)},lw=function(t){In.default(r,t);var e=uw(r);function r(n,i,a,s){var o;return hr.default(this,r),o=e.call(this,i,a),o.descriptor=n,o.cache=new aw,s&&s.forEach(function(u){o.cache.store(u.key,{key:u.key,value:u.data},u.revision)}),o}return wr.default(r,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return r.type}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"indexName",get:function(){return this.descriptor.indexName}},{key:"queryString",get:function(){return this.descriptor.queryExpression}},{key:"queryUri",get:function(){return this.descriptor.queryUri}},{key:"liveQueryDescriptor",get:function(){return this.descriptor}},{key:"onRemoved",value:function(){}},{key:"getItems",value:function(){var i={};return this.cache.forEach(function(a,s){i[a]=s.value}),i}},{key:"_update",value:function(i,a){switch(i.type){case"live_query_item_updated":this.handleItemMutated(i.item_key,i.item_data,i.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(i.item_key,i.item_revision);break;case"live_query_updated":this.handleBatchUpdate(i.items);break}a&&this._advanceLastEventId(i.last_event_id)}},{key:"handleItemMutated",value:function(i,a,s){if(this.shouldIgnoreEvent(i,s))gr.trace("Item ".concat(i," update skipped, revision: ").concat(s));else{var o={key:i,value:a};this.cache.store(i,o,s),this.broadcastEventToListeners("itemUpdated",o)}}},{key:"handleItemRemoved",value:function(i,a){var s=a===null;this.shouldIgnoreEvent(i,a)?gr.trace("Item ".concat(i," delete skipped, revision: ").concat(a)):(this.cache.delete(i,a,s),this.broadcastEventToListeners("itemRemoved",{key:i}))}},{key:"handleBatchUpdate",value:function(i){var a=this,s={};i!=null&&i.forEach(function(u){s[u.key]={data:u.data,revision:u.revision}}),this.cache.forEach(function(u,l){var c=s[u];c!=null?a.handleItemMutated(u,c.data,c.revision):a.handleItemRemoved(u,null),delete s[u]});for(var o in s)this.handleItemMutated(o,s[o].data,s[o].revision)}},{key:"shouldIgnoreEvent",value:function(i,a){return i!=null&&a!=null&&this.cache.isKnown(i,a)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i)}}],[{key:"type",get:function(){return"live_query"}}]),r}(Rd);function sA(t){return cw.apply(this,arguments)}function cw(){return cw=tt.default(fe.default.mark(function t(e){var r,n,i,a,s,o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(r=e.network,n=e.queryString,i=e.uri,a=e.type,n!=null){l.next=3;break}throw new Hn("Invalid query",400,54507);case 3:return s={query_string:n},a===qa.type&&(s.type=a),l.next=7,r.post(i,s,void 0,!0);case 7:return o=l.sent,l.abrupt("return",o.body);case 9:case"end":return l.stop()}},t)})),cw.apply(this,arguments)}var qa=function(t){In.default(r,t);var e=uw(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.liveQueryImpl=n,i.liveQueryImpl.attach(ca.default(i)),i}return wr.default(r,[{key:"type",get:function(){return lw.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){Sd.default(Kr.default(r.prototype),"close",this).call(this),this.liveQueryImpl.detach(this.listenerUuid)}},{key:"getItems",value:function(){return this.ensureNotClosed(),this.liveQueryImpl.getItems()}}],[{key:"type",get:function(){return lw.type}}]),r}(xd);Sr.default(qa,"itemUpdated","itemUpdated"),Sr.default(qa,"itemRemoved","itemRemoved");var Od=function(t){In.default(r,t);var e=uw(r);function r(n){var i;return hr.default(this,r),i=e.call(this),Sr.default(ca.default(i),"queryExpression",null),Sr.default(ca.default(i),"items",{}),Object.assign(ca.default(i),n),i.updateIndexName(n.indexName),i}return wr.default(r,[{key:"type",get:function(){return r.type}},{key:"search",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.items={},l.abrupt("return",sA({network:this.network,uri:this.queryUri,queryString:s}).then(function(c){o.queryExpression=s,c.items&&c.items.forEach(function(d){o.items[d.key]=d.data}),o.emit("searchResult",o.getItems())}).catch(function(c){throw gr.error("Error '".concat(c.message,"' while executing query '").concat(s,"'")),o.queryExpression=null,c}));case 2:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"subscribe",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.queryExpression!=null){o.next=2;break}return o.abrupt("return",Promise.reject(new Hn("Invalid query",400,54507)));case 2:return o.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(i){this.indexName=i,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(i){return new al(this.insightsUri).pathSegment(i).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),r}($r);Sr.default(Od,"searchResult","searchResult"),vr([Ge.validateTypesAsync("string"),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],Od.prototype,"search",null),vr([Ge.validateTypes(Ge.nonEmptyString),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",void 0)],Od.prototype,"updateIndexName",null);var vre="3.1.0";function mre(t){var e=gre();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Is.default(this,i)}}function gre(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function oA(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function uA(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?oA(Object(r),!0).forEach(function(n){Sr.default(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):oA(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}var yre="data_sync",dw=vre;function Lp(t){if(t){if(typeof t=="string")return{id:t,mode:"open_or_create"};var e=t.mode||(t.id?"open_or_create":"create_new");return uA(uA({},t),{},{mode:e})}else return{mode:"create_new"}}var lA="com.twilio.rtd.cds.document",cA="com.twilio.rtd.cds.list",dA="com.twilio.rtd.cds.map",fA="twilio.sync.event",ei=function(t){In.default(r,t);var e=mre(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(hr.default(this,r),i=e.call(this),!n)throw new Error("Sync library needs a valid Twilio token to be passed");a.hasOwnProperty("logLevel")?gr.setLevel(a.logLevel):gr.setLevel("silent");var s=a.productId=a.productId||yre;a.clientMetadata=a.clientMetadata||{},a.clientMetadata.hasOwnProperty("type")||(a.clientMetadata.type="sync"),a.clientMetadata.hasOwnProperty("sdk")||(a.clientMetadata.sdk="JS",a.clientMetadata.sdkv=dw);var o=!a.twilsockClient;if(!a.initRegistrations){var u=new Mp.InitRegistration(s);r.populateInitRegistrations(u),a.initRegistrations=[u]}var l=a.twilsockClient=a.twilsockClient||new Mp.Twilsock(n,s,a);l.on("tokenAboutToExpire",function(m){return i.emit("tokenAboutToExpire",m)}),l.on("tokenExpired",function(){return i.emit("tokenExpired")}),l.on("connectionError",function(m){return i.emit("connectionError",m)}),l.on("stateChanged",function(m){i.emit("connectionStateChanged",m),i.services.subscriptions.onConnectionStateChanged(m==="connected")}),l.on("message",function(m,b){return i._routeMessage(m,b)});var c=new Ute(a),d=new Zte(new dre(dw),c,l),f=new Gte(c);return i.services={config:c,twilsock:l,network:d,storage:f,router:ca.default(i),subscriptions:null},i.services.subscriptions=new zte(i.services),i.entities=new fre,o&&l.connect(),i}return wr.default(r,[{key:"_routeMessage",value:function(i,a){switch(gr.trace("Notification type:",i,"content:",a),i){case lA:case cA:case dA:this.services.subscriptions.acceptMessage(a,!1);break;case fA:this.services.subscriptions.acceptMessage(a,!0);break}}},{key:"_subscribe",value:function(i,a){this.services.subscriptions.add(i,a)}},{key:"_unsubscribe",value:function(i){this.services.subscriptions.remove(i)}},{key:"connectionState",get:function(){return this.services.twilsock.state}},{key:"ensureReady",value:function(){var n=tt.default(fe.default.mark(function a(){var s;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.services.config.sessionStorageEnabled){u.next=2;break}return u.abrupt("return");case 2:return u.prev=2,u.next=5,this.services.twilsock.storageId();case 5:s=u.sent,this.services.storage.updateStorageId(s.id),u.next=12;break;case 9:u.prev=9,u.t0=u.catch(2),gr.warn("Failed to initialize storage",u.t0);case 12:case"end":return u.stop()}},a,this,[[2,9]])}));function i(){return n.apply(this,arguments)}return i}()},{key:"storeRootInSessionCache",value:function(i,a,s){if(!(!this.services.config.sessionStorageEnabled||!a)){var o=Ni(s);(i===Xr.type||i===sn.type)&&(o.last_event_id=null,delete o.items),this.services.storage.store(i,a,o)}}},{key:"readRootFromSessionCache",value:function(i,a){return!this.services.config.sessionStorageEnabled||!a?null:this.services.storage.read(i,a)}},{key:"_get",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c,d=arguments;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(u=d.length>2&&d[2]!==void 0?d[2]:!1,o){m.next=3;break}throw new Hn("Cannot get entity without id",404);case 3:return l=new al(s).pathSegment(o).queryParam("Include",u?"items":void 0).build(),m.next=6,this.services.network.get(l);case 6:return c=m.sent,m.abrupt("return",c.body);case 8:case"end":return m.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_createDocument",value:function(i,a,s){var o={unique_name:i,data:a||{}};return s!==void 0&&(o.ttl=s),this.services.network.post(this.services.config.documentsUri,o).then(function(u){return u.body.data=o.data,u.body})}},{key:"_getDocument",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(ci.type,s)||this._get(this.services.config.documentsUri,s));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createList",value:function(i,a,s,o){var u={unique_name:i,purpose:a,context:s};return o!==void 0&&(u.ttl=o),this.services.network.post(this.services.config.listsUri,u).then(function(l){return l.body})}},{key:"_getList",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(Xr.type,s)||this._get(this.services.config.listsUri,s));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createMap",value:function(i,a){var s={unique_name:i};return a!==void 0&&(s.ttl=a),this.services.network.post(this.services.config.mapsUri,s).then(function(o){return o.body})}},{key:"_getMap",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u=arguments;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return o=u.length>1&&u[1]!==void 0?u[1]:!1,c.abrupt("return",this.readRootFromSessionCache(sn.type,s)||this._get(this.services.config.mapsUri,s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getStream",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(da.type,s)||this._get(this.services.config.streamsUri,s,!1));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createStream",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return u={unique_name:s},o!==void 0&&(u.ttl=o),d.next=4,this.services.network.post(this.services.config.streamsUri,u);case 4:return l=d.sent,d.abrupt("return",l.body);case 6:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_getLiveQuery",value:function(i){return this.readRootFromSessionCache(qa.type,i)}},{key:"getCached",value:function(i,a){return i&&this.entities.get(i,a)||null}},{key:"removeFromCacheAndSession",value:function(i,a,s){this.entities.remove(a),this.services.config.sessionStorageEnabled&&this.services.storage.remove(i,a,s)}},{key:"document",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=Lp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createDocument(u.id,u.data,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,ci.type),!c){m.next=14;break}return m.abrupt("return",new ci(c));case 14:return m.prev=14,m.next=17,this._getDocument(u.id);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createDocument(u.id,u.data,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.document(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(ci.type,u.id,l),d=new rw(this.services,l,function(b,A,N){return o.removeFromCacheAndSession(b,A,N)}),d=this.entities.store(d),m.abrupt("return",new ci(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"map",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=Lp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createMap(u.id,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,sn.type),!c){m.next=14;break}return m.abrupt("return",new sn(c));case 14:return m.prev=14,m.next=17,this._getMap(u.id,u.includeItems);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createMap(u.id,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.map(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(sn.type,u.id,l),d=new ow(this.services,l,function(b,A,N){return o.removeFromCacheAndSession(b,A,N)}),d=this.entities.store(d),m.abrupt("return",new sn(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"list",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=Lp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createList(u.id,u.purpose,u.context,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,Xr.type),!c){m.next=14;break}return m.abrupt("return",new Xr(c));case 14:return m.prev=14,m.next=17,this._getList(u.id);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createList(u.id,u.purpose,u.context,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.list(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(Xr.type,u.id,l),d=new sw(this.services,l,function(b,A,N){return o.removeFromCacheAndSession(b,A,N)}),d=this.entities.store(d),m.abrupt("return",new Xr(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"stream",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d,f;return fe.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.ensureReady();case 2:if(u=Lp(s),u.mode!=="create_new"){b.next=9;break}return b.next=6,this._createStream(u.id,u.ttl);case 6:l=b.sent,b.next=39;break;case 9:if(c=this.getCached(u.id,da.type),!c){b.next=14;break}return b.abrupt("return",new da(c));case 14:return b.prev=14,b.next=17,this._getStream(u.id);case 17:l=b.sent,b.next=39;break;case 20:if(b.prev=20,b.t0=b.catch(14),!(b.t0.status!==404||u.mode==="open_existing")){b.next=26;break}throw b.t0;case 26:return b.prev=26,b.next=29,this._createStream(u.id,u.ttl);case 29:l=b.sent,b.next=39;break;case 32:if(b.prev=32,b.t1=b.catch(26),b.t1.status!==409){b.next=38;break}return b.abrupt("return",this.stream(s));case 38:throw b.t1;case 39:return this.storeRootInSessionCache(da.type,u.id,l),d=function(N,z,X){return o.removeFromCacheAndSession(N,z,X)},f=new Ad(this.services,l,d),f=this.entities.store(f),b.abrupt("return",new da(f));case 44:case"end":return b.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shutdown",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.subscriptions.shutdown();case 2:return o.next=4,this.services.twilsock.disconnect();case 4:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"updateToken",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.twilsock.updateToken(s).catch(function(l){var c,d=l==null||(c=l.reply)===null||c===void 0?void 0:c.status;throw(d==null?void 0:d.code)===401&&(d==null?void 0:d.status)==="UNAUTHORIZED"?new Hn("Updated token was rejected by server",400,51130):l}));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"liveQuery",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u=this,l,c,d,f,m;return fe.default.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,this.ensureReady();case 2:return l=new al(this.services.config.insightsUri).pathSegment(s).pathSegment("Items").build(),A.next=5,sA({network:this.services.network,uri:l,queryString:o,type:qa.type});case 5:return c=A.sent,d=this.getCached(c.query_id,qa.type),d||(f=this._getLiveQuery(c.query_id),f||(f={indexName:s,queryExpression:o,sid:c.query_id,queryUri:l,last_event_id:c.last_event_id}),m=function(z,X,Ee){return u.removeFromCacheAndSession(z,X,Ee)},d=new lw(f,this.services,m,c.items)),this.storeRootInSessionCache(qa.type,c.query_id,d.liveQueryDescriptor),d=this.entities.store(d),A.abrupt("return",new qa(d));case 11:case"end":return A.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"instantQuery",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.ensureReady();case 2:return u=function(f,m){return o.liveQuery(f,m)},c.abrupt("return",new Od({indexName:s,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:u}));case 4:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()}],[{key:"populateInitRegistrations",value:function(i){i.populateInitRegistrations([fA,lA,cA,dA])}},{key:"version",get:function(){return dw}}]),r}($r);Sr.default(ei,"connectionStateChanged","connectionStateChanged"),Sr.default(ei,"connectionError","connectionError"),Sr.default(ei,"tokenAboutToExpire","tokenAboutToExpire"),Sr.default(ei,"tokenExpired","tokenExpired"),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open document options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"document",null),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open map options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)],includeItems:["boolean","undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"map",null),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open list options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)],purpose:["string","undefined"],context:[Ge.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"list",null),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open stream options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"stream",null),vr([Ge.validateTypesAsync(Ge.nonEmptyString),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],ei.prototype,"updateToken",null),vr([Ge.validateTypesAsync(Ge.nonEmptyString,"string"),Je("design:type",Function),Je("design:paramtypes",[String,String]),Je("design:returntype",Promise)],ei.prototype,"liveQuery",null),vr([Ge.validateTypesAsync(Ge.nonEmptyString),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],ei.prototype,"instantQuery",null),zn.Client=ei,zn.InsightsItem=pre,zn.InstantQuery=Od,zn.LiveQuery=qa,zn.Paginator=iw,zn.SyncClient=ei,zn.SyncDocument=ci,zn.SyncList=Xr,zn.SyncListItem=nw,zn.SyncMap=sn,zn.SyncMapItem=Id,zn.SyncStream=da;var hA={},bre=Lr,wre=Qi,_re=Rr,kre=_re("match"),Sre=function(t){var e;return bre(t)&&((e=t[kre])!==void 0?!!e:wre(t)==="RegExp")},$re=Sre,Tre=TypeError,pA=function(t){if($re(t))throw new Tre("The method doesn't accept regular expressions");return t},Ere=Rr,Cre=Ere("match"),vA=function(t){var e=/./;try{"/./"[t](e)}catch{try{return e[Cre]=!1,"/./"[t](e)}catch{}}return!1},Rre=er,xre=pg,Ire=Ta.f,Are=Ra,mA=nn,Ore=pA,Pre=Ii,Mre=vA,Nre=xre("".slice),Lre=Math.min,gA=Mre("startsWith"),Dre=!gA&&!!function(){var t=Ire(String.prototype,"startsWith");return t&&!t.writable}();Rre({target:"String",proto:!0,forced:!Dre&&!gA},{startsWith:function(e){var r=mA(Pre(this));Ore(e);var n=Are(Lre(arguments.length>1?arguments[1]:void 0,r.length)),i=mA(e);return Nre(r,n,n+i.length)===i}});var jre=Vt,Ure=Rr,Fre=Ar,yA=Sk,Bre=Ure("iterator"),bA=!jre(function(){var t=new URL("b?a=1&b=2&c=3","http://a"),e=t.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return t.pathname="c%20d",e.forEach(function(i,a){e.delete("b"),n+=a+i}),r.delete("a",2),r.delete("b",void 0),yA&&(!t.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b"))||!e.size&&(yA||!Fre)||!e.sort||t.href!=="http://a/c%20d?a=1&c=3"||e.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!e[Bre]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://тест").host!=="xn--e1aybc"||new URL("http://a#б").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),jo=Kt,fw=2147483647,Pd=36,wA=1,hw=26,zre=38,Hre=700,qre=72,Vre=128,Wre="-",Zre=/[^\0-\u007E]/,_A=/[.\u3002\uFF0E\uFF61]/g,kA="Overflow: input needs wider integers to process",pw=Pd-wA,SA=RangeError,Gre=jo(_A.exec),ol=Math.floor,vw=String.fromCharCode,$A=jo("".charCodeAt),TA=jo([].join),Os=jo([].push),Kre=jo("".replace),Jre=jo("".split),Yre=jo("".toLowerCase),Qre=function(t){for(var e=[],r=0,n=t.length;r<n;){var i=$A(t,r++);if(i>=55296&&i<=56319&&r<n){var a=$A(t,r++);(a&64512)===56320?Os(e,((i&1023)<<10)+(a&1023)+65536):(Os(e,i),r--)}else Os(e,i)}return e},EA=function(t){return t+22+75*(t<26)},Xre=function(t,e,r){var n=0;for(t=r?ol(t/Hre):t>>1,t+=ol(t/e);t>pw*hw>>1;)t=ol(t/pw),n+=Pd;return ol(n+(pw+1)*t/(t+zre))},ene=function(t){var e=[];t=Qre(t);var r=t.length,n=Vre,i=0,a=qre,s,o;for(s=0;s<t.length;s++)o=t[s],o<128&&Os(e,vw(o));var u=e.length,l=u;for(u&&Os(e,Wre);l<r;){var c=fw;for(s=0;s<t.length;s++)o=t[s],o>=n&&o<c&&(c=o);var d=l+1;if(c-n>ol((fw-i)/d))throw new SA(kA);for(i+=(c-n)*d,n=c,s=0;s<t.length;s++){if(o=t[s],o<n&&++i>fw)throw new SA(kA);if(o===n){for(var f=i,m=Pd;;){var b=m<=a?wA:m>=a+hw?hw:m-a;if(f<b)break;var A=f-b,N=Pd-b;Os(e,vw(EA(b+A%N))),f=ol(A/N),m+=Pd}Os(e,vw(EA(f))),a=Xre(i,d,l===u),i=0,l++}}i++,n++}return TA(e,"")},tne=function(t){var e=[],r=Jre(Kre(Yre(t),_A,"."),"."),n,i;for(n=0;n<r.length;n++)i=r[n],Os(e,Gre(Zre,i)?"xn--"+ene(i):i);return TA(e,".")},mw=er,Dp=cr,gw=W$,jp=Er,fa=Kt,Md=Ar,CA=bA,RA=Rn,rne=na,nne=op,ine=ta,ane=sE,yw=Jn,xA=ws,bw=Cr,sne=Vr,one=Ia,une=xa,lne=Gr,IA=Lr,An=nn,cne=vs,AA=bo,OA=Nh,dne=rd,Up=Fh,ul=Mg,fne=Rr,hne=Fb,pne=fne("iterator"),ll="URLSearchParams",PA=ll+"Iterator",MA=yw.set,di=yw.getterFor(ll),vne=yw.getterFor(PA),NA=gw("fetch"),Fp=gw("Request"),Nd=gw("Headers"),ww=Fp&&Fp.prototype,LA=Nd&&Nd.prototype,mne=Dp.RegExp,gne=Dp.TypeError,DA=Dp.decodeURIComponent,yne=Dp.encodeURIComponent,bne=fa("".charAt),jA=fa([].join),Uo=fa([].push),_w=fa("".replace),wne=fa([].shift),UA=fa([].splice),FA=fa("".split),_ne=fa("".slice),kne=/\+/g,BA=Array(4),Sne=function(t){return BA[t-1]||(BA[t-1]=mne("((?:%[\\da-f]{2}){"+t+"})","gi"))},$ne=function(t){try{return DA(t)}catch{return t}},zA=function(t){var e=_w(t,kne," "),r=4;try{return DA(e)}catch{for(;r;)e=_w(e,Sne(r--),$ne);return e}},Tne=/[!'()~]|%20/g,Ene={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Cne=function(t){return Ene[t]},HA=function(t){return _w(yne(t),Tne,Cne)},kw=ane(function(e,r){MA(this,{type:PA,target:di(e).entries,index:0,kind:r})},ll,function(){var e=vne(this),r=e.target,n=e.index++;if(!r||n>=r.length)return e.target=void 0,Up(void 0,!0);var i=r[n];switch(e.kind){case"keys":return Up(i.key,!1);case"values":return Up(i.value,!1)}return Up([i.key,i.value],!1)},!0),qA=function(t){this.entries=[],this.url=null,t!==void 0&&(IA(t)?this.parseObject(t):this.parseQuery(typeof t=="string"?bne(t,0)==="?"?_ne(t,1):t:An(t)))};qA.prototype={type:ll,bindURL:function(t){this.url=t,this.update()},parseObject:function(t){var e=this.entries,r=dne(t),n,i,a,s,o,u,l;if(r)for(n=OA(t,r),i=n.next;!(a=jp(i,n)).done;){if(s=OA(lne(a.value)),o=s.next,(u=jp(o,s)).done||(l=jp(o,s)).done||!jp(o,s).done)throw new gne("Expected sequence with length 2");Uo(e,{key:An(u.value),value:An(l.value)})}else for(var c in t)sne(t,c)&&Uo(e,{key:c,value:An(t[c])})},parseQuery:function(t){if(t)for(var e=this.entries,r=FA(t,"&"),n=0,i,a;n<r.length;)i=r[n++],i.length&&(a=FA(i,"="),Uo(e,{key:zA(wne(a)),value:zA(jA(a,"="))}))},serialize:function(){for(var t=this.entries,e=[],r=0,n;r<t.length;)n=t[r++],Uo(e,HA(n.key)+"="+HA(n.value));return jA(e,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Bp=function(){xA(this,cl);var e=arguments.length>0?arguments[0]:void 0,r=MA(this,new qA(e));Md||(this.size=r.entries.length)},cl=Bp.prototype;if(nne(cl,{append:function(e,r){var n=di(this);ul(arguments.length,2),Uo(n.entries,{key:An(e),value:An(r)}),Md||this.length++,n.updateURL()},delete:function(t){for(var e=di(this),r=ul(arguments.length,1),n=e.entries,i=An(t),a=r<2?void 0:arguments[1],s=a===void 0?a:An(a),o=0;o<n.length;){var u=n[o];if(u.key===i&&(s===void 0||u.value===s)){if(UA(n,o,1),s!==void 0)break}else o++}Md||(this.size=n.length),e.updateURL()},get:function(e){var r=di(this).entries;ul(arguments.length,1);for(var n=An(e),i=0;i<r.length;i++)if(r[i].key===n)return r[i].value;return null},getAll:function(e){var r=di(this).entries;ul(arguments.length,1);for(var n=An(e),i=[],a=0;a<r.length;a++)r[a].key===n&&Uo(i,r[a].value);return i},has:function(e){for(var r=di(this).entries,n=ul(arguments.length,1),i=An(e),a=n<2?void 0:arguments[1],s=a===void 0?a:An(a),o=0;o<r.length;){var u=r[o++];if(u.key===i&&(s===void 0||u.value===s))return!0}return!1},set:function(e,r){var n=di(this);ul(arguments.length,1);for(var i=n.entries,a=!1,s=An(e),o=An(r),u=0,l;u<i.length;u++)l=i[u],l.key===s&&(a?UA(i,u--,1):(a=!0,l.value=o));a||Uo(i,{key:s,value:o}),Md||(this.size=i.length),n.updateURL()},sort:function(){var e=di(this);hne(e.entries,function(r,n){return r.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var r=di(this).entries,n=one(e,arguments.length>1?arguments[1]:void 0),i=0,a;i<r.length;)a=r[i++],n(a.value,a.key,this)},keys:function(){return new kw(this,"keys")},values:function(){return new kw(this,"values")},entries:function(){return new kw(this,"entries")}},{enumerable:!0}),RA(cl,pne,cl.entries,{name:"entries"}),RA(cl,"toString",function(){return di(this).serialize()},{enumerable:!0}),Md&&rne(cl,"size",{get:function(){return di(this).entries.length},configurable:!0,enumerable:!0}),ine(Bp,ll),mw({global:!0,constructor:!0,forced:!CA},{URLSearchParams:Bp}),!CA&&bw(Nd)){var Rne=fa(LA.has),xne=fa(LA.set),VA=function(t){if(IA(t)){var e=t.body,r;if(une(e)===ll)return r=t.headers?new Nd(t.headers):new Nd,Rne(r,"content-type")||xne(r,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),cne(t,{body:AA(0,An(e)),headers:AA(0,r)})}return t};if(bw(NA)&&mw({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return NA(e,arguments.length>1?VA(arguments[1]):{})}}),bw(Fp)){var Sw=function(e){return xA(this,ww),new Fp(e,arguments.length>1?VA(arguments[1]):{})};ww.constructor=Sw,Sw.prototype=ww,mw({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Sw})}}var Ine={URLSearchParams:Bp,getState:di},Ane=er,$w=Ar,One=bA,Tw=cr,WA=Ia,fi=Kt,zp=Rn,hi=na,Pne=ws,Ew=Vr,Cw=RI,dl=XT,Li=ra,Mne=uy.codeAt,Nne=tne,Va=nn,Lne=ta,Dne=Mg,ZA=Ine,GA=Jn,jne=GA.set,Hp=GA.getterFor("URL"),Une=ZA.URLSearchParams,Fne=ZA.getState,Ld=Tw.URL,Rw=Tw.TypeError,qp=Tw.parseInt,Bne=Math.floor,KA=Math.pow,pi=fi("".charAt),Di=fi(/./.exec),Dd=fi([].join),zne=fi(1 .toString),Hne=fi([].pop),fl=fi([].push),xw=fi("".replace),qne=fi([].shift),Vne=fi("".split),jd=fi("".slice),Vp=fi("".toLowerCase),Wne=fi([].unshift),Zne="Invalid authority",Iw="Invalid scheme",Fo="Invalid host",JA="Invalid port",YA=/[a-z]/i,Gne=/[\d+-.a-z]/i,Aw=/\d/,Kne=/^0x/i,Jne=/^[0-7]+$/,Yne=/^\d+$/,QA=/^[\da-f]+$/i,Qne=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Xne=/[\0\t\n\r #/:<>?@[\\\]^|]/,eie=/^[\u0000-\u0020]+/,tie=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,rie=/[\t\n\r]/g,vi,nie=function(t){var e=Vne(t,"."),r,n,i,a,s,o,u;if(e.length&&e[e.length-1]===""&&e.length--,r=e.length,r>4)return t;for(n=[],i=0;i<r;i++){if(a=e[i],a==="")return t;if(s=10,a.length>1&&pi(a,0)==="0"&&(s=Di(Kne,a)?16:8,a=jd(a,s===8?1:2)),a==="")o=0;else{if(!Di(s===10?Yne:s===8?Jne:QA,a))return t;o=qp(a,s)}fl(n,o)}for(i=0;i<r;i++)if(o=n[i],i===r-1){if(o>=KA(256,5-r))return null}else if(o>255)return null;for(u=Hne(n),i=0;i<n.length;i++)u+=n[i]*KA(256,3-i);return u},iie=function(t){var e=[0,0,0,0,0,0,0,0],r=0,n=null,i=0,a,s,o,u,l,c,d,f=function(){return pi(t,i)};if(f()===":"){if(pi(t,1)!==":")return;i+=2,r++,n=r}for(;f();){if(r===8)return;if(f()===":"){if(n!==null)return;i++,r++,n=r;continue}for(a=s=0;s<4&&Di(QA,f());)a=a*16+qp(f(),16),i++,s++;if(f()==="."){if(s===0||(i-=s,r>6))return;for(o=0;f();){if(u=null,o>0)if(f()==="."&&o<4)i++;else return;if(!Di(Aw,f()))return;for(;Di(Aw,f());){if(l=qp(f(),10),u===null)u=l;else{if(u===0)return;u=u*10+l}if(u>255)return;i++}e[r]=e[r]*256+u,o++,(o===2||o===4)&&r++}if(o!==4)return;break}else if(f()===":"){if(i++,!f())return}else if(f())return;e[r++]=a}if(n!==null)for(c=r-n,r=7;r!==0&&c>0;)d=e[r],e[r--]=e[n+c-1],e[n+--c]=d;else if(r!==8)return;return e},aie=function(t){for(var e=null,r=1,n=null,i=0,a=0;a<8;a++)t[a]!==0?(i>r&&(e=n,r=i),n=null,i=0):(n===null&&(n=a),++i);return i>r&&(e=n,r=i),e},Ud=function(t){var e,r,n,i;if(typeof t=="number"){for(e=[],r=0;r<4;r++)Wne(e,t%256),t=Bne(t/256);return Dd(e,".")}else if(typeof t=="object"){for(e="",n=aie(t),r=0;r<8;r++)i&&t[r]===0||(i&&(i=!1),n===r?(e+=r?":":"::",i=!0):(e+=zne(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},Wp={},XA=Cw({},Wp,{" ":1,'"':1,"<":1,">":1,"`":1}),e2=Cw({},XA,{"#":1,"?":1,"{":1,"}":1}),Ow=Cw({},e2,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Ps=function(t,e){var r=Mne(t,0);return r>32&&r<127&&!Ew(e,t)?t:encodeURIComponent(t)},Zp={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Fd=function(t,e){var r;return t.length===2&&Di(YA,pi(t,0))&&((r=pi(t,1))===":"||!e&&r==="|")},t2=function(t){var e;return t.length>1&&Fd(jd(t,0,2))&&(t.length===2||(e=pi(t,2))==="/"||e==="\\"||e==="?"||e==="#")},sie=function(t){return t==="."||Vp(t)==="%2e"},oie=function(t){return t=Vp(t),t===".."||t==="%2e."||t===".%2e"||t==="%2e%2e"},Pw={},r2={},Mw={},n2={},i2={},Nw={},a2={},s2={},Gp={},Kp={},Lw={},Dw={},jw={},Uw={},o2={},Fw={},hl={},ha={},u2={},Bo={},Wa={},Bw=function(t,e,r){var n=Va(t),i,a,s;if(e){if(a=this.parse(n),a)throw new Rw(a);this.searchParams=null}else{if(r!==void 0&&(i=new Bw(r,!0)),a=this.parse(n,null,i),a)throw new Rw(a);s=Fne(new Une),s.bindURL(this),this.searchParams=s}};Bw.prototype={type:"URL",parse:function(t,e,r){var n=this,i=e||Pw,a=0,s="",o=!1,u=!1,l=!1,c,d,f,m;for(t=Va(t),e||(n.scheme="",n.username="",n.password="",n.host=null,n.port=null,n.path=[],n.query=null,n.fragment=null,n.cannotBeABaseURL=!1,t=xw(t,eie,""),t=xw(t,tie,"$1")),t=xw(t,rie,""),c=dl(t);a<=c.length;){switch(d=c[a],i){case Pw:if(d&&Di(YA,d))s+=Vp(d),i=r2;else{if(e)return Iw;i=Mw;continue}break;case r2:if(d&&(Di(Gne,d)||d==="+"||d==="-"||d==="."))s+=Vp(d);else if(d===":"){if(e&&(n.isSpecial()!==Ew(Zp,s)||s==="file"&&(n.includesCredentials()||n.port!==null)||n.scheme==="file"&&!n.host))return;if(n.scheme=s,e){n.isSpecial()&&Zp[n.scheme]===n.port&&(n.port=null);return}s="",n.scheme==="file"?i=Uw:n.isSpecial()&&r&&r.scheme===n.scheme?i=n2:n.isSpecial()?i=s2:c[a+1]==="/"?(i=i2,a++):(n.cannotBeABaseURL=!0,fl(n.path,""),i=u2)}else{if(e)return Iw;s="",i=Mw,a=0;continue}break;case Mw:if(!r||r.cannotBeABaseURL&&d!=="#")return Iw;if(r.cannotBeABaseURL&&d==="#"){n.scheme=r.scheme,n.path=Li(r.path),n.query=r.query,n.fragment="",n.cannotBeABaseURL=!0,i=Wa;break}i=r.scheme==="file"?Uw:Nw;continue;case n2:if(d==="/"&&c[a+1]==="/")i=Gp,a++;else{i=Nw;continue}break;case i2:if(d==="/"){i=Kp;break}else{i=ha;continue}case Nw:if(n.scheme=r.scheme,d===vi)n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.query=r.query;else if(d==="/"||d==="\\"&&n.isSpecial())i=a2;else if(d==="?")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.query="",i=Bo;else if(d==="#")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.query=r.query,n.fragment="",i=Wa;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.path.length--,i=ha;continue}break;case a2:if(n.isSpecial()&&(d==="/"||d==="\\"))i=Gp;else if(d==="/")i=Kp;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,i=ha;continue}break;case s2:if(i=Gp,d!=="/"||pi(s,a+1)!=="/")continue;a++;break;case Gp:if(d!=="/"&&d!=="\\"){i=Kp;continue}break;case Kp:if(d==="@"){o&&(s="%40"+s),o=!0,f=dl(s);for(var b=0;b<f.length;b++){var A=f[b];if(A===":"&&!l){l=!0;continue}var N=Ps(A,Ow);l?n.password+=N:n.username+=N}s=""}else if(d===vi||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(o&&s==="")return Zne;a-=dl(s).length+1,s="",i=Lw}else s+=d;break;case Lw:case Dw:if(e&&n.scheme==="file"){i=Fw;continue}else if(d===":"&&!u){if(s==="")return Fo;if(m=n.parseHost(s),m)return m;if(s="",i=jw,e===Dw)return}else if(d===vi||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(n.isSpecial()&&s==="")return Fo;if(e&&s===""&&(n.includesCredentials()||n.port!==null))return;if(m=n.parseHost(s),m)return m;if(s="",i=hl,e)return;continue}else d==="["?u=!0:d==="]"&&(u=!1),s+=d;break;case jw:if(Di(Aw,d))s+=d;else if(d===vi||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()||e){if(s!==""){var z=qp(s,10);if(z>65535)return JA;n.port=n.isSpecial()&&z===Zp[n.scheme]?null:z,s=""}if(e)return;i=hl;continue}else return JA;break;case Uw:if(n.scheme="file",d==="/"||d==="\\")i=o2;else if(r&&r.scheme==="file")switch(d){case vi:n.host=r.host,n.path=Li(r.path),n.query=r.query;break;case"?":n.host=r.host,n.path=Li(r.path),n.query="",i=Bo;break;case"#":n.host=r.host,n.path=Li(r.path),n.query=r.query,n.fragment="",i=Wa;break;default:t2(Dd(Li(c,a),""))||(n.host=r.host,n.path=Li(r.path),n.shortenPath()),i=ha;continue}else{i=ha;continue}break;case o2:if(d==="/"||d==="\\"){i=Fw;break}r&&r.scheme==="file"&&!t2(Dd(Li(c,a),""))&&(Fd(r.path[0],!0)?fl(n.path,r.path[0]):n.host=r.host),i=ha;continue;case Fw:if(d===vi||d==="/"||d==="\\"||d==="?"||d==="#"){if(!e&&Fd(s))i=ha;else if(s===""){if(n.host="",e)return;i=hl}else{if(m=n.parseHost(s),m)return m;if(n.host==="localhost"&&(n.host=""),e)return;s="",i=hl}continue}else s+=d;break;case hl:if(n.isSpecial()){if(i=ha,d!=="/"&&d!=="\\")continue}else if(!e&&d==="?")n.query="",i=Bo;else if(!e&&d==="#")n.fragment="",i=Wa;else if(d!==vi&&(i=ha,d!=="/"))continue;break;case ha:if(d===vi||d==="/"||d==="\\"&&n.isSpecial()||!e&&(d==="?"||d==="#")){if(oie(s)?(n.shortenPath(),d!=="/"&&!(d==="\\"&&n.isSpecial())&&fl(n.path,"")):sie(s)?d!=="/"&&!(d==="\\"&&n.isSpecial())&&fl(n.path,""):(n.scheme==="file"&&!n.path.length&&Fd(s)&&(n.host&&(n.host=""),s=pi(s,0)+":"),fl(n.path,s)),s="",n.scheme==="file"&&(d===vi||d==="?"||d==="#"))for(;n.path.length>1&&n.path[0]==="";)qne(n.path);d==="?"?(n.query="",i=Bo):d==="#"&&(n.fragment="",i=Wa)}else s+=Ps(d,e2);break;case u2:d==="?"?(n.query="",i=Bo):d==="#"?(n.fragment="",i=Wa):d!==vi&&(n.path[0]+=Ps(d,Wp));break;case Bo:!e&&d==="#"?(n.fragment="",i=Wa):d!==vi&&(d==="'"&&n.isSpecial()?n.query+="%27":d==="#"?n.query+="%23":n.query+=Ps(d,Wp));break;case Wa:d!==vi&&(n.fragment+=Ps(d,XA));break}a++}},parseHost:function(t){var e,r,n;if(pi(t,0)==="["){if(pi(t,t.length-1)!=="]"||(e=iie(jd(t,1,-1)),!e))return Fo;this.host=e}else if(this.isSpecial()){if(t=Nne(t),Di(Qne,t)||(e=nie(t),e===null))return Fo;this.host=e}else{if(Di(Xne,t))return Fo;for(e="",r=dl(t),n=0;n<r.length;n++)e+=Ps(r[n],Wp);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme==="file"},includesCredentials:function(){return this.username!==""||this.password!==""},isSpecial:function(){return Ew(Zp,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;e&&(this.scheme!=="file"||e!==1||!Fd(t[0],!0))&&t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,i=t.host,a=t.port,s=t.path,o=t.query,u=t.fragment,l=e+":";return i!==null?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=Ud(i),a!==null&&(l+=":"+a)):e==="file"&&(l+="//"),l+=t.cannotBeABaseURL?s[0]:s.length?"/"+Dd(s,"/"):"",o!==null&&(l+="?"+o),u!==null&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw new Rw(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if(t==="blob")try{return new pl(t.path[0]).origin}catch{return"null"}return t==="file"||!this.isSpecial()?"null":t+"://"+Ud(this.host)+(e!==null?":"+e:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(Va(t)+":",Pw)},getUsername:function(){return this.username},setUsername:function(t){var e=dl(Va(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=Ps(e[r],Ow)}},getPassword:function(){return this.password},setPassword:function(t){var e=dl(Va(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=Ps(e[r],Ow)}},getHost:function(){var t=this.host,e=this.port;return t===null?"":e===null?Ud(t):Ud(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,Lw)},getHostname:function(){var t=this.host;return t===null?"":Ud(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,Dw)},getPort:function(){var t=this.port;return t===null?"":Va(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(t=Va(t),t===""?this.port=null:this.parse(t,jw))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+Dd(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,hl))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){t=Va(t),t===""?this.query=null:(pi(t,0)==="?"&&(t=jd(t,1)),this.query="",this.parse(t,Bo)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){if(t=Va(t),t===""){this.fragment=null;return}pi(t,0)==="#"&&(t=jd(t,1)),this.fragment="",this.parse(t,Wa)},update:function(){this.query=this.searchParams.serialize()||null}};var pl=function(e){var r=Pne(this,On),n=Dne(arguments.length,1)>1?arguments[1]:void 0,i=jne(r,new Bw(e,!1,n));$w||(r.href=i.serialize(),r.origin=i.getOrigin(),r.protocol=i.getProtocol(),r.username=i.getUsername(),r.password=i.getPassword(),r.host=i.getHost(),r.hostname=i.getHostname(),r.port=i.getPort(),r.pathname=i.getPathname(),r.search=i.getSearch(),r.searchParams=i.getSearchParams(),r.hash=i.getHash())},On=pl.prototype,mi=function(t,e){return{get:function(){return Hp(this)[t]()},set:e&&function(r){return Hp(this)[e](r)},configurable:!0,enumerable:!0}};if($w&&(hi(On,"href",mi("serialize","setHref")),hi(On,"origin",mi("getOrigin")),hi(On,"protocol",mi("getProtocol","setProtocol")),hi(On,"username",mi("getUsername","setUsername")),hi(On,"password",mi("getPassword","setPassword")),hi(On,"host",mi("getHost","setHost")),hi(On,"hostname",mi("getHostname","setHostname")),hi(On,"port",mi("getPort","setPort")),hi(On,"pathname",mi("getPathname","setPathname")),hi(On,"search",mi("getSearch","setSearch")),hi(On,"searchParams",mi("getSearchParams")),hi(On,"hash",mi("getHash","setHash"))),zp(On,"toJSON",function(){return Hp(this).serialize()},{enumerable:!0}),zp(On,"toString",function(){return Hp(this).serialize()},{enumerable:!0}),Ld){var l2=Ld.createObjectURL,c2=Ld.revokeObjectURL;l2&&zp(pl,"createObjectURL",WA(l2,Ld)),c2&&zp(pl,"revokeObjectURL",WA(c2,Ld))}Lne(pl,"URL"),Ane({global:!0,constructor:!0,forced:!One,sham:!$w},{URL:pl});/*
1174
+ @license
1175
+ Copyright (c) 2018, Twilio, Inc.
1176
+
1177
+ Permission to use, copy, modify, and/or distribute this software for any
1178
+ purpose with or without fee is hereby granted, provided that the above
1179
+ copyright notice and this permission notice appear in all copies.
1180
+
1181
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1182
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1183
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
1184
+ SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1185
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
1186
+ OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
1187
+ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1188
+
1189
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=sa,n=Oa,i=ia,a=aa,s=li,o=_d,u=bs,l=Mu,c=Hu,d=ui,f=qu,m=oa,b=an;function A(K){return K&&typeof K=="object"&&"default"in K?K:{default:K}}function N(K){if(K&&K.__esModule)return K;var he=Object.create(null);return K&&Object.keys(K).forEach(function(G){if(G!=="default"){var de=Object.getOwnPropertyDescriptor(K,G);Object.defineProperty(he,G,de.get?de:{enumerable:!0,get:function(){return K[G]}})}}),he.default=K,Object.freeze(he)}var z=A(r),X=A(n),Ee=A(i),Ie=A(a),Fe=A(s),Oe=A(o),ze=A(u),V=A(l),xe=A(c),_e=A(d),se=N(f),Te={exports:{}},re=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(re){var oe=new Uint8Array(16);Te.exports=function(){return re(oe),oe}}else{var q=new Array(16);Te.exports=function(){for(var he=0,G;he<16;he++)he&3||(G=Math.random()*4294967296),q[he]=G>>>((he&3)<<3)&255;return q}}for(var ne=[],Se=0;Se<256;++Se)ne[Se]=(Se+256).toString(16).substr(1);function H(K,he){var G=he||0,de=ne;return[de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]]].join("")}var ye=H,ke=Te.exports,M=ye,Xe,Ct,rt=0,je=0;function ce(K,he,G){var de=he&&G||0,ee=he||[];K=K||{};var Ye=K.node||Xe,qe=K.clockseq!==void 0?K.clockseq:Ct;if(Ye==null||qe==null){var dt=ke();Ye==null&&(Ye=Xe=[dt[0]|1,dt[1],dt[2],dt[3],dt[4],dt[5]]),qe==null&&(qe=Ct=(dt[6]<<8|dt[7])&16383)}var lt=K.msecs!==void 0?K.msecs:new Date().getTime(),ht=K.nsecs!==void 0?K.nsecs:je+1,Rt=lt-rt+(ht-je)/1e4;if(Rt<0&&K.clockseq===void 0&&(qe=qe+1&16383),(Rt<0||lt>rt)&&K.nsecs===void 0&&(ht=0),ht>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");rt=lt,je=ht,Ct=qe,lt+=122192928e5;var xt=((lt&268435455)*1e4+ht)%4294967296;ee[de++]=xt>>>24&255,ee[de++]=xt>>>16&255,ee[de++]=xt>>>8&255,ee[de++]=xt&255;var kt=lt/4294967296*1e4&268435455;ee[de++]=kt>>>8&255,ee[de++]=kt&255,ee[de++]=kt>>>24&15|16,ee[de++]=kt>>>16&255,ee[de++]=qe>>>8|128,ee[de++]=qe&255;for(var $t=0;$t<6;++$t)ee[de+$t]=Ye[$t];return he||M(ee)}var Ke=ce,Be=Te.exports,be=ye;function pt(K,he,G){var de=he&&G||0;typeof K=="string"&&(he=K==="binary"?new Array(16):null,K=null),K=K||{};var ee=K.random||(K.rng||Be)();if(ee[6]=ee[6]&15|64,ee[8]=ee[8]&63|128,he)for(var Ye=0;Ye<16;++Ye)he[de+Ye]=ee[Ye];return he||be(ee)}var Ze=pt,Jt=Ke,At=Ze,Q=At;Q.v1=Jt,Q.v4=At;var Ue=Q;function ot(K){var he=Pe();return function(){var de=Fe.default(K),ee;if(he){var Ye=Fe.default(this).constructor;ee=Reflect.construct(de,arguments,Ye)}else ee=de.apply(this,arguments);return Ie.default(this,ee)}}function Pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var St=function(K){Ee.default(G,K);var he=ot(G);function G(de){var ee;z.default(this,G);var Ye=Ue.v4(),qe;return ee=he.call(this,function(dt,lt){return qe=lt,de(function(ht){G.cancellationMap.delete(Ye),dt(ht)},function(ht){G.cancellationMap.delete(Ye),lt(ht)},function(ht){G.cancellationMap.set(Ye,ht)})}),ee.id=Ye,ee.rejectPromise=qe,ee}return X.default(G,[{key:"cancel",value:function(){var ee=G.cancellationMap.get(this.id);return ee==null||ee(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),G}(Oe.default(Promise));ze.default(St,"cancellationMap",new Map);function ut(K,he,G,de){var ee=arguments.length,Ye=ee<3?he:de===null?de=Object.getOwnPropertyDescriptor(he,G):de,qe;if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Ye=Reflect.decorate(K,he,G,de);else for(var dt=K.length-1;dt>=0;dt--)(qe=K[dt])&&(Ye=(ee<3?qe(Ye):ee>3?qe(he,G,Ye):qe(he,G))||Ye);return ee>3&&Ye&&Object.defineProperty(he,G,Ye),Ye}function or(K,he){if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(K,he)}function br(K,he){return["".concat(new Date().toISOString()," MCS Client ").concat(K,":")].concat(Array.from(he))}var et=function(){function K(he){z.default(this,K),ze.default(this,"prefix",""),this.prefix=he!=null&&he.length>0?he+" ":""}return X.default(K,[{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br(this.prefix+"T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br(this.prefix+"D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.info.apply(null,br(this.prefix+"I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.warn.apply(null,br(this.prefix+"W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.error.apply(null,br(this.prefix+"E",de))}}],[{key:"scope",value:function(G){return new K(G)}},{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br("T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br("D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.info.apply(null,br("I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.warn.apply(null,br("W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.error.apply(null,br("E",de))}}]),K}(),Mr=1e3,Fr=4e3,dr=3,fr=!0,Wt=function(he){return"https://mcs.".concat(he??"us1",".twilio.com")},Ot=function(he){return he.startsWith("http")},L=function(he,G){return"".concat(Ot(he)?"":Wt(G)).concat(he)},W=function(){function K(he,G,de,ee){var Ye,qe,dt,lt,ht,Rt;z.default(this,K);var xt=(Ye=(qe=ee.MCS)!==null&&qe!==void 0?qe:ee)!==null&&Ye!==void 0?Ye:{};this.region=(dt=(lt=xt.region)!==null&&lt!==void 0?lt:ee.region)!==null&&dt!==void 0?dt:"us1",this.mediaUrl=L(G,this.region),this.mediaSetUrl=de?L(de):"".concat(this.mediaUrl,"Set"),this.token=he,this.retryWhenThrottledOverride=(ht=xt.retryWhenThrottledOverride)!==null&&ht!==void 0?ht:fr,this.backoffConfigOverride=(Rt=xt.backoffConfigOverride)!==null&&Rt!==void 0?Rt:K.backoffConfigDefault}return X.default(K,[{key:"updateToken",value:function(G){this.token=G}}],[{key:"backoffConfigDefault",get:function(){return{min:Mr,max:Fr,maxAttemptsCount:dr}}},{key:"retryWhenThrottledDefault",get:function(){return fr}}]),K}(),ie=function(){function K(he,G,de){z.default(this,K),this.config=he,this.network=G,this._update(de)}return X.default(K,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var G=this;return new St(function(){var de=V.default(xe.default.mark(function ee(Ye,qe,dt){var lt,ht;return xe.default.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return lt=G.network.get("".concat(G.config.mediaUrl,"/").concat(G.sid)),dt(function(){return lt.cancel()}),xt.prev=2,xt.next=5,lt;case 5:ht=xt.sent,G._update(ht.body),Ye(G.state.contentDirectUrl),xt.next=13;break;case 10:xt.prev=10,xt.t0=xt.catch(2),qe(xt.t0);case 13:case"end":return xt.stop()}},ee,null,[[2,10]])}));return function(ee,Ye,qe){return de.apply(this,arguments)}}())}},{key:"_update",value:function(G){var de,ee,Ye,qe;this.state={sid:G.sid,serviceSid:G.service_sid,channelSid:G.channel_sid,messageSid:G.message_sid,dateCreated:G.date_created?new Date(G.date_created):null,dateUploadUpdated:G.date_upload_updated?new Date(G.date_upload_updated):null,dateUpdated:G.date_updated?new Date(G.date_updated):null,size:G.size,contentType:G.content_type,author:G.author,url:G.url,contentUrl:G.links.content,contentDirectUrl:(de=G.links.content_direct_temporary)!==null&&de!==void 0?de:null,filename:(ee=G.filename)!==null&&ee!==void 0?ee:null,category:(Ye=G.category)!==null&&Ye!==void 0?Ye:"media",isMultipartUpstream:(qe=G.is_multipart_upstream)!==null&&qe!==void 0?qe:!1}}},{key:"_state",value:function(){var G;return{sid:this.state.sid,category:this.state.category,filename:(G=this.state.filename)!==null&&G!==void 0?G:null,contentType:this.state.contentType,size:this.state.size}}}]),K}();function He(K){var he=ct();return function(){var de=Fe.default(K),ee;if(he){var Ye=Fe.default(this).constructor;ee=Reflect.construct(de,arguments,Ye)}else ee=de.apply(this,arguments);return Ie.default(this,ee)}}function ct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var bt=function(K){Ee.default(G,K);var he=He(G);function G(de,ee,Ye,qe,dt){var lt;return z.default(this,G),lt=he.call(this,de),lt.code=ee,lt.body=Ye,lt.status=qe,lt.headers=dt,lt}return X.default(G)}(Oe.default(Error)),zt=e.XMLHttpRequest||{};function tr(K){return K?K.split(`\r
1190
+ `).map(function(he){return he.split(": ")}).filter(function(he){return he.length===2&&he[1].length>0}).reduce(function(he,G){return he[G[0]]=G[1],he},{}):{}}function Re(K){var he=K.getResponseHeader("Content-Type");if(!he||he.indexOf("application/json")!==0||K.responseText.length===0)return K.responseText;try{return JSON.parse(K.responseText)}catch{return K.responseText}}var Ne=function(){function K(){z.default(this,K)}return X.default(K,[{key:"get",value:function(G,de){return K.request("GET",G,de)}},{key:"post",value:function(G,de,ee){return K.request("POST",G,de,ee)}}],[{key:"request",value:function(G,de,ee,Ye){return new St(function(qe,dt,lt){var ht=new zt,Rt=!1;lt(function(){ht.abort(),Rt=!0}),ht.open(G,de,!0),ht.onreadystatechange=function(){if(!(ht.readyState!==4||Rt)){var $t=tr(ht.getAllResponseHeaders()),It=Re(ht);if(200<=ht.status&&ht.status<300)qe({status:ht.status,headers:$t,body:It});else{var jt,on=(jt=ht.statusText)!==null&&jt!==void 0?jt:"NONE",_n;if(typeof It=="string")if(It&&It.split(`
1191
+ `,2).length===1)_n=It;else{var Ut,qn=(Ut=It.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(Za){return Za.length})[0])===null||Ut===void 0?void 0:Ut.split(" ");_n=(qn==null?void 0:qn.length)>2?qn==null?void 0:qn.slice(1).join(" "):""}else _n=JSON.stringify(It);var pa="".concat(ht.status,": [").concat(on,"] ").concat(_n);dt(new bt(pa,ht.status,It,on,$t))}}};for(var xt in ee)ht.setRequestHeader(xt,ee[xt]),xt==="Content-Type"&&ee[xt]==="application/json"&&(Ye=JSON.stringify(Ye));ht.send(Ye)})}}]),K}(),pe=et.scope("Network"),$e=function(){function K(he,G){z.default(this,K),this.config=he,this.transport=G}return X.default(K,[{key:"backoffConfig",value:function(){return Object.assign(W.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var G,de;return(G=(de=this.config.retryWhenThrottledOverride)!==null&&de!==void 0?de:W.retryWhenThrottledDefault)!==null&&G!==void 0?G:!1}},{key:"executeWithRetry",value:function(G,de){var ee=this;return new St(function(){var Ye=V.default(xe.default.mark(function qe(dt,lt,ht){var Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:Rt=new m.Retrier(ee.backoffConfig()),xt=[502,503,504],de&&xt.push(429),ht(function(){Rt.cancel(),Rt.removeAllListeners()}),Rt.on("attempt",V.default(xe.default.mark(function It(){var jt,on;return xe.default.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return Ut.prev=0,jt=G(),ht(function(){jt.cancel(),Rt.cancel(),Rt.removeAllListeners()}),Ut.next=5,jt;case 5:on=Ut.sent,Rt.succeeded(on),Ut.next=12;break;case 9:Ut.prev=9,Ut.t0=Ut.catch(0),xt.indexOf(Ut.t0.status)>-1||Ut.t0.message==="Twilsock disconnected"?Rt.failed(Ut.t0):(Rt.removeAllListeners(),Rt.cancel(),lt(Ut.t0));case 12:case"end":return Ut.stop()}},It,null,[[0,9]])}))),Rt.on("succeeded",function(It){dt(It)}),Rt.on("cancelled",function(It){return lt(It)}),Rt.on("failed",function(It){return lt(It)}),Rt.start();case 9:case"end":return $t.stop()}},qe)}));return function(qe,dt,lt){return Ye.apply(this,arguments)}}())}},{key:"get",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return ht={"X-Twilio-Token":de.config.token},Rt=de.executeWithRetry(function(){return de.transport.get(G,ht)},de.retryWhenThrottled()),pe.trace("sending GET request to ",G," headers ",ht),lt(function(){return Rt.cancel()}),$t.prev=4,$t.next=7,Rt;case 7:xt=$t.sent,pe.trace("response",xt),qe(xt),$t.next=16;break;case 12:$t.prev=12,$t.t0=$t.catch(4),pe.debug("get() error ".concat($t.t0)),dt($t.t0);case 16:case"end":return $t.stop()}},Ye,null,[[4,12]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"post",value:function(G,de,ee,Ye,qe){var dt=this,lt={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(ee instanceof FormData))&&Ye&&Object.assign(lt,{"Content-Type":Ye});var ht=new URL(G);return de&&ht.searchParams.append("Category",de),qe&&ht.searchParams.append("Filename",qe),new St(function(){var Rt=V.default(xe.default.mark(function xt(kt,$t,It){var jt,on;return xe.default.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return jt=dt.transport.post(ht.href,lt,ee),It(function(){return jt.cancel()}),pe.trace("sending POST request to ".concat(G," with headers ").concat(lt)),Ut.prev=3,Ut.next=6,jt;case 6:on=Ut.sent,Ut.next=17;break;case 9:if(Ut.prev=9,Ut.t0=Ut.catch(3),!(e.XMLHttpRequest===void 0&&ee instanceof FormData)){Ut.next=14;break}return $t(new TypeError("Posting FormData supported only with browser engine's FormData")),Ut.abrupt("return");case 14:return pe.debug("post() error ".concat(Ut.t0)),$t(Ut.t0),Ut.abrupt("return");case 17:pe.trace("response",on),kt(on);case 19:case"end":return Ut.stop()}},xt,null,[[3,9]])}));return function(xt,kt,$t){return Rt.apply(this,arguments)}}())}}]),K}(),ae="0.6.13",me,we=et.scope("");t.default=(me=function(){function K(he,G,de){var ee,Ye,qe=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};z.default(this,K),this.options=qe,this.options.logLevel=(ee=this.options.logLevel)!==null&&ee!==void 0?ee:"silent",this.config=new W(he,G,de,this.options),we.setLevel(this.options.logLevel),this.options.transport=(Ye=this.options.transport)!==null&&Ye!==void 0?Ye:new Ne,this.transport=this.options.transport,this.network=new $e(this.config,this.transport)}return X.default(K,[{key:"updateToken",value:function(G){we.info("updateToken"),this.config.updateToken(G)}},{key:"get",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt;return xe.default.wrap(function(kt){for(;;)switch(kt.prev=kt.next){case 0:return ht=de.network.get("".concat(de.config.mediaUrl,"/").concat(G)),lt(function(){return ht.cancel()}),kt.prev=2,kt.next=5,ht;case 5:Rt=kt.sent,qe(new ie(de.config,de.network,Rt.body)),kt.next=12;break;case 9:kt.prev=9,kt.t0=kt.catch(2),dt(kt.t0);case 12:case"end":return kt.stop()}},Ye,null,[[2,9]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"post",value:function(G,de,ee,Ye){var qe=this;return new St(function(){var dt=V.default(xe.default.mark(function lt(ht,Rt,xt){var kt,$t;return xe.default.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:return kt=qe.network.post(qe.config.mediaUrl,ee??"media",de,G,Ye),xt(function(){return kt.cancel()}),jt.prev=2,jt.next=5,kt;case 5:$t=jt.sent,ht(new ie(qe.config,qe.network,$t.body)),jt.next=12;break;case 9:jt.prev=9,jt.t0=jt.catch(2),Rt(jt.t0);case 12:case"end":return jt.stop()}},lt,null,[[2,9]])}));return function(lt,ht,Rt){return dt.apply(this,arguments)}}())}},{key:"postFormData",value:function(G,de){var ee=this;return new St(function(){var Ye=V.default(xe.default.mark(function qe(dt,lt,ht){var Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return Rt=ee.network.post(ee.config.mediaUrl,de??"media",G),ht(function(){return Rt.cancel()}),$t.prev=2,$t.next=5,Rt;case 5:xt=$t.sent,dt(new ie(ee.config,ee.network,xt.body)),$t.next=12;break;case 9:$t.prev=9,$t.t0=$t.catch(2),lt($t.t0);case 12:case"end":return $t.stop()}},qe,null,[[2,9]])}));return function(qe,dt,lt){return Ye.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt,kt;return xe.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ht={command:"get",list:G.map(function(jt){return{media_sid:jt}})},Rt=de.network.post("".concat(de.config.mediaSetUrl),null,ht,"application/json"),lt(function(){return Rt.cancel()}),It.prev=3,It.next=6,Rt;case 6:xt=It.sent,kt=xt.body.map(function(jt){if(jt.code!==200){dt("Failed to obtain detailed information about Media items (failed SID ".concat(jt.media_record.sid,")"));return}return new ie(de.config,de.network,jt.media_record)}),qe(kt),It.next=14;break;case 11:It.prev=11,It.t0=It.catch(3),dt(It.t0);case 14:case"end":return It.stop()}},Ye,null,[[3,11]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt,kt;return xe.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ht={command:"get",list:G.map(function(jt){return{media_sid:jt}})},Rt=de.network.post("".concat(de.config.mediaSetUrl),null,ht,"application/json"),lt(function(){return Rt.cancel()}),It.prev=3,It.next=6,Rt;case 6:xt=It.sent,kt=new Map,xt.body.forEach(function(jt){if(jt.code!==200){dt("Failed to obtain detailed information about Media items (failed SID ".concat(jt.media_record.sid,")"));return}kt.set(jt.media_record.sid,jt.media_record.links.content_direct_temporary)}),qe(kt),It.next=15;break;case 12:It.prev=12,It.t0=It.catch(3),dt(It.t0);case 15:case"end":return It.stop()}},Ye,null,[[3,12]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}}]),K}(),ze.default(me,"version",ae),me),ut([b.validateTypes(b.nonEmptyString),or("design:type",Function),or("design:paramtypes",[String]),or("design:returntype",void 0)],t.default.prototype,"updateToken",null),ut([b.validateTypesAsync(b.nonEmptyString),or("design:type",Function),or("design:paramtypes",[String]),or("design:returntype",St)],t.default.prototype,"get",null),t.default=ut([b.validateConstructorTypes(b.nonEmptyString,b.nonEmptyString,[b.nonEmptyString,b.literal(null)],[b.pureObject,"undefined"]),or("design:paramtypes",[String,String,Object,Object])],t.default),t.CancellablePromise=St,t.Client=t.default,t.McsClient=t.default,t.McsMedia=ie,t.Media=ie})(hA);var uie=er,lie=cr,cie=ZR,die=Sh,zw="ArrayBuffer",d2=cie[zw],fie=lie[zw];uie({global:!0,constructor:!0,forced:fie!==d2},{ArrayBuffer:d2}),die(zw);var hie=er,f2=Kt,pie=si,vie=yn,h2=bn,mie=xb,p2=nn,Hw=Vt,gie=Fb,yie=_h,v2=Qx,bie=Xx,m2=$u,g2=tI,Ms=[],y2=f2(Ms.sort),wie=f2(Ms.push),_ie=Hw(function(){Ms.sort(void 0)}),kie=Hw(function(){Ms.sort(null)}),Sie=yie("sort"),b2=!Hw(function(){if(m2)return m2<70;if(!(v2&&v2>3)){if(bie)return!0;if(g2)return g2<603;var t="",e,r,n,i;for(e=65;e<76;e++){switch(r=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)Ms.push({k:r+i,v:n})}for(Ms.sort(function(a,s){return s.v-a.v}),i=0;i<Ms.length;i++)r=Ms[i].k.charAt(0),t.charAt(t.length-1)!==r&&(t+=r);return t!=="DGBEFHACIJK"}}),$ie=_ie||!kie||!Sie||!b2,Tie=function(t){return function(e,r){return r===void 0?-1:e===void 0?1:t!==void 0?+t(e,r)||0:p2(e)>p2(r)?1:-1}};hie({target:"Array",proto:!0,forced:$ie},{sort:function(e){e!==void 0&&pie(e);var r=vie(this);if(b2)return e===void 0?y2(r):y2(r,e);var n=[],i=h2(r),a,s;for(s=0;s<i;s++)s in r&&wie(n,r[s]);for(gie(n,Tie(e)),a=h2(n),s=0;s<a;)r[s]=n[s++];for(;s<i;)mie(r,s++);return r}});var Eie=er,Cie=Kt,Rie=pA,xie=Ii,w2=nn,Iie=vA,Aie=Cie("".indexOf);Eie({target:"String",proto:!0,forced:!Iie("includes")},{includes:function(e){return!!~Aie(w2(xie(this)),w2(Rie(e)),arguments.length>1?arguments[1]:void 0)}});var Oie=Kt,_2=op,Jp=sp.getWeakData,Pie=ws,Mie=Gr,Nie=xi,qw=Lr,Lie=nd,k2=Un,S2=Vr,$2=Jn,Die=$2.set,jie=$2.getterFor,Uie=k2.find,Fie=k2.findIndex,Bie=Oie([].splice),zie=0,Yp=function(t){return t.frozen||(t.frozen=new T2)},T2=function(){this.entries=[]},Vw=function(t,e){return Uie(t.entries,function(r){return r[0]===e})};T2.prototype={get:function(t){var e=Vw(this,t);if(e)return e[1]},has:function(t){return!!Vw(this,t)},set:function(t,e){var r=Vw(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=Fie(this.entries,function(r){return r[0]===t});return~e&&Bie(this.entries,e,1),!!~e}};var Hie={getConstructor:function(t,e,r,n){var i=t(function(u,l){Pie(u,a),Die(u,{type:e,id:zie++,frozen:void 0}),Nie(l)||Lie(l,u[n],{that:u,AS_ENTRIES:r})}),a=i.prototype,s=jie(e),o=function(u,l,c){var d=s(u),f=Jp(Mie(l),!0);return f===!0?Yp(d).set(l,c):f[d.id]=c,u};return _2(a,{delete:function(u){var l=s(this);if(!qw(u))return!1;var c=Jp(u);return c===!0?Yp(l).delete(u):c&&S2(c,l.id)&&delete c[l.id]},has:function(l){var c=s(this);if(!qw(l))return!1;var d=Jp(l);return d===!0?Yp(c).has(l):d&&S2(d,c.id)}}),_2(a,r?{get:function(l){var c=s(this);if(qw(l)){var d=Jp(l);return d===!0?Yp(c).get(l):d?d[c.id]:void 0}},set:function(l,c){return o(this,l,c)}}:{add:function(l){return o(this,l,!0)}}),i}},qie=Yy,Vie=Hie;qie("WeakSet",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Vie);var Qp={},E2={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(ln,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(A,N){var z=A[N];if(typeof z.bind=="function")return z.bind(A);try{return Function.prototype.bind.call(z,A)}catch{return function(){return Function.prototype.apply.apply(z,[A,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(A){return A==="debug"&&(A="log"),typeof console===r?!1:A==="trace"&&n?s:console[A]!==void 0?a(console,A):console.log!==void 0?a(console,"log"):e}function u(A,N){for(var z=0;z<i.length;z++){var X=i[z];this[X]=z<A?e:this.methodFactory(X,A,N)}this.log=this.debug}function l(A,N,z){return function(){typeof console!==r&&(u.call(this,N,z),this[A].apply(this,arguments))}}function c(A,N,z){return o(A)||l.apply(this,arguments)}function d(A,N,z){var X=this,Ee;N=N??"WARN";var Ie="loglevel";typeof A=="string"?Ie+=":"+A:typeof A=="symbol"&&(Ie=void 0);function Fe(xe){var _e=(i[xe]||"silent").toUpperCase();if(!(typeof window===r||!Ie)){try{window.localStorage[Ie]=_e;return}catch{}try{window.document.cookie=encodeURIComponent(Ie)+"="+_e+";"}catch{}}}function Oe(){var xe;if(!(typeof window===r||!Ie)){try{xe=window.localStorage[Ie]}catch{}if(typeof xe===r)try{var _e=window.document.cookie,se=_e.indexOf(encodeURIComponent(Ie)+"=");se!==-1&&(xe=/^([^;]+)/.exec(_e.slice(se))[1])}catch{}return X.levels[xe]===void 0&&(xe=void 0),xe}}function ze(){if(!(typeof window===r||!Ie)){try{window.localStorage.removeItem(Ie);return}catch{}try{window.document.cookie=encodeURIComponent(Ie)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}X.name=A,X.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},X.methodFactory=z||c,X.getLevel=function(){return Ee},X.setLevel=function(xe,_e){if(typeof xe=="string"&&X.levels[xe.toUpperCase()]!==void 0&&(xe=X.levels[xe.toUpperCase()]),typeof xe=="number"&&xe>=0&&xe<=X.levels.SILENT){if(Ee=xe,_e!==!1&&Fe(xe),u.call(X,xe,A),typeof console===r&&xe<X.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+xe},X.setDefaultLevel=function(xe){N=xe,Oe()||X.setLevel(xe,!1)},X.resetLevel=function(){X.setLevel(N,!1),ze()},X.enableAll=function(xe){X.setLevel(X.levels.TRACE,xe)},X.disableAll=function(xe){X.setLevel(X.levels.SILENT,xe)};var V=Oe();V==null&&(V=N),X.setLevel(V,!1)}var f=new d,m={};f.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=m[N];return z||(z=m[N]=new d(N,f.getLevel(),f.methodFactory)),z};var b=typeof window!==r?window.log:void 0;return f.noConflict=function(){return typeof window!==r&&window.log===f&&(window.log=b),f},f.getLoggers=function(){return m},f.default=f,f})})(E2);var Wie=E2.exports;/*
1192
+ @license
1193
+ Copyright (c) 2022 Twilio Inc.
1194
+
1195
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1196
+
1197
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1198
+
1199
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1200
+
1201
+
1202
+ */Object.defineProperty(Qp,"__esModule",{value:!0});var Zie=Wie;function Gie(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var Xp=Gie(Zie),Kie=function(e,r,n){return function(i,a,s){if(typeof s.value!="function"&&(s==null?void 0:s.get)===void 0)throw new Error("The deprecated decorator can only be applied to methods or getters");if(typeof s.value=="function"){var o=s.value;s.value=function(){Ww("The method ".concat(e," is deprecated").concat(r?", use "+r+" instead":"").concat(n?", "+n:"."));for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];return o.apply(this,c)};return}var u=s.get;s.get=function(){return Ww("The getter ".concat(e," is deprecated").concat(r?", use "+r+" instead":"").concat(n?", "+n:".")),u==null?void 0:u.apply(this)}}},Ww=function(e){var r=Xp.default.getLevel();Xp.default.setLevel("warn"),Xp.default.warn(e),Xp.default.setLevel(r)};Qp.deprecated=Kie,Qp.deprecationWarning=Ww;var Jie=er,Yie=Un.find,Qie=by,Zw="find",C2=!0;Zw in[]&&Array(1)[Zw](function(){C2=!1}),Jie({target:"Array",proto:!0,forced:C2},{find:function(e){return Yie(this,e,arguments.length>1?arguments[1]:void 0)}}),Qie(Zw);var Xie=er,eae=LC,tae=Vt,rae=Lr,nae=sp.onFreeze,Gw=Object.freeze,iae=tae(function(){Gw(1)});Xie({target:"Object",stat:!0,forced:iae,sham:!eae},{freeze:function(e){return Gw&&rae(e)?Gw(nae(e)):e}});/*
1203
+ @license
1204
+ The following license applies to all parts of this software except as
1205
+ documented below.
1206
+
1207
+ Copyright (c) 2019, Twilio, inc.
1208
+ All rights reserved.
1209
+
1210
+ Redistribution and use in source and binary forms, with or without
1211
+ modification, are permitted provided that the following conditions are
1212
+ met:
1213
+
1214
+ 1. Redistributions of source code must retain the above copyright
1215
+ notice, this list of conditions and the following disclaimer.
1216
+
1217
+ 2. Redistributions in binary form must reproduce the above copyright
1218
+ notice, this list of conditions and the following disclaimer in
1219
+ the documentation and/or other materials provided with the
1220
+ distribution.
1221
+
1222
+ 3. Neither the name of Twilio nor the names of its contributors may
1223
+ be used to endorse or promote products derived from this software
1224
+ without specific prior written permission.
1225
+
1226
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1227
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1228
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1229
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1230
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1231
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1232
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1233
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1234
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1235
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1236
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1237
+
1238
+ This software includes javascript-state-machine under the following license.
1239
+
1240
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
1241
+
1242
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1243
+ of this software and associated documentation files (the "Software"), to deal
1244
+ in the Software without restriction, including without limitation the rights
1245
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1246
+ copies of the Software, and to permit persons to whom the Software is
1247
+ furnished to do so, subject to the following conditions:
1248
+
1249
+ The above copyright notice and this permission notice shall be included in all
1250
+ copies or substantial portions of the Software.
1251
+
1252
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1253
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1254
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1255
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1256
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1257
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1258
+
1259
+ This software includes loglevel under the following license.
1260
+
1261
+ Copyright (c) 2013 Tim Perry
1262
+
1263
+ Permission is hereby granted, free of charge, to any person
1264
+ obtaining a copy of this software and associated documentation
1265
+ files (the "Software"), to deal in the Software without
1266
+ restriction, including without limitation the rights to use,
1267
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
1268
+ copies of the Software, and to permit persons to whom the
1269
+ Software is furnished to do so, subject to the following
1270
+ conditions:
1271
+
1272
+ The above copyright notice and this permission notice shall be
1273
+ included in all copies or substantial portions of the Software.
1274
+
1275
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1276
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
1277
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1278
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1279
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1280
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1281
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1282
+ OTHER DEALINGS IN THE SOFTWARE.
1283
+
1284
+ This software includes q under the following license.
1285
+
1286
+ Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
1287
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1288
+ of this software and associated documentation files (the "Software"), to
1289
+ deal in the Software without restriction, including without limitation the
1290
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1291
+ sell copies of the Software, and to permit persons to whom the Software is
1292
+ furnished to do so, subject to the following conditions:
1293
+
1294
+ The above copyright notice and this permission notice shall be included in
1295
+ all copies or substantial portions of the Software.
1296
+
1297
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1298
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1299
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1300
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1301
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1302
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1303
+ IN THE SOFTWARE.
1304
+
1305
+ This software includes platform.js under the following license.
1306
+
1307
+ Copyright 2014 Benjamin Tan <https://d10.github.io/>
1308
+ Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
1309
+
1310
+ Permission is hereby granted, free of charge, to any person obtaining
1311
+ a copy of this software and associated documentation files (the
1312
+ "Software"), to deal in the Software without restriction, including
1313
+ without limitation the rights to use, copy, modify, merge, publish,
1314
+ distribute, sublicense, and/or sell copies of the Software, and to
1315
+ permit persons to whom the Software is furnished to do so, subject to
1316
+ the following conditions:
1317
+
1318
+ The above copyright notice and this permission notice shall be
1319
+ included in all copies or substantial portions of the Software.
1320
+
1321
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1322
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1323
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1324
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1325
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1326
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1327
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1328
+
1329
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Mu,n=ys,i=ia,a=aa,s=li,o=bs,u=Oa,l=sa,c=Hu,d=ui,f=qu,m=Yz,b=an,A=ld,N=rp,z=hZ,X=ud,Ee=oa,Ie=rb,Fe=TI,Oe=zn,ze=hA,V=Qp,xe=_d,_e=pd;function se(C){return C&&typeof C=="object"&&"default"in C?C:{default:C}}function Te(C){if(C&&C.__esModule)return C;var x=Object.create(null);return C&&Object.keys(C).forEach(function(w){if(w!=="default"){var p=Object.getOwnPropertyDescriptor(C,w);Object.defineProperty(x,w,p.get?p:{enumerable:!0,get:function(){return C[w]}})}}),x.default=C,Object.freeze(x)}var re=se(r),oe=se(n),q=se(i),ne=se(a),Se=se(s),H=se(o),ye=se(u),ke=se(l),M=se(c),Xe=se(d),Ct=Te(f),rt=se(A),je=se(z),ce=se(X),Ke=se(xe);function Be(C,x,w,p){var h=arguments.length,_=h<3?x:p===null?p=Object.getOwnPropertyDescriptor(x,w):p,v;if((typeof Reflect>"u"?"undefined":Xe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(C,x,w,p);else for(var g=C.length-1;g>=0;g--)(v=C[g])&&(_=(h<3?v(_):h>3?v(x,w,_):v(x,w))||_);return h>3&&_&&Object.defineProperty(x,w,_),_}function be(C,x){if((typeof Reflect>"u"?"undefined":Xe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(C,x)}function pt(C,x){return["".concat(new Date().toISOString()," Conversations ").concat(C,":")].concat(Array.from(x))}var Ze=Ct.getLogger("twilio-conversations"),Jt=function(){function C(x){ke.default(this,C),H.default(this,"prefix",""),this.prefix=x!=null&&x.length>0?x+" ":""}return ye.default(C,[{key:"setLevel",value:function(w){Ze.setLevel(w)}},{key:"trace",value:function(){if(Ze.getLevel()==Ze.levels.TRACE){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt(this.prefix+"T",p))}}},{key:"debug",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt(this.prefix+"D",p))}},{key:"info",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.info.apply(null,pt(this.prefix+"I",p))}},{key:"warn",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.warn.apply(null,pt(this.prefix+"W",p))}},{key:"error",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.error.apply(null,pt(this.prefix+"E",p))}}],[{key:"scope",value:function(w){return new C(w)}},{key:"setLevel",value:function(w){Ze.setLevel(w)}},{key:"trace",value:function(){if(Ze.getLevel()==Ze.levels.TRACE){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt("T",p))}}},{key:"debug",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt("D",p))}},{key:"info",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.info.apply(null,pt("I",p))}},{key:"warn",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.warn.apply(null,pt("W",p))}},{key:"error",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.error.apply(null,pt("E",p))}}]),C}();function At(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Q(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?At(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):At(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}var Ue=5,ot="PT5S",Pe="PT5S",St=100,ut=1e3,or=4e3,br=3,et=!0,Mr=100,Fr=1e3,dr=ye.default(function C(){var x,w,p,h,_,v,g,y,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},S=arguments.length>1?arguments[1]:void 0,Y=arguments.length>2?arguments[2]:void 0;ke.default(this,C),H.default(this,"typingIndicatorTimeoutDefault",Ue*1e3);var J=k.Chat||k.IPMessaging||k||{};this.productId=J.productId,this.links={myConversations:S.links.my_conversations,conversations:S.links.conversations,users:S.links.users,currentUser:S.links.current_user,typing:S.links.typing,mediaService:S.links.media_service,mediaSetService:S.links.media_set_service,messagesReceipts:S.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:S.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:S.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:S.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:S.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:S.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=J.typingIndicatorTimeoutOverride,this.backoffConfiguration=Q({min:ut,max:or,maxAttemptsCount:br},J.backoffConfigOverride),this.retryWhenThrottled=J.retryWhenThrottledOverride!==void 0?J.retryWhenThrottledOverride:et,this.userInfosToSubscribe=(x=(w=J.userInfosToSubscribeOverride)!==null&&w!==void 0?w:S.options.user_infos_to_subscribe)!==null&&x!==void 0?x:St,this.reachabilityEnabled=S.options.reachability_enabled,this.userIdentity=S.identity,this.userInfo=S.sync_objects.my_user_info,this.myConversations=S.sync_objects.my_conversations;var le=(p=(h=J.httpCacheIntervalOverride)!==null&&h!==void 0?h:S.options.http_cache_interval)!==null&&p!==void 0?p:ot;try{this.httpCacheInterval=m.toSeconds(m.parse(le))}catch{Y.error("Failed to parse http cache interval ".concat(le,", using default value ").concat(ot)),this.httpCacheInterval=m.toSeconds(m.parse(ot))}var ge=(_=(v=J.consumptionReportIntervalOverride)!==null&&v!==void 0?v:S.options.consumption_report_interval)!==null&&_!==void 0?_:Pe;try{this.consumptionReportInterval=m.toSeconds(m.parse(ge))}catch{Y.error("Failed to parse consumption report interval ".concat(ge,", using default value ").concat(Pe)),this.consumptionReportInterval=m.toSeconds(m.parse(Pe))}this.channelMetadataCacheCapacity=(g=k.channelMetadataCacheCapacity)!==null&&g!==void 0?g:Mr,this.messageRecipientsCacheCapacity=(y=k.messageRecipientsCacheCapacity)!==null&&y!==void 0?y:Fr});function fr(C){return JSON.parse(JSON.stringify(C))}function Wt(C){return typeof C<"u"&&!isNaN(Number(C))?Number(C):null}function Ot(C){try{return new Date(C)}catch{return null}}function L(C,x,w){var p={};if(C)try{p=JSON.parse(C)}catch(h){w.warn(x,h)}return p}var W=function(){function C(x){ke.default(this,C),this.base=x.replace(/\/$/,""),this.args=[],this.paths=[]}return ye.default(C,[{key:"arg",value:function(w,p){return typeof p<"u"&&this.args.push(encodeURIComponent(w)+"="+encodeURIComponent(p)),this}},{key:"path",value:function(w){return this.paths.push(encodeURIComponent(w)),this}},{key:"build",value:function(){var w=this.base;return this.paths.length&&(w+="/"+this.paths.join("/")),this.args.length&&(w+="?"+this.args.join("&")),w}}]),C}(),ie=b.custom(function(C){return[["string","number","boolean","object"].includes(Xe.default(C)),"a JSON type"]}),He=b.custom(function(C){return[["undefined","string","number","boolean","object"].includes(Xe.default(C)),"an optional JSON type"]}),ct=b.objectSchema("send media options",{contentType:[b.literal(null),"string"],filename:["string","undefined"],media:[b.literal("null"),"string"].concat(rt.default(typeof Buffer=="function"?[Buffer]:[]),rt.default(typeof Blob=="function"?[Blob]:[]))});function bt(C){var x=zt();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function zt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var tr=Jt.scope("User"),Re=function(C){q.default(w,C);var x=bt(w);function w(p,h,_,v){var g;return ke.default(this,w),g=x.call(this),H.default(oe.default(g),"promiseToFetch",null),H.default(oe.default(g),"updated","updated"),H.default(oe.default(g),"userSubscribed","userSubscribed"),H.default(oe.default(g),"userUnsubscribed","userUnsubscribed"),g.services=v,g.subscribed="initializing",g.setMaxListeners(0),g.state={identity:p,entityName:h,friendlyName:null,attributes:{},online:null,notifiable:null},g._initializationPromise=new Promise(function(y){g._resolveInitializationPromise=y}),_!==null&&g._resolveInitialization(_,p,h,!1),g}return ye.default(w,[{key:"identity",get:function(){return this.state.identity},set:function(h){this.state.identity=h}},{key:"entityName",set:function(h){this.state.entityName=h}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return this.subscribed=="subscribed"}},{key:"_update",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return Y.next=2,this._initializationPromise;case 2:y=[],tr.debug("User for",this.state.identity,"updated:",v,g),Y.t0=v,Y.next=Y.t0==="friendlyName"?7:Y.t0==="attributes"?9:Y.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==g.value&&(y.push("friendlyName"),this.state.friendlyName=g.value),Y.abrupt("break",16);case 9:return k=L(g.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),tr),je.default(this.state.attributes,k)||(this.state.attributes=k,y.push("attributes")),Y.abrupt("break",16);case 12:return this.state.online!==g.online&&(this.state.online=g.online,y.push("reachabilityOnline")),this.state.notifiable!==g.notifiable&&(this.state.notifiable=g.notifiable,y.push("reachabilityNotifiable")),Y.abrupt("break",16);case 15:return Y.abrupt("return");case 16:y.length>0&&this.emit("updated",{user:this,updateReasons:y});case 17:case"end":return Y.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_updateReachabilityInfo",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){S.next=4;break}return S.abrupt("return",Promise.resolve());case 4:return S.abrupt("return",v.get("reachability").then(g).catch(function(Y){tr.warn("Failed to get reachability info for ",y.state.identity,Y)}));case 5:case"end":return S.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_fetch",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.state.entityName){y.next=4;break}return y.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(k){return v.entity=k,k.on("itemUpdated",function(S){return tr.debug(v.state.entityName+" ("+v.state.identity+") itemUpdated: "+S.item.key),v._update(S.item.key,S.item.data)}),k.on("itemAdded",function(S){return tr.debug(v.state.entityName+" ("+v.state.identity+") itemAdded: "+S.item.key),v._update(S.item.key,S.item.data)}),Promise.all([k.get("friendlyName").then(function(S){return v._update(S.key,S.data)}),k.get("attributes").then(function(S){return v._update(S.key,S.data)}),v._updateReachabilityInfo(k,function(S){return v._update(S.key,S.data)})])}).then(function(){return tr.debug("Fetched for",v.identity),v.subscribed="subscribed",v.emit("userSubscribed",v),v}).catch(function(k){throw v.promiseToFetch=null,k}),y.abrupt("return",this.promiseToFetch);case 6:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_ensureFetched",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:return g.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:v});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){g.next=9;break}return g.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_resolveInitialization",value:function(h,_,v,g){this.configuration=h,this.identity=_,this.entityName=v,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),g&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),w}(N.ReplayEventEmitter);Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],Re.prototype,"updateAttributes",null),Be([b.validateTypesAsync(["string"]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],Re.prototype,"updateFriendlyName",null);function Ne(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=pe(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1330
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function pe(C,x){if(C){if(typeof C=="string")return $e(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return $e(C,x)}}function $e(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var ae=function(){function C(x,w){ke.default(this,C),this.configuration=x,this.services=w,this.cache=new Map,this.cacheLifetime=this.configuration.httpCacheInterval*100,this.cleanupCache()}return ye.default(C,[{key:"isExpired",value:function(w){return!this.cacheLifetime||Date.now()-w>this.cacheLifetime}},{key:"cleanupCache",value:function(){var w=Ne(this.cache),p;try{for(w.s();!(p=w.n()).done;){var h=ce.default(p.value,2),_=h[0],v=h[1];this.isExpired(v.timestamp)&&this.cache.delete(_)}}catch(g){w.e(g)}finally{w.f()}this.cache.size===0&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var w=this;this.timer=this.timer||setInterval(function(){return w.cleanupCache()},this.cacheLifetime*2)}},{key:"executeWithRetry",value:function(w){var p=this,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return new Promise(function(_,v){var g=[502,503,504];h&&g.push(429);var y=new Ee.Retrier(p.configuration.backoffConfiguration);y.on("attempt",function(){w().then(function(k){return y.succeeded(k)}).catch(function(k){g.indexOf(k.status)>-1||k.message==="Twilsock disconnected"?y.failed(k):(y.removeAllListeners(),y.cancel(),v(k))})}),y.on("succeeded",function(k){_(k)}),y.on("cancelled",function(k){return v(k)}),y.on("failed",function(k){return v(k)}),y.start()})}},{key:"get",value:function(){var x=re.default(M.default.mark(function p(h){var _=this,v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(v=this.cache.get(h),!(v&&!this.isExpired(v.timestamp))){S.next=3;break}return S.abrupt("return",v.response);case 3:return g={},S.next=6,this.executeWithRetry(function(){return _.services.transport.get(h,g,_.configuration.productId)},this.configuration.retryWhenThrottled);case 6:return y=S.sent,this.cache.set(h,{response:y,timestamp:Date.now()}),this.pokeTimer(),S.abrupt("return",y);case 10:case"end":return S.stop()}},p,this)}));function w(p){return x.apply(this,arguments)}return w}()}]),C}(),me=ye.default(function C(){ke.default(this,C)});H.default(me,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),H.default(me,"NEW_MESSAGE","twilio.conversations.new_message"),H.default(me,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),H.default(me,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),H.default(me,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");function we(C){var x=K();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function K(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var he=Jt.scope("Participant"),G=function(C){q.default(w,C);var x=we(w);function w(p,h,_,v,g){var y,k,S;if(ke.default(this,w),S=x.call(this),S.conversation=_,S.links=v,S.services=g,S.state={attributes:L(p.attributes,"Retrieved malformed attributes from the server for participant: "+h,he),dateCreated:p.dateCreated?Ot(p.dateCreated):null,dateUpdated:p.dateCreated?Ot(p.dateUpdated):null,sid:h,typingTimeout:null,isTyping:!1,identity:p.identity,roleSid:(y=p.roleSid)!==null&&y!==void 0?y:"",lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,lastReadTimestamp:p.lastConsumptionTimestamp?Ot(p.lastConsumptionTimestamp):null,type:p.type||"chat",userInfo:p.userInfo,bindings:(k=p.bindings)!==null&&k!==void 0?k:{}},!p.identity&&!p.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return S}return ye.default(w,[{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){var h;return(h=this.state.bindings)!==null&&h!==void 0?h:{}}},{key:"_startTyping",value:function(h){var _=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit(w.typingStarted,this),this.conversation.emit(I.typingStarted,this),this.state.typingTimeout=Number(setTimeout(function(){return _._endTyping()},h)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit(w.typingEnded,this),this.conversation.emit(I.typingEnded,this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(h){var _=[],v=L(h.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,he);h.attributes&&!je.default(this.state.attributes,v)&&(this.state.attributes=v,_.push("attributes"));var g=Ot(h.dateUpdated);h.dateUpdated&&(g==null?void 0:g.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=g,_.push("dateUpdated"));var y=Ot(h.dateCreated);if(h.dateCreated&&(y==null?void 0:y.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=y,_.push("dateCreated")),h.roleSid&&this.state.roleSid!==h.roleSid&&(this.state.roleSid=h.roleSid,_.push("roleSid")),(Number.isInteger(h.lastConsumedMessageIndex)||h.lastConsumedMessageIndex===null)&&this.state.lastReadMessageIndex!==h.lastConsumedMessageIndex&&(this.state.lastReadMessageIndex=h.lastConsumedMessageIndex,_.push("lastReadMessageIndex")),h.lastConsumptionTimestamp){var k=new Date(h.lastConsumptionTimestamp);(!this.state.lastReadTimestamp||this.state.lastReadTimestamp.getTime()!==k.getTime())&&(this.state.lastReadTimestamp=k,_.push("lastReadTimestamp"))}return h.bindings&&!je.default(this.state.bindings,h.bindings)&&(this.state.bindings=h.bindings,_.push("bindings")),_.length>0&&this.emit(w.updated,{participant:this,updateReasons:_}),this}},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.type=="chat"){g.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return g.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter);H.default(G,"typingStarted","typingStarted"),H.default(G,"typingEnded","typingEnded"),H.default(G,"updated","updated"),Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],G.prototype,"updateAttributes",null);function de(C){var x=ee();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=Jt.scope("Participants"),qe=function(C){q.default(w,C);var x=de(w);function w(p,h,_,v){var g;return ke.default(this,w),g=x.call(this),H.default(oe.default(g),"rosterEntityPromise",null),g.conversation=p,g.participants=h,g.links=_,g.services=v,g}return ye.default(w,[{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this.rosterEntityPromise){y.next=6;break}return y.next=3,this.rosterEntityPromise;case 3:v=y.sent,v.close(),this.rosterEntityPromise=null;case 6:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"subscribe",value:function(h){var _=this,v=typeof h=="string"?this.services.syncClient.map({id:h,mode:"open_existing"}):Promise.resolve(h);return this.rosterEntityPromise=this.rosterEntityPromise||v.then(function(g){g.on(Oe.SyncMap.itemAdded,function(S){Ye.debug(_.conversation.sid+" itemAdded: "+S.item.key),_.upsertParticipant(S.item.key,S.item.data).then(function(Y){_.emit(I.participantJoined,Y)})}),g.on(Oe.SyncMap.itemRemoved,function(S){Ye.debug(_.conversation.sid+" itemRemoved: "+S.key);var Y=S.key;if(_.participants.has(Y)){var J=_.participants.get(Y);_.participants.delete(Y),J&&_.emit(I.participantLeft,J)}}),g.on(Oe.SyncMap.itemUpdated,function(S){Ye.debug(_.conversation.sid+" itemUpdated: "+S.item.key),_.upsertParticipant(S.item.key,S.item.data).catch(function(Y){return Ye.error(Y)})});var y=[],k=function S(Y){return Y.items.forEach(function(J){y.push(_.upsertParticipant(J.key,J.data))}),Y.hasNextPage?Y.nextPage().then(S):null};return g.getItems().then(k).then(function(){return Promise.all(y)}).then(function(){return g})}).catch(function(g){throw _.rosterEntityPromise=null,_.services.syncClient.connectionState!="disconnected"&&Ye.error("Failed to get roster object for conversation",_.conversation.sid,g),Ye.debug("ERROR: Failed to get roster object for conversation",_.conversation.sid,g),g})}},{key:"upsertParticipantFromResponse",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J,le,ge;return M.default.wrap(function(Et){for(;;)switch(Et.prev=Et.next){case 0:return y=v.sid,k=v.attributes,S=v.date_created,Y=v.date_updated,J=v.identity,le=v.role_sid,ge=v.messaging_binding,Et.next=3,this.upsertParticipant(y,{attributes:k,dateCreated:new Date(S),dateUpdated:new Date(Y),identity:J,roleSid:le,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:(g=ge==null?void 0:ge.type)!==null&&g!==void 0?g:"chat"});case 3:return Et.abrupt("return",Et.sent);case 4:case"end":return Et.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"upsertParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(k=this.participants.get(v),!k){J.next=3;break}return J.abrupt("return",k._update(g));case 3:return S={self:"".concat(this.links.participants,"/").concat(v)},k=new G(g,v,this.conversation,S,this.services),this.participants.set(v,k),k.on(G.updated,function(le){return y.emit(I.participantUpdated,le)}),J.abrupt("return",k);case 8:case"end":return J.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var k=[];return v.participants.forEach(function(S){return k.push(S)}),k}):[]);case 1:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g=this;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var S=g.participants.get(v);if(!S)throw new Error("Participant with SID "+v+" was not found");return S}):null);case 1:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return y=null,S.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){if(g.participants.forEach(function(Y){Y.identity===v&&(y=Y)}),!y)throw new Error("Participant with identity "+v+" was not found");return y}):null);case 2:case"end":return S.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"add",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:v,attributes:typeof g<"u"?JSON.stringify(g):void 0});case 2:return k.abrupt("return",k.sent);case 3:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k,S,Y,J=arguments;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return S=J.length>2&&J[2]!==void 0?J[2]:{},Y=J.length>3&&J[3]!==void 0?J[3]:{},ge.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:typeof S<"u"?JSON.stringify(S):void 0,messaging_binding:{address:g,proxy_address:v,name:Y==null||(y=Y.email)===null||y===void 0?void 0:y.name,level:Y==null||(k=Y.email)===null||k===void 0?void 0:k.level}});case 4:return ge.abrupt("return",ge.sent);case 5:case"end":return ge.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(h){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(h)))}}]),w}(N.ReplayEventEmitter),dt=function(){function C(x,w){var p;ke.default(this,C),H.default(this,"mcsMedia",null),this.services=w,x instanceof ze.McsMedia&&(this.mcsMedia=x),this.state={sid:x.sid,category:x.category,filename:(p=x.filename)!==null&&p!==void 0?p:null,contentType:x.contentType,size:x.size}}return ye.default(C,[{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"category",get:function(){return this.state.category}},{key:"getContentTemporaryUrl",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(k=w.mcsMedia?void 0:w._fetchMcsMedia(),S=(y=w.mcsMedia)===null||y===void 0?void 0:y.getContentUrl(),g(function(){k&&k.cancel(),S&&S.cancel()}),le.prev=3,S){le.next=9;break}return le.next=7,k;case 7:Y=le.sent,S=Y==null?void 0:Y.getContentUrl();case 9:if(le.t0=_,!S){le.next=16;break}return le.next=13,S;case 13:le.t1=le.sent,le.next=17;break;case 16:le.t1=null;case 17:le.t2=le.t1,(0,le.t0)(le.t2),le.next=24;break;case 21:le.prev=21,le.t3=le.catch(3),v(le.t3);case 24:case"end":return le.stop()}},h,null,[[3,21]])}));return function(h,_,v){return p.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return w.services.mcsClient===null&&v(new Error("Media Content Service is unavailable")),y=w.services.mcsClient.get(w.state.sid),g(function(){return y.cancel()}),S.prev=3,S.next=6,y;case 6:w.mcsMedia=S.sent,w.state=w.mcsMedia._state(),_(w.mcsMedia),S.next=14;break;case 11:S.prev=11,S.t0=S.catch(3),v(S.t0);case 14:case"end":return S.stop()}},h,null,[[3,11]])}));return function(h,_,v){return p.apply(this,arguments)}}())}},{key:"_state",value:function(){return this.state}}]),C}(),lt=function(){function C(x){ke.default(this,C),this.state=x}return ye.default(C,[{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}},{key:"_update",value:function(w){this.state=w}},{key:"_isEquals",value:function(w){var p=this.total===w.total,h=this.sent===w.sent,_=this.delivered===w.delivered,v=this.read===w.read,g=this.undelivered===w.undelivered,y=this.failed===w.failed;return p&&h&&_&&v&&g&&y}}]),C}(),ht=function(){function C(x,w,p,h){ke.default(this,C),this.state={prevToken:p,nextToken:h,source:w,items:x}}return ye.default(C,[{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}},{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):Promise.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):Promise.reject(new Error("No previous page"))}}]),C}(),Rt=ye.default(function C(x){ke.default(this,C),this.sid=x.sid,this.messageSid=x.message_sid,this.conversationSid=x.conversation_sid,this.channelMessageSid=x.channel_message_sid,this.participantSid=x.participant_sid,this.status=x.status||"queued",this.errorCode=x.error_code||0,this.dateCreated=x.date_created,this.dateUpdated=x.date_updated}),xt=function(x){return x.map(function(w){var p,h,_,v,g=JSON.stringify(w);switch(w.type){case"QUICK_REPLY":return{type:"reply",title:w.title,id:(p=w.id)!==null&&p!==void 0?p:"",index:(h=w.index)!==null&&h!==void 0?h:0,rawData:g};case"PHONE_NUMBER":return{type:"phone",title:w.title,phone:(_=w.phone)!==null&&_!==void 0?_:"",rawData:g};case"URL":return{type:"url",title:w.title,url:(v=w.url)!==null&&v!==void 0?v:"",rawData:g};default:return{type:"other",rawData:g}}})},kt=function(x,w){var p=JSON.stringify(w);switch(x){case"twilio/text":{var h=w;return{type:"text",body:h.body,rawData:p}}case"twilio/media":{var _=w;return{type:"media",body:_.body,media:_.media,rawData:p}}case"twilio/location":{var v=w;return{type:"location",longitude:v.longitude,latitude:v.latitude,label:v.label,rawData:p}}case"twilio/quick-reply":{var g=w;return{type:"quickReply",body:g.body,replies:g.actions,rawData:p}}case"twilio/call-to-action":{var y=w;return{type:"callToAction",body:y.body,actions:xt(y.actions),rawData:p}}case"twilio/list-picker":{var k=w;return{type:"listPicker",body:k.body,button:k.button,items:k.items,rawData:p}}case"twilio/card":{var S,Y,J=w;return{type:"card",title:J.title,subtitle:J.subtitle,media:(S=J.media)!==null&&S!==void 0?S:[],actions:xt((Y=J.actions)!==null&&Y!==void 0?Y:[]),rawData:p}}default:return{type:"other",rawData:p}}},$t=function(x){for(var w=new Map,p=0,h=Object.entries(x);p<h.length;p++){var _=ce.default(h[p],2),v=_[0],g=_[1];w.set(v,kt(v,g))}return w},It=function(){function C(x,w){ke.default(this,C),this.name=x,this.value=w}return ye.default(C,[{key:"copyWithValue",value:function(w){return new C(this.name,w)}}]),C}(),jt=ye.default(function C(x){ke.default(this,C),this.sid=x.sid,this.friendlyName=x.friendly_name,this.variables=Object.entries(JSON.parse(x.variables)).map(function(w){var p=ce.default(w,2),h=p[0],_=p[1];return new It(h,_)}),this.variants=$t(x.variants),this.dateCreated=new Date(x.date_created),this.dateUpdated=new Date(x.date_updated)});function on(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function _n(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?on(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):on(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Ut(C){var x=qn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function qn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function pa(C,x){Za(C,x),x.add(C)}function Za(C,x){if(x.has(C))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ti(C,x,w){if(!x.has(C))throw new TypeError("attempted to get private field on non-instance");return w}var va=Jt.scope("Message"),ri=e.XMLHttpRequest||{},gi=new WeakSet,Ga=new WeakSet,en=function(C){q.default(w,C);var x=Ut(w);function w(p,h,_,v,g,y){var k,S,Y,J,le,ge,vt,Et;return ke.default(this,w),Et=x.call(this),pa(oe.default(Et),Ga),pa(oe.default(Et),gi),Et.conversation=_,Et.links=v,Et.configuration=g,Et.services=y,Et.state={sid:h.sid,index:p,author:h.author,subject:h.subject,contentSid:h.contentSid,body:(k=h.text)!==null&&k!==void 0?k:null,timestamp:h.timestamp?new Date(h.timestamp):null,dateUpdated:h.dateUpdated?new Date(h.dateUpdated):null,lastUpdatedBy:(S=h.lastUpdatedBy)!==null&&S!==void 0?S:null,attributes:L(h.attributes,"Got malformed attributes for the message ".concat(h.sid),va),type:(Y=h.type)!==null&&Y!==void 0?Y:"text",media:null,medias:null,participantSid:(J=h.memberSid)!==null&&J!==void 0?J:null,aggregatedDeliveryReceipt:h.delivery?new lt(h.delivery):null,hasChannelMetadata:(le=h.channelMetadata)!==null&&le!==void 0?le:!1},ti(oe.default(Et),Ga,Ns).call(oe.default(Et),(ge=h.medias)!==null&&ge!==void 0?ge:null,(vt=h.media)!==null&&vt!==void 0?vt:null),Et}return ye.default(w,[{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"contentSid",get:function(){return this.state.contentSid}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategories(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}},{key:"getMediaByCategory",value:function(h){return this.getMediaByCategories(h)}},{key:"getMediaByCategories",value:function(h){var _;return((_=this.state.medias)!==null&&_!==void 0?_:[]).filter(function(v){return h.includes(v.category)})}},{key:"getEmailBody",value:function(){var h,_,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(_=this.getMediaByCategories(["body"]))===null||_===void 0?void 0:_.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"getEmailHistory",value:function(){var h,_,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(_=this.getMediaByCategories(["history"]))===null||_===void 0?void 0:_.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"_update",value:function(h){var _,v=this,g,y,k,S=[];(h.text||typeof h.text=="string")&&h.text!==this.state.body&&(this.state.body=h.text,S.push("body")),h.subject&&h.subject!==this.state.subject&&(this.state.subject=h.subject,S.push("subject")),h.lastUpdatedBy&&h.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=h.lastUpdatedBy,S.push("lastUpdatedBy")),h.author&&h.author!==this.state.author&&(this.state.author=h.author,S.push("author")),h.dateUpdated&&new Date(h.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(h.dateUpdated),S.push("dateUpdated")),h.timestamp&&new Date(h.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(h.timestamp),S.push("dateCreated"));var Y=L(h.attributes,"Got malformed attributes for the message ".concat(this.sid),va);je.default(this.state.attributes,Y)||(this.state.attributes=Y,S.push("attributes"));var J=h.delivery,le=this.state.aggregatedDeliveryReceipt,ge=!!J&&!!J.total&&!!J.delivered&&!!J.failed&&!!J.read&&!!J.sent&&!!J.undelivered;ge&&(le?le._isEquals(J)||(le._update(J),S.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new lt(J),S.push("deliveryReceipt")));var vt=((_=h.medias)!==null&&_!==void 0?_:[]).map(function(_r){var mr;return(mr=ti(v,gi,ji).call(v,_r))===null||mr===void 0?void 0:mr._state()}).filter(function(_r){return _r!==null}),Et=((g=this.state.medias)!==null&&g!==void 0?g:[]).map(function(_r){return _r._state()}).filter(function(_r){return _r!==null});if(!je.default(vt,Et)||!je.default((y=ti(this,gi,ji).call(this,h.media))===null||y===void 0?void 0:y._state(),(k=this.state.media)===null||k===void 0?void 0:k._state())){var Ht,Qt;ti(this,Ga,Ns).call(this,(Ht=h.medias)!==null&&Ht!==void 0?Ht:null,(Qt=h.media)!==null&&Qt!==void 0?Qt:null),S.push("media")}S.length>0&&this.emit("updated",{message:this,updateReasons:S})}},{key:"getParticipant",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(g=null,!this.state.participantSid){S.next=5;break}return S.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch(function(){return va.debug('Participant with sid "'.concat(v.participantSid,'" not found for message ').concat(v.sid)),null});case 4:g=S.sent;case 5:if(!(!g&&this.state.author)){S.next=9;break}return S.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch(function(){return va.debug('Participant with identity "'.concat(v.author,'" not found for message ').concat(v.sid)),null});case 8:g=S.sent;case 9:if(!g){S.next=11;break}return S.abrupt("return",g);case 11:throw y="Participant with ",this.state.participantSid&&(y+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(y+="or "),y+="identity '"+this.state.author+"' "),y==="Participant with "&&(y="Participant "),y+="was not found",new Error(y);case 17:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getDetailedDeliveryReceipts",value:function(){var p=re.default(M.default.mark(function _(){var v,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:v=k.sent,g=v.items;case 4:if(!v.hasNextPage){k.next=11;break}return k.next=7,v.nextPage();case 7:v=k.sent,g=[].concat(rt.default(g),rt.default(v.items)),k.next=4;break;case 11:return k.abrupt("return",g);case 12:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateBody",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:v});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:typeof v<"u"?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"attachTemporaryUrlsFor",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(y=v==null?void 0:v.map(function(Y){return Y.sid}),!(this.services.mcsClient&&y)){S.next=7;break}return S.next=4,this.services.mcsClient.mediaSetGet(y);case 4:return S.abrupt("return",S.sent.map(function(Y){return new dt(Y,g.services)}));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return S.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMedia",value:function(h){var _=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var _=this;return new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(Y=_.services.mcsClient.mediaSetGetContentUrls(h??[]),!(!_.services.mcsClient||!h)){ge.next=4;break}return k(new Error("Media Content Service is unavailable")),ge.abrupt("return");case 4:return S(function(){Y.cancel()}),ge.prev=5,ge.next=8,Y;case 8:J=ge.sent,y(J),ge.next=15;break;case 12:ge.prev=12,ge.t0=ge.catch(5),k(ge.t0);case 15:case"end":return ge.stop()}},g,null,[[5,12]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var h,_=this.attachedMedia,v=(h=_==null?void 0:_.map(function(g){return g.sid}))!==null&&h!==void 0?h:[];return this.getTemporaryContentUrlsForMediaSids(v)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),k=new W(y).arg("PageToken",v==null?void 0:v.pageToken).arg("PageSize",v==null?void 0:v.pageSize).build(),J.next=4,this.services.network.get(k);case 4:return S=J.sent,J.abrupt("return",new ht(S.body.delivery_receipts.map(function(le){return new Rt(le)}),function(le,ge){return g._getDetailedDeliveryReceiptsPaginator({pageToken:le,pageSize:ge})},S.body.meta.previous_token,S.body.meta.next_token));case 6:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getContentData",value:function(){var h=this;return new ze.CancellablePromise(function(){var _=re.default(M.default.mark(function v(g,y,k){var S,Y,J,le,ge,vt,Et,Ht,Qt,_r;return M.default.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:if(h.state.contentSid!==null){Gt.next=3;break}return g(null),Gt.abrupt("return");case 3:if(S=h.getMediaByCategories(["body"]),S!==null){Gt.next=7;break}return g(null),Gt.abrupt("return");case 7:if(Y="application/x-vnd.com.twilio.rich.",J=S.filter(function(yi){return yi.contentType.startsWith(Y)}),J.length!==0){Gt.next=12;break}return g(null),Gt.abrupt("return");case 12:return le=J[0],ge=le.getContentTemporaryUrl(),k(function(){ge.cancel()}),Gt.prev=15,Gt.next=18,ge;case 18:vt=Gt.sent,Gt.next=25;break;case 21:return Gt.prev=21,Gt.t0=Gt.catch(15),y(Gt.t0),Gt.abrupt("return");case 25:if(vt!==null){Gt.next=28;break}return g(null),Gt.abrupt("return");case 28:return Et=new Promise(function(yi,tv){var Lt,Fs=!1,bi=new ri;bi.open("GET",(Lt=vt)!==null&&Lt!==void 0?Lt:"",!0),bi.responseType="text",bi.onreadystatechange=function(){bi.readyState!==4||Fs||yi(bi.responseText)},bi.onerror=function(){tv(bi.statusText)},k(function(){Fs=!0,bi.abort(),tv(new Error("XHR has been aborted"))}),bi.send()}),Gt.prev=29,Gt.next=32,Et;case 32:Qt=Gt.sent,Ht=JSON.parse(Qt),Gt.next=40;break;case 36:return Gt.prev=36,Gt.t1=Gt.catch(29),y(Gt.t1),Gt.abrupt("return");case 40:_r=le.contentType.replace(Y,"").replace(".","/"),g(kt(_r,Ht.data));case 42:case"end":return Gt.stop()}},v,null,[[15,21],[29,36]])}));return function(v,g,y){return _.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.state.hasChannelMetadata){g.next=2;break}return g.abrupt("return",null);case 2:return g.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid,this.sid);case 2:return g.abrupt("return",g.sent);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter);function ji(C){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return C?x?new dt(_n(_n({},C),{},{category:x}),this.services):new dt(C,this.services):null}function Ns(C,x){var w=this;this.state.media=ti(this,gi,ji).call(this,x),this.state.medias=C?C.map(function(p){return ti(w,gi,ji).call(w,p)}).filter(function(p){return p!==null}):x&&!C?[ti(this,gi,ji).call(this,x,"media")].filter(function(p){return p!==null}):null}H.default(en,"updated","updated"),Be([V.deprecated("getMediaByCategory","getMediaByCategories"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Array)],en.prototype,"getMediaByCategory",null),Be([b.validateTypes([b.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",dt)],en.prototype,"getEmailBody",null),Be([b.validateTypes([b.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",dt)],en.prototype,"getEmailHistory",null),Be([b.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],en.prototype,"updateBody",null),Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],en.prototype,"updateAttributes",null),Be([V.deprecated("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Promise)],en.prototype,"attachTemporaryUrlsFor",null),Be([b.validateTypesAsync(b.nonEmptyArray("media",dt)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],en.prototype,"getTemporaryContentUrlsForMedia",null),Be([b.validateTypesAsync(b.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],en.prototype,"getTemporaryContentUrlsForMediaSids",null);function Ui(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Ls(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Ui(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Ui(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function zo(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Vn(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1331
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Vn(C,x){if(C){if(typeof C=="string")return Ds(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Ds(C,x)}}function Ds(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function Ho(C){var x=qo();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function qo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var hn=Jt.scope("Messages"),js=function(C){q.default(w,C);var x=Ho(w);function w(p,h,_){var v;return ke.default(this,w),v=x.call(this),v.conversation=p,v.configuration=h,v.services=_,v.messagesByIndex=new Map,v.messagesListPromise=null,v}return ye.default(w,[{key:"subscribe",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!this.messagesListPromise){S.next=2;break}return S.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise=typeof v=="string"?this.services.syncClient.list({id:v,mode:"open_existing"}):Promise.resolve(v),S.prev=3,S.next=6,this.messagesListPromise;case 6:return y=S.sent,y.on("itemAdded",function(Y){hn.debug("".concat(g.conversation.sid," itemAdded: ").concat(Y.item.index));var J={self:"".concat(g.conversation._links.messages,"/").concat(Y.item.data.sid),conversation:g.conversation._links.self,messages_receipts:"".concat(g.conversation._links.messages,"/").concat(Y.item.data.sid,"/Receipts")},le=new en(Y.item.index,Y.item.data,g.conversation,J,g.configuration,g.services);if(g.messagesByIndex.has(le.index)){hn.debug("Message arrived, but is already known and ignored",g.conversation.sid,le.index);return}g.messagesByIndex.set(le.index,le),le.on("updated",function(ge){return g.emit("messageUpdated",ge)}),g.emit("messageAdded",le)}),y.on("itemRemoved",function(Y){hn.debug("#{this.conversation.sid} itemRemoved: ".concat(Y.index));var J=Y.index;if(g.messagesByIndex.has(J)){var le=g.messagesByIndex.get(J);if(!le)return;g.messagesByIndex.delete(le.index),le.removeAllListeners("updated"),g.emit("messageRemoved",le)}}),y.on("itemUpdated",function(Y){hn.debug("".concat(g.conversation.sid," itemUpdated: ").concat(Y.item.index));var J=g.messagesByIndex.get(Y.item.index);J&&J._update(Y.item.data)}),S.abrupt("return",y);case 13:throw S.prev=13,S.t0=S.catch(3),this.messagesListPromise=null,this.services.syncClient.connectionState!=="disconnected"&&hn.error("Failed to get messages object for conversation",this.conversation.sid,S.t0),hn.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,S.t0),S.t0;case 19:case"end":return S.stop()}},_,this,[[3,13]])}));function h(_){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.messagesListPromise){y.next=2;break}return y.abrupt("return");case 2:return y.next=4,this.messagesListPromise;case 4:v=y.sent,v.close(),this.messagesListPromise=null;case 7:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"sendV2",value:function(h){var _=this;return hn.debug("Sending message V2",h.mediaContent,h.attributes,h.emailOptions),new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J,le,ge,vt,Et,Ht,Qt,_r,mr,Gt,yi;return M.default.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:J=[],le=[],S(function(){le.forEach(function(Fs){return Fs.cancel()})}),ge=zo(h.mediaContent),Lt.prev=4,ge.s();case 6:if((vt=ge.n()).done){Lt.next=25;break}return Et=ce.default(vt.value,2),Ht=Et[0],Qt=Et[1],Lt.prev=8,hn.debug("Adding media to a message as ".concat(Qt instanceof FormData?"FormData":"SendMediaOptions"),Qt),Gt=Qt instanceof FormData?_.services.mcsClient.postFormData(Qt,Ht):_.services.mcsClient.post((_r=Qt.contentType)!==null&&_r!==void 0?_r:"",(mr=Qt.media)!==null&&mr!==void 0?mr:"",Ht,Qt.filename),le.push(Gt),Lt.t0=J,Lt.next=15,Gt;case 15:Lt.t1=Lt.sent,Lt.t0.push.call(Lt.t0,Lt.t1),Lt.next=23;break;case 19:return Lt.prev=19,Lt.t2=Lt.catch(8),k(Lt.t2),Lt.abrupt("return");case 23:Lt.next=6;break;case 25:Lt.next=30;break;case 27:Lt.prev=27,Lt.t3=Lt.catch(4),ge.e(Lt.t3);case 30:return Lt.prev=30,ge.f(),Lt.finish(30);case 33:return yi=_.services.commandExecutor.mutateResource("post",_.conversation._links.messages,{body:h.text,subject:(Y=h.emailOptions)===null||Y===void 0?void 0:Y.subject,media_sids:J.map(function(Fs){return Fs.sid}),attributes:typeof h.attributes<"u"?JSON.stringify(h.attributes):void 0,content_sid:h.contentSid,content_variables:typeof h.contentVariables<"u"?JSON.stringify(h.contentVariables.reduce(function(Fs,bi){return Ls(Ls({},Fs),{},H.default({},bi.name,bi.value))},{})):void 0}),Lt.prev=34,Lt.t4=y,Lt.next=38,yi;case 38:Lt.t5=Lt.sent,(0,Lt.t4)(Lt.t5),Lt.next=45;break;case 42:Lt.prev=42,Lt.t6=Lt.catch(34),k(Lt.t6);case 45:case"end":return Lt.stop()}},g,null,[[4,27,30,33],[8,19],[34,42]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"send",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k=arguments;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return g=k.length>1&&k[1]!==void 0?k[1]:{},y=k.length>2?k[2]:void 0,hn.debug("Sending text message",v,g,y),Y.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:v??"",attributes:typeof g<"u"?JSON.stringify(g):void 0,subject:y==null?void 0:y.subject}));case 4:case"end":return Y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"sendMedia",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J=arguments;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(k=J.length>1&&J[1]!==void 0?J[1]:{},S=J.length>2?J[2]:void 0,hn.debug("Sending media message",v,k,S),hn.debug("Sending media message as ".concat(v instanceof FormData?"FormData":"SendMediaOptions"),v,k),!(v instanceof FormData)){ge.next=10;break}return ge.next=7,this.services.mcsClient.postFormData(v);case 7:ge.t0=ge.sent,ge.next=13;break;case 10:return ge.next=12,this.services.mcsClient.post((g=v.contentType)!==null&&g!==void 0?g:"",(y=v.media)!==null&&y!==void 0?y:"","media",v.filename);case 12:ge.t0=ge.sent;case 13:return Y=ge.t0,ge.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[Y.sid],attributes:typeof k<"u"?JSON.stringify(k):void 0});case 16:return ge.abrupt("return",ge.sent);case 17:case"end":return ge.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k=arguments;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=k.length>2&&k[2]!==void 0?k[2]:"backwards",Y.abrupt("return",this._getMessages(v,g,y));case 2:case"end":return Y.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_wrapPaginator",value:function(h,_,v){var g=this,y=h==="desc",k=function(){return _.nextPage().then(function(J){return g._wrapPaginator(h,J,v)})},S=function(){return _.prevPage().then(function(J){return g._wrapPaginator(h,J,v)})};return v(_.items).then(function(Y){return{items:Y.sort(function(J,le){return J.index-le.index}),hasPrevPage:y?_.hasNextPage:_.hasPrevPage,hasNextPage:y?_.hasPrevPage:_.hasNextPage,prevPage:y?k:S,nextPage:y?S:k}})}},{key:"_upsertMessage",value:function(h,_){var v=this,g=this.messagesByIndex.get(h);if(g)return g;var y={self:"".concat(this.conversation._links.messages,"/").concat(_.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(_.sid,"/Receipts")},k=new en(h,_,this.conversation,y,this.configuration,this.services);return this.messagesByIndex.set(k.index,k),k.on("updated",function(S){return v.emit("messageUpdated",S)}),k}},{key:"_getMessages",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y,k,S,Y,J,le=arguments;return M.default.wrap(function(vt){for(;;)switch(vt.prev=vt.next){case 0:return g=le.length>0&&le[0]!==void 0?le[0]:30,y=le.length>1&&le[1]!==void 0?le[1]:"end",k=le.length>2&&le[2]!==void 0?le[2]:"forward",S=k==="backwards"?"desc":"asc",vt.next=6,this.messagesListPromise;case 6:return Y=vt.sent,vt.next=9,Y==null?void 0:Y.getItems({from:y!=="end"?y:void 0,pageSize:g,order:S,limit:g});case 9:return J=vt.sent,vt.next=12,this._wrapPaginator(S,J,function(Et){return Promise.all(Et.map(function(Ht){return v._upsertMessage(Ht.index,Ht.data)}))});case 12:return vt.abrupt("return",vt.sent);case 13:case"end":return vt.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter),Pn=function(){function C(x){ke.default(this,C),H.default(this,"attributes",{}),H.default(this,"mediaContent",[]),H.default(this,"emailOptions",{}),this.messagesEntity=x}return ye.default(C,[{key:"send",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=w.messagesEntity.sendV2(w),g(function(){return y.cancel()}),Y.prev=2,Y.next=5,y;case 5:k=Y.sent,_(Wt(k.index)),Y.next=12;break;case 9:Y.prev=9,Y.t0=Y.catch(2),v(Y.t0);case 12:case"end":return Y.stop()}},h,null,[[2,9]])}));return function(h,_,v){return p.apply(this,arguments)}}())}}]),C}(),Dr=function(){function C(x,w){ke.default(this,C),this.limits=x,this.message=new Pn(w),this.emailBodies=new Map,this.emailHistories=new Map}return ye.default(C,[{key:"setBody",value:function(w){return this.message.text=w,this}},{key:"setSubject",value:function(w){return this.message.emailOptions.subject=w,this}},{key:"setAttributes",value:function(w){return this.message.attributes=w,this}},{key:"setEmailBody",value:function(w,p){return this.emailBodies.set(w,p),this}},{key:"setEmailHistory",value:function(w,p){return this.emailHistories.set(w,p),this}},{key:"setContentTemplate",value:function(w){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return this.message.contentSid=w,this.message.contentVariables=p,this}},{key:"addMedia",value:function(w){if(typeof FormData>"u"&&w instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(w instanceof FormData)){var p=w;if(!p.contentType||!p.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",w]),this}},{key:"build",value:function(){var w=this;if(this.emailBodies.forEach(function(p,h){if(!w.limits.emailBodiesAllowedContentTypes.includes(h))throw new Error("Unsupported email body content type ".concat(h))}),this.emailHistories.forEach(function(p,h){if(!w.limits.emailHistoriesAllowedContentTypes.includes(h))throw new Error("Unsupported email history content type ".concat(h))}),this.emailBodies.size>this.limits.emailBodiesAllowedContentTypes.length)throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size," > ").concat(this.limits.emailBodiesAllowedContentTypes.length,")"));if(this.emailHistories.size>this.limits.emailHistoriesAllowedContentTypes.length)throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size," > ").concat(this.limits.emailHistoriesAllowedContentTypes.length,")"));if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length," > ").concat(this.limits.mediaAttachmentsCountLimit,")"));return this.emailBodies.forEach(function(p){w.message.mediaContent.push(["body",p])}),this.emailHistories.forEach(function(p){w.message.mediaContent.push(["history",p])}),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),C}();Be([b.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Dr)],Dr.prototype,"setBody",null),Be([b.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Dr)],Dr.prototype,"setSubject",null),Be([b.validateTypes(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Dr)],Dr.prototype,"setAttributes",null),Be([b.validateTypes("string",[FormData,ct]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Dr)],Dr.prototype,"setEmailBody",null),Be([b.validateTypes("string",[FormData,ct]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Dr)],Dr.prototype,"setEmailHistory",null),Be([b.validateTypes("string",[b.array("content variables",It),"undefined"]),be("design:type",Function),be("design:paramtypes",[String,Array]),be("design:returntype",Dr)],Dr.prototype,"setContentTemplate",null),Be([b.validateTypes([FormData,ct]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Dr)],Dr.prototype,"addMedia",null);function Vo(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=ni(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1332
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function ni(C,x){if(C){if(typeof C=="string")return Mn(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Mn(C,x)}}function Mn(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function Us(C){var x=te();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function te(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ue={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},I=function(C){q.default(w,C);var x=Us(w);function w(p,h,_,v,g){var y,k,S;ke.default(this,w),S=x.call(this),S.sid=h,S._links=_,S._configuration=v,S._services=g,S._entityName=p.channel,S._internalState={uniqueName:p.uniqueName||null,status:"notParticipating",attributes:(y=p.attributes)!==null&&y!==void 0?y:{},createdBy:p.createdBy,dateCreated:Ot(p.dateCreated),dateUpdated:Ot(p.dateUpdated),friendlyName:p.friendlyName||null,lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,bindings:(k=p.bindings)!==null&&k!==void 0?k:{}},p.notificationLevel&&(S._internalState.notificationLevel=p.notificationLevel);var Y={participants:S._links.participants};return S._participants=new Map,S._participantsEntity=new qe(oe.default(S),S._participants,Y,S._services),S._participantsEntity.on(w.participantJoined,function(J){return S.emit(w.participantJoined,J)}),S._participantsEntity.on(w.participantLeft,function(J){return S.emit(w.participantLeft,J)}),S._participantsEntity.on(w.participantUpdated,function(J){return S.emit(w.participantUpdated,J)}),S._messagesEntity=new js(oe.default(S),v,g),S._messagesEntity.on(w.messageAdded,function(J){return S._onMessageAdded(J)}),S._messagesEntity.on(w.messageUpdated,function(J){return S.emit(w.messageUpdated,J)}),S._messagesEntity.on(w.messageRemoved,function(J){return S.emit(w.messageRemoved,J)}),S}return ye.default(w,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var h;return(h=this._internalState.createdBy)!==null&&h!==void 0?h:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var h;return(h=this._internalState.lastMessage)!==null&&h!==void 0?h:void 0}},{key:"notificationLevel",get:function(){var h;return(h=this._internalState.notificationLevel)!==null&&h!==void 0?h:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.abrupt("return",this._participantsEntity.add(v,g??{}));case 1:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k,S=arguments;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=S.length>2&&S[2]!==void 0?S[2]:{},k=S.length>3&&S[3]!==void 0?S[3]:{},J.abrupt("return",this._participantsEntity.addNonChatParticipant(v,g,y??{},k??{}));case 3:case"end":return J.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"advanceLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._subscribeStreams();case 2:if(!(v<((g=this.lastReadMessageIndex)!==null&&g!==void 0?g:0))){k.next=6;break}return k.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:return k.abrupt("return",k.sent);case 6:return k.next=8,this._setLastReadMessageIndex(v);case 8:return k.abrupt("return",k.sent);case 9:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"delete",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getAttributes",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribe();case 2:return g.abrupt("return",this.attributes);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=re.default(M.default.mark(function _(v,g,y){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._subscribeStreams();case 2:return S.abrupt("return",this._messagesEntity.getMessages(v,g,y));case 3:case"end":return S.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantsCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new W(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.participants_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this._participantsEntity.getParticipantBySid(v));case 1:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=re.default(M.default.mark(function _(){var v,g=arguments;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return v=g.length>0&&g[0]!==void 0?g[0]:"",k.abrupt("return",this._participantsEntity.getParticipantByIdentity(v??""));case 2:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessagesCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new W(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.messages_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getUnreadMessagesCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return v=new W(this._configuration.links.myConversations).path(this.sid).build(),S.next=3,this._services.network.get(v);case 3:if(g=S.sent,g.body.conversation_sid===this.sid){S.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if(y=g.body.unread_messages_count,typeof y!="number"){S.next=9;break}return S.abrupt("return",y);case 9:return S.abrupt("return",null);case 10:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"join",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"leave",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this._internalState.status!=="joined"){g.next=3;break}return g.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return g.abrupt("return",this);case 4:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"removeParticipant",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._participantsEntity.remove(typeof v=="string"?v:v.sid);case 2:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"sendMessage",value:function(){var p=re.default(M.default.mark(function _(v,g,y){var k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(!(typeof v=="string"||v===null)){ge.next=5;break}return ge.next=3,this._messagesEntity.send(v,g,y);case 3:return Y=ge.sent,ge.abrupt("return",(S=Wt(Y.index))!==null&&S!==void 0?S:0);case 5:return ge.next=7,this._messagesEntity.sendMedia(v,g,y);case 7:return J=ge.sent,ge.abrupt("return",(k=Wt(J.index))!==null&&k!==void 0?k:0);case 9:case"end":return ge.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"prepareMessage",value:function(){return new Dr(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.next=4,this.getMessages(1);case 4:if(v=y.sent,!(v.items.length>0)){y.next=7;break}return y.abrupt("return",this.advanceLastReadMessageIndex(v.items[0].index));case 7:return y.abrupt("return",0);case 8:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setAllMessagesUnread",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.next=4,this._setLastReadMessageIndex(null);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setUserNotificationLevel",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:v});case 2:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:v!==void 0?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.friendlyName===v){y.next=3;break}return y.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:v});case 3:return y.abrupt("return",this);case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.abrupt("return",this._setLastReadMessageIndex(v));case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.uniqueName===v){y.next=4;break}return v||(v=""),y.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:v});case 4:return y.abrupt("return",this);case 5:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,v);case 2:return y.abrupt("return",y.sent);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"_subscribe",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._entityPromise){y.next=2;break}return y.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),y.prev=3,y.next=6,this._entityPromise;case 6:return this._entity=y.sent,this._entity.on(Oe.SyncDocument.updated,function(k){return v._update(k.data)}),this._entity.on(Oe.SyncDocument.removed,function(){return v.emit(w.removed,v)}),this._update(this._entity.data),y.abrupt("return",this._entity);case 13:throw y.prev=13,y.t0=y.catch(3),this._entity=null,this._entityPromise=null,this._services.syncClient.connectionState!="disconnected"&&w._logger.error("Failed to get conversation object",y.t0),w._logger.debug("ERROR: Failed to get conversation object",y.t0),y.t0;case 20:case"end":return y.stop()}},_,this,[[3,13]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_fetchStreams",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._streamsPromise){y.next=2;break}return y.abrupt("return",this._streamsPromise);case 2:return this._streamsPromise=new Promise(function(){var k=re.default(M.default.mark(function S(Y,J){var le,ge,vt,Et,Ht;return M.default.wrap(function(_r){for(;;)switch(_r.prev=_r.next){case 0:return _r.prev=0,_r.next=3,v._subscribe();case 3:_r.next=9;break;case 5:return _r.prev=5,_r.t0=_r.catch(0),w._logger.trace("Failed to subscribe to conversation",_r.t0),_r.abrupt("return",J(_r.t0));case 9:w._logger.trace("_streamsAvailable, this.entity.data=",(le=v._entity)===null||le===void 0?void 0:le.data),vt=(ge=v._entity)===null||ge===void 0?void 0:ge.data,Et=v._services.syncClient.list({id:vt.messages,mode:"open_existing"}).then(function(mr){return v._messagesList=mr,mr}),Ht=v._services.syncClient.map({id:vt.roster,mode:"open_existing"}).then(function(mr){return v._participantsMap=mr,mr}),Promise.all([Et,Ht]).then(function(){return Y(!0)}).catch(function(mr){w._logger.trace("Failed to fetch conversation streams for conversation",v.sid,mr),J(mr)});case 14:case"end":return _r.stop()}},S,null,[[0,5]])}));return function(S,Y){return k.apply(this,arguments)}}()),y.abrupt("return",this._streamsPromise.catch(function(k){throw v._streamsPromise=null,k}));case 4:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeStreams",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y,k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return ge.prev=0,ge.next=3,this._fetchStreams();case 3:return w._logger.trace("_subscribeStreams, this.entity.data=",(v=this._entity)===null||v===void 0?void 0:v.data),S=(g=this._entity)===null||g===void 0?void 0:g.data,Y=S.messages,J=S.roster,ge.next=9,Promise.all([this._messagesEntity.subscribe((y=this._messagesList)!==null&&y!==void 0?y:Y),this._participantsEntity.subscribe((k=this._participantsMap)!==null&&k!==void 0?k:J)]);case 9:ge.next=16;break;case 11:throw ge.prev=11,ge.t0=ge.catch(0),this._services.syncClient.connectionState!=="disconnected"&&w._logger.error("Failed to subscribe on conversation objects",this.sid,ge.t0),w._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,ge.t0),ge.t0;case 16:case"end":return ge.stop()}},_,this,[[0,11]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),g.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_setStatus",value:function(h,_){var v=this;if(this._dataSource=_,this._internalState.status!==h){if(this._internalState.status=h,h==="joined"){this._subscribeStreams().catch(function(g){if(w._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g});return}this._entityPromise&&this._unsubscribe().catch(function(g){if(w._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g})}}},{key:"_update",value:function(h){var _,v,g,y,k;w._logger.trace("_update",h),w.preprocessUpdate(h,this.sid);for(var S=new Set,Y=0,J=Object.keys(h);Y<J.length;Y++){var le=J[Y],ge=ue[le];if(ge)switch(ge){case ue.status:if(!h.status||h.status==="unknown"||this._internalState.status===h.status)break;this._internalState.status=h.status,S.add(ge);break;case ue.attributes:if(je.default(this._internalState.attributes,h.attributes))break;this._internalState.attributes=h.attributes,S.add(ge);break;case ue.lastConsumedMessageIndex:if(h.lastConsumedMessageIndex===void 0||h.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=h.lastConsumedMessageIndex,S.add("lastReadMessageIndex");break;case ue.lastMessage:if(this._internalState.lastMessage&&!h.lastMessage){delete this._internalState.lastMessage,S.add(ge);break}this._internalState.lastMessage=this._internalState.lastMessage||{},((_=h.lastMessage)===null||_===void 0?void 0:_.index)!==void 0&&h.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=h.lastMessage.index,S.add(ge)),((v=h.lastMessage)===null||v===void 0?void 0:v.timestamp)!==void 0&&((g=this._internalState.lastMessage)===null||g===void 0||(y=g.dateCreated)===null||y===void 0?void 0:y.getTime())!==h.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=h.lastMessage.timestamp,S.add(ge)),je.default(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case ue.state:var vt=h.state||void 0;if(vt!==void 0&&(vt.dateUpdated=new Date(vt.dateUpdated)),je.default(this._internalState.state,vt))break;this._internalState.state=vt,S.add(ge);break;case ue.bindings:if(je.default(this._internalState.bindings,h.bindings))break;this._internalState.bindings=h.bindings,S.add(ge);break;default:var Et=h[le]instanceof Date,Ht=Et&&((k=this._internalState[ge])===null||k===void 0?void 0:k.getTime())===h[le].getTime(),Qt=!Et&&this[ge]===h[le];if(Ht||Qt)break;this._internalState[ge]=h[le],S.add(ge)}}S.size>0&&this.emit(w.updated,{conversation:this,updateReasons:rt.default(S)})}},{key:"_onMessageAdded",value:function(h){var _=Vo(this._participants.values()),v;try{for(_.s();!(v=_.n()).done;){var g=v.value;if(g.identity===h.author){g._endTyping();break}}}catch(y){_.e(y)}finally{_.f()}this.emit(w.messageAdded,h)}},{key:"_setLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:v});case 2:return g=k.sent,k.abrupt("return",g.unread_messages_count);case 4:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}],[{key:"preprocessUpdate",value:function(h,_){try{typeof h.attributes=="string"?h.attributes=JSON.parse(h.attributes):h.attributes&&JSON.stringify(h.attributes)}catch{w._logger.warn("Retrieved malformed attributes from the server for conversation: "+_),h.attributes={}}try{h.dateCreated&&(h.dateCreated=new Date(h.dateCreated))}catch{w._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+_),delete h.dateCreated}try{h.dateUpdated&&(h.dateUpdated=new Date(h.dateUpdated))}catch{w._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+_),delete h.dateUpdated}try{h.lastMessage&&h.lastMessage.timestamp&&(h.lastMessage.timestamp=new Date(h.lastMessage.timestamp))}catch{w._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+_),delete h.lastMessage.timestamp}}}]),w}(N.ReplayEventEmitter);H.default(I,"participantJoined","participantJoined"),H.default(I,"participantLeft","participantLeft"),H.default(I,"participantUpdated","participantUpdated"),H.default(I,"messageAdded","messageAdded"),H.default(I,"messageRemoved","messageRemoved"),H.default(I,"messageUpdated","messageUpdated"),H.default(I,"typingEnded","typingEnded"),H.default(I,"typingStarted","typingStarted"),H.default(I,"updated","updated"),H.default(I,"removed","removed"),H.default(I,"_logger",Jt.scope("Conversation")),Be([b.validateTypesAsync(b.nonEmptyString,He),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],I.prototype,"add",null),Be([b.validateTypesAsync(b.nonEmptyString,b.nonEmptyString,He,He),be("design:type",Function),be("design:paramtypes",[String,String,Object,Object]),be("design:returntype",Promise)],I.prototype,"addNonChatParticipant",null),Be([b.validateTypesAsync(b.nonNegativeInteger),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],I.prototype,"advanceLastReadMessageIndex",null),Be([b.validateTypesAsync(["undefined",b.nonNegativeInteger],["undefined",b.nonNegativeInteger],["undefined",b.literal("backwards","forward")]),be("design:type",Function),be("design:paramtypes",[Number,Number,String]),be("design:returntype",Promise)],I.prototype,"getMessages",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"getParticipantBySid",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"getParticipantByIdentity",null),Be([b.validateTypesAsync([b.nonEmptyString,G]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],I.prototype,"removeParticipant",null),Be([b.validateTypesAsync(["string",FormData,b.literal(null),b.objectSchema("media options",{contentType:b.nonEmptyString,media:b.custom(function(C){var x=typeof C=="string"&&C.length>0||C instanceof Uint8Array||C instanceof ArrayBuffer;return typeof Blob=="function"&&(x=x||C instanceof Blob),[x,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],He,["undefined",b.literal(null),b.objectSchema("email attributes",{subject:[b.nonEmptyString,"undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object,Object,Object]),be("design:returntype",Promise)],I.prototype,"sendMessage",null),Be([b.validateTypesAsync(b.literal("default","muted")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"setUserNotificationLevel",null),Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],I.prototype,"updateAttributes",null),Be([b.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"updateFriendlyName",null),Be([b.validateTypesAsync([b.literal(null),b.nonNegativeInteger]),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],I.prototype,"updateLastReadMessageIndex",null),Be([b.validateTypesAsync(["string",b.literal(null)]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"updateUniqueName",null);var O=function(){function C(){var x=this;ke.default(this,C),this._promise=new Promise(function(w,p){x._resolve=w,x._reject=p})}return ye.default(C,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(w){this._resolve(w)}},{key:"set",value:function(w){this.current=w,this._resolve(w)}},{key:"fail",value:function(w){this._reject(w)}}]),C}();function R(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Z(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1333
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Z(C,x){if(C){if(typeof C=="string")return j(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return j(C,x)}}function j(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function Le(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Ae(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Le(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Le(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Ve(C){var x=at();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function at(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Tt=Jt.scope("Conversations"),Br=function(C){q.default(w,C);var x=Ve(w);function w(p,h){var _;return ke.default(this,w),_=x.call(this),H.default(oe.default(_),"conversations",new Map),H.default(oe.default(_),"myConversationsRead",new O),H.default(oe.default(_),"tombstones",new Set),H.default(oe.default(_),"myConversationsFetched",!1),_.configuration=p,_.services=h,_}return ye.default(w,[{key:"addConversation",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J,le,ge,vt,Et;return M.default.wrap(function(Qt){for(;;)switch(Qt.prev=Qt.next){case 0:return S=typeof(v==null?void 0:v.attributes)<"u"?v.attributes:{},Qt.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:v.friendlyName,unique_name:v.uniqueName,access:v.access,attributes:typeof S<"u"?JSON.stringify(S):void 0});case 3:if(Y=Qt.sent,J=(g=Y.sid)!==null&&g!==void 0?g:null,le=(y=(k=Y.sync_objects)===null||k===void 0?void 0:k.conversation)!==null&&y!==void 0?y:null,ge=Ae({self:Y.url},Y.links),vt=this.conversations.get(J),!vt){Qt.next=12;break}return Qt.next=11,vt._subscribe();case 11:return Qt.abrupt("return",vt);case 12:return Et=new I({channel:le,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},J,ge,this.configuration,this.services),this.conversations.set(Et.sid,Et),this._registerForEvents(Et),Qt.next=17,Et._subscribe();case 17:return this.emit("conversationAdded",Et),Qt.abrupt("return",Et);case 19:case"end":return Qt.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"fetchConversations",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y,k,S,Y,J,le;return M.default.wrap(function(vt){for(;;)switch(vt.prev=vt.next){case 0:return vt.prev=0,vt.next=3,this._getMap();case 3:return g=vt.sent,g.on(Oe.SyncMap.itemAdded,function(Et){Tt.debug("itemAdded: ".concat(Et.item.key)),v._upsertConversation("sync",Et.item.key,Et.item.data)}),g.on(Oe.SyncMap.itemRemoved,function(Et){Tt.debug("itemRemoved: ".concat(Et.key));var Ht=Et.key;v.myConversationsFetched||v.tombstones.add(Ht);var Qt=v.conversations.get(Ht);Qt&&(Qt.status==="joined"&&(Qt._setStatus("notParticipating","sync"),v.emit("conversationLeft",Qt)),v.conversations.delete(Ht),v.emit("conversationRemoved",Qt),Qt.emit("removed",Qt))}),g.on(Oe.SyncMap.itemUpdated,function(Et){Tt.debug("itemUpdated: ".concat(Et.item.key)),v._upsertConversation("sync",Et.item.key,Et.item.data)}),vt.next=9,this._fetchMyConversations();case 9:y=vt.sent,k=[],S=R(y);try{for(S.s();!(Y=S.n()).done;)J=Y.value,k.push(this._upsertConversation("rest",J.channel_sid,J))}catch(Et){S.e(Et)}finally{S.f()}return this.myConversationsRead.set(!0),vt.next=16,Promise.all(k);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),Tt.debug("The conversations list has been successfully fetched"),vt.abrupt("return",this);case 22:throw vt.prev=22,vt.t0=vt.catch(0),le="Failed to fetch the conversations list",this.services.syncClient.connectionState!=="disconnected"&&Tt.error(le,vt.t0),Tt.debug("ERROR: ".concat(le),vt.t0),vt.t0;case 28:case"end":return vt.stop()}},_,this,[[0,22]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"getConversations",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._getMap();case 2:return g=S.sent,S.next=5,g.getItems();case 5:return y=S.sent,S.abrupt("return",this._wrapPaginator(y,function(Y){return Promise.all(Y.map(function(J){return v._upsertConversation("sync",J.key,J.data)}))}));case 7:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getConversation",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.next=2,this._getMap();case 2:return y=J.sent,J.next=5,y.getItems({key:v});case 5:return k=J.sent,S=k.items.map(function(le){return g._upsertConversation("sync",le.key,le.data)}),J.abrupt("return",S.length>0?S[0]:null);case 8:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return g=new W(this.configuration.links.myConversations).path(v).build(),le.next=3,this.services.network.get(g);case 3:return y=le.sent,k=y.body,S=k.conversation_sid,Y={entityName:null,lastConsumedMessageIndex:k.last_read_message_index,status:(k==null?void 0:k.status)||"unknown",friendlyName:k.friendly_name,dateUpdated:k.date_updated,dateCreated:k.date_created,uniqueName:k.unique_name,createdBy:k.created_by,attributes:k.attributes,channel:k.sync_objects.conversation,roster:k.sync_objects.participants,messages:k.sync_objects.messages,notificationLevel:k==null?void 0:k.notification_level,sid:S},le.abrupt("return",S?this._upsertConversation("sync",S,Y):null);case 8:case"end":return le.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"peekConversation",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return g=new W(this.configuration.links.conversations).path(v).build(),J.next=3,this.services.network.get(g);case 3:return y=J.sent,k=y.body,S={entityName:null,status:(k==null?void 0:k.status)||"unknown",friendlyName:k.friendly_name,dateUpdated:k.date_updated,dateCreated:k.date_created,uniqueName:k.unique_name,createdBy:k.created_by,attributes:k.attributes,channel:k.sync_objects.conversation||"".concat(v,".channel"),roster:k.sync_objects.participants,messages:k.sync_objects.messages,notificationLevel:k==null?void 0:k.notification_level,sid:v},J.abrupt("return",this._upsertConversation("sync",v,S));case 7:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"_getMap",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return g.abrupt("return",g.sent);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_wrapPaginator",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return Y.next=2,g(v.items);case 2:return k=Y.sent,Y.abrupt("return",{items:k.filter(function(J){return J!==null}),hasNextPage:v.hasNextPage,hasPrevPage:v.hasPrevPage,nextPage:function(){return v.nextPage().then(function(le){return y._wrapPaginator(le,g)})},prevPage:function(){return v.prevPage().then(function(le){return y._wrapPaginator(le,g)})}});case 4:case"end":return Y.stop()}},_)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_updateConversation",value:function(){var p=re.default(M.default.mark(function _(v,g,y){var k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(k=g._statusSource!==void 0&&v!==g._statusSource,S=v!=="rest"||g._statusSource==="sync",!(k&&S&&v!=="sync")){le.next=5;break}return Tt.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:g.sid,data:y.status,conversation:g.status}),le.abrupt("return");case 5:if(!(y.status==="joined"&&g.status!=="joined")){le.next=15;break}return g._setStatus("joined",v),Y={},typeof y.notificationLevel<"u"&&(Y.notificationLevel=y.notificationLevel),typeof y.lastConsumedMessageIndex<"u"&&(Y.lastConsumedMessageIndex=y.lastConsumedMessageIndex),je.default(Y,{})||g._update(Y),le.next=13,g._subscribe();case 13:return this.emit("conversationJoined",g),le.abrupt("return");case 15:if(!(y.status==="notParticipating"&&g.status==="joined")){le.next=22;break}return g._setStatus("notParticipating",v),g._update(y),le.next=20,g._subscribe();case 20:return this.emit("conversationLeft",g),le.abrupt("return");case 22:if(y.status!=="notParticipating"){le.next=26;break}return le.next=25,g._subscribe();case 25:return le.abrupt("return");case 26:g._update(y);case 27:case"end":return le.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"_upsertConversation",value:function(){var p=re.default(M.default.mark(function _(v,g,y){var k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(Tt.trace("upsertConversation called for ".concat(g),y),k=this.conversations.get(g),!k){ge.next=9;break}return Tt.trace("upsertConversation: the conversation ".concat(k.sid," is known;")+"its status is known from the source ".concat(k._statusSource," ")+"and the update came from the source ".concat(v),k),ge.next=6,this._updateConversation(v,k,y);case 6:return ge.next=8,k._subscribe();case 8:return ge.abrupt("return",k);case 9:if(!(v==="rest"&&this.tombstones.has(g))){ge.next=12;break}return Tt.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",g),ge.abrupt("return",null);case 12:return Tt.trace("upsertConversation: creating a local conversation object with sid "+g,y),S="".concat(this.configuration.links.conversations,"/").concat(g),Y={self:S,messages:"".concat(S,"/Messages"),participants:"".concat(S,"/Participants")},J=new I(y,g,Y,this.configuration,this.services),this.conversations.set(g,J),ge.prev=17,ge.next=20,J._subscribe();case 20:if(y.status!=="joined"){ge.next=23;break}return ge.next=23,J._fetchStreams();case 23:ge.next=32;break;case 25:if(ge.prev=25,ge.t0=ge.catch(17),ge.t0.name==="SyncError"){ge.next=29;break}throw ge.t0;case 29:return Tt.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",g,ge.t0),this.conversations.delete(g),ge.abrupt("return",null);case 32:return this._registerForEvents(J),this.emit("conversationAdded",J),y.status==="joined"&&(J._setStatus("joined",v),this.emit("conversationJoined",J)),ge.abrupt("return",J);case 36:case"end":return ge.stop()}},_,this,[[17,25]])}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"_fetchMyConversations",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:v=[],g=null;case 2:return k=new W(this.configuration.links.myConversations),g&&k.arg("PageToken",g),le.next=6,this.services.network.get(k.build());case 6:S=le.sent,Y=(y=S.body)===null||y===void 0?void 0:y.conversations.map(function(ge){return{descriptor:ge,channel_sid:ge.conversation_sid,status:ge.status,channel:ge.sync_objects.conversation,messages:ge.sync_objects.messages,roster:ge.sync_objects.participants||"".concat(ge.conversation_sid,".roster"),lastConsumedMessageIndex:ge.last_read_message_index,notificationLevel:ge.notification_level}}),g=S.body.meta.next_token,v=[].concat(rt.default(v),rt.default(Y));case 10:if(g){le.next=2;break}case 11:return le.abrupt("return",v);case 12:case"end":return le.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_onConversationRemoved",value:function(h){var _=this.conversations.get(h);_&&(this.conversations.delete(h),this.emit("conversationRemoved",_))}},{key:"_registerForEvents",value:function(h){var _=this;h.on("removed",function(){return _._onConversationRemoved(h.sid)}),h.on("updated",function(v){return _.emit("conversationUpdated",v)}),h.on("participantJoined",function(v){return _.emit("participantJoined",v)}),h.on("participantLeft",function(v){return _.emit("participantLeft",v)}),h.on("participantUpdated",function(v){return _.emit("participantUpdated",v)}),h.on("messageAdded",function(v){return _.emit("messageAdded",v)}),h.on("messageUpdated",function(v){return _.emit("messageUpdated",v)}),h.on("messageRemoved",function(v){return _.emit("messageRemoved",v)}),h.on("typingStarted",function(v){return _.emit("typingStarted",v)}),h.on("typingEnded",function(v){return _.emit("typingEnded",v)})}}]),w}(N.ReplayEventEmitter);function Nn(C){var x=kn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function kn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var D=function(C){q.default(w,C);var x=Nn(w);function w(p,h,_){var v;return ke.default(this,w),v=x.call(this),v.configuration=h,v.services=_,v.fifoStack=[],v.myself=p,v.myself.on("updated",function(g){return v.emit("userUpdated",g)}),v.myself.on("userSubscribed",function(){return v.emit("userSubscribed",v.myself)}),v.myself.on("userUnsubscribed",function(){v.emit("userUnsubscribed",v.myself),v.myself._ensureFetched()}),v.subscribedUsers=new Map,v}return ye.default(w,[{key:"handleUnsubscribeUser",value:function(h){this.subscribedUsers.has(h.identity)&&this.subscribedUsers.delete(h.identity);var _=0,v=this.fifoStack.find(function(g,y){return g==h.identity?(_=y,!0):!1});v&&this.fifoStack.splice(_,1),this.emit("userUnsubscribed",h)}},{key:"handleSubscribeUser",value:function(h){if(!this.subscribedUsers.has(h.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var _,v,g=this.fifoStack.shift();(_=this.subscribedUsers)===null||_===void 0||(v=_.get(g))===null||v===void 0||v.unsubscribe()}this.fifoStack.push(h.identity),this.subscribedUsers.set(h.identity,h),this.emit("userSubscribed",h)}}},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k=this,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return le.next=2,this.myself._ensureFetched();case 2:if(v!=this.myself.identity){le.next=4;break}return le.abrupt("return",this.myself);case 4:if(S=this.subscribedUsers.get(v),!S){le.next=7;break}return le.abrupt("return",S);case 7:if(!((y=g)!==null&&y!==void 0)){le.next=11;break}le.next=14;break;case 11:return le.next=13,this.getSyncUniqueName(v);case 13:g=le.sent;case 14:return Y=new Re(v,g,this.configuration,this.services),Y.on("updated",function(ge){return k.emit("userUpdated",ge)}),Y.on("userSubscribed",function(){return k.handleSubscribeUser(Y)}),Y.on("userUnsubscribed",function(){return k.handleUnsubscribeUser(Y)}),le.next=20,Y._ensureFetched();case 20:return le.abrupt("return",Y);case 21:case"end":return le.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.myself._ensureFetched();case 2:return v=[this.myself],this.subscribedUsers.forEach(function(k){return v.push(k)}),y.abrupt("return",v);case 5:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getSyncUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return k=new W(this.configuration.links.users).path(v).build(),J.next=3,this.services.network.get(k);case 3:return S=J.sent,J.abrupt("return",(g=(y=S.body)===null||y===void 0?void 0:y.sync_objects.user_info_map)!==null&&g!==void 0?g:"");case 5:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter),B=Jt.scope("TypingIndicator"),E=function(){function C(x,w,p){ke.default(this,C),this.configuration=w,this.services=p,this.getConversation=x,this.serviceTypingTimeout=null,this.sentUpdates=new Map}return ye.default(C,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var w=this;this.services.notificationClient.on("message",function(){var p=re.default(M.default.mark(function h(_,v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(_!==me.TYPING_INDICATOR){y.next=3;break}return y.next=3,w._handleRemoteTyping(v);case 3:case"end":return y.stop()}},h)}));return function(h,_){return p.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:function(){var x=re.default(M.default.mark(function p(h){var _=this;return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:B.trace("Got new typing indicator ",h),this.getConversation(h.channel_sid).then(function(y){y&&y._participants.forEach(function(k){if(!(k.identity!==h.identity&&k.type!=="apple")){var S=_.configuration.typingIndicatorTimeoutOverride?_.configuration.typingIndicatorTimeoutOverride+1e3:h.typing_timeout*1e3;k._startTyping(S)}})}).catch(function(y){throw B.error(y),y});case 2:case"end":return g.stop()}},p,this)}));function w(p){return x.apply(this,arguments)}return w}()},{key:"send",value:function(w){var p=this.sentUpdates.get(w);return p&&p>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(w,Date.now()),this._send(w))}},{key:"_send",value:function(w){var p=this;B.trace("Sending typing indicator");var h=this.configuration.links.typing,_={"Content-Type":"application/x-www-form-urlencoded"},v="ChannelSid=".concat(w);return this.services.twilsockClient.post(h,_,v,this.configuration.productId).then(function(g){g.body.hasOwnProperty("typing_timeout")&&(p.serviceTypingTimeout=g.body.typing_timeout*1e3)}).catch(function(g){throw B.error("Failed to send typing indicator:",g),g})}}]),C}(),T=ye.default(function C(x){ke.default(this,C),this.title=x.title||null,this.body=x.body||null,this.sound=x.sound||null,this.badge=x.badge||null,this.action=x.action||null,this.type=x.type||null,this.data=x.data||{}}),$="2.6.5";function U(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function P(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?U(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):U(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Me(C){var x=Ce();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Ce(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Qe=function(x){return x.replace(/(^\/+|\/+$)/g,"")},it=function(x){return x.status.code===202},Pt=function(C){q.default(w,C);var x=Me(w);function w(p){return ke.default(this,w),x.call(this,p)}return ye.default(w)}(Ke.default(Error)),vn=function(){function C(x,w,p){ke.default(this,C),this._serviceUrl=x,this._services=w,this._productId=p}return ye.default(C,[{key:"_preProcessUrl",value:function(w){var p=Qe(w);return/^https?:\/\//.test(w)?p:"".concat(Qe(this._serviceUrl),"/").concat(p)}},{key:"_makeRequest",value:function(){var x=re.default(M.default.mark(function p(h,_,v,g){var y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:y=this._preProcessUrl(_),k=P({"Content-Type":"application/json; charset=utf-8"},g||{}),le.t0=h,le.next=le.t0==="get"?5:le.t0==="post"?11:le.t0==="delete"?15:19;break;case 5:return Y=y,v&&(Y+="?"+Object.entries(v).map(function(ge){return ge.map(encodeURIComponent).join("=")}).join("&")),le.next=9,this._services.transport.get(Y,k,this._productId);case 9:return S=le.sent,le.abrupt("break",19);case 11:return le.next=13,this._services.transport.post(y,k,JSON.stringify(v),this._productId);case 13:return S=le.sent,le.abrupt("break",19);case 15:return le.next=17,this._services.transport.delete(y,k,{},this._productId);case 17:return S=le.sent,le.abrupt("break",19);case 19:if(!(S.status.code<200||S.status.code>=300)){le.next=21;break}throw new Error("Request responded with a non-success code ".concat(S.status.code));case 21:return le.abrupt("return",S);case 22:case"end":return le.stop()}},p,this)}));function w(p,h,_,v){return x.apply(this,arguments)}return w}()},{key:"fetchResource",value:function(){var x=re.default(M.default.mark(function p(h,_){var v=this,g,y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return g=6,y=new Ee.AsyncRetrier({min:50,max:1600,maxAttemptsCount:g}),Y.prev=2,Y.next=5,y.run(re.default(M.default.mark(function J(){var le,ge,vt;return M.default.wrap(function(Ht){for(;;)switch(Ht.prev=Ht.next){case 0:return Ht.prev=0,Ht.next=3,v._makeRequest("get",h,_);case 3:return le=Ht.sent,Ht.abrupt("return",{type:"success",data:le.body});case 7:if(Ht.prev=7,Ht.t0=Ht.catch(0),!((Ht.t0===null||Ht.t0===void 0||(ge=Ht.t0.body)===null||ge===void 0?void 0:ge.status)===404&&(Ht.t0===null||Ht.t0===void 0||(vt=Ht.t0.body)===null||vt===void 0?void 0:vt.code)===50530)){Ht.next=11;break}return Ht.abrupt("return",{type:"noMetadata"});case 11:throw Ht.t0;case 12:case"end":return Ht.stop()}},J,null,[[0,7]])})));case 5:k=Y.sent,Y.next=11;break;case 8:throw Y.prev=8,Y.t0=Y.catch(2),new Error('Fetch resource from "'.concat(h,'" failed.'));case 11:if(k.type!=="noMetadata"){Y.next=13;break}throw new Pt("No metadata found.");case 13:return Y.abrupt("return",k.data);case 14:case"end":return Y.stop()}},p,null,[[2,8]])}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"mutateResource",value:function(){var x=re.default(M.default.mark(function p(h,_,v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._makeRequest(h,_,v,{"X-Twilio-Mutation-Id":_e.v4()});case 2:if(g=k.sent,!it(g)){k.next=7;break}return k.next=6,this.fetchResource(g.body.resource_url);case 6:return k.abrupt("return",k.sent);case 7:return k.abrupt("return",g.body);case 8:case"end":return k.stop()}},p,this)}));function w(p,h,_){return x.apply(this,arguments)}return w}()}]),C}(),Fi=function(){function C(x){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:100,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5e3;ke.default(this,C),H.default(this,"_cachedTemplates",null),this._services=x,this._pageSize=w,this._cacheTtlMs=p}return ye.default(C,[{key:"getContentTemplates",value:function(){var x=re.default(M.default.mark(function p(){var h=this,_,v,g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(this._cachedTemplates===null){le.next=2;break}return le.abrupt("return",this._cachedTemplates);case 2:return le.next=4,this._fetchContentTemplates();case 4:_=le.sent,v=ce.default(_,2),g=v[0],y=v[1],k=g;case 9:if(y===null){le.next=19;break}return le.next=12,this._fetchContentTemplates(y);case 12:S=le.sent,Y=ce.default(S,2),g=Y[0],y=Y[1],k=[].concat(rt.default(k),rt.default(g)),le.next=9;break;case 19:return this._cachedTemplates=Object.freeze(k),setTimeout(function(){h._cachedTemplates=null},this._cacheTtlMs),le.abrupt("return",k);case 22:case"end":return le.stop()}},p,this)}));function w(){return x.apply(this,arguments)}return w}()},{key:"_fetchContentTemplates",value:function(){var x=re.default(M.default.mark(function p(h){var _,v,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return _="Client/v2/ContentTemplates",v=new W(_),v.arg("PageSize",this._pageSize),h!==void 0&&v.arg("PageToken",h),k.next=6,this._services.commandExecutor.fetchResource(v.build());case 6:return g=k.sent,k.abrupt("return",[g.templates.map(function(S){return new jt(S)}),g.meta.next_token]);case 8:case"end":return k.stop()}},p,this)}));function w(p){return x.apply(this,arguments)}return w}()}]),C}();function tn(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Bi(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1334
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Bi(C,x){if(C){if(typeof C=="string")return ev(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return ev(C,x)}}function ev(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var Kw=function(C){function x(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ke.default(this,x),!(w.maxSize&&w.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=w.maxSize,this.onEviction=w.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}return ye.default(x,[{key:"_set",value:function(p,h){if(this.cache.set(p,h),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function"){var _=tn(this.oldCache.entries()),v;try{for(_.s();!(v=_.n()).done;){var g=ce.default(v.value,2),y=g[0],k=g[1];this.onEviction(y,k)}}catch(S){_.e(S)}finally{_.f()}}this.oldCache=this.cache,this.cache=new Map}}},{key:"get",value:function(p){if(this.cache.has(p))return this.cache.get(p);if(this.oldCache.has(p)){var h=this.oldCache.get(p);return this.oldCache.delete(p),this._set(p,h),h}}},{key:"set",value:function(p,h){return this.cache.has(p)?this.cache.set(p,h):this._set(p,h),this}},{key:"has",value:function(p){return this.cache.has(p)||this.oldCache.has(p)}},{key:"peek",value:function(p){if(this.cache.has(p))return this.cache.get(p);if(this.oldCache.has(p))return this.oldCache.get(p)}},{key:"delete",value:function(p){var h=this.cache.delete(p);return h&&this._size--,this.oldCache.delete(p)||h}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"keys",value:M.default.mark(function w(){var p,h,_,v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:p=tn(this),y.prev=1,p.s();case 3:if((h=p.n()).done){y.next=9;break}return _=ce.default(h.value,1),v=_[0],y.next=7,v;case 7:y.next=3;break;case 9:y.next=14;break;case 11:y.prev=11,y.t0=y.catch(1),p.e(y.t0);case 14:return y.prev=14,p.f(),y.finish(14);case 17:case"end":return y.stop()}},w,this,[[1,11,14,17]])})},{key:"values",value:M.default.mark(function w(){var p,h,_,v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:p=tn(this),y.prev=1,p.s();case 3:if((h=p.n()).done){y.next=9;break}return _=ce.default(h.value,2),v=_[1],y.next=7,v;case 7:y.next=3;break;case 9:y.next=14;break;case 11:y.prev=11,y.t0=y.catch(1),p.e(y.t0);case 14:return y.prev=14,p.f(),y.finish(14);case 17:case"end":return y.stop()}},w,this,[[1,11,14,17]])})},{key:C,value:M.default.mark(function w(){var p,h,_,v,g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:p=tn(this.cache),J.prev=1,p.s();case 3:if((h=p.n()).done){J.next=9;break}return _=h.value,J.next=7,_;case 7:J.next=3;break;case 9:J.next=14;break;case 11:J.prev=11,J.t0=J.catch(1),p.e(J.t0);case 14:return J.prev=14,p.f(),J.finish(14);case 17:v=tn(this.oldCache),J.prev=18,v.s();case 20:if((g=v.n()).done){J.next=28;break}if(y=g.value,k=ce.default(y,1),S=k[0],this.cache.has(S)){J.next=26;break}return J.next=26,y;case 26:J.next=20;break;case 28:J.next=33;break;case 30:J.prev=30,J.t1=J.catch(18),v.e(J.t1);case 33:return J.prev=33,v.f(),J.finish(33);case 36:case"end":return J.stop()}},w,this,[[1,11,14,17],[18,30,33,36]])})},{key:"size",get:function(){var p=0,h=tn(this.oldCache.keys()),_;try{for(h.s();!(_=h.n()).done;){var v=_.value;this.cache.has(v)||p++}}catch(g){h.e(g)}finally{h.f()}return Math.min(this._size+p,this.maxSize)}}]),x}(Symbol.iterator),F=Kw,ve=ye.default(function C(x,w){ke.default(this,C),this.type=x,this.data=w,Object.freeze(w)}),We=function(){function C(x,w){ke.default(this,C),this._services=x,this._configuration=w,this._cache=new F({maxSize:w.channelMetadataCacheCapacity})}return ye.default(C,[{key:"getChannelMetadata",value:function(){var x=re.default(M.default.mark(function p(h,_){var v,g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(v="".concat(h,",").concat(_),g=this._cache.get(v),!g){J.next=4;break}return J.abrupt("return",g.item);case 4:return y="".concat(this._configuration.links.conversations,"/").concat(h,"/Messages/").concat(_,"/ChannelMetadata"),J.prev=5,J.next=8,this._services.commandExecutor.fetchResource(y);case 8:k=J.sent,J.next=17;break;case 11:if(J.prev=11,J.t0=J.catch(5),!(J.t0 instanceof Pt)){J.next=16;break}return this._cache.set(v,{item:null}),J.abrupt("return",null);case 16:throw new Error(J.t0);case 17:return S=new ve(k.type,k.data),this._cache.set(v,{item:S}),J.abrupt("return",S);case 20:case"end":return J.stop()}},p,this,[[5,11]])}));function w(p,h){return x.apply(this,arguments)}return w}()}]),C}();function wt(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Nr(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1335
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Nr(C,x){if(C){if(typeof C=="string")return Yt(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Yt(C,x)}}function Yt(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var zr=ye.default(function C(x){ke.default(this,C),H.default(this,"type","email"),this.messageSid=x.message_sid,this.level=x.level,this.name=x.name,this.address=x.address}),Jr=ye.default(function C(x){ke.default(this,C),this.type=x.type,this.messageSid=x.message_sid,this.rawData=JSON.stringify(x)}),un=function(){function C(x,w){ke.default(this,C),this._services=x,this._configuration=w,this._cache=new F({maxSize:w.messageRecipientsCacheCapacity})}return ye.default(C,[{key:"getRecipientsFromMessage",value:function(){var x=re.default(M.default.mark(function p(h,_){var v=this,g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(g="".concat(h,",").concat(_),y=this._cache.get(g),!y){le.next=4;break}return le.abrupt("return",y.item);case 4:return k=new W(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("MessageSid",_).build(),le.next=7,this._services.commandExecutor.fetchResource(k);case 7:return S=le.sent,Y=S.message_recipients.map(function(ge){return v._wrapResponse(ge)}),Y.length>0&&this._cache.set(g,{item:Y}),le.abrupt("return",Y);case 11:case"end":return le.stop()}},p,this)}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"getRecipientsFromConversation",value:function(){var x=re.default(M.default.mark(function p(h,_){var v,g,y=this,k,S,Y,J,le,ge,vt,Et,Ht,Qt;return M.default.wrap(function(mr){for(;;)switch(mr.prev=mr.next){case 0:return k=new W(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("PageToken",(v=_==null?void 0:_.pageToken)!==null&&v!==void 0?v:void 0).arg("PageSize",(g=_==null?void 0:_.pageSize)!==null&&g!==void 0?g:void 0).build(),mr.next=3,this._services.commandExecutor.fetchResource(k);case 3:S=mr.sent,Y=S.message_recipients.map(function(Gt){return y._wrapResponse(Gt)}),J=wt(Y);try{for(J.s();!(le=J.n()).done;)Et=le.value,Ht="".concat(h,",").concat(Et.messageSid),Qt=(ge=(vt=this._cache.get(Ht))===null||vt===void 0?void 0:vt.item)!==null&&ge!==void 0?ge:[],this._cache.set(Ht,{item:[].concat(rt.default(Qt),[Et])})}catch(Gt){J.e(Gt)}finally{J.f()}return mr.abrupt("return",new ht(Y,function(Gt,yi){return y.getRecipientsFromConversation(h,{pageToken:Gt,pageSize:yi})},S.meta.previous_token,S.meta.next_token));case 8:case"end":return mr.stop()}},p,this)}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"_wrapResponse",value:function(w){switch(w.type){case"email":return new zr(w);default:return new Jr(w)}}}]),C}(),Nt;function Sn(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function $n(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Sn(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Sn(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function pn(C){var x=Wn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Wn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Zt,ma=ye.default(function C(){ke.default(this,C)});t.Client=Zt=(Nt=function(C){q.default(w,C);var x=pn(w);function w(p){var h,_,v,g,y,k,S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ke.default(this,w),k=x.call(this),H.default(oe.default(k),"version",$),H.default(oe.default(k),"connectionState","unknown"),H.default(oe.default(k),"parsePushNotification",Zt.parsePushNotification),k._fpaToken=p??"",k._options=S??{},!k._options.disableDeepClone){var Y=$n($n({},k._options),{},{transport:void 0,twilsockClient:void 0});Y=fr(Y),Y.transport=k._options.transport,Y.twilsockClient=k._options.twilsockClient,k._options=Y}k._options.logLevel=(h=k._options.logLevel)!==null&&h!==void 0?h:"silent",Zt._logger.setLevel(k._options.logLevel);var J=k._options.productId="ip_messaging";if(k._options.clientMetadata=k._options.clientMetadata||{},k._options.clientMetadata.hasOwnProperty("type")||(k._options.clientMetadata.type="conversations"),k._options.clientMetadata.hasOwnProperty("sdk")||(k._options.clientMetadata.sdk="JS",k._options.clientMetadata.sdkv=$),k._options.Sync=k._options.Sync||{},typeof k._options.Sync.enableSessionStorage>"u"&&(k._options.Sync.enableSessionStorage=!0),k._options.region&&(k._options.Sync.region=k._options.region),!p)throw new Error("A valid Twilio token should be provided");k._services=new ma,k._myself=new Re("","",null,k._services);var le=!k._options.twilsockClient;if(!k._options.initRegistrations){var ge=new Ie.InitRegistration(J);Zt.populateInitRegistrations(ge),k._options.initRegistrations=[ge]}k._services.twilsockClient=k._options.twilsockClient=(_=k._options.twilsockClient)!==null&&_!==void 0?_:new Ie.TwilsockClient(p,J,k._options),k._services.twilsockClient.on(Zt.tokenAboutToExpire,function(){return k.emit(Zt.tokenAboutToExpire)}),k._services.twilsockClient.on(Zt.tokenExpired,function(){return k.emit(Zt.tokenExpired)}),k._services.twilsockClient.on(Zt.connectionError,function(mr){return k.emit(Zt.connectionError,mr)}),k._services.twilsockClient.on("stateChanged",function(mr){Zt._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(mr)),mr!==k.connectionState&&(k.connectionState=mr,k.emit(Zt.connectionStateChanged,k.connectionState))}),k._services.transport=k._options.transport=(v=k._options.transport)!==null&&v!==void 0?v:k._options.twilsockClient,k._services.notificationClient=k._options.notificationsClient=(g=k._options.notificationsClient)!==null&&g!==void 0?g:new Fe.Notifications(p,k._options),k._services.syncClient=k._options.syncClient=(y=k._options.syncClient)!==null&&y!==void 0?y:new Oe.SyncClient(p,k._options);var vt=(S==null?void 0:S.Chat)||(S==null?void 0:S.IPMessaging)||S||{},Et=vt.region||(S==null?void 0:S.region),Ht=vt.apiUri||vt.typingUri||"https://aim.".concat(Et||"us1",".twilio.com");k._services.commandExecutor=new vn(Ht,{transport:k._options.transport},J),k._services.contentClient=new Fi(k._services);var Qt=function(Gt){k._rejectEnsureReady(Gt),k.emit(Zt.stateChanged,"failed"),k.emit(Zt.initFailed,{error:Gt})},_r=function(){Qt({terminal:!0,message:"Twilsock has disconnected."}),k._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1)};return k._services.twilsockClient.once("connectionError",Qt),k._services.twilsockClient.once("disconnected",_r),k._services.twilsockClient.once("connected",re.default(M.default.mark(function mr(){var Gt,yi;return M.default.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return Zt._logger.debug("ConversationsClient started INITIALIZING"),k._services.twilsockClient.off("connectionError",Qt),k._services.twilsockClient.off("disconnected",_r),Lt.prev=3,Gt="conversations.client.startup",k._services.twilsockClient.addPartialTelemetryEvent(new Ie.TelemetryEventDescription(Gt,"Conversations client startup",new Date),Gt,Ie.TelemetryPoint.Start),Lt.next=8,k._initialize();case 8:k._services.twilsockClient.addPartialTelemetryEvent(new Ie.TelemetryEventDescription("","",new Date),Gt,Ie.TelemetryPoint.End),Lt.next=17;break;case 11:Lt.prev=11,Lt.t0=Lt.catch(3),yi={terminal:!0,message:Lt.t0.message},k._rejectEnsureReady(yi),k.emit(Zt.stateChanged,"failed"),k.emit(Zt.initFailed,{error:yi});case 17:case"end":return Lt.stop()}},mr,null,[[3,11]])}))),k._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1),le&&k._services.twilsockClient.connect(),k}return ye.default(w,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to the 'stateChanged' event to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"token",get:function(){return this._fpaToken}},{key:"shutdown",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateToken",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:if(Zt._logger.info("updateToken"),this._fpaToken!==v){y.next=5;break}return y.abrupt("return",this);case 5:return y.next=7,this._services.twilsockClient.updateToken(v);case 7:return y.next=9,this._services.notificationClient.updateToken(v);case 9:return y.next=11,this._services.mcsClient.updateToken(v);case 11:return this._fpaToken=v,y.abrupt("return",this);case 13:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return k.next=6,this._conversationsEntity.getConversation(v);case 6:if(g=k.sent,g){k.next=12;break}return k.next=10,this.peekConversationBySid(v);case 10:g=k.sent,g&&V.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(g){k.next=14;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 14:return k.abrupt("return",g);case 15:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"peekConversationBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.peekConversation(v);case 4:if(g=k.sent,g){k.next=7;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 7:return k.abrupt("return",g);case 8:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return k.next=6,this._conversationsEntity.getConversationByUniqueName(v);case 6:if(g=k.sent,g){k.next=9;break}throw new Error("Conversation with unique name ".concat(v," was not found."));case 9:return k.abrupt("return",g);case 10:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getSubscribedConversations",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._conversationsPromise.then(function(y){return y.getConversations()}));case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"createConversation",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return v=v||{},y.abrupt("return",this._conversationsPromise.then(function(k){return k.addConversation(v)}));case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"setPushRegistrationId",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(v),this._services.notificationClient.setPushRegistrationId(v,g),k.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"unsetPushRegistrationId",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(v),y.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"removePushRegistrations",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.notificationClient.removeRegistrations(v,g);case 2:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"handlePushNotification",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:Zt._logger.debug("handlePushNotification, notificationPayload=",v),this.emit("pushNotification",Zt.parsePushNotification(v));case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.abrupt("return",this._services.users.getUser(v));case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var _=this;return new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(!(!_._services.mcsClient||!h)){ge.next=3;break}return k(new Error("Media Content Service is unavailable")),ge.abrupt("return");case 3:return Y=_._services.mcsClient.mediaSetGetContentUrls(h),S(function(){Y.cancel()}),ge.prev=5,ge.next=8,Y;case 8:J=ge.sent,y(J),ge.next=15;break;case 12:ge.prev=12,ge.t0=ge.catch(5),k(ge.t0);case 15:case"end":return ge.stop()}},g,null,[[5,12]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(h){var _=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getContentTemplates",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.contentClient.getContentTemplates();case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_initialize",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return g=k.sent,this._configuration=new dr(this._options,g,Zt._logger),this._services.channelMetadataClient=new We(this._services,this._configuration),this._services.messageRecipientsClient=new un(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new E(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new ae(this._configuration,this._services),this._services.users=new D(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function(S){v.emit("userSubscribed",S)}),this._services.users.on("userUpdated",function(S){return v.emit("userUpdated",S)}),this._services.users.on("userUnsubscribed",function(S){v.emit("userUnsubscribed",S)}),this._conversationsEntity=new Br(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function(S){v.emit("conversationAdded",S)}),this._conversationsEntity.on("conversationRemoved",function(S){v.emit("conversationRemoved",S)}),this._conversationsEntity.on("conversationJoined",function(S){v.emit("conversationJoined",S)}),this._conversationsEntity.on("conversationLeft",function(S){v.emit("conversationLeft",S)}),this._conversationsEntity.on("conversationUpdated",function(S){return v.emit("conversationUpdated",S)}),this._conversationsEntity.on("participantJoined",function(S){v.emit("participantJoined",S)}),this._conversationsEntity.on("participantLeft",function(S){v.emit("participantLeft",S)}),this._conversationsEntity.on("participantUpdated",function(S){return v.emit("participantUpdated",S)}),this._conversationsEntity.on("messageAdded",function(S){return v.emit("messageAdded",S)}),this._conversationsEntity.on("messageUpdated",function(S){return v.emit("messageUpdated",S)}),this._conversationsEntity.on("messageRemoved",function(S){return v.emit("messageRemoved",S)}),this._conversationsEntity.on("typingStarted",function(S){return v.emit("typingStarted",S)}),this._conversationsEntity.on("typingEnded",function(S){return v.emit("typingEnded",S)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return v._conversationsEntity}).catch(function(S){throw console.error("Failed to fetch conversations _conversationsPromise -> client.ts",S),S}),k.next=30,this._services.users.myself._ensureFetched();case 30:Zt._supportedPushChannels.forEach(function(S){return v._subscribeToPushNotifications(S)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new ze.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,$n($n({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(Zt.stateChanged,"initialized"),this.emit(Zt.initialized);case 36:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeToPushNotifications",value:function(h){var _=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(v){_._services.notificationClient.subscribe(h,v)})}},{key:"_unsubscribeFromPushNotifications",value:function(h){var _=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(v){_._services.notificationClient.unsubscribe(h,v)})}},{key:"_initializeEnsureReady",value:function(h){var _=this;this._ensureReady=new Promise(function(v,g){_._resolveEnsureReady=v,_._rejectEnsureReady=g}).catch(function(v){if(h)throw v})}}],[{key:"create",value:function(){var p=re.default(M.default.mark(function _(v,g){var y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!(g!=null&&g.twilsockClient)){S.next=2;break}throw new Error("Obsolete usage of ConversationsClient.create() factory method: if you pass twilsock from the outside then you must use ConversationsClient constructor and be prepared to work with uninitialized client.");case 2:return y=new Zt(v,g),S.next=5,y._ensureReady;case 5:return S.abrupt("return",y);case 6:case"end":return S.stop()}},_)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"parsePushNotification",value:function(h){if(Zt._logger.debug("parsePushNotification, notificationPayload=",h),typeof h.aps<"u"){if(!h.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var _=Zt._parsePushNotificationChatData(h),v=h.aps,g,y=null;if(typeof v.alert=="string")g=v.alert||null;else{var k,S;g=((k=v.alert)===null||k===void 0?void 0:k.body)||null,y=((S=v.alert)===null||S===void 0?void 0:S.title)||null}return new T({title:y,body:g,sound:v.sound||null,badge:v.badge||null,action:v.category||null,type:h.twi_message_type,data:_})}if(typeof h.data<"u"){var Y=h.data;if(!Y.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var J=Zt._parsePushNotificationChatData(h.data);return new T({title:Y.twi_title||null,body:Y.twi_body||null,sound:Y.twi_sound||null,badge:null,action:Y.twi_action||null,type:Y.twi_message_type,data:J})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(h){var _={};for(var v in Zt._supportedPushDataFields){var g=h[v];if(!(typeof g>"u"||g===null)){if(v==="message_index"||v==="media_count"){var y=Wt(g);y!==null&&(_[Zt._supportedPushDataFields[v]]=y);continue}if(v==="media"){if(typeof g=="string")try{_[Zt._supportedPushDataFields[v]]=JSON.parse(g)}catch{Zt._logger.debug("Media message notification parsing error")}continue}_[Zt._supportedPushDataFields[v]]=g}}return _}},{key:"populateInitRegistrations",value:function(h){h.populateInitRegistrations([me.TYPING_INDICATOR]),Oe.SyncClient.populateInitRegistrations(h)}}]),w}(N.ReplayEventEmitter),H.default(Nt,"conversationAdded","conversationAdded"),H.default(Nt,"conversationJoined","conversationJoined"),H.default(Nt,"conversationLeft","conversationLeft"),H.default(Nt,"conversationRemoved","conversationRemoved"),H.default(Nt,"conversationUpdated","conversationUpdated"),H.default(Nt,"participantJoined","participantJoined"),H.default(Nt,"participantLeft","participantLeft"),H.default(Nt,"participantUpdated","participantUpdated"),H.default(Nt,"messageAdded","messageAdded"),H.default(Nt,"messageRemoved","messageRemoved"),H.default(Nt,"messageUpdated","messageUpdated"),H.default(Nt,"tokenAboutToExpire","tokenAboutToExpire"),H.default(Nt,"tokenExpired","tokenExpired"),H.default(Nt,"typingEnded","typingEnded"),H.default(Nt,"typingStarted","typingStarted"),H.default(Nt,"pushNotification","pushNotification"),H.default(Nt,"userSubscribed","userSubscribed"),H.default(Nt,"userUnsubscribed","userUnsubscribed"),H.default(Nt,"userUpdated","userUpdated"),H.default(Nt,"stateChanged","stateChanged"),H.default(Nt,"initialized","initialized"),H.default(Nt,"initFailed","initFailed"),H.default(Nt,"connectionStateChanged","connectionStateChanged"),H.default(Nt,"connectionError","connectionError"),H.default(Nt,"version",$),H.default(Nt,"_logger",Jt.scope("Client")),H.default(Nt,"_supportedPushChannels",["fcm","apn"]),H.default(Nt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),Nt),Be([V.deprecated("token"),be("design:type",String),be("design:paramtypes",[])],t.Client.prototype,"token",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"updateToken",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationBySid",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"peekConversationBySid",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationByUniqueName",null),Be([b.validateTypesAsync(["undefined",b.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"createConversation",null),Be([b.validateTypesAsync(b.literal("fcm","apn"),"string"),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"setPushRegistrationId",null),Be([b.validateTypesAsync(b.literal("fcm","apn")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"unsetPushRegistrationId",null),Be([b.validateTypesAsync(b.literal("fcm","apn"),b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"removePushRegistrations",null),Be([b.validateTypesAsync(b.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"handlePushNotification",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getUser",null),Be([b.validateTypesAsync(b.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),Be([b.validateTypesAsync(b.nonEmptyArray("media",dt)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMedia",null),Be([V.deprecated("Client.create()","new Client()"),b.validateTypesAsync("string",["undefined",b.pureObject]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],t.Client,"create",null),Be([b.validateTypes(b.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",T)],t.Client,"parsePushNotification",null),t.Client=Zt=Be([b.validateConstructorTypes(b.nonEmptyString,[b.pureObject,"undefined"]),be("design:paramtypes",[String,Object])],t.Client),Object.defineProperty(t,"CancellablePromise",{enumerable:!0,get:function(){return ze.CancellablePromise}}),t.AggregatedDeliveryReceipt=lt,t.ChannelMetadata=ve,t.ContentTemplate=jt,t.ContentTemplateVariable=It,t.Conversation=I,t.DetailedDeliveryReceipt=Rt,t.EmailRecipientDescriptor=zr,t.Media=dt,t.Message=en,t.MessageBuilder=Dr,t.NotificationTypes=me,t.Participant=G,t.PushNotification=T,t.RestPaginator=ht,t.UnknownRecipientDescriptor=Jr,t.UnsentMessage=Pn,t.User=Re})(lk);const aae=vl({__proto__:null},[lk]);Wo.AnyChatWidget=oD,Object.defineProperty(Wo,Symbol.toStringTag,{value:"Module"})});