voxnix 1.0.24 → 2.0.0

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,218 +1,70 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('*,: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: }*,: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]:where(:not([hidden=until-found])){display:none}body{background-color:transparent;--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif}.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}}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-2{top:.5rem;right:.5rem;bottom:.5rem;left:.5rem}.-right-0\\.5{right:-.125rem}.-right-1{right:-.25rem}.-top-0\\.5{top:-.125rem}.-top-1{top:-.25rem}.bottom-6{bottom:1.5rem}.bottom-full{bottom:100%}.left-1\\/2{left:50%}.left-3{left:.75rem}.right-0{right:0}.right-3{right:.75rem}.top-3{top:.75rem}.top-6{top:1.5rem}.z-10{z-index:10}.z-50{z-index:50}.z-\\[9999\\]{z-index:9999}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-6{margin-bottom:1.5rem}.ml-auto{margin-left:auto}.mt-1{margin-top:.25rem}.mt-1\\.5{margin-top:.375rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.h-1\\.5{height:.375rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-20{height:5rem}.h-28{height:7rem}.h-3{height:.75rem}.h-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-9{height:2.25rem}.h-\\[18px\\]{height:18px}.h-px{height:1px}.min-h-\\[280px\\]{min-height:280px}.min-h-\\[300px\\]{min-height:300px}.min-h-\\[44px\\]{min-height:44px}.min-h-\\[56px\\]{min-height:56px}.w-1\\.5{width:.375rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-20{width:5rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\\.5{width:.875rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-9{width:2.25rem}.w-\\[18px\\]{width:18px}.w-\\[360px\\]{width:360px}.w-full{width:100%}.max-w-\\[220px\\]{max-width:220px}.max-w-\\[260px\\]{max-width:260px}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.origin-bottom-left{transform-origin:bottom left}.origin-bottom-right{transform-origin:bottom right}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;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))}.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))}@keyframes ping{75%,to{transform:scale(2);opacity:0}}.animate-ping{animation:ping 1s cubic-bezier(0,0,.2,1) infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\\.5{gap:.375rem}.gap-10{gap:2.5rem}.gap-2{gap:.5rem}.gap-2\\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-7{gap:1.75rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.whitespace-nowrap{white-space:nowrap}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-t{border-top-width:1px}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(249 250 251 / var(--tw-border-opacity, 1))}.border-green-100{--tw-border-opacity: 1;border-color:rgb(220 252 231 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-primary{--tw-border-opacity: 1;border-color:rgb(63 49 146 / var(--tw-border-opacity, 1))}.border-primary\\/15{border-color:#3f319226}.border-primary\\/20{border-color:#3f319233}.border-red-100{--tw-border-opacity: 1;border-color:rgb(254 226 226 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.border-t-gray-600{--tw-border-opacity: 1;border-top-color:rgb(75 85 99 / var(--tw-border-opacity, 1))}.border-t-primary{--tw-border-opacity: 1;border-top-color:rgb(63 49 146 / var(--tw-border-opacity, 1))}.bg-amber-400{--tw-bg-opacity: 1;background-color:rgb(251 191 36 / var(--tw-bg-opacity, 1))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-50\\/60{background-color:#f9fafb99}.bg-gray-50\\/70{background-color:#f9fafbb3}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\\/15{background-color:#22c55e26}.bg-primary{--tw-bg-opacity: 1;background-color:rgb(63 49 146 / var(--tw-bg-opacity, 1))}.bg-primary\\/10{background-color:#3f31921a}.bg-primary\\/15{background-color:#3f319226}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\\/15{background-color:#ef444426}.bg-transparent{background-color:transparent}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\\/90{background-color:#ffffffe6}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-\\[\\#3f3192\\]{--tw-gradient-from: #3f3192 var(--tw-gradient-from-position);--tw-gradient-to: rgb(63 49 146 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-green-500{--tw-gradient-from: #22c55e var(--tw-gradient-from-position);--tw-gradient-to: rgb(34 197 94 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-\\[\\#5240c2\\]{--tw-gradient-to: #5240c2 var(--tw-gradient-to-position)}.to-green-600{--tw-gradient-to: #16a34a var(--tw-gradient-to-position)}.fill-white{fill:#fff}.p-1{padding:.25rem}.p-1\\.5{padding:.375rem}.p-6{padding:1.5rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2\\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pt-1{padding-top:.25rem}.pt-5{padding-top:1.25rem}.text-left{text-align:left}.text-center{text-align:center}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[22px\\]{font-size:22px}.text-\\[28px\\]{font-size:28px}.text-\\[9px\\]{font-size:9px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-light{font-weight:300}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-\\[0\\.12em\\]{letter-spacing:.12em}.tracking-\\[0\\.18em\\]{letter-spacing:.18em}.tracking-\\[0\\.25em\\]{letter-spacing:.25em}.tracking-\\[0\\.2em\\]{letter-spacing:.2em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-amber-500{--tw-text-opacity: 1;color:rgb(245 158 11 / var(--tw-text-opacity, 1))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-gray-200{--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-primary{--tw-text-opacity: 1;color:rgb(63 49 146 / var(--tw-text-opacity, 1))}.text-primary\\/70{color:#3f3192b3}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\\/50{color:#ffffff80}.opacity-75{opacity:.75}.shadow-\\[0_20px_60px_rgba\\(0\\,0\\,0\\,0\\.18\\)\\,0_4px_16px_rgba\\(0\\,0\\,0\\,0\\.08\\)\\]{--tw-shadow: 0 20px 60px rgba(0,0,0,.18),0 4px 16px rgba(0,0,0,.08);--tw-shadow-colored: 0 20px 60px var(--tw-shadow-color), 0 4px 16px 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-\\[0_2px_6px_rgba\\(0\\,0\\,0\\,0\\.07\\)\\]{--tw-shadow: 0 2px 6px rgba(0,0,0,.07);--tw-shadow-colored: 0 2px 6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_2px_8px_rgba\\(239\\,68\\,68\\,0\\.35\\)\\]{--tw-shadow: 0 2px 8px rgba(239,68,68,.35);--tw-shadow-colored: 0 2px 8px 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-\\[0_2px_8px_rgba\\(63\\,49\\,146\\,0\\.35\\)\\]{--tw-shadow: 0 2px 8px rgba(63,49,146,.35);--tw-shadow-colored: 0 2px 8px 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-\\[0_4px_14px_rgba\\(239\\,68\\,68\\,0\\.4\\)\\]{--tw-shadow: 0 4px 14px rgba(239,68,68,.4);--tw-shadow-colored: 0 4px 14px 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-\\[0_4px_14px_rgba\\(34\\,197\\,94\\,0\\.4\\)\\]{--tw-shadow: 0 4px 14px rgba(34,197,94,.4);--tw-shadow-colored: 0 4px 14px 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)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-primary\\/30{--tw-shadow-color: rgb(63 49 146 / .3);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.ring{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.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)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-150{transition-duration:.15s}@keyframes fadeIn{0%{opacity:0;transform:scale(.98)}to{opacity:1;transform:scale(1)}}@keyframes slideUp{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fadeIn{animation:fadeIn .25s cubic-bezier(.16,1,.3,1) forwards}.animate-slideUp{animation:slideUp .3s cubic-bezier(.16,1,.3,1) forwards}.placeholder\\:text-2xl::-moz-placeholder{font-size:1.5rem;line-height:2rem}.placeholder\\:text-2xl::placeholder{font-size:1.5rem;line-height:2rem}.placeholder\\:font-normal::-moz-placeholder{font-weight:400}.placeholder\\:font-normal::placeholder{font-weight:400}.placeholder\\:text-gray-300::-moz-placeholder{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.placeholder\\:text-gray-300::placeholder{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.last\\:border-0:last-child{border-width:0px}.hover\\:border-primary\\/20:hover{border-color:#3f319233}.hover\\:bg-amber-50:hover{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.hover\\:bg-green-600:hover{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1))}.hover\\:bg-primary-hover:hover{--tw-bg-opacity: 1;background-color:rgb(43 32 102 / var(--tw-bg-opacity, 1))}.hover\\:bg-primary\\/5:hover{background-color:#3f31920d}.hover\\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\\:from-green-600:hover{--tw-gradient-from: #16a34a var(--tw-gradient-from-position);--tw-gradient-to: rgb(22 163 74 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.hover\\:to-green-700:hover{--tw-gradient-to: #15803d var(--tw-gradient-to-position)}.hover\\:text-amber-800:hover{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.hover\\:text-gray-500:hover{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.hover\\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\\:text-green-800:hover{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.hover\\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\\:shadow-\\[0_4px_12px_rgba\\(63\\,49\\,146\\,0\\.13\\)\\]:hover{--tw-shadow: 0 4px 12px rgba(63,49,146,.13);--tw-shadow-colored: 0 4px 12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\\:shadow-\\[0_6px_18px_rgba\\(239\\,68\\,68\\,0\\.5\\)\\]:hover{--tw-shadow: 0 6px 18px rgba(239,68,68,.5);--tw-shadow-colored: 0 6px 18px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\\:shadow-\\[0_6px_20px_rgba\\(239\\,68\\,68\\,0\\.5\\)\\]:hover{--tw-shadow: 0 6px 20px rgba(239,68,68,.5);--tw-shadow-colored: 0 6px 20px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\\:shadow-\\[0_6px_20px_rgba\\(34\\,197\\,94\\,0\\.5\\)\\]:hover{--tw-shadow: 0 6px 20px rgba(34,197,94,.5);--tw-shadow-colored: 0 6px 20px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\\:border-primary:focus{--tw-border-opacity: 1;border-color:rgb(63 49 146 / var(--tw-border-opacity, 1))}.focus\\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\\:ring-primary:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(63 49 146 / var(--tw-ring-opacity, 1))}.active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;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))}.active\\:bg-primary\\/10:active{background-color:#3f31921a}.active\\:shadow-none:active{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:from-gray-200:disabled{--tw-gradient-from: #e5e7eb var(--tw-gradient-from-position);--tw-gradient-to: rgb(229 231 235 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.disabled\\:to-gray-200:disabled{--tw-gradient-to: #e5e7eb var(--tw-gradient-to-position)}.disabled\\:text-gray-400:disabled{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.disabled\\:opacity-40:disabled{opacity:.4}.disabled\\:opacity-50:disabled{opacity:.5}.disabled\\:opacity-60:disabled{opacity:.6}.disabled\\:shadow-none:disabled{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}')),document.head.appendChild(t)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
- (function(Yt,se){typeof exports=="object"&&typeof module<"u"?se(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],se):(Yt=typeof globalThis<"u"?globalThis:Yt||self,se(Yt.OmnixWidget={},Yt.React,Yt.ReactDOM))})(this,function(Yt,se,Wo){"use strict";function Go(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const Hr=Go(Wo);var ie=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vo(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function zo(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(s){var i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return r[s]}})}),t}var zs={exports:{}},$r={};/**
3
- * @license React
4
- * react-jsx-runtime.production.min.js
5
- *
6
- * Copyright (c) Facebook, Inc. and its affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var kn;function Ko(){if(kn)return $r;kn=1;var r=se,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n={key:!0,ref:!0,__self:!0,__source:!0};function a(o,d,c){var l,g={},f=null,y=null;c!==void 0&&(f=""+c),d.key!==void 0&&(f=""+d.key),d.ref!==void 0&&(y=d.ref);for(l in d)s.call(d,l)&&!n.hasOwnProperty(l)&&(g[l]=d[l]);if(o&&o.defaultProps)for(l in d=o.defaultProps,d)g[l]===void 0&&(g[l]=d[l]);return{$$typeof:e,type:o,key:f,ref:y,props:g,_owner:i.current}}return $r.Fragment=t,$r.jsx=a,$r.jsxs=a,$r}var Or={};/**
11
- * @license React
12
- * react-jsx-runtime.development.js
13
- *
14
- * Copyright (c) Facebook, Inc. and its affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- */var Bn;function Zo(){return Bn||(Bn=1,process.env.NODE_ENV!=="production"&&function(){var r=se,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),o=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),w=Symbol.iterator,b="@@iterator";function _(D){if(D===null||typeof D!="object")return null;var O=w&&D[w]||D[b];return typeof O=="function"?O:null}var x=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(D){{for(var O=arguments.length,Z=new Array(O>1?O-1:0),te=1;te<O;te++)Z[te-1]=arguments[te];E("error",D,Z)}}function E(D,O,Z){{var te=x.ReactDebugCurrentFrame,ve=te.getStackAddendum();ve!==""&&(O+="%s",Z=Z.concat([ve]));var be=Z.map(function(de){return String(de)});be.unshift("Warning: "+O),Function.prototype.apply.call(console[D],console,be)}}var C=!1,R=!1,S=!1,F=!1,h=!1,N;N=Symbol.for("react.module.reference");function A(D){return!!(typeof D=="string"||typeof D=="function"||D===s||D===n||h||D===i||D===c||D===l||F||D===y||C||R||S||typeof D=="object"&&D!==null&&(D.$$typeof===f||D.$$typeof===g||D.$$typeof===a||D.$$typeof===o||D.$$typeof===d||D.$$typeof===N||D.getModuleId!==void 0))}function u(D,O,Z){var te=D.displayName;if(te)return te;var ve=O.displayName||O.name||"";return ve!==""?Z+"("+ve+")":Z}function v(D){return D.displayName||"Context"}function m(D){if(D==null)return null;if(typeof D.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof D=="function")return D.displayName||D.name||null;if(typeof D=="string")return D;switch(D){case s:return"Fragment";case t:return"Portal";case n:return"Profiler";case i:return"StrictMode";case c:return"Suspense";case l:return"SuspenseList"}if(typeof D=="object")switch(D.$$typeof){case o:var O=D;return v(O)+".Consumer";case a:var Z=D;return v(Z._context)+".Provider";case d:return u(D,D.render,"ForwardRef");case g:var te=D.displayName||null;return te!==null?te:m(D.type)||"Memo";case f:{var ve=D,be=ve._payload,de=ve._init;try{return m(de(be))}catch{return null}}}return null}var U=Object.assign,j=0,J,z,ne,he,ue,I,H;function $(){}$.__reactDisabledLog=!0;function P(){{if(j===0){J=console.log,z=console.info,ne=console.warn,he=console.error,ue=console.group,I=console.groupCollapsed,H=console.groupEnd;var D={configurable:!0,enumerable:!0,value:$,writable:!0};Object.defineProperties(console,{info:D,log:D,warn:D,error:D,group:D,groupCollapsed:D,groupEnd:D})}j++}}function we(){{if(j--,j===0){var D={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:U({},D,{value:J}),info:U({},D,{value:z}),warn:U({},D,{value:ne}),error:U({},D,{value:he}),group:U({},D,{value:ue}),groupCollapsed:U({},D,{value:I}),groupEnd:U({},D,{value:H})})}j<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pe=x.ReactCurrentDispatcher,Be;function q(D,O,Z){{if(Be===void 0)try{throw Error()}catch(ve){var te=ve.stack.trim().match(/\n( *(at )?)/);Be=te&&te[1]||""}return`
19
- `+Be+D}}var V=!1,Ee;{var St=typeof WeakMap=="function"?WeakMap:Map;Ee=new St}function xt(D,O){if(!D||V)return"";{var Z=Ee.get(D);if(Z!==void 0)return Z}var te;V=!0;var ve=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var be;be=pe.current,pe.current=null,P();try{if(O){var de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(Je){te=Je}Reflect.construct(D,[],de)}else{try{de.call()}catch(Je){te=Je}D.call(de.prototype)}}else{try{throw Error()}catch(Je){te=Je}D()}}catch(Je){if(Je&&te&&typeof Je.stack=="string"){for(var oe=Je.stack.split(`
20
- `),Ve=te.stack.split(`
21
- `),Fe=oe.length-1,Ie=Ve.length-1;Fe>=1&&Ie>=0&&oe[Fe]!==Ve[Ie];)Ie--;for(;Fe>=1&&Ie>=0;Fe--,Ie--)if(oe[Fe]!==Ve[Ie]){if(Fe!==1||Ie!==1)do if(Fe--,Ie--,Ie<0||oe[Fe]!==Ve[Ie]){var lt=`
22
- `+oe[Fe].replace(" at new "," at ");return D.displayName&&lt.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",D.displayName)),typeof D=="function"&&Ee.set(D,lt),lt}while(Fe>=1&&Ie>=0);break}}}finally{V=!1,pe.current=be,we(),Error.prepareStackTrace=ve}var Pr=D?D.displayName||D.name:"",pr=Pr?q(Pr):"";return typeof D=="function"&&Ee.set(D,pr),pr}function Ye(D,O,Z){return xt(D,!1)}function Me(D){var O=D.prototype;return!!(O&&O.isReactComponent)}function ct(D,O,Z){if(D==null)return"";if(typeof D=="function")return xt(D,Me(D));if(typeof D=="string")return q(D);switch(D){case c:return q("Suspense");case l:return q("SuspenseList")}if(typeof D=="object")switch(D.$$typeof){case d:return Ye(D.render);case g:return ct(D.type,O,Z);case f:{var te=D,ve=te._payload,be=te._init;try{return ct(be(ve),O,Z)}catch{}}}return""}var Xe=Object.prototype.hasOwnProperty,Tt={},pt=x.ReactDebugCurrentFrame;function mt(D){if(D){var O=D._owner,Z=ct(D.type,D._source,O?O.type:null);pt.setExtraStackFrame(Z)}else pt.setExtraStackFrame(null)}function gr(D,O,Z,te,ve){{var be=Function.call.bind(Xe);for(var de in D)if(be(D,de)){var oe=void 0;try{if(typeof D[de]!="function"){var Ve=Error((te||"React class")+": "+Z+" type `"+de+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof D[de]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ve.name="Invariant Violation",Ve}oe=D[de](O,de,te,Z,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Fe){oe=Fe}oe&&!(oe instanceof Error)&&(mt(ve),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",te||"React class",Z,de,typeof oe),mt(null)),oe instanceof Error&&!(oe.message in Tt)&&(Tt[oe.message]=!0,mt(ve),p("Failed %s type: %s",Z,oe.message),mt(null))}}}var rt=Array.isArray;function We(D){return rt(D)}function Rt(D){{var O=typeof Symbol=="function"&&Symbol.toStringTag,Z=O&&D[Symbol.toStringTag]||D.constructor.name||"Object";return Z}}function kr(D){try{return ts(D),!1}catch{return!0}}function ts(D){return""+D}function Ut(D){if(kr(D))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Rt(D)),ts(D)}var tr=x.ReactCurrentOwner,_n={key:!0,ref:!0,__self:!0,__source:!0},rs,ss;function rr(D){if(Xe.call(D,"ref")){var O=Object.getOwnPropertyDescriptor(D,"ref").get;if(O&&O.isReactWarning)return!1}return D.ref!==void 0}function xr(D){if(Xe.call(D,"key")){var O=Object.getOwnPropertyDescriptor(D,"key").get;if(O&&O.isReactWarning)return!1}return D.key!==void 0}function Cn(D,O){typeof D.ref=="string"&&tr.current}function Ns(D,O){{var Z=function(){rs||(rs=!0,p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};Z.isReactWarning=!0,Object.defineProperty(D,"key",{get:Z,configurable:!0})}}function Ms(D,O){{var Z=function(){ss||(ss=!0,p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};Z.isReactWarning=!0,Object.defineProperty(D,"ref",{get:Z,configurable:!0})}}var Dn=function(D,O,Z,te,ve,be,de){var oe={$$typeof:e,type:D,key:O,ref:Z,props:de,_owner:be};return oe._store={},Object.defineProperty(oe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(oe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:te}),Object.defineProperty(oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ve}),Object.freeze&&(Object.freeze(oe.props),Object.freeze(oe)),oe};function An(D,O,Z,te,ve){{var be,de={},oe=null,Ve=null;Z!==void 0&&(Ut(Z),oe=""+Z),xr(O)&&(Ut(O.key),oe=""+O.key),rr(O)&&(Ve=O.ref,Cn(O,ve));for(be in O)Xe.call(O,be)&&!_n.hasOwnProperty(be)&&(de[be]=O[be]);if(D&&D.defaultProps){var Fe=D.defaultProps;for(be in Fe)de[be]===void 0&&(de[be]=Fe[be])}if(oe||Ve){var Ie=typeof D=="function"?D.displayName||D.name||"Unknown":D;oe&&Ns(de,Ie),Ve&&Ms(de,Ie)}return Dn(D,oe,Ve,ve,te,tr.current,de)}}var Br=x.ReactCurrentOwner,js=x.ReactDebugCurrentFrame;function Lt(D){if(D){var O=D._owner,Z=ct(D.type,D._source,O?O.type:null);js.setExtraStackFrame(Z)}else js.setExtraStackFrame(null)}var is;is=!1;function Ir(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function qs(){{if(Br.current){var D=m(Br.current.type);if(D)return`
23
-
24
- Check the render method of \``+D+"`."}return""}}function Sn(D){return""}var Us={};function Ls(D){{var O=qs();if(!O){var Z=typeof D=="string"?D:D.displayName||D.name;Z&&(O=`
25
-
26
- Check the top-level render call using <`+Z+">.")}return O}}function Ys(D,O){{if(!D._store||D._store.validated||D.key!=null)return;D._store.validated=!0;var Z=Ls(O);if(Us[Z])return;Us[Z]=!0;var te="";D&&D._owner&&D._owner!==Br.current&&(te=" It was passed a child from "+m(D._owner.type)+"."),Lt(D),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Z,te),Lt(null)}}function Ws(D,O){{if(typeof D!="object")return;if(We(D))for(var Z=0;Z<D.length;Z++){var te=D[Z];Ir(te)&&Ys(te,O)}else if(Ir(D))D._store&&(D._store.validated=!0);else if(D){var ve=_(D);if(typeof ve=="function"&&ve!==D.entries)for(var be=ve.call(D),de;!(de=be.next()).done;)Ir(de.value)&&Ys(de.value,O)}}}function Gs(D){{var O=D.type;if(O==null||typeof O=="string")return;var Z;if(typeof O=="function")Z=O.propTypes;else if(typeof O=="object"&&(O.$$typeof===d||O.$$typeof===g))Z=O.propTypes;else return;if(Z){var te=m(O);gr(Z,D.props,"prop",te,D)}else if(O.PropTypes!==void 0&&!is){is=!0;var ve=m(O);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ve||"Unknown")}typeof O.getDefaultProps=="function"&&!O.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tn(D){{for(var O=Object.keys(D.props),Z=0;Z<O.length;Z++){var te=O[Z];if(te!=="children"&&te!=="key"){Lt(D),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",te),Lt(null);break}}D.ref!==null&&(Lt(D),p("Invalid attribute `ref` supplied to `React.Fragment`."),Lt(null))}}var ns={};function Ge(D,O,Z,te,ve,be){{var de=A(D);if(!de){var oe="";(D===void 0||typeof D=="object"&&D!==null&&Object.keys(D).length===0)&&(oe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ve=Sn();Ve?oe+=Ve:oe+=qs();var Fe;D===null?Fe="null":We(D)?Fe="array":D!==void 0&&D.$$typeof===e?(Fe="<"+(m(D.type)||"Unknown")+" />",oe=" Did you accidentally export a JSX literal instead of a component?"):Fe=typeof D,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Fe,oe)}var Ie=An(D,O,Z,ve,be);if(Ie==null)return Ie;if(de){var lt=O.children;if(lt!==void 0)if(te)if(We(lt)){for(var Pr=0;Pr<lt.length;Pr++)Ws(lt[Pr],D);Object.freeze&&Object.freeze(lt)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ws(lt,D)}if(Xe.call(O,"key")){var pr=m(D),Je=Object.keys(O).filter(function(Ou){return Ou!=="key"}),Fn=Je.length>0?"{key: someKey, "+Je.join(": ..., ")+": ...}":"{key: someKey}";if(!ns[pr+Fn]){var $u=Je.length>0?"{"+Je.join(": ..., ")+": ...}":"{}";p(`A props object containing a "key" prop is being spread into JSX:
27
- let props = %s;
28
- <%s {...props} />
29
- React keys must be passed directly to JSX without using spread:
30
- let props = %s;
31
- <%s key={someKey} {...props} />`,Fn,pr,$u,pr),ns[pr+Fn]=!0}}return D===s?Tn(Ie):Gs(Ie),Ie}}function Ft(D,O,Z){return Ge(D,O,Z,!0)}function Vs(D,O,Z){return Ge(D,O,Z,!1)}var Rn=Vs,Hu=Ft;Or.Fragment=s,Or.jsx=Rn,Or.jsxs=Hu}()),Or}process.env.NODE_ENV==="production"?zs.exports=Ko():zs.exports=Zo();var T=zs.exports;/**
32
- * @license lucide-react v0.344.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */var Xo={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
37
- * @license lucide-react v0.344.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Jo=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),qe=(r,e)=>{const t=se.forwardRef(({color:s="currentColor",size:i=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:o="",children:d,...c},l)=>se.createElement("svg",{ref:l,...Xo,width:i,height:i,stroke:s,strokeWidth:a?Number(n)*24/Number(i):n,className:["lucide",`lucide-${Jo(r)}`,o].join(" "),...c},[...e.map(([g,f])=>se.createElement(g,f)),...Array.isArray(d)?d:[d]]));return t.displayName=`${r}`,t};/**
42
- * @license lucide-react v0.344.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const Qo=qe("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
47
- * @license lucide-react v0.344.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const In=qe("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
52
- * @license lucide-react v0.344.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const e0=qe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
57
- * @license lucide-react v0.344.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const t0=qe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
62
- * @license lucide-react v0.344.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const Pn=qe("Coffee",[["path",{d:"M17 8h1a4 4 0 1 1 0 8h-1",key:"jx4kbh"}],["path",{d:"M3 8h14v9a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4Z",key:"1bxrl0"}],["line",{x1:"6",x2:"6",y1:"2",y2:"4",key:"1cr9l3"}],["line",{x1:"10",x2:"10",y1:"2",y2:"4",key:"170wym"}],["line",{x1:"14",x2:"14",y1:"2",y2:"4",key:"1c5f70"}]]);/**
67
- * @license lucide-react v0.344.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const r0=qe("Delete",[["path",{d:"M20 5H9l-7 7 7 7h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2Z",key:"1oy587"}],["line",{x1:"18",x2:"12",y1:"9",y2:"15",key:"1olkx5"}],["line",{x1:"12",x2:"18",y1:"9",y2:"15",key:"1n50pc"}]]);/**
72
- * @license lucide-react v0.344.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const s0=qe("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
77
- * @license lucide-react v0.344.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const i0=qe("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
82
- * @license lucide-react v0.344.0 - ISC
83
- *
84
- * This source code is licensed under the ISC license.
85
- * See the LICENSE file in the root directory of this source tree.
86
- */const n0=qe("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
87
- * @license lucide-react v0.344.0 - ISC
88
- *
89
- * This source code is licensed under the ISC license.
90
- * See the LICENSE file in the root directory of this source tree.
91
- */const Hn=qe("Pause",[["rect",{width:"4",height:"16",x:"6",y:"4",key:"iffhe4"}],["rect",{width:"4",height:"16",x:"14",y:"4",key:"sjin7j"}]]);/**
92
- * @license lucide-react v0.344.0 - ISC
93
- *
94
- * This source code is licensed under the ISC license.
95
- * See the LICENSE file in the root directory of this source tree.
96
- */const a0=qe("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/**
97
- * @license lucide-react v0.344.0 - ISC
98
- *
99
- * This source code is licensed under the ISC license.
100
- * See the LICENSE file in the root directory of this source tree.
101
- */const as=qe("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/**
102
- * @license lucide-react v0.344.0 - ISC
103
- *
104
- * This source code is licensed under the ISC license.
105
- * See the LICENSE file in the root directory of this source tree.
106
- */const Nr=qe("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/**
107
- * @license lucide-react v0.344.0 - ISC
108
- *
109
- * This source code is licensed under the ISC license.
110
- * See the LICENSE file in the root directory of this source tree.
111
- */const o0=qe("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/**
112
- * @license lucide-react v0.344.0 - ISC
113
- *
114
- * This source code is licensed under the ISC license.
115
- * See the LICENSE file in the root directory of this source tree.
116
- */const $n=qe("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
117
- * @license lucide-react v0.344.0 - ISC
118
- *
119
- * This source code is licensed under the ISC license.
120
- * See the LICENSE file in the root directory of this source tree.
121
- */const c0=qe("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),l0=[{n:"1",l:""},{n:"2",l:"ABC"},{n:"3",l:"DEF"},{n:"4",l:"GHI"},{n:"5",l:"JKL"},{n:"6",l:"MNO"},{n:"7",l:"PQRS"},{n:"8",l:"TUV"},{n:"9",l:"WXYZ"},{n:"*",l:""},{n:"0",l:"+"},{n:"#",l:""}],On=({onKeyPress:r})=>T.jsx("div",{className:"grid grid-cols-3 gap-2.5 w-full px-5 py-2",children:l0.map(({n:e,l:t})=>T.jsxs("button",{onClick:()=>r(e),className:`
122
- relative flex flex-col items-center justify-center
123
- h-16 rounded-2xl select-none
124
- bg-white border border-gray-100
125
- shadow-[0_2px_6px_rgba(0,0,0,0.07)]
126
- hover:shadow-[0_4px_12px_rgba(63,49,146,0.13)]
127
- hover:border-primary/20 hover:bg-primary/5
128
- active:shadow-none active:bg-primary/10 active:scale-95
129
- transition-all duration-150
130
- `,children:[T.jsx("span",{className:"text-[22px] font-medium text-gray-800 leading-none",children:e}),t?T.jsx("span",{className:"text-[9px] text-gray-400 font-semibold tracking-[0.18em] mt-1.5",children:t}):T.jsx("span",{className:"h-3.5"})]},e))});class d0{constructor(){this.listeners={}}on(e,t){return this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t),()=>this.off(e,t)}off(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter(s=>s!==t))}emitLocal(e,t){this.listeners[e]&&this.listeners[e].forEach(s=>{try{s(t)}catch(i){console.error(`Error in event listener for ${e}:`,i)}})}emitToParent(e,t){this.emitLocal(e,t)}}const G=new d0;var Nn={exports:{}};function h0(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ks={exports:{}};const u0=zo(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Mn;function ce(){return Mn||(Mn=1,function(r,e){(function(t,s){r.exports=s()})(ie,function(){var t=t||function(s,i){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof ie<"u"&&ie.crypto&&(n=ie.crypto),!n&&typeof h0=="function")try{n=u0}catch{}var a=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function p(){}return function(E){var C;return p.prototype=E,C=new p,p.prototype=null,C}}(),d={},c=d.lib={},l=c.Base=function(){return{extend:function(p){var E=o(this);return p&&E.mixIn(p),(!E.hasOwnProperty("init")||this.init===E.init)&&(E.init=function(){E.$super.init.apply(this,arguments)}),E.init.prototype=E,E.$super=this,E},create:function(){var p=this.extend();return p.init.apply(p,arguments),p},init:function(){},mixIn:function(p){for(var E in p)p.hasOwnProperty(E)&&(this[E]=p[E]);p.hasOwnProperty("toString")&&(this.toString=p.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=c.WordArray=l.extend({init:function(p,E){p=this.words=p||[],E!=i?this.sigBytes=E:this.sigBytes=p.length*4},toString:function(p){return(p||y).stringify(this)},concat:function(p){var E=this.words,C=p.words,R=this.sigBytes,S=p.sigBytes;if(this.clamp(),R%4)for(var F=0;F<S;F++){var h=C[F>>>2]>>>24-F%4*8&255;E[R+F>>>2]|=h<<24-(R+F)%4*8}else for(var N=0;N<S;N+=4)E[R+N>>>2]=C[N>>>2];return this.sigBytes+=S,this},clamp:function(){var p=this.words,E=this.sigBytes;p[E>>>2]&=4294967295<<32-E%4*8,p.length=s.ceil(E/4)},clone:function(){var p=l.clone.call(this);return p.words=this.words.slice(0),p},random:function(p){for(var E=[],C=0;C<p;C+=4)E.push(a());return new g.init(E,p)}}),f=d.enc={},y=f.Hex={stringify:function(p){for(var E=p.words,C=p.sigBytes,R=[],S=0;S<C;S++){var F=E[S>>>2]>>>24-S%4*8&255;R.push((F>>>4).toString(16)),R.push((F&15).toString(16))}return R.join("")},parse:function(p){for(var E=p.length,C=[],R=0;R<E;R+=2)C[R>>>3]|=parseInt(p.substr(R,2),16)<<24-R%8*4;return new g.init(C,E/2)}},w=f.Latin1={stringify:function(p){for(var E=p.words,C=p.sigBytes,R=[],S=0;S<C;S++){var F=E[S>>>2]>>>24-S%4*8&255;R.push(String.fromCharCode(F))}return R.join("")},parse:function(p){for(var E=p.length,C=[],R=0;R<E;R++)C[R>>>2]|=(p.charCodeAt(R)&255)<<24-R%4*8;return new g.init(C,E)}},b=f.Utf8={stringify:function(p){try{return decodeURIComponent(escape(w.stringify(p)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(p){return w.parse(unescape(encodeURIComponent(p)))}},_=c.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(p){typeof p=="string"&&(p=b.parse(p)),this._data.concat(p),this._nDataBytes+=p.sigBytes},_process:function(p){var E,C=this._data,R=C.words,S=C.sigBytes,F=this.blockSize,h=F*4,N=S/h;p?N=s.ceil(N):N=s.max((N|0)-this._minBufferSize,0);var A=N*F,u=s.min(A*4,S);if(A){for(var v=0;v<A;v+=F)this._doProcessBlock(R,v);E=R.splice(0,A),C.sigBytes-=u}return new g.init(E,u)},clone:function(){var p=l.clone.call(this);return p._data=this._data.clone(),p},_minBufferSize:0});c.Hasher=_.extend({cfg:l.extend(),init:function(p){this.cfg=this.cfg.extend(p),this.reset()},reset:function(){_.reset.call(this),this._doReset()},update:function(p){return this._append(p),this._process(),this},finalize:function(p){p&&this._append(p);var E=this._doFinalize();return E},blockSize:16,_createHelper:function(p){return function(E,C){return new p.init(C).finalize(E)}},_createHmacHelper:function(p){return function(E,C){return new x.HMAC.init(p,C).finalize(E)}}});var x=d.algo={};return d}(Math);return t})}(Ks)),Ks.exports}var Zs={exports:{}},jn;function os(){return jn||(jn=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(s){var i=t,n=i.lib,a=n.Base,o=n.WordArray,d=i.x64={};d.Word=a.extend({init:function(c,l){this.high=c,this.low=l}}),d.WordArray=a.extend({init:function(c,l){c=this.words=c||[],l!=s?this.sigBytes=l:this.sigBytes=c.length*8},toX32:function(){for(var c=this.words,l=c.length,g=[],f=0;f<l;f++){var y=c[f];g.push(y.high),g.push(y.low)}return o.create(g,this.sigBytes)},clone:function(){for(var c=a.clone.call(this),l=c.words=this.words.slice(0),g=l.length,f=0;f<g;f++)l[f]=l[f].clone();return c}})}(),t})}(Zs)),Zs.exports}var Xs={exports:{}},qn;function f0(){return qn||(qn=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(){if(typeof ArrayBuffer=="function"){var s=t,i=s.lib,n=i.WordArray,a=n.init,o=n.init=function(d){if(d instanceof ArrayBuffer&&(d=new Uint8Array(d)),(d instanceof Int8Array||typeof Uint8ClampedArray<"u"&&d instanceof Uint8ClampedArray||d instanceof Int16Array||d instanceof Uint16Array||d instanceof Int32Array||d instanceof Uint32Array||d instanceof Float32Array||d instanceof Float64Array)&&(d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength)),d instanceof Uint8Array){for(var c=d.byteLength,l=[],g=0;g<c;g++)l[g>>>2]|=d[g]<<24-g%4*8;a.call(this,l,c)}else a.apply(this,arguments)};o.prototype=n}}(),t.lib.WordArray})}(Xs)),Xs.exports}var Js={exports:{}},Un;function g0(){return Un||(Un=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.WordArray,a=s.enc;a.Utf16=a.Utf16BE={stringify:function(d){for(var c=d.words,l=d.sigBytes,g=[],f=0;f<l;f+=2){var y=c[f>>>2]>>>16-f%4*8&65535;g.push(String.fromCharCode(y))}return g.join("")},parse:function(d){for(var c=d.length,l=[],g=0;g<c;g++)l[g>>>1]|=d.charCodeAt(g)<<16-g%2*16;return n.create(l,c*2)}},a.Utf16LE={stringify:function(d){for(var c=d.words,l=d.sigBytes,g=[],f=0;f<l;f+=2){var y=o(c[f>>>2]>>>16-f%4*8&65535);g.push(String.fromCharCode(y))}return g.join("")},parse:function(d){for(var c=d.length,l=[],g=0;g<c;g++)l[g>>>1]|=o(d.charCodeAt(g)<<16-g%2*16);return n.create(l,c*2)}};function o(d){return d<<8&4278255360|d>>>8&16711935}}(),t.enc.Utf16})}(Js)),Js.exports}var Qs={exports:{}},Ln;function sr(){return Ln||(Ln=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.WordArray,a=s.enc;a.Base64={stringify:function(d){var c=d.words,l=d.sigBytes,g=this._map;d.clamp();for(var f=[],y=0;y<l;y+=3)for(var w=c[y>>>2]>>>24-y%4*8&255,b=c[y+1>>>2]>>>24-(y+1)%4*8&255,_=c[y+2>>>2]>>>24-(y+2)%4*8&255,x=w<<16|b<<8|_,p=0;p<4&&y+p*.75<l;p++)f.push(g.charAt(x>>>6*(3-p)&63));var E=g.charAt(64);if(E)for(;f.length%4;)f.push(E);return f.join("")},parse:function(d){var c=d.length,l=this._map,g=this._reverseMap;if(!g){g=this._reverseMap=[];for(var f=0;f<l.length;f++)g[l.charCodeAt(f)]=f}var y=l.charAt(64);if(y){var w=d.indexOf(y);w!==-1&&(c=w)}return o(d,c,g)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function o(d,c,l){for(var g=[],f=0,y=0;y<c;y++)if(y%4){var w=l[d.charCodeAt(y-1)]<<y%4*2,b=l[d.charCodeAt(y)]>>>6-y%4*2,_=w|b;g[f>>>2]|=_<<24-f%4*8,f++}return n.create(g,f)}}(),t.enc.Base64})}(Qs)),Qs.exports}var ei={exports:{}},Yn;function x0(){return Yn||(Yn=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.WordArray,a=s.enc;a.Base64url={stringify:function(d,c){c===void 0&&(c=!0);var l=d.words,g=d.sigBytes,f=c?this._safe_map:this._map;d.clamp();for(var y=[],w=0;w<g;w+=3)for(var b=l[w>>>2]>>>24-w%4*8&255,_=l[w+1>>>2]>>>24-(w+1)%4*8&255,x=l[w+2>>>2]>>>24-(w+2)%4*8&255,p=b<<16|_<<8|x,E=0;E<4&&w+E*.75<g;E++)y.push(f.charAt(p>>>6*(3-E)&63));var C=f.charAt(64);if(C)for(;y.length%4;)y.push(C);return y.join("")},parse:function(d,c){c===void 0&&(c=!0);var l=d.length,g=c?this._safe_map:this._map,f=this._reverseMap;if(!f){f=this._reverseMap=[];for(var y=0;y<g.length;y++)f[g.charCodeAt(y)]=y}var w=g.charAt(64);if(w){var b=d.indexOf(w);b!==-1&&(l=b)}return o(d,l,f)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function o(d,c,l){for(var g=[],f=0,y=0;y<c;y++)if(y%4){var w=l[d.charCodeAt(y-1)]<<y%4*2,b=l[d.charCodeAt(y)]>>>6-y%4*2,_=w|b;g[f>>>2]|=_<<24-f%4*8,f++}return n.create(g,f)}}(),t.enc.Base64url})}(ei)),ei.exports}var ti={exports:{}},Wn;function ir(){return Wn||(Wn=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(s){var i=t,n=i.lib,a=n.WordArray,o=n.Hasher,d=i.algo,c=[];(function(){for(var b=0;b<64;b++)c[b]=s.abs(s.sin(b+1))*4294967296|0})();var l=d.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(b,_){for(var x=0;x<16;x++){var p=_+x,E=b[p];b[p]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360}var C=this._hash.words,R=b[_+0],S=b[_+1],F=b[_+2],h=b[_+3],N=b[_+4],A=b[_+5],u=b[_+6],v=b[_+7],m=b[_+8],U=b[_+9],j=b[_+10],J=b[_+11],z=b[_+12],ne=b[_+13],he=b[_+14],ue=b[_+15],I=C[0],H=C[1],$=C[2],P=C[3];I=g(I,H,$,P,R,7,c[0]),P=g(P,I,H,$,S,12,c[1]),$=g($,P,I,H,F,17,c[2]),H=g(H,$,P,I,h,22,c[3]),I=g(I,H,$,P,N,7,c[4]),P=g(P,I,H,$,A,12,c[5]),$=g($,P,I,H,u,17,c[6]),H=g(H,$,P,I,v,22,c[7]),I=g(I,H,$,P,m,7,c[8]),P=g(P,I,H,$,U,12,c[9]),$=g($,P,I,H,j,17,c[10]),H=g(H,$,P,I,J,22,c[11]),I=g(I,H,$,P,z,7,c[12]),P=g(P,I,H,$,ne,12,c[13]),$=g($,P,I,H,he,17,c[14]),H=g(H,$,P,I,ue,22,c[15]),I=f(I,H,$,P,S,5,c[16]),P=f(P,I,H,$,u,9,c[17]),$=f($,P,I,H,J,14,c[18]),H=f(H,$,P,I,R,20,c[19]),I=f(I,H,$,P,A,5,c[20]),P=f(P,I,H,$,j,9,c[21]),$=f($,P,I,H,ue,14,c[22]),H=f(H,$,P,I,N,20,c[23]),I=f(I,H,$,P,U,5,c[24]),P=f(P,I,H,$,he,9,c[25]),$=f($,P,I,H,h,14,c[26]),H=f(H,$,P,I,m,20,c[27]),I=f(I,H,$,P,ne,5,c[28]),P=f(P,I,H,$,F,9,c[29]),$=f($,P,I,H,v,14,c[30]),H=f(H,$,P,I,z,20,c[31]),I=y(I,H,$,P,A,4,c[32]),P=y(P,I,H,$,m,11,c[33]),$=y($,P,I,H,J,16,c[34]),H=y(H,$,P,I,he,23,c[35]),I=y(I,H,$,P,S,4,c[36]),P=y(P,I,H,$,N,11,c[37]),$=y($,P,I,H,v,16,c[38]),H=y(H,$,P,I,j,23,c[39]),I=y(I,H,$,P,ne,4,c[40]),P=y(P,I,H,$,R,11,c[41]),$=y($,P,I,H,h,16,c[42]),H=y(H,$,P,I,u,23,c[43]),I=y(I,H,$,P,U,4,c[44]),P=y(P,I,H,$,z,11,c[45]),$=y($,P,I,H,ue,16,c[46]),H=y(H,$,P,I,F,23,c[47]),I=w(I,H,$,P,R,6,c[48]),P=w(P,I,H,$,v,10,c[49]),$=w($,P,I,H,he,15,c[50]),H=w(H,$,P,I,A,21,c[51]),I=w(I,H,$,P,z,6,c[52]),P=w(P,I,H,$,h,10,c[53]),$=w($,P,I,H,j,15,c[54]),H=w(H,$,P,I,S,21,c[55]),I=w(I,H,$,P,m,6,c[56]),P=w(P,I,H,$,ue,10,c[57]),$=w($,P,I,H,u,15,c[58]),H=w(H,$,P,I,ne,21,c[59]),I=w(I,H,$,P,N,6,c[60]),P=w(P,I,H,$,J,10,c[61]),$=w($,P,I,H,F,15,c[62]),H=w(H,$,P,I,U,21,c[63]),C[0]=C[0]+I|0,C[1]=C[1]+H|0,C[2]=C[2]+$|0,C[3]=C[3]+P|0},_doFinalize:function(){var b=this._data,_=b.words,x=this._nDataBytes*8,p=b.sigBytes*8;_[p>>>5]|=128<<24-p%32;var E=s.floor(x/4294967296),C=x;_[(p+64>>>9<<4)+15]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,_[(p+64>>>9<<4)+14]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360,b.sigBytes=(_.length+1)*4,this._process();for(var R=this._hash,S=R.words,F=0;F<4;F++){var h=S[F];S[F]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360}return R},clone:function(){var b=o.clone.call(this);return b._hash=this._hash.clone(),b}});function g(b,_,x,p,E,C,R){var S=b+(_&x|~_&p)+E+R;return(S<<C|S>>>32-C)+_}function f(b,_,x,p,E,C,R){var S=b+(_&p|x&~p)+E+R;return(S<<C|S>>>32-C)+_}function y(b,_,x,p,E,C,R){var S=b+(_^x^p)+E+R;return(S<<C|S>>>32-C)+_}function w(b,_,x,p,E,C,R){var S=b+(x^(_|~p))+E+R;return(S<<C|S>>>32-C)+_}i.MD5=o._createHelper(l),i.HmacMD5=o._createHmacHelper(l)}(Math),t.MD5})}(ti)),ti.exports}var ri={exports:{}},Gn;function Vn(){return Gn||(Gn=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.WordArray,a=i.Hasher,o=s.algo,d=[],c=o.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(l,g){for(var f=this._hash.words,y=f[0],w=f[1],b=f[2],_=f[3],x=f[4],p=0;p<80;p++){if(p<16)d[p]=l[g+p]|0;else{var E=d[p-3]^d[p-8]^d[p-14]^d[p-16];d[p]=E<<1|E>>>31}var C=(y<<5|y>>>27)+x+d[p];p<20?C+=(w&b|~w&_)+1518500249:p<40?C+=(w^b^_)+1859775393:p<60?C+=(w&b|w&_|b&_)-1894007588:C+=(w^b^_)-899497514,x=_,_=b,b=w<<30|w>>>2,w=y,y=C}f[0]=f[0]+y|0,f[1]=f[1]+w|0,f[2]=f[2]+b|0,f[3]=f[3]+_|0,f[4]=f[4]+x|0},_doFinalize:function(){var l=this._data,g=l.words,f=this._nDataBytes*8,y=l.sigBytes*8;return g[y>>>5]|=128<<24-y%32,g[(y+64>>>9<<4)+14]=Math.floor(f/4294967296),g[(y+64>>>9<<4)+15]=f,l.sigBytes=g.length*4,this._process(),this._hash},clone:function(){var l=a.clone.call(this);return l._hash=this._hash.clone(),l}});s.SHA1=a._createHelper(c),s.HmacSHA1=a._createHmacHelper(c)}(),t.SHA1})}(ri)),ri.exports}var si={exports:{}},zn;function ii(){return zn||(zn=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){return function(s){var i=t,n=i.lib,a=n.WordArray,o=n.Hasher,d=i.algo,c=[],l=[];(function(){function y(x){for(var p=s.sqrt(x),E=2;E<=p;E++)if(!(x%E))return!1;return!0}function w(x){return(x-(x|0))*4294967296|0}for(var b=2,_=0;_<64;)y(b)&&(_<8&&(c[_]=w(s.pow(b,1/2))),l[_]=w(s.pow(b,1/3)),_++),b++})();var g=[],f=d.SHA256=o.extend({_doReset:function(){this._hash=new a.init(c.slice(0))},_doProcessBlock:function(y,w){for(var b=this._hash.words,_=b[0],x=b[1],p=b[2],E=b[3],C=b[4],R=b[5],S=b[6],F=b[7],h=0;h<64;h++){if(h<16)g[h]=y[w+h]|0;else{var N=g[h-15],A=(N<<25|N>>>7)^(N<<14|N>>>18)^N>>>3,u=g[h-2],v=(u<<15|u>>>17)^(u<<13|u>>>19)^u>>>10;g[h]=A+g[h-7]+v+g[h-16]}var m=C&R^~C&S,U=_&x^_&p^x&p,j=(_<<30|_>>>2)^(_<<19|_>>>13)^(_<<10|_>>>22),J=(C<<26|C>>>6)^(C<<21|C>>>11)^(C<<7|C>>>25),z=F+J+m+l[h]+g[h],ne=j+U;F=S,S=R,R=C,C=E+z|0,E=p,p=x,x=_,_=z+ne|0}b[0]=b[0]+_|0,b[1]=b[1]+x|0,b[2]=b[2]+p|0,b[3]=b[3]+E|0,b[4]=b[4]+C|0,b[5]=b[5]+R|0,b[6]=b[6]+S|0,b[7]=b[7]+F|0},_doFinalize:function(){var y=this._data,w=y.words,b=this._nDataBytes*8,_=y.sigBytes*8;return w[_>>>5]|=128<<24-_%32,w[(_+64>>>9<<4)+14]=s.floor(b/4294967296),w[(_+64>>>9<<4)+15]=b,y.sigBytes=w.length*4,this._process(),this._hash},clone:function(){var y=o.clone.call(this);return y._hash=this._hash.clone(),y}});i.SHA256=o._createHelper(f),i.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256})}(si)),si.exports}var ni={exports:{}},Kn;function p0(){return Kn||(Kn=1,function(r,e){(function(t,s,i){r.exports=s(ce(),ii())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.WordArray,a=s.algo,o=a.SHA256,d=a.SHA224=o.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var c=o._doFinalize.call(this);return c.sigBytes-=4,c}});s.SHA224=o._createHelper(d),s.HmacSHA224=o._createHmacHelper(d)}(),t.SHA224})}(ni)),ni.exports}var ai={exports:{}},Zn;function Xn(){return Zn||(Zn=1,function(r,e){(function(t,s,i){r.exports=s(ce(),os())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.Hasher,a=s.x64,o=a.Word,d=a.WordArray,c=s.algo;function l(){return o.create.apply(o,arguments)}var g=[l(1116352408,3609767458),l(1899447441,602891725),l(3049323471,3964484399),l(3921009573,2173295548),l(961987163,4081628472),l(1508970993,3053834265),l(2453635748,2937671579),l(2870763221,3664609560),l(3624381080,2734883394),l(310598401,1164996542),l(607225278,1323610764),l(1426881987,3590304994),l(1925078388,4068182383),l(2162078206,991336113),l(2614888103,633803317),l(3248222580,3479774868),l(3835390401,2666613458),l(4022224774,944711139),l(264347078,2341262773),l(604807628,2007800933),l(770255983,1495990901),l(1249150122,1856431235),l(1555081692,3175218132),l(1996064986,2198950837),l(2554220882,3999719339),l(2821834349,766784016),l(2952996808,2566594879),l(3210313671,3203337956),l(3336571891,1034457026),l(3584528711,2466948901),l(113926993,3758326383),l(338241895,168717936),l(666307205,1188179964),l(773529912,1546045734),l(1294757372,1522805485),l(1396182291,2643833823),l(1695183700,2343527390),l(1986661051,1014477480),l(2177026350,1206759142),l(2456956037,344077627),l(2730485921,1290863460),l(2820302411,3158454273),l(3259730800,3505952657),l(3345764771,106217008),l(3516065817,3606008344),l(3600352804,1432725776),l(4094571909,1467031594),l(275423344,851169720),l(430227734,3100823752),l(506948616,1363258195),l(659060556,3750685593),l(883997877,3785050280),l(958139571,3318307427),l(1322822218,3812723403),l(1537002063,2003034995),l(1747873779,3602036899),l(1955562222,1575990012),l(2024104815,1125592928),l(2227730452,2716904306),l(2361852424,442776044),l(2428436474,593698344),l(2756734187,3733110249),l(3204031479,2999351573),l(3329325298,3815920427),l(3391569614,3928383900),l(3515267271,566280711),l(3940187606,3454069534),l(4118630271,4000239992),l(116418474,1914138554),l(174292421,2731055270),l(289380356,3203993006),l(460393269,320620315),l(685471733,587496836),l(852142971,1086792851),l(1017036298,365543100),l(1126000580,2618297676),l(1288033470,3409855158),l(1501505948,4234509866),l(1607167915,987167468),l(1816402316,1246189591)],f=[];(function(){for(var w=0;w<80;w++)f[w]=l()})();var y=c.SHA512=n.extend({_doReset:function(){this._hash=new d.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(w,b){for(var _=this._hash.words,x=_[0],p=_[1],E=_[2],C=_[3],R=_[4],S=_[5],F=_[6],h=_[7],N=x.high,A=x.low,u=p.high,v=p.low,m=E.high,U=E.low,j=C.high,J=C.low,z=R.high,ne=R.low,he=S.high,ue=S.low,I=F.high,H=F.low,$=h.high,P=h.low,we=N,pe=A,Be=u,q=v,V=m,Ee=U,St=j,xt=J,Ye=z,Me=ne,ct=he,Xe=ue,Tt=I,pt=H,mt=$,gr=P,rt=0;rt<80;rt++){var We,Rt,kr=f[rt];if(rt<16)Rt=kr.high=w[b+rt*2]|0,We=kr.low=w[b+rt*2+1]|0;else{var ts=f[rt-15],Ut=ts.high,tr=ts.low,_n=(Ut>>>1|tr<<31)^(Ut>>>8|tr<<24)^Ut>>>7,rs=(tr>>>1|Ut<<31)^(tr>>>8|Ut<<24)^(tr>>>7|Ut<<25),ss=f[rt-2],rr=ss.high,xr=ss.low,Cn=(rr>>>19|xr<<13)^(rr<<3|xr>>>29)^rr>>>6,Ns=(xr>>>19|rr<<13)^(xr<<3|rr>>>29)^(xr>>>6|rr<<26),Ms=f[rt-7],Dn=Ms.high,An=Ms.low,Br=f[rt-16],js=Br.high,Lt=Br.low;We=rs+An,Rt=_n+Dn+(We>>>0<rs>>>0?1:0),We=We+Ns,Rt=Rt+Cn+(We>>>0<Ns>>>0?1:0),We=We+Lt,Rt=Rt+js+(We>>>0<Lt>>>0?1:0),kr.high=Rt,kr.low=We}var is=Ye&ct^~Ye&Tt,Ir=Me&Xe^~Me&pt,qs=we&Be^we&V^Be&V,Sn=pe&q^pe&Ee^q&Ee,Us=(we>>>28|pe<<4)^(we<<30|pe>>>2)^(we<<25|pe>>>7),Ls=(pe>>>28|we<<4)^(pe<<30|we>>>2)^(pe<<25|we>>>7),Ys=(Ye>>>14|Me<<18)^(Ye>>>18|Me<<14)^(Ye<<23|Me>>>9),Ws=(Me>>>14|Ye<<18)^(Me>>>18|Ye<<14)^(Me<<23|Ye>>>9),Gs=g[rt],Tn=Gs.high,ns=Gs.low,Ge=gr+Ws,Ft=mt+Ys+(Ge>>>0<gr>>>0?1:0),Ge=Ge+Ir,Ft=Ft+is+(Ge>>>0<Ir>>>0?1:0),Ge=Ge+ns,Ft=Ft+Tn+(Ge>>>0<ns>>>0?1:0),Ge=Ge+We,Ft=Ft+Rt+(Ge>>>0<We>>>0?1:0),Vs=Ls+Sn,Rn=Us+qs+(Vs>>>0<Ls>>>0?1:0);mt=Tt,gr=pt,Tt=ct,pt=Xe,ct=Ye,Xe=Me,Me=xt+Ge|0,Ye=St+Ft+(Me>>>0<xt>>>0?1:0)|0,St=V,xt=Ee,V=Be,Ee=q,Be=we,q=pe,pe=Ge+Vs|0,we=Ft+Rn+(pe>>>0<Ge>>>0?1:0)|0}A=x.low=A+pe,x.high=N+we+(A>>>0<pe>>>0?1:0),v=p.low=v+q,p.high=u+Be+(v>>>0<q>>>0?1:0),U=E.low=U+Ee,E.high=m+V+(U>>>0<Ee>>>0?1:0),J=C.low=J+xt,C.high=j+St+(J>>>0<xt>>>0?1:0),ne=R.low=ne+Me,R.high=z+Ye+(ne>>>0<Me>>>0?1:0),ue=S.low=ue+Xe,S.high=he+ct+(ue>>>0<Xe>>>0?1:0),H=F.low=H+pt,F.high=I+Tt+(H>>>0<pt>>>0?1:0),P=h.low=P+gr,h.high=$+mt+(P>>>0<gr>>>0?1:0)},_doFinalize:function(){var w=this._data,b=w.words,_=this._nDataBytes*8,x=w.sigBytes*8;b[x>>>5]|=128<<24-x%32,b[(x+128>>>10<<5)+30]=Math.floor(_/4294967296),b[(x+128>>>10<<5)+31]=_,w.sigBytes=b.length*4,this._process();var p=this._hash.toX32();return p},clone:function(){var w=n.clone.call(this);return w._hash=this._hash.clone(),w},blockSize:1024/32});s.SHA512=n._createHelper(y),s.HmacSHA512=n._createHmacHelper(y)}(),t.SHA512})}(ai)),ai.exports}var oi={exports:{}},Jn;function m0(){return Jn||(Jn=1,function(r,e){(function(t,s,i){r.exports=s(ce(),os(),Xn())})(ie,function(t){return function(){var s=t,i=s.x64,n=i.Word,a=i.WordArray,o=s.algo,d=o.SHA512,c=o.SHA384=d.extend({_doReset:function(){this._hash=new a.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var l=d._doFinalize.call(this);return l.sigBytes-=16,l}});s.SHA384=d._createHelper(c),s.HmacSHA384=d._createHmacHelper(c)}(),t.SHA384})}(oi)),oi.exports}var ci={exports:{}},Qn;function v0(){return Qn||(Qn=1,function(r,e){(function(t,s,i){r.exports=s(ce(),os())})(ie,function(t){return function(s){var i=t,n=i.lib,a=n.WordArray,o=n.Hasher,d=i.x64,c=d.Word,l=i.algo,g=[],f=[],y=[];(function(){for(var _=1,x=0,p=0;p<24;p++){g[_+5*x]=(p+1)*(p+2)/2%64;var E=x%5,C=(2*_+3*x)%5;_=E,x=C}for(var _=0;_<5;_++)for(var x=0;x<5;x++)f[_+5*x]=x+(2*_+3*x)%5*5;for(var R=1,S=0;S<24;S++){for(var F=0,h=0,N=0;N<7;N++){if(R&1){var A=(1<<N)-1;A<32?h^=1<<A:F^=1<<A-32}R&128?R=R<<1^113:R<<=1}y[S]=c.create(F,h)}})();var w=[];(function(){for(var _=0;_<25;_++)w[_]=c.create()})();var b=l.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var _=this._state=[],x=0;x<25;x++)_[x]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(_,x){for(var p=this._state,E=this.blockSize/2,C=0;C<E;C++){var R=_[x+2*C],S=_[x+2*C+1];R=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360,S=(S<<8|S>>>24)&16711935|(S<<24|S>>>8)&4278255360;var F=p[C];F.high^=S,F.low^=R}for(var h=0;h<24;h++){for(var N=0;N<5;N++){for(var A=0,u=0,v=0;v<5;v++){var F=p[N+5*v];A^=F.high,u^=F.low}var m=w[N];m.high=A,m.low=u}for(var N=0;N<5;N++)for(var U=w[(N+4)%5],j=w[(N+1)%5],J=j.high,z=j.low,A=U.high^(J<<1|z>>>31),u=U.low^(z<<1|J>>>31),v=0;v<5;v++){var F=p[N+5*v];F.high^=A,F.low^=u}for(var ne=1;ne<25;ne++){var A,u,F=p[ne],he=F.high,ue=F.low,I=g[ne];I<32?(A=he<<I|ue>>>32-I,u=ue<<I|he>>>32-I):(A=ue<<I-32|he>>>64-I,u=he<<I-32|ue>>>64-I);var H=w[f[ne]];H.high=A,H.low=u}var $=w[0],P=p[0];$.high=P.high,$.low=P.low;for(var N=0;N<5;N++)for(var v=0;v<5;v++){var ne=N+5*v,F=p[ne],we=w[ne],pe=w[(N+1)%5+5*v],Be=w[(N+2)%5+5*v];F.high=we.high^~pe.high&Be.high,F.low=we.low^~pe.low&Be.low}var F=p[0],q=y[h];F.high^=q.high,F.low^=q.low}},_doFinalize:function(){var _=this._data,x=_.words;this._nDataBytes*8;var p=_.sigBytes*8,E=this.blockSize*32;x[p>>>5]|=1<<24-p%32,x[(s.ceil((p+1)/E)*E>>>5)-1]|=128,_.sigBytes=x.length*4,this._process();for(var C=this._state,R=this.cfg.outputLength/8,S=R/8,F=[],h=0;h<S;h++){var N=C[h],A=N.high,u=N.low;A=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,u=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360,F.push(u),F.push(A)}return new a.init(F,R)},clone:function(){for(var _=o.clone.call(this),x=_._state=this._state.slice(0),p=0;p<25;p++)x[p]=x[p].clone();return _}});i.SHA3=o._createHelper(b),i.HmacSHA3=o._createHmacHelper(b)}(Math),t.SHA3})}(ci)),ci.exports}var li={exports:{}},ea;function y0(){return ea||(ea=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){/** @preserve
131
- (c) 2012 by Cédric Mesnil. All rights reserved.
132
-
133
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
134
-
135
- - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
136
- - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
137
-
138
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
139
- */return function(s){var i=t,n=i.lib,a=n.WordArray,o=n.Hasher,d=i.algo,c=a.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),l=a.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),g=a.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=a.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),y=a.create([0,1518500249,1859775393,2400959708,2840853838]),w=a.create([1352829926,1548603684,1836072691,2053994217,0]),b=d.RIPEMD160=o.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(S,F){for(var h=0;h<16;h++){var N=F+h,A=S[N];S[N]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360}var u=this._hash.words,v=y.words,m=w.words,U=c.words,j=l.words,J=g.words,z=f.words,ne,he,ue,I,H,$,P,we,pe,Be;$=ne=u[0],P=he=u[1],we=ue=u[2],pe=I=u[3],Be=H=u[4];for(var q,h=0;h<80;h+=1)q=ne+S[F+U[h]]|0,h<16?q+=_(he,ue,I)+v[0]:h<32?q+=x(he,ue,I)+v[1]:h<48?q+=p(he,ue,I)+v[2]:h<64?q+=E(he,ue,I)+v[3]:q+=C(he,ue,I)+v[4],q=q|0,q=R(q,J[h]),q=q+H|0,ne=H,H=I,I=R(ue,10),ue=he,he=q,q=$+S[F+j[h]]|0,h<16?q+=C(P,we,pe)+m[0]:h<32?q+=E(P,we,pe)+m[1]:h<48?q+=p(P,we,pe)+m[2]:h<64?q+=x(P,we,pe)+m[3]:q+=_(P,we,pe)+m[4],q=q|0,q=R(q,z[h]),q=q+Be|0,$=Be,Be=pe,pe=R(we,10),we=P,P=q;q=u[1]+ue+pe|0,u[1]=u[2]+I+Be|0,u[2]=u[3]+H+$|0,u[3]=u[4]+ne+P|0,u[4]=u[0]+he+we|0,u[0]=q},_doFinalize:function(){var S=this._data,F=S.words,h=this._nDataBytes*8,N=S.sigBytes*8;F[N>>>5]|=128<<24-N%32,F[(N+64>>>9<<4)+14]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360,S.sigBytes=(F.length+1)*4,this._process();for(var A=this._hash,u=A.words,v=0;v<5;v++){var m=u[v];u[v]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360}return A},clone:function(){var S=o.clone.call(this);return S._hash=this._hash.clone(),S}});function _(S,F,h){return S^F^h}function x(S,F,h){return S&F|~S&h}function p(S,F,h){return(S|~F)^h}function E(S,F,h){return S&h|F&~h}function C(S,F,h){return S^(F|~h)}function R(S,F){return S<<F|S>>>32-F}i.RIPEMD160=o._createHelper(b),i.HmacRIPEMD160=o._createHmacHelper(b)}(),t.RIPEMD160})}(li)),li.exports}var di={exports:{}},ta;function hi(){return ta||(ta=1,function(r,e){(function(t,s){r.exports=s(ce())})(ie,function(t){(function(){var s=t,i=s.lib,n=i.Base,a=s.enc,o=a.Utf8,d=s.algo;d.HMAC=n.extend({init:function(c,l){c=this._hasher=new c.init,typeof l=="string"&&(l=o.parse(l));var g=c.blockSize,f=g*4;l.sigBytes>f&&(l=c.finalize(l)),l.clamp();for(var y=this._oKey=l.clone(),w=this._iKey=l.clone(),b=y.words,_=w.words,x=0;x<g;x++)b[x]^=1549556828,_[x]^=909522486;y.sigBytes=w.sigBytes=f,this.reset()},reset:function(){var c=this._hasher;c.reset(),c.update(this._iKey)},update:function(c){return this._hasher.update(c),this},finalize:function(c){var l=this._hasher,g=l.finalize(c);l.reset();var f=l.finalize(this._oKey.clone().concat(g));return f}})})()})}(di)),di.exports}var ui={exports:{}},ra;function w0(){return ra||(ra=1,function(r,e){(function(t,s,i){r.exports=s(ce(),ii(),hi())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.Base,a=i.WordArray,o=s.algo,d=o.SHA256,c=o.HMAC,l=o.PBKDF2=n.extend({cfg:n.extend({keySize:128/32,hasher:d,iterations:25e4}),init:function(g){this.cfg=this.cfg.extend(g)},compute:function(g,f){for(var y=this.cfg,w=c.create(y.hasher,g),b=a.create(),_=a.create([1]),x=b.words,p=_.words,E=y.keySize,C=y.iterations;x.length<E;){var R=w.update(f).finalize(_);w.reset();for(var S=R.words,F=S.length,h=R,N=1;N<C;N++){h=w.finalize(h),w.reset();for(var A=h.words,u=0;u<F;u++)S[u]^=A[u]}b.concat(R),p[0]++}return b.sigBytes=E*4,b}});s.PBKDF2=function(g,f,y){return l.create(y).compute(g,f)}}(),t.PBKDF2})}(ui)),ui.exports}var fi={exports:{}},sa;function Wt(){return sa||(sa=1,function(r,e){(function(t,s,i){r.exports=s(ce(),Vn(),hi())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.Base,a=i.WordArray,o=s.algo,d=o.MD5,c=o.EvpKDF=n.extend({cfg:n.extend({keySize:128/32,hasher:d,iterations:1}),init:function(l){this.cfg=this.cfg.extend(l)},compute:function(l,g){for(var f,y=this.cfg,w=y.hasher.create(),b=a.create(),_=b.words,x=y.keySize,p=y.iterations;_.length<x;){f&&w.update(f),f=w.update(l).finalize(g),w.reset();for(var E=1;E<p;E++)f=w.finalize(f),w.reset();b.concat(f)}return b.sigBytes=x*4,b}});s.EvpKDF=function(l,g,f){return c.create(f).compute(l,g)}}(),t.EvpKDF})}(fi)),fi.exports}var gi={exports:{}},ia;function $e(){return ia||(ia=1,function(r,e){(function(t,s,i){r.exports=s(ce(),Wt())})(ie,function(t){t.lib.Cipher||function(s){var i=t,n=i.lib,a=n.Base,o=n.WordArray,d=n.BufferedBlockAlgorithm,c=i.enc;c.Utf8;var l=c.Base64,g=i.algo,f=g.EvpKDF,y=n.Cipher=d.extend({cfg:a.extend(),createEncryptor:function(A,u){return this.create(this._ENC_XFORM_MODE,A,u)},createDecryptor:function(A,u){return this.create(this._DEC_XFORM_MODE,A,u)},init:function(A,u,v){this.cfg=this.cfg.extend(v),this._xformMode=A,this._key=u,this.reset()},reset:function(){d.reset.call(this),this._doReset()},process:function(A){return this._append(A),this._process()},finalize:function(A){A&&this._append(A);var u=this._doFinalize();return u},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function A(u){return typeof u=="string"?N:S}return function(u){return{encrypt:function(v,m,U){return A(m).encrypt(u,v,m,U)},decrypt:function(v,m,U){return A(m).decrypt(u,v,m,U)}}}}()});n.StreamCipher=y.extend({_doFinalize:function(){var A=this._process(!0);return A},blockSize:1});var w=i.mode={},b=n.BlockCipherMode=a.extend({createEncryptor:function(A,u){return this.Encryptor.create(A,u)},createDecryptor:function(A,u){return this.Decryptor.create(A,u)},init:function(A,u){this._cipher=A,this._iv=u}}),_=w.CBC=function(){var A=b.extend();A.Encryptor=A.extend({processBlock:function(v,m){var U=this._cipher,j=U.blockSize;u.call(this,v,m,j),U.encryptBlock(v,m),this._prevBlock=v.slice(m,m+j)}}),A.Decryptor=A.extend({processBlock:function(v,m){var U=this._cipher,j=U.blockSize,J=v.slice(m,m+j);U.decryptBlock(v,m),u.call(this,v,m,j),this._prevBlock=J}});function u(v,m,U){var j,J=this._iv;J?(j=J,this._iv=s):j=this._prevBlock;for(var z=0;z<U;z++)v[m+z]^=j[z]}return A}(),x=i.pad={},p=x.Pkcs7={pad:function(A,u){for(var v=u*4,m=v-A.sigBytes%v,U=m<<24|m<<16|m<<8|m,j=[],J=0;J<m;J+=4)j.push(U);var z=o.create(j,m);A.concat(z)},unpad:function(A){var u=A.words[A.sigBytes-1>>>2]&255;A.sigBytes-=u}};n.BlockCipher=y.extend({cfg:y.cfg.extend({mode:_,padding:p}),reset:function(){var A;y.reset.call(this);var u=this.cfg,v=u.iv,m=u.mode;this._xformMode==this._ENC_XFORM_MODE?A=m.createEncryptor:(A=m.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==A?this._mode.init(this,v&&v.words):(this._mode=A.call(m,this,v&&v.words),this._mode.__creator=A)},_doProcessBlock:function(A,u){this._mode.processBlock(A,u)},_doFinalize:function(){var A,u=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(u.pad(this._data,this.blockSize),A=this._process(!0)):(A=this._process(!0),u.unpad(A)),A},blockSize:128/32});var E=n.CipherParams=a.extend({init:function(A){this.mixIn(A)},toString:function(A){return(A||this.formatter).stringify(this)}}),C=i.format={},R=C.OpenSSL={stringify:function(A){var u,v=A.ciphertext,m=A.salt;return m?u=o.create([1398893684,1701076831]).concat(m).concat(v):u=v,u.toString(l)},parse:function(A){var u,v=l.parse(A),m=v.words;return m[0]==1398893684&&m[1]==1701076831&&(u=o.create(m.slice(2,4)),m.splice(0,4),v.sigBytes-=16),E.create({ciphertext:v,salt:u})}},S=n.SerializableCipher=a.extend({cfg:a.extend({format:R}),encrypt:function(A,u,v,m){m=this.cfg.extend(m);var U=A.createEncryptor(v,m),j=U.finalize(u),J=U.cfg;return E.create({ciphertext:j,key:v,iv:J.iv,algorithm:A,mode:J.mode,padding:J.padding,blockSize:A.blockSize,formatter:m.format})},decrypt:function(A,u,v,m){m=this.cfg.extend(m),u=this._parse(u,m.format);var U=A.createDecryptor(v,m).finalize(u.ciphertext);return U},_parse:function(A,u){return typeof A=="string"?u.parse(A,this):A}}),F=i.kdf={},h=F.OpenSSL={execute:function(A,u,v,m,U){if(m||(m=o.random(64/8)),U)var j=f.create({keySize:u+v,hasher:U}).compute(A,m);else var j=f.create({keySize:u+v}).compute(A,m);var J=o.create(j.words.slice(u),v*4);return j.sigBytes=u*4,E.create({key:j,iv:J,salt:m})}},N=n.PasswordBasedCipher=S.extend({cfg:S.cfg.extend({kdf:h}),encrypt:function(A,u,v,m){m=this.cfg.extend(m);var U=m.kdf.execute(v,A.keySize,A.ivSize,m.salt,m.hasher);m.iv=U.iv;var j=S.encrypt.call(this,A,u,U.key,m);return j.mixIn(U),j},decrypt:function(A,u,v,m){m=this.cfg.extend(m),u=this._parse(u,m.format);var U=m.kdf.execute(v,A.keySize,A.ivSize,u.salt,m.hasher);m.iv=U.iv;var j=S.decrypt.call(this,A,u,U.key,m);return j}})}()})}(gi)),gi.exports}var xi={exports:{}},na;function E0(){return na||(na=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.mode.CFB=function(){var s=t.lib.BlockCipherMode.extend();s.Encryptor=s.extend({processBlock:function(n,a){var o=this._cipher,d=o.blockSize;i.call(this,n,a,d,o),this._prevBlock=n.slice(a,a+d)}}),s.Decryptor=s.extend({processBlock:function(n,a){var o=this._cipher,d=o.blockSize,c=n.slice(a,a+d);i.call(this,n,a,d,o),this._prevBlock=c}});function i(n,a,o,d){var c,l=this._iv;l?(c=l.slice(0),this._iv=void 0):c=this._prevBlock,d.encryptBlock(c,0);for(var g=0;g<o;g++)n[a+g]^=c[g]}return s}(),t.mode.CFB})}(xi)),xi.exports}var pi={exports:{}},aa;function b0(){return aa||(aa=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.mode.CTR=function(){var s=t.lib.BlockCipherMode.extend(),i=s.Encryptor=s.extend({processBlock:function(n,a){var o=this._cipher,d=o.blockSize,c=this._iv,l=this._counter;c&&(l=this._counter=c.slice(0),this._iv=void 0);var g=l.slice(0);o.encryptBlock(g,0),l[d-1]=l[d-1]+1|0;for(var f=0;f<d;f++)n[a+f]^=g[f]}});return s.Decryptor=i,s}(),t.mode.CTR})}(pi)),pi.exports}var mi={exports:{}},oa;function _0(){return oa||(oa=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){/** @preserve
140
- * Counter block mode compatible with Dr Brian Gladman fileenc.c
141
- * derived from CryptoJS.mode.CTR
142
- * Jan Hruby jhruby.web@gmail.com
143
- */return t.mode.CTRGladman=function(){var s=t.lib.BlockCipherMode.extend();function i(o){if((o>>24&255)===255){var d=o>>16&255,c=o>>8&255,l=o&255;d===255?(d=0,c===255?(c=0,l===255?l=0:++l):++c):++d,o=0,o+=d<<16,o+=c<<8,o+=l}else o+=1<<24;return o}function n(o){return(o[0]=i(o[0]))===0&&(o[1]=i(o[1])),o}var a=s.Encryptor=s.extend({processBlock:function(o,d){var c=this._cipher,l=c.blockSize,g=this._iv,f=this._counter;g&&(f=this._counter=g.slice(0),this._iv=void 0),n(f);var y=f.slice(0);c.encryptBlock(y,0);for(var w=0;w<l;w++)o[d+w]^=y[w]}});return s.Decryptor=a,s}(),t.mode.CTRGladman})}(mi)),mi.exports}var vi={exports:{}},ca;function C0(){return ca||(ca=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.mode.OFB=function(){var s=t.lib.BlockCipherMode.extend(),i=s.Encryptor=s.extend({processBlock:function(n,a){var o=this._cipher,d=o.blockSize,c=this._iv,l=this._keystream;c&&(l=this._keystream=c.slice(0),this._iv=void 0),o.encryptBlock(l,0);for(var g=0;g<d;g++)n[a+g]^=l[g]}});return s.Decryptor=i,s}(),t.mode.OFB})}(vi)),vi.exports}var yi={exports:{}},la;function D0(){return la||(la=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.mode.ECB=function(){var s=t.lib.BlockCipherMode.extend();return s.Encryptor=s.extend({processBlock:function(i,n){this._cipher.encryptBlock(i,n)}}),s.Decryptor=s.extend({processBlock:function(i,n){this._cipher.decryptBlock(i,n)}}),s}(),t.mode.ECB})}(yi)),yi.exports}var wi={exports:{}},da;function A0(){return da||(da=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.pad.AnsiX923={pad:function(s,i){var n=s.sigBytes,a=i*4,o=a-n%a,d=n+o-1;s.clamp(),s.words[d>>>2]|=o<<24-d%4*8,s.sigBytes+=o},unpad:function(s){var i=s.words[s.sigBytes-1>>>2]&255;s.sigBytes-=i}},t.pad.Ansix923})}(wi)),wi.exports}var Ei={exports:{}},ha;function S0(){return ha||(ha=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.pad.Iso10126={pad:function(s,i){var n=i*4,a=n-s.sigBytes%n;s.concat(t.lib.WordArray.random(a-1)).concat(t.lib.WordArray.create([a<<24],1))},unpad:function(s){var i=s.words[s.sigBytes-1>>>2]&255;s.sigBytes-=i}},t.pad.Iso10126})}(Ei)),Ei.exports}var bi={exports:{}},ua;function T0(){return ua||(ua=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.pad.Iso97971={pad:function(s,i){s.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(s,i)},unpad:function(s){t.pad.ZeroPadding.unpad(s),s.sigBytes--}},t.pad.Iso97971})}(bi)),bi.exports}var _i={exports:{}},fa;function R0(){return fa||(fa=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.pad.ZeroPadding={pad:function(s,i){var n=i*4;s.clamp(),s.sigBytes+=n-(s.sigBytes%n||n)},unpad:function(s){for(var i=s.words,n=s.sigBytes-1,n=s.sigBytes-1;n>=0;n--)if(i[n>>>2]>>>24-n%4*8&255){s.sigBytes=n+1;break}}},t.pad.ZeroPadding})}(_i)),_i.exports}var Ci={exports:{}},ga;function F0(){return ga||(ga=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding})}(Ci)),Ci.exports}var Di={exports:{}},xa;function k0(){return xa||(xa=1,function(r,e){(function(t,s,i){r.exports=s(ce(),$e())})(ie,function(t){return function(s){var i=t,n=i.lib,a=n.CipherParams,o=i.enc,d=o.Hex,c=i.format;c.Hex={stringify:function(l){return l.ciphertext.toString(d)},parse:function(l){var g=d.parse(l);return a.create({ciphertext:g})}}}(),t.format.Hex})}(Di)),Di.exports}var Ai={exports:{}},pa;function B0(){return pa||(pa=1,function(r,e){(function(t,s,i){r.exports=s(ce(),sr(),ir(),Wt(),$e())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.BlockCipher,a=s.algo,o=[],d=[],c=[],l=[],g=[],f=[],y=[],w=[],b=[],_=[];(function(){for(var E=[],C=0;C<256;C++)C<128?E[C]=C<<1:E[C]=C<<1^283;for(var R=0,S=0,C=0;C<256;C++){var F=S^S<<1^S<<2^S<<3^S<<4;F=F>>>8^F&255^99,o[R]=F,d[F]=R;var h=E[R],N=E[h],A=E[N],u=E[F]*257^F*16843008;c[R]=u<<24|u>>>8,l[R]=u<<16|u>>>16,g[R]=u<<8|u>>>24,f[R]=u;var u=A*16843009^N*65537^h*257^R*16843008;y[F]=u<<24|u>>>8,w[F]=u<<16|u>>>16,b[F]=u<<8|u>>>24,_[F]=u,R?(R=h^E[E[E[A^h]]],S^=E[E[S]]):R=S=1}})();var x=[0,1,2,4,8,16,32,64,128,27,54],p=a.AES=n.extend({_doReset:function(){var E;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var C=this._keyPriorReset=this._key,R=C.words,S=C.sigBytes/4,F=this._nRounds=S+6,h=(F+1)*4,N=this._keySchedule=[],A=0;A<h;A++)A<S?N[A]=R[A]:(E=N[A-1],A%S?S>6&&A%S==4&&(E=o[E>>>24]<<24|o[E>>>16&255]<<16|o[E>>>8&255]<<8|o[E&255]):(E=E<<8|E>>>24,E=o[E>>>24]<<24|o[E>>>16&255]<<16|o[E>>>8&255]<<8|o[E&255],E^=x[A/S|0]<<24),N[A]=N[A-S]^E);for(var u=this._invKeySchedule=[],v=0;v<h;v++){var A=h-v;if(v%4)var E=N[A];else var E=N[A-4];v<4||A<=4?u[v]=E:u[v]=y[o[E>>>24]]^w[o[E>>>16&255]]^b[o[E>>>8&255]]^_[o[E&255]]}}},encryptBlock:function(E,C){this._doCryptBlock(E,C,this._keySchedule,c,l,g,f,o)},decryptBlock:function(E,C){var R=E[C+1];E[C+1]=E[C+3],E[C+3]=R,this._doCryptBlock(E,C,this._invKeySchedule,y,w,b,_,d);var R=E[C+1];E[C+1]=E[C+3],E[C+3]=R},_doCryptBlock:function(E,C,R,S,F,h,N,A){for(var u=this._nRounds,v=E[C]^R[0],m=E[C+1]^R[1],U=E[C+2]^R[2],j=E[C+3]^R[3],J=4,z=1;z<u;z++){var ne=S[v>>>24]^F[m>>>16&255]^h[U>>>8&255]^N[j&255]^R[J++],he=S[m>>>24]^F[U>>>16&255]^h[j>>>8&255]^N[v&255]^R[J++],ue=S[U>>>24]^F[j>>>16&255]^h[v>>>8&255]^N[m&255]^R[J++],I=S[j>>>24]^F[v>>>16&255]^h[m>>>8&255]^N[U&255]^R[J++];v=ne,m=he,U=ue,j=I}var ne=(A[v>>>24]<<24|A[m>>>16&255]<<16|A[U>>>8&255]<<8|A[j&255])^R[J++],he=(A[m>>>24]<<24|A[U>>>16&255]<<16|A[j>>>8&255]<<8|A[v&255])^R[J++],ue=(A[U>>>24]<<24|A[j>>>16&255]<<16|A[v>>>8&255]<<8|A[m&255])^R[J++],I=(A[j>>>24]<<24|A[v>>>16&255]<<16|A[m>>>8&255]<<8|A[U&255])^R[J++];E[C]=ne,E[C+1]=he,E[C+2]=ue,E[C+3]=I},keySize:256/32});s.AES=n._createHelper(p)}(),t.AES})}(Ai)),Ai.exports}var Si={exports:{}},ma;function I0(){return ma||(ma=1,function(r,e){(function(t,s,i){r.exports=s(ce(),sr(),ir(),Wt(),$e())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.WordArray,a=i.BlockCipher,o=s.algo,d=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],c=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],l=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],g=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],y=o.DES=a.extend({_doReset:function(){for(var x=this._key,p=x.words,E=[],C=0;C<56;C++){var R=d[C]-1;E[C]=p[R>>>5]>>>31-R%32&1}for(var S=this._subKeys=[],F=0;F<16;F++){for(var h=S[F]=[],N=l[F],C=0;C<24;C++)h[C/6|0]|=E[(c[C]-1+N)%28]<<31-C%6,h[4+(C/6|0)]|=E[28+(c[C+24]-1+N)%28]<<31-C%6;h[0]=h[0]<<1|h[0]>>>31;for(var C=1;C<7;C++)h[C]=h[C]>>>(C-1)*4+3;h[7]=h[7]<<5|h[7]>>>27}for(var A=this._invSubKeys=[],C=0;C<16;C++)A[C]=S[15-C]},encryptBlock:function(x,p){this._doCryptBlock(x,p,this._subKeys)},decryptBlock:function(x,p){this._doCryptBlock(x,p,this._invSubKeys)},_doCryptBlock:function(x,p,E){this._lBlock=x[p],this._rBlock=x[p+1],w.call(this,4,252645135),w.call(this,16,65535),b.call(this,2,858993459),b.call(this,8,16711935),w.call(this,1,1431655765);for(var C=0;C<16;C++){for(var R=E[C],S=this._lBlock,F=this._rBlock,h=0,N=0;N<8;N++)h|=g[N][((F^R[N])&f[N])>>>0];this._lBlock=F,this._rBlock=S^h}var A=this._lBlock;this._lBlock=this._rBlock,this._rBlock=A,w.call(this,1,1431655765),b.call(this,8,16711935),b.call(this,2,858993459),w.call(this,16,65535),w.call(this,4,252645135),x[p]=this._lBlock,x[p+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function w(x,p){var E=(this._lBlock>>>x^this._rBlock)&p;this._rBlock^=E,this._lBlock^=E<<x}function b(x,p){var E=(this._rBlock>>>x^this._lBlock)&p;this._lBlock^=E,this._rBlock^=E<<x}s.DES=a._createHelper(y);var _=o.TripleDES=a.extend({_doReset:function(){var x=this._key,p=x.words;if(p.length!==2&&p.length!==4&&p.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var E=p.slice(0,2),C=p.length<4?p.slice(0,2):p.slice(2,4),R=p.length<6?p.slice(0,2):p.slice(4,6);this._des1=y.createEncryptor(n.create(E)),this._des2=y.createEncryptor(n.create(C)),this._des3=y.createEncryptor(n.create(R))},encryptBlock:function(x,p){this._des1.encryptBlock(x,p),this._des2.decryptBlock(x,p),this._des3.encryptBlock(x,p)},decryptBlock:function(x,p){this._des3.decryptBlock(x,p),this._des2.encryptBlock(x,p),this._des1.decryptBlock(x,p)},keySize:192/32,ivSize:64/32,blockSize:64/32});s.TripleDES=a._createHelper(_)}(),t.TripleDES})}(Si)),Si.exports}var Ti={exports:{}},va;function P0(){return va||(va=1,function(r,e){(function(t,s,i){r.exports=s(ce(),sr(),ir(),Wt(),$e())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.StreamCipher,a=s.algo,o=a.RC4=n.extend({_doReset:function(){for(var l=this._key,g=l.words,f=l.sigBytes,y=this._S=[],w=0;w<256;w++)y[w]=w;for(var w=0,b=0;w<256;w++){var _=w%f,x=g[_>>>2]>>>24-_%4*8&255;b=(b+y[w]+x)%256;var p=y[w];y[w]=y[b],y[b]=p}this._i=this._j=0},_doProcessBlock:function(l,g){l[g]^=d.call(this)},keySize:256/32,ivSize:0});function d(){for(var l=this._S,g=this._i,f=this._j,y=0,w=0;w<4;w++){g=(g+1)%256,f=(f+l[g])%256;var b=l[g];l[g]=l[f],l[f]=b,y|=l[(l[g]+l[f])%256]<<24-w*8}return this._i=g,this._j=f,y}s.RC4=n._createHelper(o);var c=a.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var l=this.cfg.drop;l>0;l--)d.call(this)}});s.RC4Drop=n._createHelper(c)}(),t.RC4})}(Ti)),Ti.exports}var Ri={exports:{}},ya;function H0(){return ya||(ya=1,function(r,e){(function(t,s,i){r.exports=s(ce(),sr(),ir(),Wt(),$e())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.StreamCipher,a=s.algo,o=[],d=[],c=[],l=a.Rabbit=n.extend({_doReset:function(){for(var f=this._key.words,y=this.cfg.iv,w=0;w<4;w++)f[w]=(f[w]<<8|f[w]>>>24)&16711935|(f[w]<<24|f[w]>>>8)&4278255360;var b=this._X=[f[0],f[3]<<16|f[2]>>>16,f[1],f[0]<<16|f[3]>>>16,f[2],f[1]<<16|f[0]>>>16,f[3],f[2]<<16|f[1]>>>16],_=this._C=[f[2]<<16|f[2]>>>16,f[0]&4294901760|f[1]&65535,f[3]<<16|f[3]>>>16,f[1]&4294901760|f[2]&65535,f[0]<<16|f[0]>>>16,f[2]&4294901760|f[3]&65535,f[1]<<16|f[1]>>>16,f[3]&4294901760|f[0]&65535];this._b=0;for(var w=0;w<4;w++)g.call(this);for(var w=0;w<8;w++)_[w]^=b[w+4&7];if(y){var x=y.words,p=x[0],E=x[1],C=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,R=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,S=C>>>16|R&4294901760,F=R<<16|C&65535;_[0]^=C,_[1]^=S,_[2]^=R,_[3]^=F,_[4]^=C,_[5]^=S,_[6]^=R,_[7]^=F;for(var w=0;w<4;w++)g.call(this)}},_doProcessBlock:function(f,y){var w=this._X;g.call(this),o[0]=w[0]^w[5]>>>16^w[3]<<16,o[1]=w[2]^w[7]>>>16^w[5]<<16,o[2]=w[4]^w[1]>>>16^w[7]<<16,o[3]=w[6]^w[3]>>>16^w[1]<<16;for(var b=0;b<4;b++)o[b]=(o[b]<<8|o[b]>>>24)&16711935|(o[b]<<24|o[b]>>>8)&4278255360,f[y+b]^=o[b]},blockSize:128/32,ivSize:64/32});function g(){for(var f=this._X,y=this._C,w=0;w<8;w++)d[w]=y[w];y[0]=y[0]+1295307597+this._b|0,y[1]=y[1]+3545052371+(y[0]>>>0<d[0]>>>0?1:0)|0,y[2]=y[2]+886263092+(y[1]>>>0<d[1]>>>0?1:0)|0,y[3]=y[3]+1295307597+(y[2]>>>0<d[2]>>>0?1:0)|0,y[4]=y[4]+3545052371+(y[3]>>>0<d[3]>>>0?1:0)|0,y[5]=y[5]+886263092+(y[4]>>>0<d[4]>>>0?1:0)|0,y[6]=y[6]+1295307597+(y[5]>>>0<d[5]>>>0?1:0)|0,y[7]=y[7]+3545052371+(y[6]>>>0<d[6]>>>0?1:0)|0,this._b=y[7]>>>0<d[7]>>>0?1:0;for(var w=0;w<8;w++){var b=f[w]+y[w],_=b&65535,x=b>>>16,p=((_*_>>>17)+_*x>>>15)+x*x,E=((b&4294901760)*b|0)+((b&65535)*b|0);c[w]=p^E}f[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,f[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,f[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,f[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,f[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,f[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,f[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,f[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}s.Rabbit=n._createHelper(l)}(),t.Rabbit})}(Ri)),Ri.exports}var Fi={exports:{}},wa;function $0(){return wa||(wa=1,function(r,e){(function(t,s,i){r.exports=s(ce(),sr(),ir(),Wt(),$e())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.StreamCipher,a=s.algo,o=[],d=[],c=[],l=a.RabbitLegacy=n.extend({_doReset:function(){var f=this._key.words,y=this.cfg.iv,w=this._X=[f[0],f[3]<<16|f[2]>>>16,f[1],f[0]<<16|f[3]>>>16,f[2],f[1]<<16|f[0]>>>16,f[3],f[2]<<16|f[1]>>>16],b=this._C=[f[2]<<16|f[2]>>>16,f[0]&4294901760|f[1]&65535,f[3]<<16|f[3]>>>16,f[1]&4294901760|f[2]&65535,f[0]<<16|f[0]>>>16,f[2]&4294901760|f[3]&65535,f[1]<<16|f[1]>>>16,f[3]&4294901760|f[0]&65535];this._b=0;for(var _=0;_<4;_++)g.call(this);for(var _=0;_<8;_++)b[_]^=w[_+4&7];if(y){var x=y.words,p=x[0],E=x[1],C=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,R=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,S=C>>>16|R&4294901760,F=R<<16|C&65535;b[0]^=C,b[1]^=S,b[2]^=R,b[3]^=F,b[4]^=C,b[5]^=S,b[6]^=R,b[7]^=F;for(var _=0;_<4;_++)g.call(this)}},_doProcessBlock:function(f,y){var w=this._X;g.call(this),o[0]=w[0]^w[5]>>>16^w[3]<<16,o[1]=w[2]^w[7]>>>16^w[5]<<16,o[2]=w[4]^w[1]>>>16^w[7]<<16,o[3]=w[6]^w[3]>>>16^w[1]<<16;for(var b=0;b<4;b++)o[b]=(o[b]<<8|o[b]>>>24)&16711935|(o[b]<<24|o[b]>>>8)&4278255360,f[y+b]^=o[b]},blockSize:128/32,ivSize:64/32});function g(){for(var f=this._X,y=this._C,w=0;w<8;w++)d[w]=y[w];y[0]=y[0]+1295307597+this._b|0,y[1]=y[1]+3545052371+(y[0]>>>0<d[0]>>>0?1:0)|0,y[2]=y[2]+886263092+(y[1]>>>0<d[1]>>>0?1:0)|0,y[3]=y[3]+1295307597+(y[2]>>>0<d[2]>>>0?1:0)|0,y[4]=y[4]+3545052371+(y[3]>>>0<d[3]>>>0?1:0)|0,y[5]=y[5]+886263092+(y[4]>>>0<d[4]>>>0?1:0)|0,y[6]=y[6]+1295307597+(y[5]>>>0<d[5]>>>0?1:0)|0,y[7]=y[7]+3545052371+(y[6]>>>0<d[6]>>>0?1:0)|0,this._b=y[7]>>>0<d[7]>>>0?1:0;for(var w=0;w<8;w++){var b=f[w]+y[w],_=b&65535,x=b>>>16,p=((_*_>>>17)+_*x>>>15)+x*x,E=((b&4294901760)*b|0)+((b&65535)*b|0);c[w]=p^E}f[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,f[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,f[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,f[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,f[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,f[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,f[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,f[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}s.RabbitLegacy=n._createHelper(l)}(),t.RabbitLegacy})}(Fi)),Fi.exports}var ki={exports:{}},Ea;function O0(){return Ea||(Ea=1,function(r,e){(function(t,s,i){r.exports=s(ce(),sr(),ir(),Wt(),$e())})(ie,function(t){return function(){var s=t,i=s.lib,n=i.BlockCipher,a=s.algo;const o=16,d=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],c=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var l={pbox:[],sbox:[]};function g(_,x){let p=x>>24&255,E=x>>16&255,C=x>>8&255,R=x&255,S=_.sbox[0][p]+_.sbox[1][E];return S=S^_.sbox[2][C],S=S+_.sbox[3][R],S}function f(_,x,p){let E=x,C=p,R;for(let S=0;S<o;++S)E=E^_.pbox[S],C=g(_,E)^C,R=E,E=C,C=R;return R=E,E=C,C=R,C=C^_.pbox[o],E=E^_.pbox[o+1],{left:E,right:C}}function y(_,x,p){let E=x,C=p,R;for(let S=o+1;S>1;--S)E=E^_.pbox[S],C=g(_,E)^C,R=E,E=C,C=R;return R=E,E=C,C=R,C=C^_.pbox[1],E=E^_.pbox[0],{left:E,right:C}}function w(_,x,p){for(let F=0;F<4;F++){_.sbox[F]=[];for(let h=0;h<256;h++)_.sbox[F][h]=c[F][h]}let E=0;for(let F=0;F<o+2;F++)_.pbox[F]=d[F]^x[E],E++,E>=p&&(E=0);let C=0,R=0,S=0;for(let F=0;F<o+2;F+=2)S=f(_,C,R),C=S.left,R=S.right,_.pbox[F]=C,_.pbox[F+1]=R;for(let F=0;F<4;F++)for(let h=0;h<256;h+=2)S=f(_,C,R),C=S.left,R=S.right,_.sbox[F][h]=C,_.sbox[F][h+1]=R;return!0}var b=a.Blowfish=n.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var _=this._keyPriorReset=this._key,x=_.words,p=_.sigBytes/4;w(l,x,p)}},encryptBlock:function(_,x){var p=f(l,_[x],_[x+1]);_[x]=p.left,_[x+1]=p.right},decryptBlock:function(_,x){var p=y(l,_[x],_[x+1]);_[x]=p.left,_[x+1]=p.right},blockSize:64/32,keySize:128/32,ivSize:64/32});s.Blowfish=n._createHelper(b)}(),t.Blowfish})}(ki)),ki.exports}(function(r,e){(function(t,s,i){r.exports=s(ce(),os(),f0(),g0(),sr(),x0(),ir(),Vn(),ii(),p0(),Xn(),m0(),v0(),y0(),hi(),w0(),Wt(),$e(),E0(),b0(),_0(),C0(),D0(),A0(),S0(),T0(),R0(),F0(),k0(),B0(),I0(),P0(),H0(),$0(),O0())})(ie,function(t){return t})})(Nn);var N0=Nn.exports;const nr=Vo(N0);let L=null,Ae=null,mr=null;const Te={setConfig(r){L=r},getConfig(){return L},decrypt(r,e=null,t=null){var s,i;try{const n=e||((s=L==null?void 0:L.env)==null?void 0:s.DECODE_IV)||"default_iv_1234",a=t||((i=L==null?void 0:L.env)==null?void 0:i.DECODE_KEY)||"default_key_1234",o=nr.enc.Base64.parse(r),d=nr.enc.Utf8.parse(a),c=nr.enc.Utf8.parse(n);return nr.AES.decrypt({ciphertext:o},d,{iv:c,mode:nr.mode.CTR,padding:nr.pad.NoPadding}).toString(nr.enc.Utf8)}catch(n){return console.log("ERROR ===> failed decrypt:",n),!1}},pushSound(){try{mr&&clearInterval(mr);const r=()=>{try{(!Ae||Ae.state==="closed")&&(Ae=new(window.AudioContext||window.webkitAudioContext)),Ae.state==="suspended"&&Ae.resume();const e=Ae.createOscillator(),t=Ae.createOscillator(),s=Ae.createGain();e.type="sine",t.type="sine",e.frequency.setValueAtTime(400,Ae.currentTime),t.frequency.setValueAtTime(450,Ae.currentTime);const i=Ae.createOscillator(),n=Ae.createGain();i.frequency.value=25,n.gain.value=15,i.connect(n),n.connect(e.frequency),n.connect(t.frequency),e.connect(s),t.connect(s),s.connect(Ae.destination),s.gain.setValueAtTime(0,Ae.currentTime),s.gain.linearRampToValueAtTime(.08,Ae.currentTime+.05),s.gain.setValueAtTime(.08,Ae.currentTime+1.2),s.gain.linearRampToValueAtTime(0,Ae.currentTime+1.3),i.start(),e.start(),t.start(),i.stop(Ae.currentTime+1.4),e.stop(Ae.currentTime+1.4),t.stop(Ae.currentTime+1.4)}catch(e){console.warn("Failed to play synthesized tone:",e)}};r(),mr=setInterval(r,3e3)}catch(r){console.warn("AudioContext initialization failed:",r)}},stopSound(){mr&&(clearInterval(mr),mr=null),Ae&&(Ae.close().catch(()=>{}),Ae=null)},pushNotification(r){G.emitToParent("show_notification",{message:r})},toHHMMSS(r){const e=parseInt(r,10),t=Math.floor(e/3600),s=Math.floor(e/60)%60,i=e%60;return[t,s,i].map(n=>n<10?"0"+n:n).filter((n,a)=>n!=="00"||a>0).join(":")},mute(r,e,t,s){r?e?r.unmute():r.mute():s&&(e?s.unmuteAudio():s.muteAudio()),t(!e)},hold(r,e,t,s){r?e?r.unhold():r.hold():s&&(e?s.unhold():s.hold()),t(!e)},async hangup(r,e,t,s,i,n,a,o){s&&await s(!1),i&&i(!1),n&&n(0),r&&r.current&&clearInterval(r.current),e?(await(e==null?void 0:e.terminate("hangup")),a&&a(!1),G.emitLocal("yeastarSession",!1)):t&&(await(t==null?void 0:t.hangup()),o&&o(!1),G.emitLocal("flashphonerCall",!1))},attachRemoteAudio(r){if(!r)return;let e=document.getElementById("ys-remote-audio");e||(e=document.createElement("audio"),e.id="ys-remote-audio",e.autoplay=!0,e.playsInline=!0,e.hidden=!0,document.body.appendChild(e)),e.srcObject=r,e.play().catch(()=>{console.warn("User gesture needed to play audio"),G.emitLocal("needUserGestureToPlay",!0)})},getContactName(r){return r&&((L==null?void 0:L.contacts)||{1001:"John Doe",1002:"Jane Smith","08123456789":"Alice Johnson",123:"Customer Support"})[r]||null},getCpaasBaseUrl(){var r,e;return(L==null?void 0:L.cpaas_base_url)||(L==null?void 0:L.cpaasBaseUrl)||((r=L==null?void 0:L.env)==null?void 0:r.CPAAS_BASE_URL)||((e=L==null?void 0:L.pabxConfig)==null?void 0:e.cpaas_base_url)||"https://api-cpaas.omnix.co.id"},getSipHost(){var e,t,s;const r=i=>{var n;return((n=i==null?void 0:i.replace("https://",""))==null?void 0:n.replace("http://",""))||null};return r(L==null?void 0:L.pbx_url)||r((e=L==null?void 0:L.pabxConfig)==null?void 0:e.pbx_url)||r((t=L==null?void 0:L.auth)==null?void 0:t.pabx_host)||((s=L==null?void 0:L.auth)==null?void 0:s.pbxurl)||null},getWssHost(){var e;const r=t=>{var s;return((s=t==null?void 0:t.replace(/^wss?:\/\//,""))==null?void 0:s.replace(/\/$/,""))||null};return r(L==null?void 0:L.sip_url)||r((e=L==null?void 0:L.pabxConfig)==null?void 0:e.sip_url)||this.getSipHost()},async updateExtensionStatus(r,e="Ready",t="ready"){var s,i,n;try{const a=(L==null?void 0:L["X-CPAAS-Key-Fingerprint"])||(L==null?void 0:L.fingerprint)||(L==null?void 0:L.cpaasKeyFingerprint)||((s=L==null?void 0:L.env)==null?void 0:s.fingerprint)||((i=L==null?void 0:L.env)==null?void 0:i.X_CPAAS_Key_Fingerprint)||((n=L==null?void 0:L.pabxConfig)==null?void 0:n["X-CPAAS-Key-Fingerprint"]);if(!a)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot update extension status."),!1;const o=this.getCpaasBaseUrl(),d=await fetch(`${o}/voice/extensions/status`,{method:"POST",headers:{"X-CPAAS-Key-Fingerprint":a,"Content-Type":"application/json"},body:JSON.stringify({extension:r,status:e,reason:t})}),c=await d.json();return console.log(`[ExtStatus] ${e}/${t}:`,c),d.ok}catch(a){return console.error("Failed to update extension status:",a),!1}},async fetchExtensionStatus(r){var e,t,s,i;try{const n=(L==null?void 0:L["X-CPAAS-Key-Fingerprint"])||(L==null?void 0:L.fingerprint)||(L==null?void 0:L.cpaasKeyFingerprint)||((e=L==null?void 0:L.env)==null?void 0:e.fingerprint)||((t=L==null?void 0:L.env)==null?void 0:t.X_CPAAS_Key_Fingerprint)||((s=L==null?void 0:L.pabxConfig)==null?void 0:s["X-CPAAS-Key-Fingerprint"]);if(!n)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot fetch extension status."),null;const a=this.getCpaasBaseUrl(),o=await fetch(`${a}/voice/portal/extension?extension=${encodeURIComponent(r)}`,{method:"GET",headers:{"X-CPAAS-Key-Fingerprint":n,"Content-Type":"application/json"}});if(!o.ok)return null;const d=await o.json(),c=(i=d==null?void 0:d.data)==null?void 0:i[0];return console.log(`[ExtStatus] fetch ${r}:`,c),c||null}catch(n){return console.error("Failed to fetch extension status:",n),null}},getExtensionUsername(){var r,e;return((r=L==null?void 0:L.auth)==null?void 0:r.user_pbx)||((e=L==null?void 0:L.auth)==null?void 0:e.username)||null}},M0="0.21.1";class ar extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class Bi extends ar{constructor(e){super(e||"Unsupported content type.")}}class Ii extends ar{constructor(e){super(e||"Request pending.")}}class j0 extends ar{constructor(e){super(e||"Unspecified session description handler error.")}}class Pi extends ar{constructor(){super("The session has terminated.")}}class Mr extends ar{constructor(e){super(e||"An error occurred during state transition.")}}class q0{constructor(e){this.incomingAckRequest=e}get request(){return this.incomingAckRequest.message}}class U0{constructor(e){this.incomingByeRequest=e}get request(){return this.incomingByeRequest.message}accept(e){return this.incomingByeRequest.accept(e),Promise.resolve()}reject(e){return this.incomingByeRequest.reject(e),Promise.resolve()}}class L0{constructor(e){this.incomingCancelRequest=e}get request(){return this.incomingCancelRequest}}class jr{constructor(){this.listeners=new Array}addListener(e,t){const s=i=>{this.removeListener(s),e(i)};(t==null?void 0:t.once)===!0?this.listeners.push(s):this.listeners.push(e)}emit(e){this.listeners.slice().forEach(t=>t(e))}removeAllListeners(){this.listeners=[]}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}on(e){return this.addListener(e)}off(e){return this.removeListener(e)}once(e){return this.addListener(e,{once:!0})}}class Y0{constructor(e){this.incomingInfoRequest=e}get request(){return this.incomingInfoRequest.message}accept(e){return this.incomingInfoRequest.accept(e),Promise.resolve()}reject(e){return this.incomingInfoRequest.reject(e),Promise.resolve()}}class ba{constructor(e){this.parameters={};for(const t in e)e.hasOwnProperty(t)&&this.setParam(t,e[t])}setParam(e,t){e&&(this.parameters[e.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(e){if(e)return this.parameters[e.toLowerCase()]}hasParam(e){return!!(e&&this.parameters[e.toLowerCase()]!==void 0)}deleteParam(e){if(e=e.toLowerCase(),this.hasParam(e)){const t=this.parameters[e];return delete this.parameters[e],t}}clearParams(){this.parameters={}}}class ze extends ba{constructor(e,t,s){super(s),this.uri=e,this._displayName=t}get friendlyName(){return this.displayName||this.uri.aor}get displayName(){return this._displayName}set displayName(e){this._displayName=e}clone(){return new ze(this.uri.clone(),this._displayName,JSON.parse(JSON.stringify(this.parameters)))}toString(){let e=this.displayName||this.displayName==="0"?'"'+this.displayName+'" ':"";e+="<"+this.uri.toString()+">";for(const t in this.parameters)this.parameters.hasOwnProperty(t)&&(e+=";"+t,this.parameters[t]!==null&&(e+="="+this.parameters[t]));return e}}class vt extends ba{constructor(e="sip",t,s,i,n,a){if(super(n||{}),this.headers={},!s)throw new TypeError('missing or invalid "host" parameter');for(const o in a)a.hasOwnProperty(o)&&this.setHeader(o,a[o]);this.raw={scheme:e,user:t,host:s,port:i},this.normal={scheme:e.toLowerCase(),user:t,host:s.toLowerCase(),port:i}}get scheme(){return this.normal.scheme}set scheme(e){this.raw.scheme=e,this.normal.scheme=e.toLowerCase()}get user(){return this.normal.user}set user(e){this.normal.user=this.raw.user=e}get host(){return this.normal.host}set host(e){this.raw.host=e,this.normal.host=e.toLowerCase()}get aor(){return this.normal.user+"@"+this.normal.host}get port(){return this.normal.port}set port(e){this.normal.port=this.raw.port=e}setHeader(e,t){this.headers[this.headerize(e)]=t instanceof Array?t:[t]}getHeader(e){if(e)return this.headers[this.headerize(e)]}hasHeader(e){return!!e&&!!this.headers.hasOwnProperty(this.headerize(e))}deleteHeader(e){if(e=this.headerize(e),this.headers.hasOwnProperty(e)){const t=this.headers[e];return delete this.headers[e],t}}clearHeaders(){this.headers={}}clone(){return new vt(this._raw.scheme,this._raw.user||"",this._raw.host,this._raw.port,JSON.parse(JSON.stringify(this.parameters)),JSON.parse(JSON.stringify(this.headers)))}toRaw(){return this._toString(this._raw)}toString(){return this._toString(this._normal)}get _normal(){return this.normal}get _raw(){return this.raw}_toString(e){let t=e.scheme+":";e.scheme.toLowerCase().match("^sips?$")||(t+="//"),e.user&&(t+=this.escapeUser(e.user)+"@"),t+=e.host,(e.port||e.port===0)&&(t+=":"+e.port);for(const i in this.parameters)this.parameters.hasOwnProperty(i)&&(t+=";"+i,this.parameters[i]!==null&&(t+="="+this.parameters[i]));const s=[];for(const i in this.headers)if(this.headers.hasOwnProperty(i))for(const n in this.headers[i])this.headers[i].hasOwnProperty(n)&&s.push(i+"="+this.headers[i][n]);return s.length>0&&(t+="?"+s.join("&")),t}escapeUser(e){let t;try{t=decodeURIComponent(e)}catch(s){throw s}return encodeURIComponent(t).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")}headerize(e){const t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},s=e.toLowerCase().replace(/_/g,"-").split("-"),i=s.length;let n="";for(let a=0;a<i;a++)a!==0&&(n+="-"),n+=s[a].charAt(0).toUpperCase()+s[a].substring(1);return t[n]&&(n=t[n]),n}}function _a(r,e){if(r.scheme!==e.scheme||r.user!==e.user||r.host!==e.host||r.port!==e.port)return!1;function t(n,a){const o=Object.keys(n.parameters),d=Object.keys(a.parameters);return!(!o.filter(l=>d.includes(l)).every(l=>n.parameters[l]===a.parameters[l])||!["user","ttl","method","transport"].every(l=>n.hasParam(l)&&a.hasParam(l)||!n.hasParam(l)&&!a.hasParam(l))||!["maddr"].every(l=>n.hasParam(l)&&a.hasParam(l)||!n.hasParam(l)&&!a.hasParam(l)))}if(!t(r,e))return!1;const s=Object.keys(r.headers),i=Object.keys(e.headers);if(s.length!==0||i.length!==0){if(s.length!==i.length)return!1;const n=s.filter(a=>i.includes(a));if(n.length!==i.length||!n.every(a=>r.headers[a].length&&e.headers[a].length&&r.headers[a][0]===e.headers[a][0]))return!1}return!0}function Hi(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}class vr extends Error{constructor(e,t,s,i){super(),this.message=e,this.expected=t,this.found=s,this.location=i,this.name="SyntaxError",typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(this,vr.prototype):this.__proto__=vr.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,vr)}static buildMessage(e,t){function s(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,l=>"\\x0"+s(l)).replace(/[\x10-\x1F\x7F-\x9F]/g,l=>"\\x"+s(l))}function n(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,l=>"\\x0"+s(l)).replace(/[\x10-\x1F\x7F-\x9F]/g,l=>"\\x"+s(l))}function a(c){switch(c.type){case"literal":return'"'+i(c.text)+'"';case"class":const l=c.parts.map(g=>Array.isArray(g)?n(g[0])+"-"+n(g[1]):n(g));return"["+(c.inverted?"^":"")+l+"]";case"any":return"any character";case"end":return"end of input";case"other":return c.description}}function o(c){const l=c.map(a);let g,f;if(l.sort(),l.length>0){for(g=1,f=1;g<l.length;g++)l[g-1]!==l[g]&&(l[f]=l[g],f++);l.length=f}switch(l.length){case 1:return l[0];case 2:return l[0]+" or "+l[1];default:return l.slice(0,-1).join(", ")+", or "+l[l.length-1]}}function d(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+o(e)+" but "+d(t)+" found."}format(e){let t="Error: "+this.message;if(this.location){let s=null,i;for(i=0;i<e.length;i++)if(e[i].source===this.location.source){s=e[i].text.split(/\r\n|\n|\r/g);break}let n=this.location.start,a=this.location.source+":"+n.line+":"+n.column;if(s){let o=this.location.end,d=Hi("",n.line.toString().length," "),c=s[n.line-1],l=n.line===o.line?o.column:c.length+1;t+=`
144
- --> `+a+`
145
- `+d+` |
146
- `+n.line+" | "+c+`
147
- `+d+" | "+Hi("",n.column-1," ")+Hi("",l-n.column,"^")}else t+=`
148
- at `+a}return t}}function W0(r,e){e=e!==void 0?e:{};const t={},s=e.grammarSource,i={Contact:119,Name_Addr_Header:156,Record_Route:176,Request_Response:81,SIP_URI:45,Subscription_State:186,Supported:191,Require:182,Via:194,absoluteURI:84,Call_ID:118,Content_Disposition:130,Content_Length:135,Content_Type:136,CSeq:146,displayName:122,Event:149,From:151,host:52,Max_Forwards:154,Min_SE:213,Proxy_Authenticate:157,quoted_string:40,Refer_To:178,Replaces:179,Session_Expires:210,stun_URI:217,To:192,turn_URI:223,uuid:226,WWW_Authenticate:209,challenge:158,sipfrag:230,Referred_By:231};let n=119;const a=[`\r
149
- `,x(`\r
150
- `,!1),/^[0-9]/,p([["0","9"]],!1,!1),/^[a-zA-Z]/,p([["a","z"],["A","Z"]],!1,!1),/^[0-9a-fA-F]/,p([["0","9"],["a","f"],["A","F"]],!1,!1),/^[\0-\xFF]/,p([["\0","ÿ"]],!1,!1),/^["]/,p(['"'],!1,!1)," ",x(" ",!1)," ",x(" ",!1),/^[a-zA-Z0-9]/,p([["a","z"],["A","Z"],["0","9"]],!1,!1),";",x(";",!1),"/",x("/",!1),"?",x("?",!1),":",x(":",!1),"@",x("@",!1),"&",x("&",!1),"=",x("=",!1),"+",x("+",!1),"$",x("$",!1),",",x(",",!1),"-",x("-",!1),"_",x("_",!1),".",x(".",!1),"!",x("!",!1),"~",x("~",!1),"*",x("*",!1),"'",x("'",!1),"(",x("(",!1),")",x(")",!1),"%",x("%",!1),function(){return" "},function(){return":"},/^[!-~]/,p([["!","~"]],!1,!1),/^[\x80-\uFFFF]/,p([["€","￿"]],!1,!1),/^[\x80-\xBF]/,p([["€","¿"]],!1,!1),/^[a-f]/,p([["a","f"]],!1,!1),"`",x("`",!1),"<",x("<",!1),">",x(">",!1),"\\",x("\\",!1),"[",x("[",!1),"]",x("]",!1),"{",x("{",!1),"}",x("}",!1),function(){return"*"},function(){return"/"},function(){return"="},function(){return"("},function(){return")"},function(){return">"},function(){return"<"},function(){return","},function(){return";"},function(){return":"},function(){return'"'},/^[!-']/,p([["!","'"]],!1,!1),/^[*-[]/,p([["*","["]],!1,!1),/^[\]-~]/,p([["]","~"]],!1,!1),function(u){return u},/^[#-[]/,p([["#","["]],!1,!1),/^[\0-\t]/,p([["\0"," "]],!1,!1),/^[\v-\f]/,p([["\v","\f"]],!1,!1),/^[\x0E-\x7F]/,p([["",""]],!1,!1),function(){e=e||{data:{}},e.data.uri=new vt(e.data.scheme,e.data.user,e.data.host,e.data.port),delete e.data.scheme,delete e.data.user,delete e.data.host,delete e.data.host_type,delete e.data.port},function(){e=e||{data:{}},e.data.uri=new vt(e.data.scheme,e.data.user,e.data.host,e.data.port,e.data.uri_params,e.data.uri_headers),delete e.data.scheme,delete e.data.user,delete e.data.host,delete e.data.host_type,delete e.data.port,delete e.data.uri_params,e.startRule==="SIP_URI"&&(e.data=e.data.uri)},"sips",x("sips",!0),"sip",x("sip",!0),function(u){e=e||{data:{}},e.data.scheme=u},function(){e=e||{data:{}},e.data.user=decodeURIComponent(b().slice(0,-1))},function(){e=e||{data:{}},e.data.password=b()},function(){return e=e||{data:{}},e.data.host=b(),e.data.host},function(){return e=e||{data:{}},e.data.host_type="domain",b()},/^[a-zA-Z0-9_\-]/,p([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),/^[a-zA-Z0-9\-]/,p([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),function(){return e=e||{data:{}},e.data.host_type="IPv6",b()},"::",x("::",!1),function(){return e=e||{data:{}},e.data.host_type="IPv6",b()},function(){return e=e||{data:{}},e.data.host_type="IPv4",b()},"25",x("25",!1),/^[0-5]/,p([["0","5"]],!1,!1),"2",x("2",!1),/^[0-4]/,p([["0","4"]],!1,!1),"1",x("1",!1),/^[1-9]/,p([["1","9"]],!1,!1),function(u){return e=e||{data:{}},u=parseInt(u.join("")),e.data.port=u,u},"transport=",x("transport=",!0),"udp",x("udp",!0),"tcp",x("tcp",!0),"sctp",x("sctp",!0),"tls",x("tls",!0),function(u){e=e||{data:{}},e.data.uri_params||(e.data.uri_params={}),e.data.uri_params.transport=u.toLowerCase()},"user=",x("user=",!0),"phone",x("phone",!0),"ip",x("ip",!0),function(u){e=e||{data:{}},e.data.uri_params||(e.data.uri_params={}),e.data.uri_params.user=u.toLowerCase()},"method=",x("method=",!0),function(u){e=e||{data:{}},e.data.uri_params||(e.data.uri_params={}),e.data.uri_params.method=u},"ttl=",x("ttl=",!0),function(u){e=e||{data:{}},e.data.params||(e.data.params={}),e.data.params.ttl=u},"maddr=",x("maddr=",!0),function(u){e=e||{data:{}},e.data.uri_params||(e.data.uri_params={}),e.data.uri_params.maddr=u},"lr",x("lr",!0),function(){e=e||{data:{}},e.data.uri_params||(e.data.uri_params={}),e.data.uri_params.lr=void 0},function(u,v){e=e||{data:{}},e.data.uri_params||(e.data.uri_params={}),v===null?v=void 0:v=v[1],e.data.uri_params[u.toLowerCase()]=v},function(u,v){u=u.join("").toLowerCase(),v=v.join(""),e=e||{data:{}},e.data.uri_headers||(e.data.uri_headers={}),e.data.uri_headers[u]?e.data.uri_headers[u].push(v):e.data.uri_headers[u]=[v]},function(){e=e||{data:{}},e.startRule==="Refer_To"&&(e.data.uri=new vt(e.data.scheme,e.data.user,e.data.host,e.data.port,e.data.uri_params,e.data.uri_headers),delete e.data.scheme,delete e.data.user,delete e.data.host,delete e.data.host_type,delete e.data.port,delete e.data.uri_params)},"//",x("//",!1),function(){e=e||{data:{}},e.data.scheme=b()},x("SIP",!0),function(){e=e||{data:{}},e.data.sip_version=b()},"INVITE",x("INVITE",!1),"ACK",x("ACK",!1),"VXACH",x("VXACH",!1),"OPTIONS",x("OPTIONS",!1),"BYE",x("BYE",!1),"CANCEL",x("CANCEL",!1),"REGISTER",x("REGISTER",!1),"SUBSCRIBE",x("SUBSCRIBE",!1),"NOTIFY",x("NOTIFY",!1),"REFER",x("REFER",!1),"PUBLISH",x("PUBLISH",!1),function(){return e=e||{data:{}},e.data.method=b(),e.data.method},function(u){e=e||{data:{}},e.data.status_code=parseInt(u.join(""))},function(){e=e||{data:{}},e.data.reason_phrase=b()},function(){e=e||{data:{}},e.data=b()},function(){var u,v;for(e=e||{data:{}},v=e.data.multi_header.length,u=0;u<v;u++)if(e.data.multi_header[u].parsed===null){e.data=null;break}e.data!==null?e.data=e.data.multi_header:e.data=-1},function(){var u;e=e||{data:{}},e.data.multi_header||(e.data.multi_header=[]);try{u=new ze(e.data.uri,e.data.displayName,e.data.params),delete e.data.uri,delete e.data.displayName,delete e.data.params}catch{u=null}e.data.multi_header.push({position:d,offset:_().start.offset,parsed:u})},function(u){u=b().trim(),u[0]==='"'&&(u=u.substring(1,u.length-1)),e=e||{data:{}},e.data.displayName=u},"q",x("q",!0),function(u){e=e||{data:{}},e.data.params||(e.data.params={}),e.data.params.q=u},"expires",x("expires",!0),function(u){e=e||{data:{}},e.data.params||(e.data.params={}),e.data.params.expires=u},function(u){return parseInt(u.join(""))},"0",x("0",!1),function(){return parseFloat(b())},function(u,v){e=e||{data:{}},e.data.params||(e.data.params={}),v===null?v=void 0:v=v[1],e.data.params[u.toLowerCase()]=v},"render",x("render",!0),"session",x("session",!0),"icon",x("icon",!0),"alert",x("alert",!0),function(){e=e||{data:{}},e.startRule==="Content_Disposition"&&(e.data.type=b().toLowerCase())},"handling",x("handling",!0),"optional",x("optional",!0),"required",x("required",!0),function(u){e=e||{data:{}},e.data=parseInt(u.join(""))},function(){e=e||{data:{}},e.data=b()},"text",x("text",!0),"image",x("image",!0),"audio",x("audio",!0),"video",x("video",!0),"application",x("application",!0),"message",x("message",!0),"multipart",x("multipart",!0),"x-",x("x-",!0),function(u){e=e||{data:{}},e.data.value=parseInt(u.join(""))},function(u){e=e||{data:{}},e.data=u},function(u){e=e||{data:{}},e.data.event=u.toLowerCase()},function(){e=e||{data:{}};var u=e.data.tag;e.data=new ze(e.data.uri,e.data.displayName,e.data.params),u&&e.data.setParam("tag",u)},"tag",x("tag",!0),function(u){e=e||{data:{}},e.data.tag=u},function(u){e=e||{data:{}},e.data=parseInt(u.join(""))},function(u){e=e||{data:{}},e.data=u},function(){e=e||{data:{}},e.data=new ze(e.data.uri,e.data.displayName,e.data.params)},"digest",x("Digest",!0),"realm",x("realm",!0),function(u){e=e||{data:{}},e.data.realm=u},"domain",x("domain",!0),"nonce",x("nonce",!0),function(u){e=e||{data:{}},e.data.nonce=u},"opaque",x("opaque",!0),function(u){e=e||{data:{}},e.data.opaque=u},"stale",x("stale",!0),"true",x("true",!0),function(){e=e||{data:{}},e.data.stale=!0},"false",x("false",!0),function(){e=e||{data:{}},e.data.stale=!1},"algorithm",x("algorithm",!0),"md5",x("MD5",!0),"md5-sess",x("MD5-sess",!0),function(u){e=e||{data:{}},e.data.algorithm=u.toUpperCase()},"qop",x("qop",!0),"auth-int",x("auth-int",!0),"auth",x("auth",!0),function(u){e=e||{data:{}},e.data.qop||(e.data.qop=[]),e.data.qop.push(u.toLowerCase())},function(u){e=e||{data:{}},e.data.value=parseInt(u.join(""))},function(){var u,v;for(e=e||{data:{}},v=e.data.multi_header.length,u=0;u<v;u++)if(e.data.multi_header[u].parsed===null){e.data=null;break}e.data!==null?e.data=e.data.multi_header:e.data=-1},function(){var u;e=e||{data:{}},e.data.multi_header||(e.data.multi_header=[]);try{u=new ze(e.data.uri,e.data.displayName,e.data.params),delete e.data.uri,delete e.data.displayName,delete e.data.params}catch{u=null}e.data.multi_header.push({position:d,offset:_().start.offset,parsed:u})},function(){e=e||{data:{}},e.data=new ze(e.data.uri,e.data.displayName,e.data.params)},function(){e=e||{data:{}},e.data.replaces_from_tag&&e.data.replaces_to_tag||(e.data=-1)},function(){e=e||{data:{}},e.data={call_id:e.data}},"from-tag",x("from-tag",!0),function(u){e=e||{data:{}},e.data.replaces_from_tag=u},"to-tag",x("to-tag",!0),function(u){e=e||{data:{}},e.data.replaces_to_tag=u},"early-only",x("early-only",!0),function(){e=e||{data:{}},e.data.early_only=!0},function(u,v){return v},function(u,v){return A(u,v)},function(u){e=e||{data:{}},e.startRule==="Require"&&(e.data=u||[])},function(u){e=e||{data:{}},e.data.value=parseInt(u.join(""))},"active",x("active",!0),"pending",x("pending",!0),"terminated",x("terminated",!0),function(){e=e||{data:{}},e.data.state=b()},"reason",x("reason",!0),function(u){e=e||{data:{}},typeof u<"u"&&(e.data.reason=u)},function(u){e=e||{data:{}},typeof u<"u"&&(e.data.expires=u)},"retry_after",x("retry_after",!0),function(u){e=e||{data:{}},typeof u<"u"&&(e.data.retry_after=u)},"deactivated",x("deactivated",!0),"probation",x("probation",!0),"rejected",x("rejected",!0),"timeout",x("timeout",!0),"giveup",x("giveup",!0),"noresource",x("noresource",!0),"invariant",x("invariant",!0),function(u){e=e||{data:{}},e.startRule==="Supported"&&(e.data=u||[])},function(){e=e||{data:{}};var u=e.data.tag;e.data=new ze(e.data.uri,e.data.displayName,e.data.params),u&&e.data.setParam("tag",u)},"ttl",x("ttl",!0),function(u){e=e||{data:{}},e.data.ttl=u},"maddr",x("maddr",!0),function(u){e=e||{data:{}},e.data.maddr=u},"received",x("received",!0),function(u){e=e||{data:{}},e.data.received=u},"branch",x("branch",!0),function(u){e=e||{data:{}},e.data.branch=u},"rport",x("rport",!0),function(u){e=e||{data:{}},typeof u<"u"&&(e.data.rport=u.join(""))},function(u){e=e||{data:{}},e.data.protocol=u},x("UDP",!0),x("TCP",!0),x("TLS",!0),x("SCTP",!0),function(u){e=e||{data:{}},e.data.transport=u},function(){e=e||{data:{}},e.data.host=b()},function(u){e=e||{data:{}},e.data.port=parseInt(u.join(""))},function(u){return parseInt(u.join(""))},function(u){e=e||{data:{}},e.startRule==="Session_Expires"&&(e.data.deltaSeconds=u)},"refresher",x("refresher",!1),"uas",x("uas",!1),"uac",x("uac",!1),function(u){e=e||{data:{}},e.startRule==="Session_Expires"&&(e.data.refresher=u)},function(u){e=e||{data:{}},e.startRule==="Min_SE"&&(e.data=u)},"stuns",x("stuns",!0),"stun",x("stun",!0),function(u){e=e||{data:{}},e.data.scheme=u},function(u){e=e||{data:{}},e.data.host=u},"?transport=",x("?transport=",!1),"turns",x("turns",!0),"turn",x("turn",!0),function(u){e=e||{data:{}},e.data.transport=u},function(){e=e||{data:{}},e.data=b()},"Referred-By",x("Referred-By",!1),"b",x("b",!1),"cid",x("cid",!1)],o=[h('2 ""6 7!'),h('4"""5!7#'),h('4$""5!7%'),h(`4&""5!7'`),h(";'.# &;("),h('4(""5!7)'),h('4*""5!7+'),h('2,""6,7-'),h('2.""6.7/'),h('40""5!71'),h('22""6273.‰ &24""6475.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),h(";).# &;,"),h('2F""6F7G.} &2H""6H7I.q &2J""6J7K.e &2L""6L7M.Y &2N""6N7O.M &2P""6P7Q.A &2R""6R7S.5 &2T""6T7U.) &2V""6V7W'),h(`%%2X""6X7Y/5#;#/,$;#/#$+#)(#'#("'#&'#/"!&,)`),h(`%%$;$0#*;$&/,#; /#$+")("'#&'#." &"/=#$;$/&#0#*;$&&&#/'$8":Z" )("'#&'#`),h(';.." &"'),h(`%$;'.# &;(0)*;'.# &;(&/?#28""6879/0$;//'$8#:[# )(#'#("'#&'#`),h(`%%$;2/&#0#*;2&&&#/g#$%$;.0#*;.&/,#;2/#$+")("'#&'#0=*%$;.0#*;.&/,#;2/#$+")("'#&'#&/#$+")("'#&'#/"!&,)`),h('4\\""5!7].# &;3'),h('4^""5!7_'),h('4`""5!7a'),h(';!.) &4b""5!7c'),h('%$;).• &2F""6F7G.‰ &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/ž#0›*;).• &2F""6F7G.‰ &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),h('%$;).‰ &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/’#0*;).‰ &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),h(`2T""6T7U.ã &2V""6V7W.× &2f""6f7g.Ë &2h""6h7i.¿ &2:""6:7;.³ &2D""6D7E.§ &22""6273.› &28""6879. &2j""6j7k.ƒ &;&.} &24""6475.q &2l""6l7m.e &2n""6n7o.Y &26""6677.M &2>""6>7?.A &2p""6p7q.5 &2r""6r7s.) &;'.# &;(`),h('%$;).ī &2F""6F7G.ğ &2J""6J7K.ē &2L""6L7M.ć &2X""6X7Y.û &2P""6P7Q.ï &2H""6H7I.ã &2@""6@7A.× &2d""6d7e.Ë &2R""6R7S.¿ &2N""6N7O.³ &2T""6T7U.§ &2V""6V7W.› &2f""6f7g. &2h""6h7i.ƒ &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s/Ĵ#0ı*;).ī &2F""6F7G.ğ &2J""6J7K.ē &2L""6L7M.ć &2X""6X7Y.û &2P""6P7Q.ï &2H""6H7I.ã &2@""6@7A.× &2d""6d7e.Ë &2R""6R7S.¿ &2N""6N7O.³ &2T""6T7U.§ &2V""6V7W.› &2f""6f7g. &2h""6h7i.ƒ &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s&&&#/"!&,)'),h(`%;//?#2P""6P7Q/0$;//'$8#:t# )(#'#("'#&'#`),h(`%;//?#24""6475/0$;//'$8#:u# )(#'#("'#&'#`),h(`%;//?#2>""6>7?/0$;//'$8#:v# )(#'#("'#&'#`),h(`%;//?#2T""6T7U/0$;//'$8#:w# )(#'#("'#&'#`),h(`%;//?#2V""6V7W/0$;//'$8#:x# )(#'#("'#&'#`),h(`%2h""6h7i/0#;//'$8":y" )("'#&'#`),h(`%;//6#2f""6f7g/'$8":z" )("'#&'#`),h(`%;//?#2D""6D7E/0$;//'$8#:{# )(#'#("'#&'#`),h(`%;//?#22""6273/0$;//'$8#:|# )(#'#("'#&'#`),h(`%;//?#28""6879/0$;//'$8#:}# )(#'#("'#&'#`),h(`%;//0#;&/'$8":~" )("'#&'#`),h(`%;&/0#;//'$8":~" )("'#&'#`),h(`%;=/T#$;G.) &;K.# &;F0/*;G.) &;K.# &;F&/,$;>/#$+#)(#'#("'#&'#`),h('4""5!7€.A &4""5!7‚.5 &4ƒ""5!7„.) &;3.# &;.'),h(`%%;//Q#;&/H$$;J.# &;K0)*;J.# &;K&/,$;&/#$+$)($'#(#'#("'#&'#/"!&,)`),h(`%;//]#;&/T$%$;J.# &;K0)*;J.# &;K&/"!&,)/1$;&/($8$:…$!!)($'#(#'#("'#&'#`),h(';..G &2L""6L7M.; &4†""5!7‡./ &4ƒ""5!7„.# &;3'),h(`%2j""6j7k/J#4ˆ""5!7‰.5 &4Š""5!7‹.) &4Œ""5!7/#$+")("'#&'#`),h(`%;N/M#28""6879/>$;O." &"/0$;S/'$8$:Ž$ )($'#(#'#("'#&'#`),h(`%;N/d#28""6879/U$;O." &"/G$;S/>$;_/5$;l." &"/'$8&:& )(&'#(%'#($'#(#'#("'#&'#`),h(`%3""5$7‘.) &3’""5#7“/' 8!:”!! )`),h(`%;P/]#%28""6879/,#;R/#$+")("'#&'#." &"/6$2:""6:7;/'$8#:•# )(#'#("'#&'#`),h("$;+.) &;-.# &;Q/2#0/*;+.) &;-.# &;Q&&&#"),h('2<""6<7=.q &2>""6>7?.e &2@""6@7A.Y &2B""6B7C.M &2D""6D7E.A &22""6273.5 &26""6677.) &24""6475'),h('%$;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E0e*;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E&/& 8!:–! )'),h(`%;T/J#%28""6879/,#;^/#$+")("'#&'#." &"/#$+")("'#&'#`),h("%;U.) &;\\.# &;X/& 8!:—! )"),h(`%$%;V/2#2J""6J7K/#$+")("'#&'#0<*%;V/2#2J""6J7K/#$+")("'#&'#&/D#;W/;$2J""6J7K." &"/'$8#:˜# )(#'#("'#&'#`),h('$4™""5!7š/,#0)*4™""5!7š&&&#'),h(`%4$""5!7%/?#$4›""5!7œ0)*4›""5!7œ&/#$+")("'#&'#`),h(`%2l""6l7m/?#;Y/6$2n""6n7o/'$8#:# )(#'#("'#&'#`),h(`%%;Z/³#28""6879/¤$;Z/›$28""6879/Œ$;Z/ƒ$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+-)(-'#(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#("'#&'#.ސ &%2ž""6ž7Ÿ/¤#;Z/›$28""6879/Œ$;Z/ƒ$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+,)(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#("'#&'#.۹ &%2ž""6ž7Ÿ/Œ#;Z/ƒ$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*'#()'#(('#(''#(&'#(%'#($'#(#'#("'#&'#.ٺ &%2ž""6ž7Ÿ/t#;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+()(('#(''#(&'#(%'#($'#(#'#("'#&'#.ؓ &%2ž""6ž7Ÿ/\\#;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+&)(&'#(%'#($'#(#'#("'#&'#.ׄ &%2ž""6ž7Ÿ/D#;Z/;$28""6879/,$;[/#$+$)($'#(#'#("'#&'#.֍ &%2ž""6ž7Ÿ/,#;[/#$+")("'#&'#.ծ &%2ž""6ž7Ÿ/,#;Z/#$+")("'#&'#.Տ &%;Z/›#2ž""6ž7Ÿ/Œ$;Z/ƒ$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$++)(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#("'#&'#.Ӈ &%;Z/ª#%28""6879/,#;Z/#$+")("'#&'#." &"/ƒ$2ž""6ž7Ÿ/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*'#()'#(('#(''#(&'#(%'#($'#(#'#("'#&'#.а &%;Z/¹#%28""6879/,#;Z/#$+")("'#&'#." &"/’$%28""6879/,#;Z/#$+")("'#&'#." &"/k$2ž""6ž7Ÿ/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+))()'#(('#(''#(&'#(%'#($'#(#'#("'#&'#.Ί &%;Z/È#%28""6879/,#;Z/#$+")("'#&'#." &"/¡$%28""6879/,#;Z/#$+")("'#&'#." &"/z$%28""6879/,#;Z/#$+")("'#&'#." &"/S$2ž""6ž7Ÿ/D$;Z/;$28""6879/,$;[/#$+()(('#(''#(&'#(%'#($'#(#'#("'#&'#.˕ &%;Z/×#%28""6879/,#;Z/#$+")("'#&'#." &"/°$%28""6879/,#;Z/#$+")("'#&'#." &"/‰$%28""6879/,#;Z/#$+")("'#&'#." &"/b$%28""6879/,#;Z/#$+")("'#&'#." &"/;$2ž""6ž7Ÿ/,$;[/#$+')(''#(&'#(%'#($'#(#'#("'#&'#.ȑ &%;Z/þ#%28""6879/,#;Z/#$+")("'#&'#." &"/×$%28""6879/,#;Z/#$+")("'#&'#." &"/°$%28""6879/,#;Z/#$+")("'#&'#." &"/‰$%28""6879/,#;Z/#$+")("'#&'#." &"/b$%28""6879/,#;Z/#$+")("'#&'#." &"/;$2ž""6ž7Ÿ/,$;Z/#$+()(('#(''#(&'#(%'#($'#(#'#("'#&'#.Ħ &%;Z/Ĝ#%28""6879/,#;Z/#$+")("'#&'#." &"/õ$%28""6879/,#;Z/#$+")("'#&'#." &"/Î$%28""6879/,#;Z/#$+")("'#&'#." &"/§$%28""6879/,#;Z/#$+")("'#&'#." &"/€$%28""6879/,#;Z/#$+")("'#&'#." &"/Y$%28""6879/,#;Z/#$+")("'#&'#." &"/2$2ž""6ž7Ÿ/#$+()(('#(''#(&'#(%'#($'#(#'#("'#&'#/& 8!: ! )`),h(`%;#/M#;#." &"/?$;#." &"/1$;#." &"/#$+$)($'#(#'#("'#&'#`),h(`%;Z/;#28""6879/,$;Z/#$+#)(#'#("'#&'#.# &;\\`),h(`%;]/o#2J""6J7K/\`$;]/W$2J""6J7K/H$;]/?$2J""6J7K/0$;]/'$8':¡' )(''#(&'#(%'#($'#(#'#("'#&'#`),h(`%2¢""6¢7£/2#4¤""5!7¥/#$+")("'#&'#.˜ &%2¦""6¦7§/;#4¨""5!7©/,$;!/#$+#)(#'#("'#&'#.j &%2ª""6ª7«/5#;!/,$;!/#$+#)(#'#("'#&'#.B &%4¬""5!7­/,#;!/#$+")("'#&'#.# &;!`),h(`%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%'#($'#(#'#("'#&'#/' 8!:®!! )`),h(`$%22""6273/,#;\`/#$+")("'#&'#0<*%22""6273/,#;\`/#$+")("'#&'#&`),h(";a.A &;b.; &;c.5 &;d./ &;e.) &;f.# &;g"),h(`%3¯""5*7°/a#3±""5#7².G &3³""5#7´.; &3µ""5$7¶./ &3·""5#7¸.# &;6/($8":¹"! )("'#&'#`),h(`%3º""5%7»/I#3¼""5%7½./ &3¾""5"7¿.# &;6/($8":À"! )("'#&'#`),h(`%3Á""5'7Â/1#;/($8":Ã"! )("'#&'#`),h(`%3Ä""5$7Å/1#;ð/($8":Æ"! )("'#&'#`),h(`%3Ç""5&7È/1#;T/($8":É"! )("'#&'#`),h(`%3Ê""5"7Ë/N#%2>""6>7?/,#;6/#$+")("'#&'#." &"/'$8":Ì" )("'#&'#`),h(`%;h/P#%2>""6>7?/,#;i/#$+")("'#&'#." &"/)$8":Í""! )("'#&'#`),h('%$;j/&#0#*;j&&&#/"!&,)'),h('%$;j/&#0#*;j&&&#/"!&,)'),h(";k.) &;+.# &;-"),h('2l""6l7m.e &2n""6n7o.Y &24""6475.M &28""6879.A &2<""6<7=.5 &2@""6@7A.) &2B""6B7C'),h(`%26""6677/n#;m/e$$%2<""6<7=/,#;m/#$+")("'#&'#0<*%2<""6<7=/,#;m/#$+")("'#&'#&/#$+#)(#'#("'#&'#`),h(`%;n/A#2>""6>7?/2$;o/)$8#:Î#"" )(#'#("'#&'#`),h("$;p.) &;+.# &;-/2#0/*;p.) &;+.# &;-&&&#"),h("$;p.) &;+.# &;-0/*;p.) &;+.# &;-&"),h('2l""6l7m.e &2n""6n7o.Y &24""6475.M &26""6677.A &28""6879.5 &2@""6@7A.) &2B""6B7C'),h(";‘.# &;r"),h(`%;/G#;'/>$;s/5$;'/,$;„/#$+%)(%'#($'#(#'#("'#&'#`),h(";M.# &;t"),h(`%;/E#28""6879/6$;u.# &;x/'$8#:Ï# )(#'#("'#&'#`),h(`%;v.# &;w/J#%26""6677/,#;ƒ/#$+")("'#&'#." &"/#$+")("'#&'#`),h(`%2Ð""6Ð7Ñ/:#;€/1$;w." &"/#$+#)(#'#("'#&'#`),h(`%24""6475/,#;{/#$+")("'#&'#`),h(`%;z/3#$;y0#*;y&/#$+")("'#&'#`),h(";*.) &;+.# &;-"),h(';+. &;-.‰ &22""6273.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),h(`%;|/e#$%24""6475/,#;|/#$+")("'#&'#0<*%24""6475/,#;|/#$+")("'#&'#&/#$+")("'#&'#`),h(`%$;~0#*;~&/e#$%22""6273/,#;}/#$+")("'#&'#0<*%22""6273/,#;}/#$+")("'#&'#&/#$+")("'#&'#`),h("$;~0#*;~&"),h(';+.w &;-.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),h(`%%;"/‡#$;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K0M*;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K&/#$+")("'#&'#/& 8!:Ò! )`),h(";.# &;‚"),h(`%%;O/2#2:""6:7;/#$+")("'#&'#." &"/,#;S/#$+")("'#&'#." &"`),h('$;+.ƒ &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A/Œ#0‰*;+.ƒ &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A&&&#'),h("$;y0#*;y&"),h(`%3’""5#7Ó/q#24""6475/b$$;!/&#0#*;!&&&#/L$2J""6J7K/=$$;!/&#0#*;!&&&#/'$8%:Ô% )(%'#($'#(#'#("'#&'#`),h('2Õ""6Õ7Ö'),h('2×""6×7Ø'),h('2Ù""6Ù7Ú'),h('2Û""6Û7Ü'),h('2Ý""6Ý7Þ'),h('2ß""6ß7à'),h('2á""6á7â'),h('2ã""6ã7ä'),h('2å""6å7æ'),h('2ç""6ç7è'),h('2é""6é7ê'),h("%;….Y &;†.S &;ˆ.M &;‰.G &;Š.A &;‹.; &;Œ.5 &;./ &;.) &;Ž.# &;6/& 8!:ë! )"),h(`%;„/G#;'/>$;’/5$;'/,$;”/#$+%)(%'#($'#(#'#("'#&'#`),h("%;“/' 8!:ì!! )"),h(`%;!/5#;!/,$;!/#$+#)(#'#("'#&'#`),h("%$;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(0G*;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(&/& 8!:í! )"),h(`%;¶/Y#$%;A/,#;¶/#$+")("'#&'#06*%;A/,#;¶/#$+")("'#&'#&/#$+")("'#&'#`),h(`%;9/N#%2:""6:7;/,#;9/#$+")("'#&'#." &"/'$8":î" )("'#&'#`),h(`%;:.c &%;˜/Y#$%;A/,#;˜/#$+")("'#&'#06*%;A/,#;˜/#$+")("'#&'#&/#$+")("'#&'#/& 8!:ï! )`),h(`%;L.# &;™/]#$%;B/,#;›/#$+")("'#&'#06*%;B/,#;›/#$+")("'#&'#&/'$8":ð" )("'#&'#`),h(`%;š." &"/>#;@/5$;M/,$;?/#$+$)($'#(#'#("'#&'#`),h(`%%;6/Y#$%;./,#;6/#$+")("'#&'#06*%;./,#;6/#$+")("'#&'#&/#$+")("'#&'#.# &;H/' 8!:ñ!! )`),h(";œ.) &;.# &; "),h(`%3ò""5!7ó/:#;</1$;Ÿ/($8#:ô#! )(#'#("'#&'#`),h(`%3õ""5'7ö/:#;</1$;ž/($8#:÷#! )(#'#("'#&'#`),h("%$;!/&#0#*;!&&&#/' 8!:ø!! )"),h(`%2ù""6ù7ú/o#%2J""6J7K/M#;!." &"/?$;!." &"/1$;!." &"/#$+$)($'#(#'#("'#&'#." &"/'$8":û" )("'#&'#`),h(`%;6/J#%;</,#;¡/#$+")("'#&'#." &"/)$8":ü""! )("'#&'#`),h(";6.) &;T.# &;H"),h(`%;£/Y#$%;B/,#;¤/#$+")("'#&'#06*%;B/,#;¤/#$+")("'#&'#&/#$+")("'#&'#`),h(`%3ý""5&7þ.G &3ÿ""5'7Ā.; &3ā""5$7Ă./ &3ă""5%7Ą.# &;6/& 8!:ą! )`),h(";¥.# &; "),h(`%3Ć""5(7ć/M#;</D$3Ĉ""5(7ĉ./ &3Ċ""5(7ċ.# &;6/#$+#)(#'#("'#&'#`),h(`%;6/Y#$%;A/,#;6/#$+")("'#&'#06*%;A/,#;6/#$+")("'#&'#&/#$+")("'#&'#`),h("%$;!/&#0#*;!&&&#/' 8!:Č!! )"),h("%;©/& 8!:č! )"),h(`%;ª/k#;;/b$;¯/Y$$%;B/,#;°/#$+")("'#&'#06*%;B/,#;°/#$+")("'#&'#&/#$+$)($'#(#'#("'#&'#`),h(";«.# &;¬"),h('3Ď""5$7ď.S &3Đ""5%7đ.G &3Ē""5%7ē.; &3Ĕ""5%7ĕ./ &3Ė""5+7ė.# &;­'),h(`3Ę""5'7ę./ &3Ě""5)7ě.# &;­`),h(";6.# &;®"),h(`%3Ĝ""5"7ĝ/,#;6/#$+")("'#&'#`),h(";­.# &;6"),h(`%;6/5#;</,$;±/#$+#)(#'#("'#&'#`),h(";6.# &;H"),h(`%;³/5#;./,$;/#$+#)(#'#("'#&'#`),h("%$;!/&#0#*;!&&&#/' 8!:Ğ!! )"),h("%;ž/' 8!:ğ!! )"),h(`%;¶/^#$%;B/,#; /#$+")("'#&'#06*%;B/,#; /#$+")("'#&'#&/($8":Ġ"!!)("'#&'#`),h(`%%;7/e#$%2J""6J7K/,#;7/#$+")("'#&'#0<*%2J""6J7K/,#;7/#$+")("'#&'#&/#$+")("'#&'#/"!&,)`),h(`%;L.# &;™/]#$%;B/,#;¸/#$+")("'#&'#06*%;B/,#;¸/#$+")("'#&'#&/'$8":ġ" )("'#&'#`),h(";¹.# &; "),h(`%3Ģ""5#7ģ/:#;</1$;6/($8#:Ĥ#! )(#'#("'#&'#`),h("%$;!/&#0#*;!&&&#/' 8!:ĥ!! )"),h("%;ž/' 8!:Ħ!! )"),h(`%$;š0#*;š&/x#;@/o$;M/f$;?/]$$%;B/,#; /#$+")("'#&'#06*%;B/,#; /#$+")("'#&'#&/'$8%:ħ% )(%'#($'#(#'#("'#&'#`),h(";¾"),h(`%3Ĩ""5&7ĩ/k#;./b$;Á/Y$$%;A/,#;Á/#$+")("'#&'#06*%;A/,#;Á/#$+")("'#&'#&/#$+$)($'#(#'#("'#&'#.# &;¿`),h(`%;6/k#;./b$;À/Y$$%;A/,#;À/#$+")("'#&'#06*%;A/,#;À/#$+")("'#&'#&/#$+$)($'#(#'#("'#&'#`),h(`%;6/;#;</2$;6.# &;H/#$+#)(#'#("'#&'#`),h(";Â.G &;Ä.A &;Æ.; &;È.5 &;É./ &;Ê.) &;Ë.# &;À"),h(`%3Ī""5%7ī/5#;</,$;Ã/#$+#)(#'#("'#&'#`),h("%;I/' 8!:Ĭ!! )"),h(`%3ĭ""5&7Į/—#;</Ž$;D/…$;Å/|$$%$;'/&#0#*;'&&&#/,#;Å/#$+")("'#&'#0C*%$;'/&#0#*;'&&&#/,#;Å/#$+")("'#&'#&/,$;E/#$+&)(&'#(%'#($'#(#'#("'#&'#`),h(";t.# &;w"),h(`%3į""5%7İ/5#;</,$;Ç/#$+#)(#'#("'#&'#`),h("%;I/' 8!:ı!! )"),h(`%3IJ""5&7ij/:#;</1$;I/($8#:Ĵ#! )(#'#("'#&'#`),h(`%3ĵ""5%7Ķ/]#;</T$%3ķ""5$7ĸ/& 8!:Ĺ! ).4 &%3ĺ""5%7Ļ/& 8!:ļ! )/#$+#)(#'#("'#&'#`),h(`%3Ľ""5)7ľ/R#;</I$3Ŀ""5#7ŀ./ &3Ł""5(7ł.# &;6/($8#:Ń#! )(#'#("'#&'#`),h(`%3ń""5#7Ņ/“#;</Š$;D/$%;Ì/e#$%2D""6D7E/,#;Ì/#$+")("'#&'#0<*%2D""6D7E/,#;Ì/#$+")("'#&'#&/#$+")("'#&'#/,$;E/#$+%)(%'#($'#(#'#("'#&'#`),h(`%3ņ""5(7Ň./ &3ň""5$7ʼn.# &;6/' 8!:Ŋ!! )`),h(`%;6/Y#$%;A/,#;6/#$+")("'#&'#06*%;A/,#;6/#$+")("'#&'#&/#$+")("'#&'#`),h(`%;Ï/G#;./>$;Ï/5$;./,$;/#$+%)(%'#($'#(#'#("'#&'#`),h("%$;!/&#0#*;!&&&#/' 8!:ŋ!! )"),h(`%;Ñ/]#$%;A/,#;Ñ/#$+")("'#&'#06*%;A/,#;Ñ/#$+")("'#&'#&/'$8":Ō" )("'#&'#`),h(`%;™/]#$%;B/,#; /#$+")("'#&'#06*%;B/,#; /#$+")("'#&'#&/'$8":ō" )("'#&'#`),h(`%;L.O &;™.I &%;@." &"/:#;t/1$;?." &"/#$+#)(#'#("'#&'#/]#$%;B/,#; /#$+")("'#&'#06*%;B/,#; /#$+")("'#&'#&/'$8":Ŏ" )("'#&'#`),h(`%;Ô/]#$%;B/,#;Õ/#$+")("'#&'#06*%;B/,#;Õ/#$+")("'#&'#&/'$8":ŏ" )("'#&'#`),h("%;–/& 8!:Ő! )"),h(`%3ő""5(7Œ/:#;</1$;6/($8#:œ#! )(#'#("'#&'#.g &%3Ŕ""5&7ŕ/:#;</1$;6/($8#:Ŗ#! )(#'#("'#&'#.: &%3ŗ""5*7Ř/& 8!:ř! ).# &; `),h(`%%;6/k#$%;A/2#;6/)$8":Ś""$ )("'#&'#0<*%;A/2#;6/)$8":Ś""$ )("'#&'#&/)$8":ś""! )("'#&'#." &"/' 8!:Ŝ!! )`),h(`%;Ø/Y#$%;A/,#;Ø/#$+")("'#&'#06*%;A/,#;Ø/#$+")("'#&'#&/#$+")("'#&'#`),h(`%;™/Y#$%;B/,#; /#$+")("'#&'#06*%;B/,#; /#$+")("'#&'#&/#$+")("'#&'#`),h("%$;!/&#0#*;!&&&#/' 8!:ŝ!! )"),h(`%;Û/Y#$%;B/,#;Ü/#$+")("'#&'#06*%;B/,#;Ü/#$+")("'#&'#&/#$+")("'#&'#`),h(`%3Ş""5&7ş.; &3Š""5'7š./ &3Ţ""5*7ţ.# &;6/& 8!:Ť! )`),h(`%3ť""5&7Ŧ/:#;</1$;Ý/($8#:ŧ#! )(#'#("'#&'#.} &%3õ""5'7ö/:#;</1$;ž/($8#:Ũ#! )(#'#("'#&'#.P &%3ũ""5+7Ū/:#;</1$;ž/($8#:ū#! )(#'#("'#&'#.# &; `),h(`3Ŭ""5+7ŭ.k &3Ů""5)7ů._ &3Ű""5(7ű.S &3Ų""5'7ų.G &3Ŵ""5&7ŵ.; &3Ŷ""5*7ŷ./ &3Ÿ""5)7Ź.# &;6`),h(';1." &"'),h(`%%;6/k#$%;A/2#;6/)$8":Ś""$ )("'#&'#0<*%;A/2#;6/)$8":Ś""$ )("'#&'#&/)$8":ś""! )("'#&'#." &"/' 8!:ź!! )`),h(`%;L.# &;™/]#$%;B/,#;á/#$+")("'#&'#06*%;B/,#;á/#$+")("'#&'#&/'$8":Ż" )("'#&'#`),h(";¹.# &; "),h(`%;ã/Y#$%;A/,#;ã/#$+")("'#&'#06*%;A/,#;ã/#$+")("'#&'#&/#$+")("'#&'#`),h(`%;ê/k#;./b$;í/Y$$%;B/,#;ä/#$+")("'#&'#06*%;B/,#;ä/#$+")("'#&'#&/#$+$)($'#(#'#("'#&'#`),h(";å.; &;æ.5 &;ç./ &;è.) &;é.# &; "),h(`%3ż""5#7Ž/:#;</1$;ð/($8#:ž#! )(#'#("'#&'#`),h(`%3ſ""5%7ƀ/:#;</1$;T/($8#:Ɓ#! )(#'#("'#&'#`),h(`%3Ƃ""5(7ƃ/F#;</=$;\\.) &;Y.# &;X/($8#:Ƅ#! )(#'#("'#&'#`),h(`%3ƅ""5&7Ɔ/:#;</1$;6/($8#:Ƈ#! )(#'#("'#&'#`),h(`%3ƈ""5%7Ɖ/A#;</8$$;!0#*;!&/($8#:Ɗ#! )(#'#("'#&'#`),h(`%;ë/G#;;/>$;6/5$;;/,$;ì/#$+%)(%'#($'#(#'#("'#&'#`),h(`%3’""5#7Ó.# &;6/' 8!:Ƌ!! )`),h(`%3±""5#7ƌ.G &3³""5#7ƍ.; &3·""5#7Ǝ./ &3µ""5$7Ə.# &;6/' 8!:Ɛ!! )`),h(`%;î/D#%;C/,#;ï/#$+")("'#&'#." &"/#$+")("'#&'#`),h("%;U.) &;\\.# &;X/& 8!:Ƒ! )"),h(`%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%'#($'#(#'#("'#&'#/' 8!:ƒ!! )`),h(`%%;!/?#;!." &"/1$;!." &"/#$+#)(#'#("'#&'#/' 8!:Ɠ!! )`),h(";¾"),h(`%;ž/^#$%;B/,#;ó/#$+")("'#&'#06*%;B/,#;ó/#$+")("'#&'#&/($8":Ɣ"!!)("'#&'#`),h(";ô.# &; "),h(`%2ƕ""6ƕ7Ɩ/L#;</C$2Ɨ""6Ɨ7Ƙ.) &2ƙ""6ƙ7ƚ/($8#:ƛ#! )(#'#("'#&'#`),h(`%;ž/^#$%;B/,#; /#$+")("'#&'#06*%;B/,#; /#$+")("'#&'#&/($8":Ɯ"!!)("'#&'#`),h(`%;6/5#;0/,$;÷/#$+#)(#'#("'#&'#`),h("$;2.) &;4.# &;.0/*;2.) &;4.# &;.&"),h("$;%0#*;%&"),h(`%;ú/;#28""6879/,$;û/#$+#)(#'#("'#&'#`),h(`%3Ɲ""5%7ƞ.) &3Ɵ""5$7Ơ/' 8!:ơ!! )`),h(`%;ü/J#%28""6879/,#;^/#$+")("'#&'#." &"/#$+")("'#&'#`),h("%;\\.) &;X.# &;‚/' 8!:Ƣ!! )"),h(';".S &;!.M &2F""6F7G.A &2J""6J7K.5 &2H""6H7I.) &2N""6N7O'),h('2L""6L7M.• &2B""6B7C.‰ &2<""6<7=.} &2R""6R7S.q &2T""6T7U.e &2V""6V7W.Y &2P""6P7Q.M &2@""6@7A.A &2D""6D7E.5 &22""6273.) &2>""6>7?'),h(`%;Ā/b#28""6879/S$;û/J$%2ƣ""6ƣ7Ƥ/,#;ì/#$+")("'#&'#." &"/#$+$)($'#(#'#("'#&'#`),h(`%3ƥ""5%7Ʀ.) &3Ƨ""5$7ƨ/' 8!:ơ!! )`),h(`%3±""5#7².6 &3³""5#7´.* &$;+0#*;+&/' 8!:Ʃ!! )`),h(`%;Ą/‡#2F""6F7G/x$;ă/o$2F""6F7G/\`$;ă/W$2F""6F7G/H$;ă/?$2F""6F7G/0$;ą/'$8):ƪ) )()'#(('#(''#(&'#(%'#($'#(#'#("'#&'#`),h(`%;#/>#;#/5$;#/,$;#/#$+$)($'#(#'#("'#&'#`),h(`%;ă/,#;ă/#$+")("'#&'#`),h(`%;ă/5#;ă/,$;ă/#$+#)(#'#("'#&'#`),h(`%;q/T#$;m0#*;m&/D$%; /,#;ø/#$+")("'#&'#." &"/#$+#)(#'#("'#&'#`),h(`%2ƫ""6ƫ7Ƭ.) &2ƭ""6ƭ7Ʈ/w#;0/n$;Ĉ/e$$%;B/2#;ĉ.# &; /#$+")("'#&'#0<*%;B/2#;ĉ.# &; /#$+")("'#&'#&/#$+$)($'#(#'#("'#&'#`),h(";™.# &;L"),h(`%2Ư""6Ư7ư/5#;</,$;Ċ/#$+#)(#'#("'#&'#`),h(`%;D/S#;,/J$2:""6:7;/;$;,.# &;T/,$;E/#$+%)(%'#($'#(#'#("'#&'#`)];let d=0,c=0;const l=[{line:1,column:1}];let g=0,f=[],y=0,w;if(e.startRule!==void 0){if(!(e.startRule in i))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');n=i[e.startRule]}function b(){return r.substring(c,d)}function _(){return R(c,d)}function x(u,v){return{type:"literal",text:u,ignoreCase:v}}function p(u,v,m){return{type:"class",parts:u,inverted:v,ignoreCase:m}}function E(){return{type:"end"}}function C(u){let v=l[u],m;if(v)return v;for(m=u-1;!l[m];)m--;for(v=l[m],v={line:v.line,column:v.column};m<u;)r.charCodeAt(m)===10?(v.line++,v.column=1):v.column++,m++;return l[u]=v,v}function R(u,v){const m=C(u),U=C(v);return{source:s,start:{offset:u,line:m.line,column:m.column},end:{offset:v,line:U.line,column:U.column}}}function S(u){d<g||(d>g&&(g=d,f=[]),f.push(u))}function F(u,v,m){return new vr(vr.buildMessage(u,v),u,v,m)}function h(u){return u.split("").map(v=>v.charCodeAt(0)-32)}function N(u){const v=o[u];let m=0;const U=[];let j=v.length;const J=[],z=[];let ne;for(;;){for(;m<j;)switch(v[m]){case 0:z.push(a[v[m+1]]),m+=2;break;case 1:z.push(void 0),m++;break;case 2:z.push(null),m++;break;case 3:z.push(t),m++;break;case 4:z.push([]),m++;break;case 5:z.push(d),m++;break;case 6:z.pop(),m++;break;case 7:d=z.pop(),m++;break;case 8:z.length-=v[m+1],m+=2;break;case 9:z.splice(-2,1),m++;break;case 10:z[z.length-2].push(z.pop()),m++;break;case 11:z.push(z.splice(z.length-v[m+1],v[m+1])),m+=2;break;case 12:z.push(r.substring(z.pop(),d)),m++;break;case 13:J.push(j),U.push(m+3+v[m+1]+v[m+2]),z[z.length-1]?(j=m+3+v[m+1],m+=3):(j=m+3+v[m+1]+v[m+2],m+=3+v[m+1]);break;case 14:J.push(j),U.push(m+3+v[m+1]+v[m+2]),z[z.length-1]===t?(j=m+3+v[m+1],m+=3):(j=m+3+v[m+1]+v[m+2],m+=3+v[m+1]);break;case 15:J.push(j),U.push(m+3+v[m+1]+v[m+2]),z[z.length-1]!==t?(j=m+3+v[m+1],m+=3):(j=m+3+v[m+1]+v[m+2],m+=3+v[m+1]);break;case 16:z[z.length-1]!==t?(J.push(j),U.push(m),j=m+2+v[m+1],m+=2):m+=2+v[m+1];break;case 17:J.push(j),U.push(m+3+v[m+1]+v[m+2]),r.length>d?(j=m+3+v[m+1],m+=3):(j=m+3+v[m+1]+v[m+2],m+=3+v[m+1]);break;case 18:J.push(j),U.push(m+4+v[m+2]+v[m+3]),r.substr(d,a[v[m+1]].length)===a[v[m+1]]?(j=m+4+v[m+2],m+=4):(j=m+4+v[m+2]+v[m+3],m+=4+v[m+2]);break;case 19:J.push(j),U.push(m+4+v[m+2]+v[m+3]),r.substr(d,a[v[m+1]].length).toLowerCase()===a[v[m+1]]?(j=m+4+v[m+2],m+=4):(j=m+4+v[m+2]+v[m+3],m+=4+v[m+2]);break;case 20:J.push(j),U.push(m+4+v[m+2]+v[m+3]),a[v[m+1]].test(r.charAt(d))?(j=m+4+v[m+2],m+=4):(j=m+4+v[m+2]+v[m+3],m+=4+v[m+2]);break;case 21:z.push(r.substr(d,v[m+1])),d+=v[m+1],m+=2;break;case 22:z.push(a[v[m+1]]),d+=a[v[m+1]].length,m+=2;break;case 23:z.push(t),y===0&&S(a[v[m+1]]),m+=2;break;case 24:c=z[z.length-1-v[m+1]],m+=2;break;case 25:c=d,m++;break;case 26:ne=v.slice(m+4,m+4+v[m+3]).map(function(he){return z[z.length-1-he]}),z.splice(z.length-v[m+2],v[m+2],a[v[m+1]].apply(null,ne)),m+=4+v[m+3];break;case 27:z.push(N(v[m+1])),m+=2;break;case 28:y++,m++;break;case 29:y--,m++;break;default:throw new Error("Invalid opcode: "+v[m]+".")}if(J.length>0)j=J.pop(),m=U.pop();else break}return z[0]}e.data={};function A(u,v){return[u].concat(v)}if(w=N(n),w!==t&&d===r.length)return w;throw w!==t&&d<r.length&&S(E()),F(f,g<r.length?r.charAt(g):null,g<r.length?R(g,g+1):R(g,g))}const G0=W0;var Pe;(function(r){function e(i,n){const a={startRule:n};try{G0(i,a)}catch{a.data=-1}return a.data}r.parse=e;function t(i){const n=r.parse(i,"Name_Addr_Header");return n!==-1?n:void 0}r.nameAddrHeaderParse=t;function s(i){const n=r.parse(i,"SIP_URI");return n!==-1?n:void 0}r.URIParse=s})(Pe=Pe||(Pe={}));const V0={100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"};function or(r,e=32){let t="";for(let s=0;s<r;s++){const i=Math.floor(Math.random()*e);t+=i.toString(e)}return t}function cs(r){return V0[r]||""}function ls(){return or(10)}function yt(r){const e={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},t=r.toLowerCase().replace(/_/g,"-").split("-"),s=t.length;let i="";for(let n=0;n<s;n++)n!==0&&(i+="-"),i+=t[n].charAt(0).toUpperCase()+t[n].substring(1);return e[i]&&(i=e[i]),i}function qr(r){return encodeURIComponent(r).replace(/%[A-F\d]{2}/g,"U").length}class Ca{constructor(){this.headers={}}addHeader(e,t){const s={raw:t};e=yt(e),this.headers[e]?this.headers[e].push(s):this.headers[e]=[s]}getHeader(e){const t=this.headers[yt(e)];if(t){if(t[0])return t[0].raw}else return}getHeaders(e){const t=this.headers[yt(e)],s=[];if(!t)return[];for(const i of t)s.push(i.raw);return s}hasHeader(e){return!!this.headers[yt(e)]}parseHeader(e,t=0){if(e=yt(e),this.headers[e]){if(t>=this.headers[e].length)return}else return;const s=this.headers[e][t],i=s.raw;if(s.parsed)return s.parsed;const n=Pe.parse(i,e.replace(/-/g,"_"));if(n===-1){this.headers[e].splice(t,1);return}else return s.parsed=n,n}s(e,t=0){return this.parseHeader(e,t)}setHeader(e,t){this.headers[yt(e)]=[{raw:t}]}toString(){return this.data}}class yr extends Ca{constructor(){super()}}class Gt extends Ca{constructor(){super()}}class cr{constructor(e,t,s,i,n,a,o){this.headers={},this.extraHeaders=[],this.options=cr.getDefaultOptions(),n&&(this.options=Object.assign(Object.assign({},this.options),n),this.options.optionTags&&this.options.optionTags.length&&(this.options.optionTags=this.options.optionTags.slice()),this.options.routeSet&&this.options.routeSet.length&&(this.options.routeSet=this.options.routeSet.slice())),a&&a.length&&(this.extraHeaders=a.slice()),o&&(this.body={body:o.content,contentType:o.contentType}),this.method=e,this.ruri=t.clone(),this.fromURI=s.clone(),this.fromTag=this.options.fromTag?this.options.fromTag:ls(),this.from=cr.makeNameAddrHeader(this.fromURI,this.options.fromDisplayName,this.fromTag),this.toURI=i.clone(),this.toTag=this.options.toTag,this.to=cr.makeNameAddrHeader(this.toURI,this.options.toDisplayName,this.toTag),this.callId=this.options.callId?this.options.callId:this.options.callIdPrefix+or(15),this.cseq=this.options.cseq,this.setHeader("route",this.options.routeSet),this.setHeader("via",""),this.setHeader("to",this.to.toString()),this.setHeader("from",this.from.toString()),this.setHeader("cseq",this.cseq+" "+this.method),this.setHeader("call-id",this.callId),this.setHeader("max-forwards","70")}static getDefaultOptions(){return{callId:"",callIdPrefix:"",cseq:1,toDisplayName:"",toTag:"",fromDisplayName:"",fromTag:"",forceRport:!1,hackViaTcp:!1,optionTags:["outbound"],routeSet:[],userAgentString:"sip.js",viaHost:""}}static makeNameAddrHeader(e,t,s){const i={};return s&&(i.tag=s),new ze(e,t,i)}getHeader(e){const t=this.headers[yt(e)];if(t){if(t[0])return t[0]}else{const s=new RegExp("^\\s*"+e+"\\s*:","i");for(const i of this.extraHeaders)if(s.test(i))return i.substring(i.indexOf(":")+1).trim()}}getHeaders(e){const t=[],s=this.headers[yt(e)];if(s)for(const i of s)t.push(i);else{const i=new RegExp("^\\s*"+e+"\\s*:","i");for(const n of this.extraHeaders)i.test(n)&&t.push(n.substring(n.indexOf(":")+1).trim())}return t}hasHeader(e){if(this.headers[yt(e)])return!0;{const t=new RegExp("^\\s*"+e+"\\s*:","i");for(const s of this.extraHeaders)if(t.test(s))return!0}return!1}setHeader(e,t){this.headers[yt(e)]=t instanceof Array?t:[t]}setViaHeader(e,t){this.options.hackViaTcp&&(t="TCP");let s="SIP/2.0/"+t;s+=" "+this.options.viaHost+";branch="+e,this.options.forceRport&&(s+=";rport"),this.setHeader("via",s),this.branch=e}toString(){let e="";e+=this.method+" "+this.ruri.toRaw()+` SIP/2.0\r
151
- `;for(const t in this.headers)if(this.headers[t])for(const s of this.headers[t])e+=t+": "+s+`\r
152
- `;for(const t of this.extraHeaders)e+=t.trim()+`\r
153
- `;return e+="Supported: "+this.options.optionTags.join(", ")+`\r
154
- `,e+="User-Agent: "+this.options.userAgentString+`\r
155
- `,this.body?typeof this.body=="string"?(e+="Content-Length: "+qr(this.body)+`\r
1
+ (function(Tt,Ot){typeof exports=="object"&&typeof module<"u"?Ot(exports):typeof define=="function"&&define.amd?define(["exports"],Ot):(Tt=typeof globalThis<"u"?globalThis:Tt||self,Ot(Tt.OmnixWidget={}))})(this,function(Tt){"use strict";class Ot{constructor(){this.listeners={}}on(n,s){return this.listeners[n]||(this.listeners[n]=[]),this.listeners[n].push(s),()=>this.off(n,s)}off(n,s){this.listeners[n]&&(this.listeners[n]=this.listeners[n].filter(o=>o!==s))}emitLocal(n,s){this.listeners[n]&&this.listeners[n].forEach(o=>{try{o(s)}catch(c){console.error(`Error in event listener for ${n}:`,c)}})}emitToParent(n,s){this.emitLocal(n,s)}}const ts=new Ot;function Ji(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}const zr={title:"JsSIP",version:"3.13.8"},Xr=zr;var oe={USER_AGENT:`${Xr.title} ${Xr.version}`,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",DTMF_TRANSPORT:{INFO:"INFO",RFC2833:"RFC2833"},REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60,CONNECTION_RECOVERY_MAX_INTERVAL:30,CONNECTION_RECOVERY_MIN_INTERVAL:2};class Qi extends Error{constructor(n,s){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=n,this.value=s,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class Zi extends Error{constructor(n){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=n,this.message=`Invalid status: ${n}`}}class ea extends Error{constructor(n){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=n}}class ta extends Error{constructor(n){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=n}}var He={ConfigurationError:Qi,InvalidStateError:Zi,NotSupportedError:ea,NotReadyError:ta},fe={},$s,Jr;function Ps(){if(Jr)return $s;Jr=1;const f=Ze(),n=$e();return $s=class zi{static parse(o){if(o=n.parse(o,"Name_Addr_Header"),o!==-1)return o}constructor(o,c,t){if(!o||!(o instanceof f))throw new TypeError('missing or invalid "uri" parameter');this._uri=o,this._parameters={},this.display_name=c;for(const d in t)Object.prototype.hasOwnProperty.call(t,d)&&this.setParam(d,t[d])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(o){this._display_name=o===0?"0":o}setParam(o,c){o&&(this._parameters[o.toLowerCase()]=typeof c>"u"||c===null?null:c.toString())}getParam(o){if(o)return this._parameters[o.toLowerCase()]}hasParam(o){if(o)return this._parameters.hasOwnProperty(o.toLowerCase())&&!0||!1}deleteParam(o){if(o=o.toLowerCase(),this._parameters.hasOwnProperty(o)){const c=this._parameters[o];return delete this._parameters[o],c}}clearParams(){this._parameters={}}clone(){return new zi(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(o){return o.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let o=this._display_name?`"${this._quote(this._display_name)}" `:"";o+=`<${this._uri.toString()}>`;for(const c in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,c)&&(o+=`;${c}`,this._parameters[c]!==null&&(o+=`=${this._parameters[c]}`));return o}},$s}var Ms,Qr;function $e(){return Qr||(Qr=1,Ms=function(){function f(s){return'"'+s.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(s,o){var c={CRLF:T,DIGIT:m,ALPHA:S,HEXDIG:O,WSP:H,OCTET:B,DQUOTE:k,SP:U,HTAB:de,alphanum:ne,reserved:tt,unreserved:y,mark:$,escaped:ae,LWS:_e,SWS:X,HCOLON:ft,TEXT_UTF8_TRIM:N,TEXT_UTF8char:I,UTF8_NONASCII:b,UTF8_CONT:w,LHEX:wt,token:q,token_nodot:ze,separators:yt,word:We,STAR:ht,SLASH:Xe,EQUAL:z,LPAREN:dt,RPAREN:_t,RAQUOT:st,LAQUOT:rt,COMMA:Q,SEMI:j,COLON:pt,LDQUOT:nt,RDQUOT:gs,comment:W,ctext:G,quoted_string:V,quoted_string_clean:K,qdtext:ue,quoted_pair:ce,SIP_URI_noparams:te,SIP_URI:Je,uri_scheme:Oe,uri_scheme_sips:al,uri_scheme_sip:ol,userinfo:Ts,user:ul,user_unreserved:vr,password:cl,hostport:Es,host:jt,hostname:Rr,domainlabel:Ir,toplabel:fl,IPv6reference:br,IPv6address:wr,h16:P,ls32:xe,IPv4address:Yt,dec_octet:Kt,port:hl,uri_parameters:dl,uri_parameter:yr,transport_param:_l,user_param:pl,method_param:ml,ttl_param:gl,maddr_param:Tl,lr_param:El,other_param:Sl,pname:Cl,pvalue:Al,paramchar:zt,param_unreserved:vl,headers:Rl,header:Ss,hname:Il,hvalue:bl,hnv_unreserved:Xt,Request_Response:Yu,Request_Line:wl,Request_URI:yl,absoluteURI:Nr,hier_part:Nl,net_path:Ol,abs_path:Cs,opaque_part:xl,uric:Jt,uric_no_slash:Dl,path_segments:Ul,segment:As,param:Or,pchar:Qt,scheme:$l,authority:Pl,srvr:Ml,reg_name:Ll,query:Hl,SIP_Version:xr,INVITEm:Fl,ACKm:kl,OPTIONSm:ql,BYEm:Gl,CANCELm:Bl,REGISTERm:Wl,SUBSCRIBEm:Vl,NOTIFYm:jl,REFERm:Yl,Method:vs,Status_Line:Kl,Status_Code:zl,extension_code:Xl,Reason_Phrase:Jl,Allow_Events:Ku,Call_ID:zu,Contact:Xu,contact_param:Rs,name_addr:mt,display_name:Is,contact_params:Dr,c_p_q:Ql,c_p_expires:Zl,delta_seconds:gt,qvalue:ei,generic_param:ge,gen_value:ti,Content_Disposition:Ju,disp_type:si,disp_param:Ur,handling_param:ri,Content_Encoding:Qu,Content_Length:Zu,Content_Type:ec,media_type:ni,m_type:li,discrete_type:ii,composite_type:ai,extension_token:bs,x_token:oi,m_subtype:ui,m_parameter:$r,m_value:ci,CSeq:tc,CSeq_value:fi,Expires:sc,Event:rc,event_type:Zt,From:nc,from_param:Pr,tag_param:Mr,Max_Forwards:lc,Min_Expires:ic,Name_Addr_Header:ac,Proxy_Authenticate:oc,challenge:Lr,other_challenge:hi,auth_param:es,digest_cln:ws,realm:di,realm_value:_i,domain:pi,URI:ys,nonce:mi,nonce_value:gi,opaque:Ti,stale:Ei,algorithm:Si,qop_options:Ci,qop_value:Ns,Proxy_Require:uc,Record_Route:cc,rec_route:Os,Reason:fc,reason_param:Hr,reason_cause:Ai,Require:hc,Route:dc,route_param:xs,Subscription_State:_c,substate_value:vi,subexp_params:Fr,event_reason_value:Ri,Subject:pc,Supported:mc,To:gc,to_param:kr,Via:Tc,via_param:Ds,via_params:qr,via_ttl:Ii,via_maddr:bi,via_received:wi,via_branch:yi,response_port:Ni,rport:Oi,sent_protocol:xi,protocol_name:Di,transport:Ui,sent_by:$i,via_host:Pi,via_port:Mi,ttl:Gr,WWW_Authenticate:Ec,Session_Expires:Sc,s_e_expires:Li,s_e_params:Br,s_e_refresher:Hi,extension_header:Cc,header_value:Fi,message_body:Ac,uuid_URI:vc,uuid:ki,hex4:Qe,hex8:qi,hex12:Gi,Refer_To:Rc,Replaces:Ic,call_id:Bi,replaces_param:Wr,to_tag:Wi,from_tag:Vi,early_flag:ji};if(o!==void 0){if(c[o]===void 0)throw new Error("Invalid rule name: "+f(o)+".")}else o="CRLF";var t=0,d=0,p=[];function a(e){t<d||(t>d&&(d=t,p=[]),p.push(e))}function T(){var e;return s.substr(t,2)===`\r
2
+ `?(e=`\r
3
+ `,t+=2):(e=null,a('"\\r\\n"')),e}function m(){var e;return/^[0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[0-9]")),e}function S(){var e;return/^[a-zA-Z]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-zA-Z]")),e}function O(){var e;return/^[0-9a-fA-F]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[0-9a-fA-F]")),e}function H(){var e;return e=U(),e===null&&(e=de()),e}function B(){var e;return/^[\0-\xFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\0-\\xFF]")),e}function k(){var e;return/^["]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a('["]')),e}function U(){var e;return s.charCodeAt(t)===32?(e=" ",t++):(e=null,a('" "')),e}function de(){var e;return s.charCodeAt(t)===9?(e=" ",t++):(e=null,a('"\\t"')),e}function ne(){var e;return/^[a-zA-Z0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-zA-Z0-9]")),e}function tt(){var e;return s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","'))))))))))),e}function y(){var e;return e=ne(),e===null&&(e=$()),e}function $(){var e;return s.charCodeAt(t)===45?(e="-",t++):(e=null,a('"-"')),e===null&&(s.charCodeAt(t)===95?(e="_",t++):(e=null,a('"_"')),e===null&&(s.charCodeAt(t)===46?(e=".",t++):(e=null,a('"."')),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,a('"!"')),e===null&&(s.charCodeAt(t)===126?(e="~",t++):(e=null,a('"~"')),e===null&&(s.charCodeAt(t)===42?(e="*",t++):(e=null,a('"*"')),e===null&&(s.charCodeAt(t)===39?(e="'",t++):(e=null,a(`"'"`)),e===null&&(s.charCodeAt(t)===40?(e="(",t++):(e=null,a('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,a('")"')))))))))),e}function ae(){var e,r,l,i,u;return i=t,u=t,s.charCodeAt(t)===37?(e="%",t++):(e=null,a('"%"')),e!==null?(r=O(),r!==null?(l=O(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){return _.join("")}(i,e)),e===null&&(t=i),e}function _e(){var e,r,l,i,u,h;for(i=t,u=t,h=t,e=[],r=H();r!==null;)e.push(r),r=H();if(e!==null?(r=T(),r!==null?e=[e,r]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null){if(l=H(),l!==null)for(r=[];l!==null;)r.push(l),l=H();else r=null;r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=function(_){return" "}()),e===null&&(t=i),e}function X(){var e;return e=_e(),e=e!==null?e:"",e}function ft(){var e,r,l,i,u;for(i=t,u=t,e=[],r=U(),r===null&&(r=de());r!==null;)e.push(r),r=U(),r===null&&(r=de());return e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function N(){var e,r,l,i,u,h,_;if(u=t,h=t,r=I(),r!==null)for(e=[];r!==null;)e.push(r),r=I();else e=null;if(e!==null){for(r=[],_=t,l=[],i=_e();i!==null;)l.push(i),i=_e();for(l!==null?(i=I(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;){for(r.push(l),_=t,l=[],i=_e();i!==null;)l.push(i),i=_e();l!==null?(i=I(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_)}r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){return s.substring(t,E)}(u)),e===null&&(t=u),e}function I(){var e;return/^[!-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[!-~]")),e===null&&(e=b()),e}function b(){var e;return/^[\x80-\uFFFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\x80-\\uFFFF]")),e}function w(){var e;return/^[\x80-\xBF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\x80-\\xBF]")),e}function wt(){var e;return e=m(),e===null&&(/^[a-f]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-f]"))),e}function q(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"'))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function ze(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"'))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function yt(){var e;return s.charCodeAt(t)===40?(e="(",t++):(e=null,a('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,a('")"')),e===null&&(s.charCodeAt(t)===60?(e="<",t++):(e=null,a('"<"')),e===null&&(s.charCodeAt(t)===62?(e=">",t++):(e=null,a('">"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===92?(e="\\",t++):(e=null,a('"\\\\"')),e===null&&(e=k(),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===123?(e="{",t++):(e=null,a('"{"')),e===null&&(s.charCodeAt(t)===125?(e="}",t++):(e=null,a('"}"')),e===null&&(e=U(),e===null&&(e=de())))))))))))))))))),e}function We(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,a('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,a('"\\\\"')),r===null&&(r=k(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,a('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,a('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,a('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,a('"}"'))))))))))))))))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,a('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,a('"\\\\"')),r===null&&(r=k(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,a('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,a('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,a('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,a('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function ht(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"*"}()),e===null&&(t=i),e}function Xe(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"/"}()),e===null&&(t=i),e}function z(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"="}()),e===null&&(t=i),e}function dt(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"("}()),e===null&&(t=i),e}function _t(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return")"}()),e===null&&(t=i),e}function st(){var e,r,l,i;return l=t,i=t,s.charCodeAt(t)===62?(e=">",t++):(e=null,a('">"')),e!==null?(r=X(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return">"}()),e===null&&(t=l),e}function rt(){var e,r,l,i;return l=t,i=t,e=X(),e!==null?(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return"<"}()),e===null&&(t=l),e}function Q(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return","}()),e===null&&(t=i),e}function j(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return";"}()),e===null&&(t=i),e}function pt(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function nt(){var e,r,l,i;return l=t,i=t,e=X(),e!==null?(r=k(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return'"'}()),e===null&&(t=l),e}function gs(){var e,r,l,i;return l=t,i=t,e=k(),e!==null?(r=X(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return'"'}()),e===null&&(t=l),e}function W(){var e,r,l,i;if(i=t,e=dt(),e!==null){for(r=[],l=G(),l===null&&(l=ce(),l===null&&(l=W()));l!==null;)r.push(l),l=G(),l===null&&(l=ce(),l===null&&(l=W()));r!==null?(l=_t(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)}else e=null,t=i;return e}function G(){var e;return/^[!-']/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[!-']")),e===null&&(/^[*-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[*-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\]-~]")),e===null&&(e=b(),e===null&&(e=_e())))),e}function V(){var e,r,l,i,u,h;if(u=t,h=t,e=X(),e!==null)if(r=k(),r!==null){for(l=[],i=ue(),i===null&&(i=ce());i!==null;)l.push(i),i=ue(),i===null&&(i=ce());l!==null?(i=k(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_){return s.substring(t,_)}(u)),e===null&&(t=u),e}function K(){var e,r,l,i,u,h;if(u=t,h=t,e=X(),e!==null)if(r=k(),r!==null){for(l=[],i=ue(),i===null&&(i=ce());i!==null;)l.push(i),i=ue(),i===null&&(i=ce());l!==null?(i=k(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_){var E=s.substring(t,_).trim();return E.substring(1,E.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(u)),e===null&&(t=u),e}function ue(){var e;return e=_e(),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,a('"!"')),e===null&&(/^[#-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[#-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\]-~]")),e===null&&(e=b())))),e}function ce(){var e,r,l;return l=t,s.charCodeAt(t)===92?(e="\\",t++):(e=null,a('"\\\\"')),e!==null?(/^[\0-\t]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\0-\\t]")),r===null&&(/^[\x0B-\f]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\x0B-\\f]")),r===null&&(/^[\x0E-]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\x0E-]")))),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function te(){var e,r,l,i,u,h;return u=t,h=t,e=Oe(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Ts(),l=l!==null?l:"",l!==null?(i=Es(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e!==null&&(e=function(_){try{g.uri=new Yi(g.scheme,g.user,g.host,g.port),delete g.scheme,delete g.user,delete g.host,delete g.host_type,delete g.port}catch{g=-1}}()),e===null&&(t=u),e}function Je(){var e,r,l,i,u,h,_,E;return _=t,E=t,e=Oe(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Ts(),l=l!==null?l:"",l!==null?(i=Es(),i!==null?(u=dl(),u!==null?(h=Rl(),h=h!==null?h:"",h!==null?e=[e,r,l,i,u,h]:(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E),e!==null&&(e=function(v){try{g.uri=new Yi(g.scheme,g.user,g.host,g.port,g.uri_params,g.uri_headers),delete g.scheme,delete g.user,delete g.host,delete g.host_type,delete g.port,delete g.uri_params,o==="SIP_URI"&&(g=g.uri)}catch{g=-1}}()),e===null&&(t=_),e}function Oe(){var e;return e=al(),e===null&&(e=ol()),e}function al(){var e,r;return r=t,s.substr(t,4).toLowerCase()==="sips"?(e=s.substr(t,4),t+=4):(e=null,a('"sips"')),e!==null&&(e=function(l,i){g.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function ol(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"sip"')),e!==null&&(e=function(l,i){g.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function Ts(){var e,r,l,i,u,h;return i=t,u=t,e=ul(),e!==null?(h=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=cl(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?(s.charCodeAt(t)===64?(l="@",t++):(l=null,a('"@"')),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g.user=decodeURIComponent(s.substring(t-1,_))}(i)),e===null&&(t=i),e}function ul(){var e,r;if(r=y(),r===null&&(r=ae(),r===null&&(r=vr())),r!==null)for(e=[];r!==null;)e.push(r),r=y(),r===null&&(r=ae(),r===null&&(r=vr()));else e=null;return e}function vr(){var e;return s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"'))))))))),e}function cl(){var e,r,l;for(l=t,e=[],r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","'))))))));r!==null;)e.push(r),r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","'))))))));return e!==null&&(e=function(i){g.password=s.substring(t,i)}(l)),e===null&&(t=l),e}function Es(){var e,r,l,i,u;return i=t,e=jt(),e!==null?(u=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=hl(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function jt(){var e,r;return r=t,e=Rr(),e===null&&(e=Yt(),e===null&&(e=br())),e!==null&&(e=function(l){return g.host=s.substring(t,l).toLowerCase(),g.host}(r)),e===null&&(t=r),e}function Rr(){var e,r,l,i,u,h;for(i=t,u=t,e=[],h=t,r=Ir(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);r!==null;)e.push(r),h=t,r=Ir(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);return e!==null?(r=fl(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){return g.host_type="domain",s.substring(t,_)}(i)),e===null&&(t=i),e}function Ir(){var e,r,l,i;if(i=t,e=ne(),e!==null){for(r=[],l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));l!==null;)r.push(l),l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function fl(){var e,r,l,i;if(i=t,e=S(),e!==null){for(r=[],l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));l!==null;)r.push(l),l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function br(){var e,r,l,i,u;return i=t,u=t,s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e!==null?(r=wr(),r!==null?(s.charCodeAt(t)===93?(l="]",t++):(l=null,a('"]"')),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return g.host_type="IPv6",s.substring(t,h)}(i)),e===null&&(t=i),e}function wr(){var e,r,l,i,u,h,_,E,v,F,le,Ve,Us,jr,C,M;return jr=t,C=t,e=P(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?(s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=P(),v!==null?(s.charCodeAt(t)===58?(F=":",t++):(F=null,a('":"')),F!==null?(le=P(),le!==null?(s.charCodeAt(t)===58?(Ve=":",t++):(Ve=null,a('":"')),Ve!==null?(Us=xe(),Us!==null?e=[e,r,l,i,u,h,_,E,v,F,le,Ve,Us]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=P(),F!==null?(s.charCodeAt(t)===58?(le=":",t++):(le=null,a('":"')),le!==null?(Ve=xe(),Ve!==null?e=[e,r,l,i,u,h,_,E,v,F,le,Ve]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=xe(),F!==null?e=[e,r,l,i,u,h,_,E,v,F]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=xe(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=xe(),h!==null?e=[e,r,l,i,u,h]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=xe(),i!==null?e=[e,r,l,i]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=xe(),r!==null?e=[e,r]:(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?e=[e,r]:(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(s.substr(t,2)==="::"?(r="::",t+=2):(r=null,a('"::"')),r!==null?(l=P(),l!==null?(s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=P(),v!==null?(s.charCodeAt(t)===58?(F=":",t++):(F=null,a('":"')),F!==null?(le=xe(),le!==null?e=[e,r,l,i,u,h,_,E,v,F,le]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(s.substr(t,2)==="::"?(l="::",t+=2):(l=null,a('"::"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=xe(),F!==null?e=[e,r,l,i,u,h,_,E,v,F]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(s.substr(t,2)==="::"?(i="::",t+=2):(i=null,a('"::"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=xe(),v!==null?e=[e,r,l,i,u,h,_,E,v]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(s.substr(t,2)==="::"?(u="::",t+=2):(u=null,a('"::"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=xe(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(s.substr(t,2)==="::"?(h="::",t+=2):(h=null,a('"::"')),h!==null?(_=xe(),_!==null?e=[e,r,l,i,u,h,_]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(M=t,s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?h=[h,_]:(h=null,t=M)):(h=null,t=M),h=h!==null?h:"",h!==null?(s.substr(t,2)==="::"?(_="::",t+=2):(_=null,a('"::"')),_!==null?(E=P(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(M=t,s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?h=[h,_]:(h=null,t=M)):(h=null,t=M),h=h!==null?h:"",h!==null?(M=t,s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?_=[_,E]:(_=null,t=M)):(_=null,t=M),_=_!==null?_:"",_!==null?(s.substr(t,2)==="::"?(E="::",t+=2):(E=null,a('"::"')),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C))))))))))))))),e!==null&&(e=function(Oc){return g.host_type="IPv6",s.substring(t,Oc)}(jr)),e===null&&(t=jr),e}function P(){var e,r,l,i,u;return u=t,e=O(),e!==null?(r=O(),r=r!==null?r:"",r!==null?(l=O(),l=l!==null?l:"",l!==null?(i=O(),i=i!==null?i:"",i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function xe(){var e,r,l,i;return i=t,e=P(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(e=Yt()),e}function Yt(){var e,r,l,i,u,h,_,E,v;return E=t,v=t,e=Kt(),e!==null?(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r!==null?(l=Kt(),l!==null?(s.charCodeAt(t)===46?(i=".",t++):(i=null,a('"."')),i!==null?(u=Kt(),u!==null?(s.charCodeAt(t)===46?(h=".",t++):(h=null,a('"."')),h!==null?(_=Kt(),_!==null?e=[e,r,l,i,u,h,_]:(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v),e!==null&&(e=function(F){return g.host_type="IPv4",s.substring(t,F)}(E)),e===null&&(t=E),e}function Kt(){var e,r,l,i;return i=t,s.substr(t,2)==="25"?(e="25",t+=2):(e=null,a('"25"')),e!==null?(/^[0-5]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[0-5]")),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e===null&&(i=t,s.charCodeAt(t)===50?(e="2",t++):(e=null,a('"2"')),e!==null?(/^[0-4]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[0-4]")),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(i=t,s.charCodeAt(t)===49?(e="1",t++):(e=null,a('"1"')),e!==null?(r=m(),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(i=t,/^[1-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[1-9]")),e!==null?(r=m(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e===null&&(e=m())))),e}function hl(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){return v=parseInt(v.join("")),g.port=v,v}(h,e)),e===null&&(t=h),e}function dl(){var e,r,l,i;for(e=[],i=t,s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=yr(),l!==null?r=[r,l]:(r=null,t=i)):(r=null,t=i);r!==null;)e.push(r),i=t,s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=yr(),l!==null?r=[r,l]:(r=null,t=i)):(r=null,t=i);return e}function yr(){var e;return e=_l(),e===null&&(e=pl(),e===null&&(e=ml(),e===null&&(e=gl(),e===null&&(e=Tl(),e===null&&(e=El(),e===null&&(e=Sl())))))),e}function _l(){var e,r,l,i;return l=t,i=t,s.substr(t,10).toLowerCase()==="transport="?(e=s.substr(t,10),t+=10):(e=null,a('"transport="')),e!==null?(s.substr(t,3).toLowerCase()==="udp"?(r=s.substr(t,3),t+=3):(r=null,a('"udp"')),r===null&&(s.substr(t,3).toLowerCase()==="tcp"?(r=s.substr(t,3),t+=3):(r=null,a('"tcp"')),r===null&&(s.substr(t,4).toLowerCase()==="sctp"?(r=s.substr(t,4),t+=4):(r=null,a('"sctp"')),r===null&&(s.substr(t,3).toLowerCase()==="tls"?(r=s.substr(t,3),t+=3):(r=null,a('"tls"')),r===null&&(r=q())))),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.transport=h.toLowerCase()}(l,e[1])),e===null&&(t=l),e}function pl(){var e,r,l,i;return l=t,i=t,s.substr(t,5).toLowerCase()==="user="?(e=s.substr(t,5),t+=5):(e=null,a('"user="')),e!==null?(s.substr(t,5).toLowerCase()==="phone"?(r=s.substr(t,5),t+=5):(r=null,a('"phone"')),r===null&&(s.substr(t,2).toLowerCase()==="ip"?(r=s.substr(t,2),t+=2):(r=null,a('"ip"')),r===null&&(r=q())),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.user=h.toLowerCase()}(l,e[1])),e===null&&(t=l),e}function ml(){var e,r,l,i;return l=t,i=t,s.substr(t,7).toLowerCase()==="method="?(e=s.substr(t,7),t+=7):(e=null,a('"method="')),e!==null?(r=vs(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.method=h}(l,e[1])),e===null&&(t=l),e}function gl(){var e,r,l,i;return l=t,i=t,s.substr(t,4).toLowerCase()==="ttl="?(e=s.substr(t,4),t+=4):(e=null,a('"ttl="')),e!==null?(r=Gr(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.params||(g.params={}),g.params.ttl=h}(l,e[1])),e===null&&(t=l),e}function Tl(){var e,r,l,i;return l=t,i=t,s.substr(t,6).toLowerCase()==="maddr="?(e=s.substr(t,6),t+=6):(e=null,a('"maddr="')),e!==null?(r=jt(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.maddr=h}(l,e[1])),e===null&&(t=l),e}function El(){var e,r,l,i,u,h;return i=t,u=t,s.substr(t,2).toLowerCase()==="lr"?(e=s.substr(t,2),t+=2):(e=null,a('"lr"')),e!==null?(h=t,s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=q(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g.uri_params||(g.uri_params={}),g.uri_params.lr=void 0}()),e===null&&(t=i),e}function Sl(){var e,r,l,i,u,h;return i=t,u=t,e=Cl(),e!==null?(h=t,s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=Al(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_,E,v){g.uri_params||(g.uri_params={}),typeof v>"u"?v=void 0:v=v[1],g.uri_params[E.toLowerCase()]=v}(i,e[0],e[1])),e===null&&(t=i),e}function Cl(){var e,r,l;if(l=t,r=zt(),r!==null)for(e=[];r!==null;)e.push(r),r=zt();else e=null;return e!==null&&(e=function(i,u){return u.join("")}(l,e)),e===null&&(t=l),e}function Al(){var e,r,l;if(l=t,r=zt(),r!==null)for(e=[];r!==null;)e.push(r),r=zt();else e=null;return e!==null&&(e=function(i,u){return u.join("")}(l,e)),e===null&&(t=l),e}function zt(){var e;return e=vl(),e===null&&(e=y(),e===null&&(e=ae())),e}function vl(){var e;return s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')))))))),e}function Rl(){var e,r,l,i,u,h,_;if(h=t,s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e!==null)if(r=Ss(),r!==null){for(l=[],_=t,s.charCodeAt(t)===38?(i="&",t++):(i=null,a('"&"')),i!==null?(u=Ss(),u!==null?i=[i,u]:(i=null,t=_)):(i=null,t=_);i!==null;)l.push(i),_=t,s.charCodeAt(t)===38?(i="&",t++):(i=null,a('"&"')),i!==null?(u=Ss(),u!==null?i=[i,u]:(i=null,t=_)):(i=null,t=_);l!==null?e=[e,r,l]:(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e}function Ss(){var e,r,l,i,u;return i=t,u=t,e=Il(),e!==null?(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=bl(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_,E){_=_.join("").toLowerCase(),E=E.join(""),g.uri_headers||(g.uri_headers={}),g.uri_headers[_]?g.uri_headers[_].push(E):g.uri_headers[_]=[E]}(i,e[0],e[2])),e===null&&(t=i),e}function Il(){var e,r;if(r=Xt(),r===null&&(r=y(),r===null&&(r=ae())),r!==null)for(e=[];r!==null;)e.push(r),r=Xt(),r===null&&(r=y(),r===null&&(r=ae()));else e=null;return e}function bl(){var e,r;for(e=[],r=Xt(),r===null&&(r=y(),r===null&&(r=ae()));r!==null;)e.push(r),r=Xt(),r===null&&(r=y(),r===null&&(r=ae()));return e}function Xt(){var e;return s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')))))))),e}function Yu(){var e;return e=Kl(),e===null&&(e=wl()),e}function wl(){var e,r,l,i,u,h;return h=t,e=vs(),e!==null?(r=U(),r!==null?(l=yl(),l!==null?(i=U(),i!==null?(u=xr(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function yl(){var e;return e=Je(),e===null&&(e=Nr()),e}function Nr(){var e,r,l,i;return i=t,e=$l(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Nl(),l===null&&(l=xl()),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Nl(){var e,r,l,i,u;return i=t,e=Ol(),e===null&&(e=Cs()),e!==null?(u=t,s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r!==null?(l=Hl(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Ol(){var e,r,l,i;return i=t,s.substr(t,2)==="//"?(e="//",t+=2):(e=null,a('"//"')),e!==null?(r=Pl(),r!==null?(l=Cs(),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Cs(){var e,r,l;return l=t,s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e!==null?(r=Ul(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function xl(){var e,r,l,i;if(i=t,e=Dl(),e!==null){for(r=[],l=Jt();l!==null;)r.push(l),l=Jt();r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function Jt(){var e;return e=tt(),e===null&&(e=y(),e===null&&(e=ae())),e}function Dl(){var e;return e=y(),e===null&&(e=ae(),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')))))))))))),e}function Ul(){var e,r,l,i,u,h;if(u=t,e=As(),e!==null){for(r=[],h=t,s.charCodeAt(t)===47?(l="/",t++):(l=null,a('"/"')),l!==null?(i=As(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===47?(l="/",t++):(l=null,a('"/"')),l!==null?(i=As(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function As(){var e,r,l,i,u,h;for(u=t,e=[],r=Qt();r!==null;)e.push(r),r=Qt();if(e!==null){for(r=[],h=t,s.charCodeAt(t)===59?(l=";",t++):(l=null,a('";"')),l!==null?(i=Or(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===59?(l=";",t++):(l=null,a('";"')),l!==null?(i=Or(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Or(){var e,r;for(e=[],r=Qt();r!==null;)e.push(r),r=Qt();return e}function Qt(){var e;return e=y(),e===null&&(e=ae(),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')))))))))),e}function $l(){var e,r,l,i,u;if(i=t,u=t,e=S(),e!==null){for(r=[],l=S(),l===null&&(l=m(),l===null&&(s.charCodeAt(t)===43?(l="+",t++):(l=null,a('"+"')),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."'))))));l!==null;)r.push(l),l=S(),l===null&&(l=m(),l===null&&(s.charCodeAt(t)===43?(l="+",t++):(l=null,a('"+"')),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."'))))));r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=function(h){g.scheme=s.substring(t,h)}(i)),e===null&&(t=i),e}function Pl(){var e;return e=Ml(),e===null&&(e=Ll()),e}function Ml(){var e,r,l,i;return l=t,i=t,e=Ts(),e!==null?(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e=e!==null?e:"",e!==null?(r=Es(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e=e!==null?e:"",e}function Ll(){var e,r;if(r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r===null&&(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"'))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r===null&&(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')))))))))));else e=null;return e}function Hl(){var e,r;for(e=[],r=Jt();r!==null;)e.push(r),r=Jt();return e}function xr(){var e,r,l,i,u,h,_,E;if(_=t,E=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e!==null)if(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r!==null){if(i=m(),i!==null)for(l=[];i!==null;)l.push(i),i=m();else l=null;if(l!==null)if(s.charCodeAt(t)===46?(i=".",t++):(i=null,a('"."')),i!==null){if(h=m(),h!==null)for(u=[];h!==null;)u.push(h),h=m();else u=null;u!==null?e=[e,r,l,i,u]:(e=null,t=E)}else e=null,t=E;else e=null,t=E}else e=null,t=E;else e=null,t=E;return e!==null&&(e=function(v){g.sip_version=s.substring(t,v)}(_)),e===null&&(t=_),e}function Fl(){var e;return s.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,a('"INVITE"')),e}function kl(){var e;return s.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,a('"ACK"')),e}function ql(){var e;return s.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,a('"OPTIONS"')),e}function Gl(){var e;return s.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,a('"BYE"')),e}function Bl(){var e;return s.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,a('"CANCEL"')),e}function Wl(){var e;return s.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,a('"REGISTER"')),e}function Vl(){var e;return s.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,a('"SUBSCRIBE"')),e}function jl(){var e;return s.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,a('"NOTIFY"')),e}function Yl(){var e;return s.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,a('"REFER"')),e}function vs(){var e,r;return r=t,e=Fl(),e===null&&(e=kl(),e===null&&(e=ql(),e===null&&(e=Gl(),e===null&&(e=Bl(),e===null&&(e=Wl(),e===null&&(e=Vl(),e===null&&(e=jl(),e===null&&(e=Yl(),e===null&&(e=q()))))))))),e!==null&&(e=function(l){return g.method=s.substring(t,l),g.method}(r)),e===null&&(t=r),e}function Kl(){var e,r,l,i,u,h;return h=t,e=xr(),e!==null?(r=U(),r!==null?(l=zl(),l!==null?(i=U(),i!==null?(u=Jl(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function zl(){var e,r;return r=t,e=Xl(),e!==null&&(e=function(l,i){g.status_code=parseInt(i.join(""))}(r,e)),e===null&&(t=r),e}function Xl(){var e,r,l,i;return i=t,e=m(),e!==null?(r=m(),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Jl(){var e,r,l;for(l=t,e=[],r=tt(),r===null&&(r=y(),r===null&&(r=ae(),r===null&&(r=b(),r===null&&(r=w(),r===null&&(r=U(),r===null&&(r=de()))))));r!==null;)e.push(r),r=tt(),r===null&&(r=y(),r===null&&(r=ae(),r===null&&(r=b(),r===null&&(r=w(),r===null&&(r=U(),r===null&&(r=de()))))));return e!==null&&(e=function(i){g.reason_phrase=s.substring(t,i)}(l)),e===null&&(t=l),e}function Ku(){var e,r,l,i,u,h;if(u=t,e=Zt(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=Zt(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=Zt(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function zu(){var e,r,l,i,u,h;return i=t,u=t,e=We(),e!==null?(h=t,s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?(l=We(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g=s.substring(t,_)}(i)),e===null&&(t=i),e}function Xu(){var e,r,l,i,u,h,_;if(u=t,e=ht(),e===null)if(h=t,e=Rs(),e!==null){for(r=[],_=t,l=Q(),l!==null?(i=Rs(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=Q(),l!==null?(i=Rs(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v,F;for(F=g.multi_header.length,v=0;v<F;v++)if(g.multi_header[v].parsed===null){g=null;break}g!==null?g=g.multi_header:g=-1}()),e===null&&(t=u),e}function Rs(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Dr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Dr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v;g.multi_header||(g.multi_header=[]);try{v=new Nt(g.uri,g.display_name,g.params),delete g.uri,delete g.display_name,delete g.params}catch{v=null}g.multi_header.push({possition:t,offset:E,parsed:v})}(u)),e===null&&(t=u),e}function mt(){var e,r,l,i,u;return u=t,e=Is(),e=e!==null?e:"",e!==null?(r=rt(),r!==null?(l=Je(),l!==null?(i=st(),i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Is(){var e,r,l,i,u,h,_;if(u=t,h=t,e=q(),e!==null){for(r=[],_=t,l=_e(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=_e(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e===null&&(e=K()),e!==null&&(e=function(E,v){typeof v=="string"?g.display_name=v:g.display_name=v[1].reduce(function(F,le){return F+le[0]+le[1]},v[0])}(u,e)),e===null&&(t=u),e}function Dr(){var e;return e=Ql(),e===null&&(e=Zl(),e===null&&(e=ge())),e}function Ql(){var e,r,l,i,u;return i=t,u=t,s.substr(t,1).toLowerCase()==="q"?(e=s.substr(t,1),t++):(e=null,a('"q"')),e!==null?(r=z(),r!==null?(l=ei(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.params||(g.params={}),g.params.q=_}(i,e[2])),e===null&&(t=i),e}function Zl(){var e,r,l,i,u;return i=t,u=t,s.substr(t,7).toLowerCase()==="expires"?(e=s.substr(t,7),t+=7):(e=null,a('"expires"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.params||(g.params={}),g.params.expires=_}(i,e[2])),e===null&&(t=i),e}function gt(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){return parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function ei(){var e,r,l,i,u,h,_,E;return h=t,_=t,s.charCodeAt(t)===48?(e="0",t++):(e=null,a('"0"')),e!==null?(E=t,s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?r=[r,l,i,u]:(r=null,t=E)):(r=null,t=E)):(r=null,t=E)):(r=null,t=E),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(v){return parseFloat(s.substring(t,v))}(h)),e===null&&(t=h),e}function ge(){var e,r,l,i,u,h;return i=t,u=t,e=q(),e!==null?(h=t,r=z(),r!==null?(l=ti(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_,E,v){g.params||(g.params={}),typeof v>"u"?v=void 0:v=v[1],g.params[E.toLowerCase()]=v}(i,e[0],e[1])),e===null&&(t=i),e}function ti(){var e;return e=q(),e===null&&(e=jt(),e===null&&(e=V())),e}function Ju(){var e,r,l,i,u,h;if(u=t,e=si(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Ur(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Ur(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function si(){var e;return s.substr(t,6).toLowerCase()==="render"?(e=s.substr(t,6),t+=6):(e=null,a('"render"')),e===null&&(s.substr(t,7).toLowerCase()==="session"?(e=s.substr(t,7),t+=7):(e=null,a('"session"')),e===null&&(s.substr(t,4).toLowerCase()==="icon"?(e=s.substr(t,4),t+=4):(e=null,a('"icon"')),e===null&&(s.substr(t,5).toLowerCase()==="alert"?(e=s.substr(t,5),t+=5):(e=null,a('"alert"')),e===null&&(e=q())))),e}function Ur(){var e;return e=ri(),e===null&&(e=ge()),e}function ri(){var e,r,l,i;return i=t,s.substr(t,8).toLowerCase()==="handling"?(e=s.substr(t,8),t+=8):(e=null,a('"handling"')),e!==null?(r=z(),r!==null?(s.substr(t,8).toLowerCase()==="optional"?(l=s.substr(t,8),t+=8):(l=null,a('"optional"')),l===null&&(s.substr(t,8).toLowerCase()==="required"?(l=s.substr(t,8),t+=8):(l=null,a('"required"')),l===null&&(l=q())),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Qu(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Zu(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){g=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function ec(){var e,r;return r=t,e=ni(),e!==null&&(e=function(l){g=s.substring(t,l)}(r)),e===null&&(t=r),e}function ni(){var e,r,l,i,u,h,_,E;if(_=t,e=li(),e!==null)if(r=Xe(),r!==null)if(l=ui(),l!==null){for(i=[],E=t,u=j(),u!==null?(h=$r(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=j(),u!==null?(h=$r(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function li(){var e;return e=ii(),e===null&&(e=ai()),e}function ii(){var e;return s.substr(t,4).toLowerCase()==="text"?(e=s.substr(t,4),t+=4):(e=null,a('"text"')),e===null&&(s.substr(t,5).toLowerCase()==="image"?(e=s.substr(t,5),t+=5):(e=null,a('"image"')),e===null&&(s.substr(t,5).toLowerCase()==="audio"?(e=s.substr(t,5),t+=5):(e=null,a('"audio"')),e===null&&(s.substr(t,5).toLowerCase()==="video"?(e=s.substr(t,5),t+=5):(e=null,a('"video"')),e===null&&(s.substr(t,11).toLowerCase()==="application"?(e=s.substr(t,11),t+=11):(e=null,a('"application"')),e===null&&(e=bs()))))),e}function ai(){var e;return s.substr(t,7).toLowerCase()==="message"?(e=s.substr(t,7),t+=7):(e=null,a('"message"')),e===null&&(s.substr(t,9).toLowerCase()==="multipart"?(e=s.substr(t,9),t+=9):(e=null,a('"multipart"')),e===null&&(e=bs())),e}function bs(){var e;return e=q(),e===null&&(e=oi()),e}function oi(){var e,r,l;return l=t,s.substr(t,2).toLowerCase()==="x-"?(e=s.substr(t,2),t+=2):(e=null,a('"x-"')),e!==null?(r=q(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function ui(){var e;return e=bs(),e===null&&(e=q()),e}function $r(){var e,r,l,i;return i=t,e=q(),e!==null?(r=z(),r!==null?(l=ci(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function ci(){var e;return e=q(),e===null&&(e=V()),e}function tc(){var e,r,l,i;return i=t,e=fi(),e!==null?(r=_e(),r!==null?(l=vs(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function fi(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){g.value=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function sc(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){g=i}(r,e)),e===null&&(t=r),e}function rc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=Zt(),e!==null){for(r=[],_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E,v){g.event=v.join("").toLowerCase()}(u,e[0])),e===null&&(t=u),e}function Zt(){var e,r,l,i,u,h;if(u=t,e=ze(),e!==null){for(r=[],h=t,s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?(i=ze(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?(i=ze(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function nc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Pr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Pr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v=g.tag;try{g=new Nt(g.uri,g.display_name,g.params),v&&g.setParam("tag",v)}catch{g=-1}}()),e===null&&(t=u),e}function Pr(){var e;return e=Mr(),e===null&&(e=ge()),e}function Mr(){var e,r,l,i,u;return i=t,u=t,s.substr(t,3).toLowerCase()==="tag"?(e=s.substr(t,3),t+=3):(e=null,a('"tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.tag=_}(i,e[2])),e===null&&(t=i),e}function lc(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){g=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function ic(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){g=i}(r,e)),e===null&&(t=r),e}function ac(){var e,r,l,i,u,h,_,E,v,F;for(E=t,v=t,e=[],r=Is();r!==null;)e.push(r),r=Is();if(e!==null)if(r=rt(),r!==null)if(l=Je(),l!==null)if(i=st(),i!==null){for(u=[],F=t,h=j(),h!==null?(_=ge(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);h!==null;)u.push(h),F=t,h=j(),h!==null?(_=ge(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);u!==null?e=[e,r,l,i,u]:(e=null,t=v)}else e=null,t=v;else e=null,t=v;else e=null,t=v;else e=null,t=v;return e!==null&&(e=function(le){try{g=new Nt(g.uri,g.display_name,g.params)}catch{g=-1}}()),e===null&&(t=E),e}function oc(){var e;return e=Lr(),e}function Lr(){var e,r,l,i,u,h,_,E;if(_=t,s.substr(t,6).toLowerCase()==="digest"?(e=s.substr(t,6),t+=6):(e=null,a('"Digest"')),e!==null)if(r=_e(),r!==null)if(l=ws(),l!==null){for(i=[],E=t,u=Q(),u!==null?(h=ws(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=Q(),u!==null?(h=ws(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e===null&&(e=hi()),e}function hi(){var e,r,l,i,u,h,_,E;if(_=t,e=q(),e!==null)if(r=_e(),r!==null)if(l=es(),l!==null){for(i=[],E=t,u=Q(),u!==null?(h=es(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=Q(),u!==null?(h=es(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function es(){var e,r,l,i;return i=t,e=q(),e!==null?(r=z(),r!==null?(l=q(),l===null&&(l=V()),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function ws(){var e;return e=di(),e===null&&(e=pi(),e===null&&(e=mi(),e===null&&(e=Ti(),e===null&&(e=Ei(),e===null&&(e=Si(),e===null&&(e=Ci(),e===null&&(e=es()))))))),e}function di(){var e,r,l,i;return i=t,s.substr(t,5).toLowerCase()==="realm"?(e=s.substr(t,5),t+=5):(e=null,a('"realm"')),e!==null?(r=z(),r!==null?(l=_i(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function _i(){var e,r;return r=t,e=K(),e!==null&&(e=function(l,i){g.realm=i}(r,e)),e===null&&(t=r),e}function pi(){var e,r,l,i,u,h,_,E,v;if(E=t,s.substr(t,6).toLowerCase()==="domain"?(e=s.substr(t,6),t+=6):(e=null,a('"domain"')),e!==null)if(r=z(),r!==null)if(l=nt(),l!==null)if(i=ys(),i!==null){if(u=[],v=t,_=U(),_!==null)for(h=[];_!==null;)h.push(_),_=U();else h=null;for(h!==null?(_=ys(),_!==null?h=[h,_]:(h=null,t=v)):(h=null,t=v);h!==null;){if(u.push(h),v=t,_=U(),_!==null)for(h=[];_!==null;)h.push(_),_=U();else h=null;h!==null?(_=ys(),_!==null?h=[h,_]:(h=null,t=v)):(h=null,t=v)}u!==null?(h=gs(),h!==null?e=[e,r,l,i,u,h]:(e=null,t=E)):(e=null,t=E)}else e=null,t=E;else e=null,t=E;else e=null,t=E;else e=null,t=E;return e}function ys(){var e;return e=Nr(),e===null&&(e=Cs()),e}function mi(){var e,r,l,i;return i=t,s.substr(t,5).toLowerCase()==="nonce"?(e=s.substr(t,5),t+=5):(e=null,a('"nonce"')),e!==null?(r=z(),r!==null?(l=gi(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function gi(){var e,r;return r=t,e=K(),e!==null&&(e=function(l,i){g.nonce=i}(r,e)),e===null&&(t=r),e}function Ti(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="opaque"?(e=s.substr(t,6),t+=6):(e=null,a('"opaque"')),e!==null?(r=z(),r!==null?(l=K(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.opaque=_}(i,e[2])),e===null&&(t=i),e}function Ei(){var e,r,l,i,u;return i=t,s.substr(t,5).toLowerCase()==="stale"?(e=s.substr(t,5),t+=5):(e=null,a('"stale"')),e!==null?(r=z(),r!==null?(u=t,s.substr(t,4).toLowerCase()==="true"?(l=s.substr(t,4),t+=4):(l=null,a('"true"')),l!==null&&(l=function(h){g.stale=!0}()),l===null&&(t=u),l===null&&(u=t,s.substr(t,5).toLowerCase()==="false"?(l=s.substr(t,5),t+=5):(l=null,a('"false"')),l!==null&&(l=function(h){g.stale=!1}()),l===null&&(t=u)),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Si(){var e,r,l,i,u;return i=t,u=t,s.substr(t,9).toLowerCase()==="algorithm"?(e=s.substr(t,9),t+=9):(e=null,a('"algorithm"')),e!==null?(r=z(),r!==null?(s.substr(t,3).toLowerCase()==="md5"?(l=s.substr(t,3),t+=3):(l=null,a('"MD5"')),l===null&&(s.substr(t,8).toLowerCase()==="md5-sess"?(l=s.substr(t,8),t+=8):(l=null,a('"MD5-sess"')),l===null&&(l=q())),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.algorithm=_.toUpperCase()}(i,e[2])),e===null&&(t=i),e}function Ci(){var e,r,l,i,u,h,_,E,v,F;if(E=t,s.substr(t,3).toLowerCase()==="qop"?(e=s.substr(t,3),t+=3):(e=null,a('"qop"')),e!==null)if(r=z(),r!==null)if(l=nt(),l!==null){if(v=t,i=Ns(),i!==null){for(u=[],F=t,s.charCodeAt(t)===44?(h=",",t++):(h=null,a('","')),h!==null?(_=Ns(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);h!==null;)u.push(h),F=t,s.charCodeAt(t)===44?(h=",",t++):(h=null,a('","')),h!==null?(_=Ns(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);u!==null?i=[i,u]:(i=null,t=v)}else i=null,t=v;i!==null?(u=gs(),u!==null?e=[e,r,l,i,u]:(e=null,t=E)):(e=null,t=E)}else e=null,t=E;else e=null,t=E;else e=null,t=E;return e}function Ns(){var e,r;return r=t,s.substr(t,8).toLowerCase()==="auth-int"?(e=s.substr(t,8),t+=8):(e=null,a('"auth-int"')),e===null&&(s.substr(t,4).toLowerCase()==="auth"?(e=s.substr(t,4),t+=4):(e=null,a('"auth"')),e===null&&(e=q())),e!==null&&(e=function(l,i){g.qop||(g.qop=[]),g.qop.push(i.toLowerCase())}(r,e)),e===null&&(t=r),e}function uc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function cc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=Os(),e!==null){for(r=[],_=t,l=Q(),l!==null?(i=Os(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=Q(),l!==null?(i=Os(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v,F;for(F=g.multi_header.length,v=0;v<F;v++)if(g.multi_header[v].parsed===null){g=null;break}g!==null?g=g.multi_header:g=-1}()),e===null&&(t=u),e}function Os(){var e,r,l,i,u,h,_;if(u=t,h=t,e=mt(),e!==null){for(r=[],_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v;g.multi_header||(g.multi_header=[]);try{v=new Nt(g.uri,g.display_name,g.params),delete g.uri,delete g.display_name,delete g.params}catch{v=null}g.multi_header.push({possition:t,offset:E,parsed:v})}(u)),e===null&&(t=u),e}function fc(){var e,r,l,i,u,h,_;if(u=t,h=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e===null&&(e=q()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Hr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Hr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E,v){if(g.protocol=v.toLowerCase(),g.params||(g.params={}),g.params.text&&g.params.text[0]==='"'){var F=g.params.text;g.text=F.substring(1,F.length-1),delete g.params.text}}(u,e[0])),e===null&&(t=u),e}function Hr(){var e;return e=Ai(),e===null&&(e=ge()),e}function Ai(){var e,r,l,i,u,h;if(u=t,h=t,s.substr(t,5).toLowerCase()==="cause"?(e=s.substr(t,5),t+=5):(e=null,a('"cause"')),e!==null)if(r=z(),r!==null){if(i=m(),i!==null)for(l=[];i!==null;)l.push(i),i=m();else l=null;l!==null?e=[e,r,l]:(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_,E){g.cause=parseInt(E.join(""))}(u,e[2])),e===null&&(t=u),e}function hc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function dc(){var e,r,l,i,u,h;if(u=t,e=xs(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=xs(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=xs(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function xs(){var e,r,l,i,u,h;if(u=t,e=mt(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function _c(){var e,r,l,i,u,h;if(u=t,e=vi(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Fr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Fr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function vi(){var e,r;return r=t,s.substr(t,6).toLowerCase()==="active"?(e=s.substr(t,6),t+=6):(e=null,a('"active"')),e===null&&(s.substr(t,7).toLowerCase()==="pending"?(e=s.substr(t,7),t+=7):(e=null,a('"pending"')),e===null&&(s.substr(t,10).toLowerCase()==="terminated"?(e=s.substr(t,10),t+=10):(e=null,a('"terminated"')),e===null&&(e=q()))),e!==null&&(e=function(l){g.state=s.substring(t,l)}(r)),e===null&&(t=r),e}function Fr(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="reason"?(e=s.substr(t,6),t+=6):(e=null,a('"reason"')),e!==null?(r=z(),r!==null?(l=Ri(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(g.reason=_)}(i,e[2])),e===null&&(t=i),e===null&&(i=t,u=t,s.substr(t,7).toLowerCase()==="expires"?(e=s.substr(t,7),t+=7):(e=null,a('"expires"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(g.expires=_)}(i,e[2])),e===null&&(t=i),e===null&&(i=t,u=t,s.substr(t,11).toLowerCase()==="retry_after"?(e=s.substr(t,11),t+=11):(e=null,a('"retry_after"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(g.retry_after=_)}(i,e[2])),e===null&&(t=i),e===null&&(e=ge()))),e}function Ri(){var e;return s.substr(t,11).toLowerCase()==="deactivated"?(e=s.substr(t,11),t+=11):(e=null,a('"deactivated"')),e===null&&(s.substr(t,9).toLowerCase()==="probation"?(e=s.substr(t,9),t+=9):(e=null,a('"probation"')),e===null&&(s.substr(t,8).toLowerCase()==="rejected"?(e=s.substr(t,8),t+=8):(e=null,a('"rejected"')),e===null&&(s.substr(t,7).toLowerCase()==="timeout"?(e=s.substr(t,7),t+=7):(e=null,a('"timeout"')),e===null&&(s.substr(t,6).toLowerCase()==="giveup"?(e=s.substr(t,6),t+=6):(e=null,a('"giveup"')),e===null&&(s.substr(t,10).toLowerCase()==="noresource"?(e=s.substr(t,10),t+=10):(e=null,a('"noresource"')),e===null&&(s.substr(t,9).toLowerCase()==="invariant"?(e=s.substr(t,9),t+=9):(e=null,a('"invariant"')),e===null&&(e=q()))))))),e}function pc(){var e;return e=N(),e=e!==null?e:"",e}function mc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e=e!==null?e:"",e}function gc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=kr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=kr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v=g.tag;try{g=new Nt(g.uri,g.display_name,g.params),v&&g.setParam("tag",v)}catch{g=-1}}()),e===null&&(t=u),e}function kr(){var e;return e=Mr(),e===null&&(e=ge()),e}function Tc(){var e,r,l,i,u,h;if(u=t,e=Ds(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=Ds(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=Ds(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Ds(){var e,r,l,i,u,h,_,E;if(_=t,e=xi(),e!==null)if(r=_e(),r!==null)if(l=$i(),l!==null){for(i=[],E=t,u=j(),u!==null?(h=qr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=j(),u!==null?(h=qr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function qr(){var e;return e=Ii(),e===null&&(e=bi(),e===null&&(e=wi(),e===null&&(e=yi(),e===null&&(e=Ni(),e===null&&(e=ge()))))),e}function Ii(){var e,r,l,i,u;return i=t,u=t,s.substr(t,3).toLowerCase()==="ttl"?(e=s.substr(t,3),t+=3):(e=null,a('"ttl"')),e!==null?(r=z(),r!==null?(l=Gr(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.ttl=_}(i,e[2])),e===null&&(t=i),e}function bi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,5).toLowerCase()==="maddr"?(e=s.substr(t,5),t+=5):(e=null,a('"maddr"')),e!==null?(r=z(),r!==null?(l=jt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.maddr=_}(i,e[2])),e===null&&(t=i),e}function wi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,8).toLowerCase()==="received"?(e=s.substr(t,8),t+=8):(e=null,a('"received"')),e!==null?(r=z(),r!==null?(l=Yt(),l===null&&(l=wr()),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.received=_}(i,e[2])),e===null&&(t=i),e}function yi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="branch"?(e=s.substr(t,6),t+=6):(e=null,a('"branch"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.branch=_}(i,e[2])),e===null&&(t=i),e}function Ni(){var e,r,l,i,u;return i=t,s.substr(t,5).toLowerCase()==="rport"?(e=s.substr(t,5),t+=5):(e=null,a('"rport"')),e!==null?(u=t,r=z(),r!==null?(l=Oi(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Oi(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){g.rport=parseInt(v.join(""))}(h,e)),e===null&&(t=h),e}function xi(){var e,r,l,i,u,h;return h=t,e=Di(),e!==null?(r=Xe(),r!==null?(l=q(),l!==null?(i=Xe(),i!==null?(u=Ui(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function Di(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e===null&&(e=q()),e!==null&&(e=function(l,i){g.protocol=i}(r,e)),e===null&&(t=r),e}function Ui(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="udp"?(e=s.substr(t,3),t+=3):(e=null,a('"UDP"')),e===null&&(s.substr(t,3).toLowerCase()==="tcp"?(e=s.substr(t,3),t+=3):(e=null,a('"TCP"')),e===null&&(s.substr(t,3).toLowerCase()==="tls"?(e=s.substr(t,3),t+=3):(e=null,a('"TLS"')),e===null&&(s.substr(t,4).toLowerCase()==="sctp"?(e=s.substr(t,4),t+=4):(e=null,a('"SCTP"')),e===null&&(e=q())))),e!==null&&(e=function(l,i){g.transport=i}(r,e)),e===null&&(t=r),e}function $i(){var e,r,l,i,u;return i=t,e=Pi(),e!==null?(u=t,r=pt(),r!==null?(l=Mi(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Pi(){var e,r;return r=t,e=Yt(),e===null&&(e=br(),e===null&&(e=Rr())),e!==null&&(e=function(l){g.host=s.substring(t,l)}(r)),e===null&&(t=r),e}function Mi(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){g.port=parseInt(v.join(""))}(h,e)),e===null&&(t=h),e}function Gr(){var e,r,l,i,u;return i=t,u=t,e=m(),e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){return parseInt(_.join(""))}(i,e)),e===null&&(t=i),e}function Ec(){var e;return e=Lr(),e}function Sc(){var e,r,l,i,u,h;if(u=t,e=Li(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Br(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Br(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Li(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){g.expires=i}(r,e)),e===null&&(t=r),e}function Br(){var e;return e=Hi(),e===null&&(e=ge()),e}function Hi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,9).toLowerCase()==="refresher"?(e=s.substr(t,9),t+=9):(e=null,a('"refresher"')),e!==null?(r=z(),r!==null?(s.substr(t,3).toLowerCase()==="uac"?(l=s.substr(t,3),t+=3):(l=null,a('"uac"')),l===null&&(s.substr(t,3).toLowerCase()==="uas"?(l=s.substr(t,3),t+=3):(l=null,a('"uas"'))),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.refresher=_.toLowerCase()}(i,e[2])),e===null&&(t=i),e}function Cc(){var e,r,l,i;return i=t,e=q(),e!==null?(r=ft(),r!==null?(l=Fi(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Fi(){var e,r;for(e=[],r=I(),r===null&&(r=w(),r===null&&(r=_e()));r!==null;)e.push(r),r=I(),r===null&&(r=w(),r===null&&(r=_e()));return e}function Ac(){var e,r;for(e=[],r=B();r!==null;)e.push(r),r=B();return e}function vc(){var e,r,l;return l=t,s.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,a('"uuid:"')),e!==null?(r=ki(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function ki(){var e,r,l,i,u,h,_,E,v,F,le;return F=t,le=t,e=qi(),e!==null?(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r!==null?(l=Qe(),l!==null?(s.charCodeAt(t)===45?(i="-",t++):(i=null,a('"-"')),i!==null?(u=Qe(),u!==null?(s.charCodeAt(t)===45?(h="-",t++):(h=null,a('"-"')),h!==null?(_=Qe(),_!==null?(s.charCodeAt(t)===45?(E="-",t++):(E=null,a('"-"')),E!==null?(v=Gi(),v!==null?e=[e,r,l,i,u,h,_,E,v]:(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le),e!==null&&(e=function(Ve,Us){g=s.substring(t+5,Ve)}(F,e[0])),e===null&&(t=F),e}function Qe(){var e,r,l,i,u;return u=t,e=O(),e!==null?(r=O(),r!==null?(l=O(),l!==null?(i=O(),i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function qi(){var e,r,l;return l=t,e=Qe(),e!==null?(r=Qe(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function Gi(){var e,r,l,i;return i=t,e=Qe(),e!==null?(r=Qe(),r!==null?(l=Qe(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Rc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){try{g=new Nt(g.uri,g.display_name,g.params)}catch{g=-1}}()),e===null&&(t=u),e}function Ic(){var e,r,l,i,u,h;if(u=t,e=Bi(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Wr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Wr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Bi(){var e,r,l,i,u,h;return i=t,u=t,e=We(),e!==null?(h=t,s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?(l=We(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g.call_id=s.substring(t,_)}(i)),e===null&&(t=i),e}function Wr(){var e;return e=Wi(),e===null&&(e=Vi(),e===null&&(e=ji(),e===null&&(e=ge()))),e}function Wi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6)==="to-tag"?(e="to-tag",t+=6):(e=null,a('"to-tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.to_tag=_}(i,e[2])),e===null&&(t=i),e}function Vi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,8)==="from-tag"?(e="from-tag",t+=8):(e=null,a('"from-tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.from_tag=_}(i,e[2])),e===null&&(t=i),e}function ji(){var e,r;return r=t,s.substr(t,10)==="early-only"?(e="early-only",t+=10):(e=null,a('"early-only"')),e!==null&&(e=function(l){g.early_only=!0}()),e===null&&(t=r),e}function bc(e){e.sort();for(var r=null,l=[],i=0;i<e.length;i++)e[i]!==r&&(l.push(e[i]),r=e[i]);return l}function wc(){for(var e=1,r=1,l=!1,i=0;i<Math.max(t,d);i++){var u=s.charAt(i);u===`
4
+ `?(l||e++,r=1,l=!1):u==="\r"||u==="\u2028"||u==="\u2029"?(e++,r=1,l=!0):(r++,l=!1)}return{line:e,column:r}}var Yi=Ze(),Nt=Ps(),g={},yc=c[o]();if(yc===null||t!==s.length){var Vr=Math.max(t,d),Nc=Vr<s.length?s.charAt(Vr):null,Ki=wc();return new this.SyntaxError(bc(p),Nc,Vr,Ki.line,Ki.column),-1}return g},toSource:function(){return this._source}};return n.SyntaxError=function(s,o,c,t,d){function p(a,T){var m,S;switch(a.length){case 0:m="end of input";break;case 1:m=a[0];break;default:m=a.slice(0,a.length-1).join(", ")+" or "+a[a.length-1]}return S=T?f(T):"end of input","Expected "+m+" but "+S+" found."}this.name="SyntaxError",this.expected=s,this.found=o,this.message=p(s,o),this.offset=c,this.line=t,this.column=d},n.SyntaxError.prototype=Error.prototype,n}()),Ms}var Ls,Zr;function Ze(){if(Zr)return Ls;Zr=1;const f=oe,n=Ce(),s=$e();return Ls=class Xi{static parse(c){if(c=s.parse(c,"SIP_URI"),c!==-1)return c}constructor(c,t,d,p,a={},T={}){if(!d)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=c||f.SIP,this._user=t,this._host=d,this._port=p;for(const m in a)Object.prototype.hasOwnProperty.call(a,m)&&this.setParam(m,a[m]);for(const m in T)Object.prototype.hasOwnProperty.call(T,m)&&this.setHeader(m,T[m])}get scheme(){return this._scheme}set scheme(c){this._scheme=c.toLowerCase()}get user(){return this._user}set user(c){this._user=c}get host(){return this._host}set host(c){this._host=c.toLowerCase()}get port(){return this._port}set port(c){this._port=c===0?c:parseInt(c,10)||null}setParam(c,t){c&&(this._parameters[c.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(c){if(c)return this._parameters[c.toLowerCase()]}hasParam(c){if(c)return this._parameters.hasOwnProperty(c.toLowerCase())&&!0||!1}deleteParam(c){if(c=c.toLowerCase(),this._parameters.hasOwnProperty(c)){const t=this._parameters[c];return delete this._parameters[c],t}}clearParams(){this._parameters={}}setHeader(c,t){this._headers[n.headerize(c)]=Array.isArray(t)?t:[t]}getHeader(c){if(c)return this._headers[n.headerize(c)]}hasHeader(c){if(c)return this._headers.hasOwnProperty(n.headerize(c))&&!0||!1}deleteHeader(c){if(c=n.headerize(c),this._headers.hasOwnProperty(c)){const t=this._headers[c];return delete this._headers[c],t}}clearHeaders(){this._headers={}}clone(){return new Xi(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const c=[];let t=`${this._scheme}:`;this._user&&(t+=`${n.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const d in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,d)&&(t+=`;${d}`,this._parameters[d]!==null&&(t+=`=${this._parameters[d]}`));for(const d in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,d))for(const p of this._headers[d])c.push(`${d}=${p}`);return c.length>0&&(t+=`?${c.join("&")}`),t}toAor(c){let t=`${this._scheme}:`;return this._user&&(t+=`${n.escapeUser(this._user)}@`),t+=this._host,c&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},Ls}var en;function Ce(){if(en)return fe;en=1;const f=oe,n=Ze(),s=$e();fe.str_utf8_length=d=>unescape(encodeURIComponent(d)).length;const o=fe.isFunction=d=>d!==void 0?Object.prototype.toString.call(d)==="[object Function]":!1;fe.isString=d=>d!==void 0?Object.prototype.toString.call(d)==="[object String]":!1,fe.isDecimal=d=>!isNaN(d)&&parseFloat(d)===parseInt(d,10),fe.isEmpty=d=>d===null||d===""||d===void 0||Array.isArray(d)&&d.length===0||typeof d=="number"&&isNaN(d),fe.hasMethods=function(d,...p){for(const a of p)if(o(d[a]))return!1;return!0};const c=fe.createRandomToken=(d,p=32)=>{let a,T,m="";for(a=0;a<d;a++)T=Math.random()*p|0,m+=T.toString(p);return m};fe.newTag=()=>c(10),fe.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const a=Math.random()*16|0;return(p==="x"?a:a&3|8).toString(16)}),fe.hostType=d=>{if(d){if(d=s.parse(d,"host"),d!==-1)return d.host_type}else return};const t=fe.escapeUser=d=>encodeURIComponent(decodeURIComponent(d)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/");return fe.normalizeTarget=(d,p)=>{if(d){if(d instanceof n)return d;if(typeof d=="string"){const a=d.split("@");let T,m;switch(a.length){case 1:{if(!p)return;T=d,m=p;break}case 2:{T=a[0],m=a[1];break}default:T=a.slice(0,a.length-1).join("@"),m=a[a.length-1]}T=T.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(T)&&(T=T.replace(/[-.()]/g,"")),d=`${f.SIP}:${t(T)}@${m}`;let S;return(S=n.parse(d))?S:void 0}else return}else return},fe.headerize=d=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},a=d.toLowerCase().replace(/_/g,"-").split("-");let T="";const m=a.length;let S;for(S=0;S<m;S++)S!==0&&(T+="-"),T+=a[S].charAt(0).toUpperCase()+a[S].substring(1);return p[T]&&(T=p[T]),T},fe.sipErrorCause=d=>{for(const p in f.SIP_ERROR_CAUSES)if(f.SIP_ERROR_CAUSES[p].indexOf(d)!==-1)return f.causes[p];return f.causes.SIP_FAILURE_CODE},fe.getRandomTestNetIP=()=>{function d(p,a){return Math.floor(Math.random()*(a-p+1)+p)}return`192.0.2.${d(1,254)}`},fe.calculateMD5=d=>{function p(W,G){return W<<G|W>>>32-G}function a(W,G){const V=W&2147483648,K=G&2147483648,ue=W&1073741824,ce=G&1073741824,te=(W&1073741823)+(G&1073741823);return ue&ce?te^2147483648^V^K:ue|ce?te&1073741824?te^3221225472^V^K:te^1073741824^V^K:te^V^K}function T(W,G,V){return W&G|~W&V}function m(W,G,V){return W&V|G&~V}function S(W,G,V){return W^G^V}function O(W,G,V){return G^(W|~V)}function H(W,G,V,K,ue,ce,te){return W=a(W,a(a(T(G,V,K),ue),te)),a(p(W,ce),G)}function B(W,G,V,K,ue,ce,te){return W=a(W,a(a(m(G,V,K),ue),te)),a(p(W,ce),G)}function k(W,G,V,K,ue,ce,te){return W=a(W,a(a(S(G,V,K),ue),te)),a(p(W,ce),G)}function U(W,G,V,K,ue,ce,te){return W=a(W,a(a(O(G,V,K),ue),te)),a(p(W,ce),G)}function de(W){let G;const V=W.length,K=V+8,ce=((K-K%64)/64+1)*16,te=new Array(ce-1);let Je=0,Oe=0;for(;Oe<V;)G=(Oe-Oe%4)/4,Je=Oe%4*8,te[G]=te[G]|W.charCodeAt(Oe)<<Je,Oe++;return G=(Oe-Oe%4)/4,Je=Oe%4*8,te[G]=te[G]|128<<Je,te[ce-2]=V<<3,te[ce-1]=V>>>29,te}function ne(W){let G="",V="",K,ue;for(ue=0;ue<=3;ue++)K=W>>>ue*8&255,V=`0${K.toString(16)}`,G=G+V.substr(V.length-2,2);return G}function tt(W){let G="";for(let V=0;V<W.length;V++){const K=W.charCodeAt(V);K<128?G+=String.fromCharCode(K):K>127&&K<2048?(G+=String.fromCharCode(K>>6|192),G+=String.fromCharCode(K&63|128)):(G+=String.fromCharCode(K>>12|224),G+=String.fromCharCode(K>>6&63|128),G+=String.fromCharCode(K&63|128))}return G}let y=[],$,ae,_e,X,ft,N,I,b,w;const wt=7,q=12,ze=17,yt=22,We=5,ht=9,Xe=14,z=20,dt=4,_t=11,st=16,rt=23,Q=6,j=10,pt=15,nt=21;for(d=tt(d),y=de(d),N=1732584193,I=4023233417,b=2562383102,w=271733878,$=0;$<y.length;$+=16)ae=N,_e=I,X=b,ft=w,N=H(N,I,b,w,y[$+0],wt,3614090360),w=H(w,N,I,b,y[$+1],q,3905402710),b=H(b,w,N,I,y[$+2],ze,606105819),I=H(I,b,w,N,y[$+3],yt,3250441966),N=H(N,I,b,w,y[$+4],wt,4118548399),w=H(w,N,I,b,y[$+5],q,1200080426),b=H(b,w,N,I,y[$+6],ze,2821735955),I=H(I,b,w,N,y[$+7],yt,4249261313),N=H(N,I,b,w,y[$+8],wt,1770035416),w=H(w,N,I,b,y[$+9],q,2336552879),b=H(b,w,N,I,y[$+10],ze,4294925233),I=H(I,b,w,N,y[$+11],yt,2304563134),N=H(N,I,b,w,y[$+12],wt,1804603682),w=H(w,N,I,b,y[$+13],q,4254626195),b=H(b,w,N,I,y[$+14],ze,2792965006),I=H(I,b,w,N,y[$+15],yt,1236535329),N=B(N,I,b,w,y[$+1],We,4129170786),w=B(w,N,I,b,y[$+6],ht,3225465664),b=B(b,w,N,I,y[$+11],Xe,643717713),I=B(I,b,w,N,y[$+0],z,3921069994),N=B(N,I,b,w,y[$+5],We,3593408605),w=B(w,N,I,b,y[$+10],ht,38016083),b=B(b,w,N,I,y[$+15],Xe,3634488961),I=B(I,b,w,N,y[$+4],z,3889429448),N=B(N,I,b,w,y[$+9],We,568446438),w=B(w,N,I,b,y[$+14],ht,3275163606),b=B(b,w,N,I,y[$+3],Xe,4107603335),I=B(I,b,w,N,y[$+8],z,1163531501),N=B(N,I,b,w,y[$+13],We,2850285829),w=B(w,N,I,b,y[$+2],ht,4243563512),b=B(b,w,N,I,y[$+7],Xe,1735328473),I=B(I,b,w,N,y[$+12],z,2368359562),N=k(N,I,b,w,y[$+5],dt,4294588738),w=k(w,N,I,b,y[$+8],_t,2272392833),b=k(b,w,N,I,y[$+11],st,1839030562),I=k(I,b,w,N,y[$+14],rt,4259657740),N=k(N,I,b,w,y[$+1],dt,2763975236),w=k(w,N,I,b,y[$+4],_t,1272893353),b=k(b,w,N,I,y[$+7],st,4139469664),I=k(I,b,w,N,y[$+10],rt,3200236656),N=k(N,I,b,w,y[$+13],dt,681279174),w=k(w,N,I,b,y[$+0],_t,3936430074),b=k(b,w,N,I,y[$+3],st,3572445317),I=k(I,b,w,N,y[$+6],rt,76029189),N=k(N,I,b,w,y[$+9],dt,3654602809),w=k(w,N,I,b,y[$+12],_t,3873151461),b=k(b,w,N,I,y[$+15],st,530742520),I=k(I,b,w,N,y[$+2],rt,3299628645),N=U(N,I,b,w,y[$+0],Q,4096336452),w=U(w,N,I,b,y[$+7],j,1126891415),b=U(b,w,N,I,y[$+14],pt,2878612391),I=U(I,b,w,N,y[$+5],nt,4237533241),N=U(N,I,b,w,y[$+12],Q,1700485571),w=U(w,N,I,b,y[$+3],j,2399980690),b=U(b,w,N,I,y[$+10],pt,4293915773),I=U(I,b,w,N,y[$+1],nt,2240044497),N=U(N,I,b,w,y[$+8],Q,1873313359),w=U(w,N,I,b,y[$+15],j,4264355552),b=U(b,w,N,I,y[$+6],pt,2734768916),I=U(I,b,w,N,y[$+13],nt,1309151649),N=U(N,I,b,w,y[$+4],Q,4149444226),w=U(w,N,I,b,y[$+11],j,3174756917),b=U(b,w,N,I,y[$+2],pt,718787259),I=U(I,b,w,N,y[$+9],nt,3951481745),N=a(N,ae),I=a(I,_e),b=a(b,X),w=a(w,ft);return(ne(N)+ne(I)+ne(b)+ne(w)).toLowerCase()},fe.closeMediaStream=d=>{if(d)try{let p;if(d.getTracks){p=d.getTracks();for(const a of p)a.stop()}else{p=d.getAudioTracks();for(const a of p)a.stop();p=d.getVideoTracks();for(const a of p)a.stop()}}catch{(typeof d.stop=="function"||typeof d.stop=="object")&&d.stop()}},fe.cloneArray=d=>d&&d.slice()||[],fe.cloneObject=(d,p={})=>d&&Object.assign({},d)||p,fe}var Hs={exports:{}},Et=typeof Reflect=="object"?Reflect:null,tn=Et&&typeof Et.apply=="function"?Et.apply:function(n,s,o){return Function.prototype.apply.call(n,s,o)},ss;Et&&typeof Et.ownKeys=="function"?ss=Et.ownKeys:Object.getOwnPropertySymbols?ss=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:ss=function(n){return Object.getOwnPropertyNames(n)};function sa(f){console&&console.warn&&console.warn(f)}var sn=Number.isNaN||function(n){return n!==n};function J(){J.init.call(this)}Hs.exports=J,Hs.exports.once=ia,J.EventEmitter=J,J.prototype._events=void 0,J.prototype._eventsCount=0,J.prototype._maxListeners=void 0;var rn=10;function rs(f){if(typeof f!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof f)}Object.defineProperty(J,"defaultMaxListeners",{enumerable:!0,get:function(){return rn},set:function(f){if(typeof f!="number"||f<0||sn(f))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+f+".");rn=f}}),J.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},J.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||sn(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function nn(f){return f._maxListeners===void 0?J.defaultMaxListeners:f._maxListeners}J.prototype.getMaxListeners=function(){return nn(this)},J.prototype.emit=function(n){for(var s=[],o=1;o<arguments.length;o++)s.push(arguments[o]);var c=n==="error",t=this._events;if(t!==void 0)c=c&&t.error===void 0;else if(!c)return!1;if(c){var d;if(s.length>0&&(d=s[0]),d instanceof Error)throw d;var p=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw p.context=d,p}var a=t[n];if(a===void 0)return!1;if(typeof a=="function")tn(a,this,s);else for(var T=a.length,m=cn(a,T),o=0;o<T;++o)tn(m[o],this,s);return!0};function ln(f,n,s,o){var c,t,d;if(rs(s),t=f._events,t===void 0?(t=f._events=Object.create(null),f._eventsCount=0):(t.newListener!==void 0&&(f.emit("newListener",n,s.listener?s.listener:s),t=f._events),d=t[n]),d===void 0)d=t[n]=s,++f._eventsCount;else if(typeof d=="function"?d=t[n]=o?[s,d]:[d,s]:o?d.unshift(s):d.push(s),c=nn(f),c>0&&d.length>c&&!d.warned){d.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+d.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=f,p.type=n,p.count=d.length,sa(p)}return f}J.prototype.addListener=function(n,s){return ln(this,n,s,!1)},J.prototype.on=J.prototype.addListener,J.prototype.prependListener=function(n,s){return ln(this,n,s,!0)};function ra(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function an(f,n,s){var o={fired:!1,wrapFn:void 0,target:f,type:n,listener:s},c=ra.bind(o);return c.listener=s,o.wrapFn=c,c}J.prototype.once=function(n,s){return rs(s),this.on(n,an(this,n,s)),this},J.prototype.prependOnceListener=function(n,s){return rs(s),this.prependListener(n,an(this,n,s)),this},J.prototype.removeListener=function(n,s){var o,c,t,d,p;if(rs(s),c=this._events,c===void 0)return this;if(o=c[n],o===void 0)return this;if(o===s||o.listener===s)--this._eventsCount===0?this._events=Object.create(null):(delete c[n],c.removeListener&&this.emit("removeListener",n,o.listener||s));else if(typeof o!="function"){for(t=-1,d=o.length-1;d>=0;d--)if(o[d]===s||o[d].listener===s){p=o[d].listener,t=d;break}if(t<0)return this;t===0?o.shift():na(o,t),o.length===1&&(c[n]=o[0]),c.removeListener!==void 0&&this.emit("removeListener",n,p||s)}return this},J.prototype.off=J.prototype.removeListener,J.prototype.removeAllListeners=function(n){var s,o,c;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[n]),this;if(arguments.length===0){var t=Object.keys(o),d;for(c=0;c<t.length;++c)d=t[c],d!=="removeListener"&&this.removeAllListeners(d);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(s=o[n],typeof s=="function")this.removeListener(n,s);else if(s!==void 0)for(c=s.length-1;c>=0;c--)this.removeListener(n,s[c]);return this};function on(f,n,s){var o=f._events;if(o===void 0)return[];var c=o[n];return c===void 0?[]:typeof c=="function"?s?[c.listener||c]:[c]:s?la(c):cn(c,c.length)}J.prototype.listeners=function(n){return on(this,n,!0)},J.prototype.rawListeners=function(n){return on(this,n,!1)},J.listenerCount=function(f,n){return typeof f.listenerCount=="function"?f.listenerCount(n):un.call(f,n)},J.prototype.listenerCount=un;function un(f){var n=this._events;if(n!==void 0){var s=n[f];if(typeof s=="function")return 1;if(s!==void 0)return s.length}return 0}J.prototype.eventNames=function(){return this._eventsCount>0?ss(this._events):[]};function cn(f,n){for(var s=new Array(n),o=0;o<n;++o)s[o]=f[o];return s}function na(f,n){for(;n+1<f.length;n++)f[n]=f[n+1];f.pop()}function la(f){for(var n=new Array(f.length),s=0;s<n.length;++s)n[s]=f[s].listener||f[s];return n}function ia(f,n){return new Promise(function(s,o){function c(d){f.removeListener(n,t),o(d)}function t(){typeof f.removeListener=="function"&&f.removeListener("error",c),s([].slice.call(arguments))}fn(f,n,t,{once:!0}),n!=="error"&&aa(f,c,{once:!0})})}function aa(f,n,s){typeof f.on=="function"&&fn(f,"error",n,s)}function fn(f,n,s,o){if(typeof f.on=="function")o.once?f.once(n,s):f.on(n,s);else if(typeof f.addEventListener=="function")f.addEventListener(n,function c(t){o.once&&f.removeEventListener(n,c),s(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof f)}var Fe=Hs.exports,Fs={exports:{}},ks,hn;function oa(){if(hn)return ks;hn=1;var f=1e3,n=f*60,s=n*60,o=s*24,c=o*7,t=o*365.25;ks=function(m,S){S=S||{};var O=typeof m;if(O==="string"&&m.length>0)return d(m);if(O==="number"&&isFinite(m))return S.long?a(m):p(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function d(m){if(m=String(m),!(m.length>100)){var S=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(S){var O=parseFloat(S[1]),H=(S[2]||"ms").toLowerCase();switch(H){case"years":case"year":case"yrs":case"yr":case"y":return O*t;case"weeks":case"week":case"w":return O*c;case"days":case"day":case"d":return O*o;case"hours":case"hour":case"hrs":case"hr":case"h":return O*s;case"minutes":case"minute":case"mins":case"min":case"m":return O*n;case"seconds":case"second":case"secs":case"sec":case"s":return O*f;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return O;default:return}}}}function p(m){var S=Math.abs(m);return S>=o?Math.round(m/o)+"d":S>=s?Math.round(m/s)+"h":S>=n?Math.round(m/n)+"m":S>=f?Math.round(m/f)+"s":m+"ms"}function a(m){var S=Math.abs(m);return S>=o?T(m,S,o,"day"):S>=s?T(m,S,s,"hour"):S>=n?T(m,S,n,"minute"):S>=f?T(m,S,f,"second"):m+" ms"}function T(m,S,O,H){var B=S>=O*1.5;return Math.round(m/O)+" "+H+(B?"s":"")}return ks}function ua(f){s.debug=s,s.default=s,s.coerce=a,s.disable=d,s.enable=c,s.enabled=p,s.humanize=oa(),s.destroy=T,Object.keys(f).forEach(m=>{s[m]=f[m]}),s.names=[],s.skips=[],s.formatters={};function n(m){let S=0;for(let O=0;O<m.length;O++)S=(S<<5)-S+m.charCodeAt(O),S|=0;return s.colors[Math.abs(S)%s.colors.length]}s.selectColor=n;function s(m){let S,O=null,H,B;function k(...U){if(!k.enabled)return;const de=k,ne=Number(new Date),tt=ne-(S||ne);de.diff=tt,de.prev=S,de.curr=ne,S=ne,U[0]=s.coerce(U[0]),typeof U[0]!="string"&&U.unshift("%O");let y=0;U[0]=U[0].replace(/%([a-zA-Z%])/g,(ae,_e)=>{if(ae==="%%")return"%";y++;const X=s.formatters[_e];if(typeof X=="function"){const ft=U[y];ae=X.call(de,ft),U.splice(y,1),y--}return ae}),s.formatArgs.call(de,U),(de.log||s.log).apply(de,U)}return k.namespace=m,k.useColors=s.useColors(),k.color=s.selectColor(m),k.extend=o,k.destroy=s.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>O!==null?O:(H!==s.namespaces&&(H=s.namespaces,B=s.enabled(m)),B),set:U=>{O=U}}),typeof s.init=="function"&&s.init(k),k}function o(m,S){const O=s(this.namespace+(typeof S>"u"?":":S)+m);return O.log=this.log,O}function c(m){s.save(m),s.namespaces=m,s.names=[],s.skips=[];const S=(typeof m=="string"?m:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const O of S)O[0]==="-"?s.skips.push(O.slice(1)):s.names.push(O)}function t(m,S){let O=0,H=0,B=-1,k=0;for(;O<m.length;)if(H<S.length&&(S[H]===m[O]||S[H]==="*"))S[H]==="*"?(B=H,k=O,H++):(O++,H++);else if(B!==-1)H=B+1,k++,O=k;else return!1;for(;H<S.length&&S[H]==="*";)H++;return H===S.length}function d(){const m=[...s.names,...s.skips.map(S=>"-"+S)].join(",");return s.enable(""),m}function p(m){for(const S of s.skips)if(t(m,S))return!1;for(const S of s.names)if(t(m,S))return!0;return!1}function a(m){return m instanceof Error?m.stack||m.message:m}function T(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return s.enable(s.load()),s}var ca=ua;(function(f,n){n.formatArgs=o,n.save=c,n.load=t,n.useColors=s,n.storage=d(),n.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function s(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+f.exports.humanize(this.diff),!this.useColors)return;const T="color: "+this.color;a.splice(1,0,T,"color: inherit");let m=0,S=0;a[0].replace(/%[a-zA-Z%]/g,O=>{O!=="%%"&&(m++,O==="%c"&&(S=m))}),a.splice(S,0,T)}n.log=console.debug||console.log||(()=>{});function c(a){try{a?n.storage.setItem("debug",a):n.storage.removeItem("debug")}catch{}}function t(){let a;try{a=n.storage.getItem("debug")||n.storage.getItem("DEBUG")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function d(){try{return localStorage}catch{}}f.exports=ca(n);const{formatters:p}=f.exports;p.j=function(a){try{return JSON.stringify(a)}catch(T){return"[UnexpectedJSONParseError]: "+T.message}}})(Fs,Fs.exports);var qs=Fs.exports;const St=qs,Ct="JsSIP";var pe=class{constructor(n){n?(this._debug=St.default(`${Ct}:${n}`),this._warn=St.default(`${Ct}:WARN:${n}`),this._error=St.default(`${Ct}:ERROR:${n}`)):(this._debug=St.default(Ct),this._warn=St.default(`${Ct}:WARN`),this._error=St.default(`${Ct}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Pe={},dn={},_n={exports:{}},pn=_n.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(f){return f.encoding?"rtpmap:%d %s/%s/%s":f.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(f){return f.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(f){return f.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(f){return"extmap:%d"+(f.direction?"/%s":"%v")+(f["encrypt-uri"]?" %s":"%v")+" %s"+(f.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(f){return f.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(f){var n="candidate:%s %d %s %d %s %d typ %s";return n+=f.raddr!=null?" raddr %s rport %d":"%v%v",n+=f.tcptype!=null?" tcptype %s":"%v",f.generation!=null&&(n+=" generation %d"),n+=f["network-id"]!=null?" network-id %d":"%v",n+=f["network-cost"]!=null?" network-cost %d":"%v",n}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(f){var n="ssrc:%d";return f.attribute!=null&&(n+=" %s",f.value!=null&&(n+=":%s")),n}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(f){return f.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(f){return f.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(f){return"imageattr:%s %s %s"+(f.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(f){return"simulcast:%s %s"+(f.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(f){return"ts-refclk:%s"+(f.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(f){var n="mediaclk:";return n+=f.id!=null?"id=%s %s":"%v%s",n+=f.mediaClockValue!=null?"=%s":"",n+=f.rateNumerator!=null?" rate=%s":"",n+=f.rateDenominator!=null?"/%s":"",n}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(pn).forEach(function(f){var n=pn[f];n.forEach(function(s){s.reg||(s.reg=/(.*)/),s.format||(s.format="%s")})});var Gs=_n.exports;(function(f){var n=function(p){return String(Number(p))===p?Number(p):p},s=function(p,a,T,m){if(m&&!T)a[m]=n(p[1]);else for(var S=0;S<T.length;S+=1)p[S+1]!=null&&(a[T[S]]=n(p[S+1]))},o=function(p,a,T){var m=p.name&&p.names;p.push&&!a[p.push]?a[p.push]=[]:m&&!a[p.name]&&(a[p.name]={});var S=p.push?{}:m?a[p.name]:a;s(T.match(p.reg),S,p.names,p.name),p.push&&a[p.push].push(S)},c=Gs,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);f.parse=function(p){var a={},T=[],m=a;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(S){var O=S[0],H=S.slice(2);O==="m"&&(T.push({rtp:[],fmtp:[]}),m=T[T.length-1]);for(var B=0;B<(c[O]||[]).length;B+=1){var k=c[O][B];if(k.reg.test(H))return o(k,m,H)}}),a.media=T,a};var d=function(p,a){var T=a.split(/=(.+)/,2);return T.length===2?p[T[0]]=n(T[1]):T.length===1&&a.length>1&&(p[T[0]]=void 0),p};f.parseParams=function(p){return p.split(/;\s?/).reduce(d,{})},f.parseFmtpConfig=f.parseParams,f.parsePayloads=function(p){return p.toString().split(" ").map(Number)},f.parseRemoteCandidates=function(p){for(var a=[],T=p.split(" ").map(n),m=0;m<T.length;m+=3)a.push({component:T[m],ip:T[m+1],port:T[m+2]});return a},f.parseImageAttributes=function(p){return p.split(" ").map(function(a){return a.substring(1,a.length-1).split(",").reduce(d,{})})},f.parseSimulcastStreamList=function(p){return p.split(";").map(function(a){return a.split(",").map(function(T){var m,S=!1;return T[0]!=="~"?m=n(T):(m=n(T.substring(1,T.length)),S=!0),{scid:m,paused:S}})})}})(dn);var Bs=Gs,fa=/%[sdv%]/g,ha=function(f){var n=1,s=arguments,o=s.length;return f.replace(fa,function(c){if(n>=o)return c;var t=s[n];switch(n+=1,c){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},xt=function(f,n,s){var o=n.format instanceof Function?n.format(n.push?s:s[n.name]):n.format,c=[f+"="+o];if(n.names)for(var t=0;t<n.names.length;t+=1){var d=n.names[t];n.name?c.push(s[n.name][d]):c.push(s[n.names[t]])}else c.push(s[n.name]);return ha.apply(null,c)},da=["v","o","s","i","u","e","p","c","b","t","r","z","a"],_a=["i","c","b","a"],pa=function(f,n){n=n||{},f.version==null&&(f.version=0),f.name==null&&(f.name=" "),f.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var s=n.outerOrder||da,o=n.innerOrder||_a,c=[];return s.forEach(function(t){Bs[t].forEach(function(d){d.name in f&&f[d.name]!=null?c.push(xt(t,d,f)):d.push in f&&f[d.push]!=null&&f[d.push].forEach(function(p){c.push(xt(t,d,p))})})}),f.media.forEach(function(t){c.push(xt("m",Bs.m[0],t)),o.forEach(function(d){Bs[d].forEach(function(p){p.name in t&&t[p.name]!=null?c.push(xt(d,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(a){c.push(xt(d,p,a))})})})}),c.join(`\r
5
+ `)+`\r
6
+ `},lt=dn,ma=pa,ga=Gs;Pe.grammar=ga,Pe.write=ma,Pe.parse=lt.parse,Pe.parseParams=lt.parseParams,Pe.parseFmtpConfig=lt.parseFmtpConfig,Pe.parsePayloads=lt.parsePayloads,Pe.parseRemoteCandidates=lt.parseRemoteCandidates,Pe.parseImageAttributes=lt.parseImageAttributes,Pe.parseSimulcastStreamList=lt.parseSimulcastStreamList;const mn=Pe,Ta=pe,Ae=oe,me=Ce(),gn=Ps(),Ea=$e(),Ws=new Ta("SIPMessage");class ns{constructor(n,s,o,c,t,d){if(!n||!s||!o)return null;c=c||{},this.ua=o,this.headers={},this.method=n,this.ruri=s,this.body=d,this.extraHeaders=me.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),c.route_set?this.setHeader("route",c.route_set):o.configuration.use_preloaded_route&&this.setHeader("route",`<${o.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",Ae.MAX_FORWARDS);const p=c.to_uri||s,a=c.to_tag?{tag:c.to_tag}:null,T=typeof c.to_display_name<"u"?c.to_display_name:null;this.to=new gn(p,T,a),this.setHeader("to",this.to.toString());const m=c.from_uri||o.configuration.uri,S={tag:c.from_tag||me.newTag()};let O;typeof c.from_display_name<"u"?O=c.from_display_name:o.configuration.display_name?O=o.configuration.display_name:O=null,this.from=new gn(m,O,S),this.setHeader("from",this.from.toString());const H=c.call_id||o.configuration.jssip_id+me.createRandomToken(15);this.call_id=H,this.setHeader("call-id",H);const B=c.cseq||Math.floor(Math.random()*1e4);this.cseq=B,this.setHeader("cseq",`${B} ${n}`)}setHeader(n,s){const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(let c=0;c<this.extraHeaders.length;c++)o.test(this.extraHeaders[c])&&this.extraHeaders.splice(c,1);this.headers[me.headerize(n)]=Array.isArray(s)?s:[s]}getHeader(n){const s=this.headers[me.headerize(n)];if(s){if(s[0])return s[0]}else{const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(const c of this.extraHeaders)if(o.test(c))return c.substring(c.indexOf(":")+1).trim()}}getHeaders(n){const s=this.headers[me.headerize(n)],o=[];if(s){for(const c of s)o.push(c);return o}else{const c=new RegExp(`^\\s*${n}\\s*:`,"i");for(const t of this.extraHeaders)c.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(n){if(this.headers[me.headerize(n)])return!0;{const s=new RegExp(`^\\s*${n}\\s*:`,"i");for(const o of this.extraHeaders)if(s.test(o))return!0}return!1}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=mn.parse(this.body||""),this.sdp)}toString(){let n=`${this.method} ${this.ruri} SIP/2.0\r
7
+ `;for(const c in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,c))for(const t of this.headers[c])n+=`${c}: ${t}\r
8
+ `;for(const c of this.extraHeaders)n+=`${c.trim()}\r
9
+ `;const s=[];switch(this.method){case Ae.REGISTER:{s.push("path","gruu");break}case Ae.INVITE:{this.ua.configuration.session_timers&&s.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&s.push("gruu"),s.push("ice","replaces");break}case Ae.UPDATE:{this.ua.configuration.session_timers&&s.push("timer"),s.push("ice");break}}s.push("outbound");const o=this.ua.configuration.user_agent||Ae.USER_AGENT;if(n+=`Allow: ${Ae.ALLOWED_METHODS}\r
10
+ `,n+=`Supported: ${s}\r
11
+ `,n+=`User-Agent: ${o}\r
12
+ `,this.body){const c=me.str_utf8_length(this.body);n+=`Content-Length: ${c}\r
156
13
  \r
157
- `,e+=this.body):this.body.body&&this.body.contentType?(e+="Content-Type: "+this.body.contentType+`\r
158
- `,e+="Content-Length: "+qr(this.body.body)+`\r
14
+ `,n+=this.body}else n+=`Content-Length: 0\r
159
15
  \r
160
- `,e+=this.body.body):e+=`Content-Length: 0\r
16
+ `;return n}clone(){const n=new ns(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(s){n.headers[s]=this.headers[s].slice()},this),n.body=this.body,n.extraHeaders=me.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n}}class Vs extends ns{constructor(n,s,o,c,t){super(Ae.INVITE,n,s,o,c,t),this.transaction=null}cancel(n){this.transaction.cancel(n)}clone(){const n=new Vs(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(s){n.headers[s]=this.headers[s].slice()},this),n.body=this.body,n.extraHeaders=me.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n.transaction=this.transaction,n}}class Tn{constructor(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}addHeader(n,s){const o={raw:s};n=me.headerize(n),this.headers[n]?this.headers[n].push(o):this.headers[n]=[o]}getHeader(n){const s=this.headers[me.headerize(n)];if(s){if(s[0])return s[0].raw}else return}getHeaders(n){const s=this.headers[me.headerize(n)],o=[];if(!s)return[];for(const c of s)o.push(c.raw);return o}hasHeader(n){return!!this.headers[me.headerize(n)]}parseHeader(n,s=0){if(n=me.headerize(n),this.headers[n]){if(s>=this.headers[n].length){Ws.debug(`not so many "${n}" headers present`);return}}else{Ws.debug(`header "${n}" not present`);return}const o=this.headers[n][s],c=o.raw;if(o.parsed)return o.parsed;const t=Ea.parse(c,n.replace(/-/g,"_"));if(t===-1){this.headers[n].splice(s,1),Ws.debug(`error parsing "${n}" header field with value "${c}"`);return}else return o.parsed=t,t}s(n,s){return this.parseHeader(n,s)}setHeader(n,s){const o={raw:s};this.headers[me.headerize(n)]=[o]}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=mn.parse(this.body||""),this.sdp)}toString(){return this.data}}class Sa extends Tn{constructor(n){super(),this.ua=n,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(n,s,o,c,t,d){const p=[];let a=this.getHeader("To");if(n=n||null,s=s||null,!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(s&&typeof s!="string"&&!(s instanceof String))throw new TypeError(`Invalid reason_phrase: ${s}`);s=s||Ae.REASON_PHRASE[n]||"",o=me.cloneArray(o),this.ua.configuration.extra_headers&&(o=o.concat(this.ua.configuration.extra_headers));let T=`SIP/2.0 ${n} ${s}\r
17
+ `;if(this.method===Ae.INVITE&&n>100&&n<=200){const S=this.getHeaders("record-route");for(const O of S)T+=`Record-Route: ${O}\r
18
+ `}const m=this.getHeaders("via");for(const S of m)T+=`Via: ${S}\r
19
+ `;!this.to_tag&&n>100?a+=`;tag=${me.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(a+=`;tag=${this.to_tag}`),T+=`To: ${a}\r
20
+ `,T+=`From: ${this.getHeader("From")}\r
21
+ `,T+=`Call-ID: ${this.call_id}\r
22
+ `,T+=`CSeq: ${this.cseq} ${this.method}\r
23
+ `;for(const S of o)T+=`${S.trim()}\r
24
+ `;switch(this.method){case Ae.INVITE:{this.ua.configuration.session_timers&&p.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&p.push("gruu"),p.push("ice","replaces");break}case Ae.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),c&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===Ae.OPTIONS?(T+=`Allow: ${Ae.ALLOWED_METHODS}\r
25
+ `,T+=`Accept: ${Ae.ACCEPTED_BODY_TYPES}\r
26
+ `):n===405?T+=`Allow: ${Ae.ALLOWED_METHODS}\r
27
+ `:n===415&&(T+=`Accept: ${Ae.ACCEPTED_BODY_TYPES}\r
28
+ `),T+=`Supported: ${p}\r
29
+ `,c){const S=me.str_utf8_length(c);T+=`Content-Type: application/sdp\r
30
+ `,T+=`Content-Length: ${S}\r
161
31
  \r
162
- `:e+=`Content-Length: 0\r
32
+ `,T+=c}else T+=`Content-Length: 0\r
163
33
  \r
164
- `,e}}function Da(r){return r==="application/sdp"?"session":"render"}function ds(r){const e=typeof r=="string"?r:r.body,t=typeof r=="string"?"application/sdp":r.contentType;return{contentDisposition:Da(t),contentType:t,content:e}}function Aa(r){return r&&typeof r.content=="string"&&typeof r.contentType=="string"&&r.contentDisposition===void 0?!0:typeof r.contentDisposition=="string"}function Ur(r){let e,t,s;if(r instanceof yr&&r.body){const i=r.parseHeader("Content-Disposition");e=i?i.type:void 0,t=r.parseHeader("Content-Type"),s=r.body}if(r instanceof Gt&&r.body){const i=r.parseHeader("Content-Disposition");e=i?i.type:void 0,t=r.parseHeader("Content-Type"),s=r.body}if(r instanceof cr&&r.body)if(e=r.getHeader("Content-Disposition"),t=r.getHeader("Content-Type"),typeof r.body=="string"){if(!t)throw new Error("Header content type header does not equal body content type.");s=r.body}else{if(t&&t!==r.body.contentType)throw new Error("Header content type header does not equal body content type.");t=r.body.contentType,s=r.body.body}if(Aa(r)&&(e=r.contentDisposition,t=r.contentType,s=r.content),!!s){if(t&&!e&&(e=Da(t)),!e)throw new Error("Content disposition undefined.");if(!t)throw new Error("Content type undefined.");return{contentDisposition:e,contentType:t,content:s}}}var st;(function(r){r.Initial="Initial",r.Early="Early",r.AckWait="AckWait",r.Confirmed="Confirmed",r.Terminated="Terminated"})(st=st||(st={}));var Y;(function(r){r.Initial="Initial",r.HaveLocalOffer="HaveLocalOffer",r.HaveRemoteOffer="HaveRemoteOffer",r.Stable="Stable",r.Closed="Closed"})(Y=Y||(Y={}));const kt=500,z0=4e3,Sa=5e3,Oe={T1:kt,T2:z0,TIMER_B:64*kt,TIMER_D:0*kt,TIMER_F:64*kt,TIMER_H:64*kt,TIMER_I:0*Sa,TIMER_J:0*kt,TIMER_K:0*Sa,TIMER_L:64*kt,TIMER_M:64*kt,TIMER_N:64*kt,PROVISIONAL_RESPONSE_INTERVAL:6e4};class Vt extends ar{constructor(e){super(e||"Transaction state error.")}}var K;(function(r){r.ACK="ACK",r.BYE="BYE",r.CANCEL="CANCEL",r.INFO="INFO",r.INVITE="INVITE",r.MESSAGE="MESSAGE",r.NOTIFY="NOTIFY",r.OPTIONS="OPTIONS",r.REGISTER="REGISTER",r.UPDATE="UPDATE",r.SUBSCRIBE="SUBSCRIBE",r.PUBLISH="PUBLISH",r.REFER="REFER",r.PRACK="PRACK"})(K=K||(K={}));const zt=[K.ACK,K.BYE,K.CANCEL,K.INFO,K.INVITE,K.MESSAGE,K.NOTIFY,K.OPTIONS,K.PRACK,K.REFER,K.REGISTER,K.SUBSCRIBE];class Ta{constructor(e){this.incomingMessageRequest=e}get request(){return this.incomingMessageRequest.message}accept(e){return this.incomingMessageRequest.accept(e),Promise.resolve()}reject(e){return this.incomingMessageRequest.reject(e),Promise.resolve()}}class $i{constructor(e){this.incomingNotifyRequest=e}get request(){return this.incomingNotifyRequest.message}accept(e){return this.incomingNotifyRequest.accept(e),Promise.resolve()}reject(e){return this.incomingNotifyRequest.reject(e),Promise.resolve()}}class K0{constructor(e,t){this.incomingReferRequest=e,this.session=t}get referTo(){const e=this.incomingReferRequest.message.parseHeader("refer-to");if(!(e instanceof ze))throw new Error("Failed to parse Refer-To header.");return e}get referredBy(){return this.incomingReferRequest.message.getHeader("referred-by")}get replaces(){const e=this.referTo.uri.getHeader("replaces");return e instanceof Array?e[0]:e}get request(){return this.incomingReferRequest.message}accept(e={statusCode:202}){return this.incomingReferRequest.accept(e),Promise.resolve()}reject(e){return this.incomingReferRequest.reject(e),Promise.resolve()}makeInviter(e){if(this.inviter)return this.inviter;const t=this.referTo.uri.clone();t.clearHeaders(),e=e||{};const s=(e.extraHeaders||[]).slice(),i=this.replaces;i&&s.push("Replaces: "+decodeURIComponent(i));const n=this.referredBy;return n&&s.push("Referred-By: "+n),e.extraHeaders=s,this.inviter=this.session.userAgent._makeInviter(t,e),this.inviter._referred=this.session,this.session._referral=this.inviter,this.inviter}}var B;(function(r){r.Initial="Initial",r.Establishing="Establishing",r.Established="Established",r.Terminating="Terminating",r.Terminated="Terminated"})(B=B||(B={}));class Lr{constructor(e,t={}){this.pendingReinvite=!1,this.pendingReinviteAck=!1,this._state=B.Initial,this.delegate=t.delegate,this._stateEventEmitter=new jr,this._userAgent=e}dispose(){switch(this.logger.log(`Session ${this.id} in state ${this._state} is being disposed`),delete this.userAgent._sessions[this.id],this._sessionDescriptionHandler&&this._sessionDescriptionHandler.close(),this.state){case B.Initial:break;case B.Establishing:break;case B.Established:return new Promise(e=>{this._bye({onAccept:()=>e(),onRedirect:()=>e(),onReject:()=>e()})});case B.Terminating:break;case B.Terminated:break;default:throw new Error("Unknown state.")}return Promise.resolve()}get assertedIdentity(){return this._assertedIdentity}get dialog(){return this._dialog}get id(){return this._id}get replacee(){return this._replacee}get sessionDescriptionHandler(){return this._sessionDescriptionHandler}get sessionDescriptionHandlerFactory(){return this.userAgent.configuration.sessionDescriptionHandlerFactory}get sessionDescriptionHandlerModifiers(){return this._sessionDescriptionHandlerModifiers||[]}set sessionDescriptionHandlerModifiers(e){this._sessionDescriptionHandlerModifiers=e.slice()}get sessionDescriptionHandlerOptions(){return this._sessionDescriptionHandlerOptions||{}}set sessionDescriptionHandlerOptions(e){this._sessionDescriptionHandlerOptions=Object.assign({},e)}get sessionDescriptionHandlerModifiersReInvite(){return this._sessionDescriptionHandlerModifiersReInvite||[]}set sessionDescriptionHandlerModifiersReInvite(e){this._sessionDescriptionHandlerModifiersReInvite=e.slice()}get sessionDescriptionHandlerOptionsReInvite(){return this._sessionDescriptionHandlerOptionsReInvite||{}}set sessionDescriptionHandlerOptionsReInvite(e){this._sessionDescriptionHandlerOptionsReInvite=Object.assign({},e)}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get userAgent(){return this._userAgent}bye(e={}){let t="Session.bye() may only be called if established session.";switch(this.state){case B.Initial:typeof this.cancel=="function"?(t+=" However Inviter.invite() has not yet been called.",t+=" Perhaps you should have called Inviter.cancel()?"):typeof this.reject=="function"&&(t+=" However Invitation.accept() has not yet been called.",t+=" Perhaps you should have called Invitation.reject()?");break;case B.Establishing:typeof this.cancel=="function"?(t+=" However a dialog does not yet exist.",t+=" Perhaps you should have called Inviter.cancel()?"):typeof this.reject=="function"&&(t+=" However Invitation.accept() has not yet been called (or not yet resolved).",t+=" Perhaps you should have called Invitation.reject()?");break;case B.Established:{const s=e.requestDelegate,i=this.copyRequestOptions(e.requestOptions);return this._bye(s,i)}case B.Terminating:t+=" However this session is already terminating.",typeof this.cancel=="function"?t+=" Perhaps you have already called Inviter.cancel()?":typeof this.reject=="function"&&(t+=" Perhaps you have already called Session.bye()?");break;case B.Terminated:t+=" However this session is already terminated.";break;default:throw new Error("Unknown state")}return this.logger.error(t),Promise.reject(new Error(`Invalid session state ${this.state}`))}info(e={}){if(this.state!==B.Established)return this.logger.error("Session.info() may only be called if established session."),Promise.reject(new Error(`Invalid session state ${this.state}`));const t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._info(t,s)}invite(e={}){if(this.logger.log("Session.invite"),this.state!==B.Established)return Promise.reject(new Error(`Invalid session state ${this.state}`));if(this.pendingReinvite)return Promise.reject(new Ii("Reinvite in progress. Please wait until complete, then try again."));this.pendingReinvite=!0,e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiersReInvite=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptionsReInvite=e.sessionDescriptionHandlerOptions);const t={onAccept:n=>{const a=Ur(n.message);if(!a){this.logger.error("Received 2xx response to re-INVITE without a session description"),this.ackAndBye(n,400,"Missing session description"),this.stateTransition(B.Terminated),this.pendingReinvite=!1;return}if(e.withoutSdp){const o={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.setOfferAndGetAnswer(a,o).then(d=>{n.ack({body:d})}).catch(d=>{this.logger.error("Failed to handle offer in 2xx response to re-INVITE"),this.logger.error(d.message),this.state===B.Terminated?n.ack():(this.ackAndBye(n,488,"Bad Media Description"),this.stateTransition(B.Terminated))}).then(()=>{this.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(n)})}else{const o={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.setAnswer(a,o).then(()=>{n.ack()}).catch(d=>{this.logger.error("Failed to handle answer in 2xx response to re-INVITE"),this.logger.error(d.message),this.state!==B.Terminated?(this.ackAndBye(n,488,"Bad Media Description"),this.stateTransition(B.Terminated)):n.ack()}).then(()=>{this.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(n)})}},onProgress:n=>{},onRedirect:n=>{},onReject:n=>{this.logger.warn("Received a non-2xx response to re-INVITE"),this.pendingReinvite=!1,e.withoutSdp?e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(n):this.rollbackOffer().catch(a=>{if(this.logger.error("Failed to rollback offer on non-2xx response to re-INVITE"),this.logger.error(a.message),this.state!==B.Terminated){if(!this.dialog)throw new Error("Dialog undefined.");const o=[];o.push("Reason: "+this.getReasonHeaderValue(500,"Internal Server Error")),this.dialog.bye(void 0,{extraHeaders:o}),this.stateTransition(B.Terminated)}}).then(()=>{e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(n)})},onTrying:n=>{}},s=e.requestOptions||{};if(s.extraHeaders=(s.extraHeaders||[]).slice(),s.extraHeaders.push("Allow: "+zt.toString()),s.extraHeaders.push("Contact: "+this._contact),e.withoutSdp){if(!this.dialog)throw this.pendingReinvite=!1,new Error("Dialog undefined.");return Promise.resolve(this.dialog.invite(t,s))}const i={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};return this.getOffer(i).then(n=>{if(!this.dialog)throw this.pendingReinvite=!1,new Error("Dialog undefined.");return s.body=n,this.dialog.invite(t,s)}).catch(n=>{throw this.logger.error(n.message),this.logger.error("Failed to send re-INVITE"),this.pendingReinvite=!1,n})}message(e={}){if(this.state!==B.Established)return this.logger.error("Session.message() may only be called if established session."),Promise.reject(new Error(`Invalid session state ${this.state}`));const t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._message(t,s)}refer(e,t={}){if(this.state!==B.Established)return this.logger.error("Session.refer() may only be called if established session."),Promise.reject(new Error(`Invalid session state ${this.state}`));if(e instanceof Lr&&!e.dialog)return this.logger.error("Session.refer() may only be called with session which is established. You are perhaps attempting to attended transfer to a target for which there is not dialog yet established. Perhaps you are attempting a 'semi-attended' tansfer? Regardless, this is not supported. The recommended approached is to check to see if the target Session is in the Established state before calling refer(); if the state is not Established you may proceed by falling back using a URI as the target (blind transfer)."),Promise.reject(new Error(`Invalid session state ${this.state}`));const s=t.requestDelegate,i=this.copyRequestOptions(t.requestOptions);return i.extraHeaders=i.extraHeaders?i.extraHeaders.concat(this.referExtraHeaders(this.referToString(e))):this.referExtraHeaders(this.referToString(e)),this._refer(t.onNotify,s,i)}_bye(e,t){if(!this.dialog)return Promise.reject(new Error("Session dialog undefined."));const s=this.dialog;switch(s.sessionState){case st.Initial:throw new Error(`Invalid dialog state ${s.sessionState}`);case st.Early:throw new Error(`Invalid dialog state ${s.sessionState}`);case st.AckWait:return this.stateTransition(B.Terminating),new Promise(i=>{s.delegate={onAck:()=>{const n=s.bye(e,t);return this.stateTransition(B.Terminated),i(n),Promise.resolve()},onAckTimeout:()=>{const n=s.bye(e,t);this.stateTransition(B.Terminated),i(n)}}});case st.Confirmed:{const i=s.bye(e,t);return this.stateTransition(B.Terminated),Promise.resolve(i)}case st.Terminated:throw new Error(`Invalid dialog state ${s.sessionState}`);default:throw new Error("Unrecognized state.")}}_info(e,t){return this.dialog?Promise.resolve(this.dialog.info(e,t)):Promise.reject(new Error("Session dialog undefined."))}_message(e,t){return this.dialog?Promise.resolve(this.dialog.message(e,t)):Promise.reject(new Error("Session dialog undefined."))}_refer(e,t,s){return this.dialog?(this.onNotify=e,Promise.resolve(this.dialog.refer(t,s))):Promise.reject(new Error("Session dialog undefined."))}ackAndBye(e,t,s){e.ack();const i=[];t&&i.push("Reason: "+this.getReasonHeaderValue(t,s)),e.session.bye(void 0,{extraHeaders:i})}onAckRequest(e){if(this.logger.log("Session.onAckRequest"),this.state!==B.Established&&this.state!==B.Terminating)return this.logger.error(`ACK received while in state ${this.state}, dropping request`),Promise.resolve();const t=this.dialog;if(!t)throw new Error("Dialog undefined.");const s={sessionDescriptionHandlerOptions:this.pendingReinviteAck?this.sessionDescriptionHandlerOptionsReInvite:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.pendingReinviteAck?this._sessionDescriptionHandlerModifiersReInvite:this._sessionDescriptionHandlerModifiers};if(this.delegate&&this.delegate.onAck){const i=new q0(e);this.delegate.onAck(i)}switch(this.pendingReinviteAck=!1,t.signalingState){case Y.Initial:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);const i=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:i}),this.stateTransition(B.Terminated),Promise.resolve()}case Y.Stable:{const i=Ur(e.message);return i?i.contentDisposition==="render"?(this._renderbody=i.content,this._rendertype=i.contentType,Promise.resolve()):i.contentDisposition!=="session"?Promise.resolve():this.setAnswer(i,s).catch(n=>{this.logger.error(n.message);const a=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];t.bye(void 0,{extraHeaders:a}),this.stateTransition(B.Terminated)}):Promise.resolve()}case Y.HaveLocalOffer:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);const i=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:i}),this.stateTransition(B.Terminated),Promise.resolve()}case Y.HaveRemoteOffer:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);const i=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:i}),this.stateTransition(B.Terminated),Promise.resolve()}case Y.Closed:throw new Error(`Invalid signaling state ${t.signalingState}.`);default:throw new Error(`Invalid signaling state ${t.signalingState}.`)}}onByeRequest(e){if(this.logger.log("Session.onByeRequest"),this.state!==B.Established){this.logger.error(`BYE received while in state ${this.state}, dropping request`);return}if(this.delegate&&this.delegate.onBye){const t=new U0(e);this.delegate.onBye(t)}else e.accept();this.stateTransition(B.Terminated)}onInfoRequest(e){if(this.logger.log("Session.onInfoRequest"),this.state!==B.Established){this.logger.error(`INFO received while in state ${this.state}, dropping request`);return}if(this.delegate&&this.delegate.onInfo){const t=new Y0(e);this.delegate.onInfo(t)}else e.accept()}onInviteRequest(e){if(this.logger.log("Session.onInviteRequest"),this.state!==B.Established){this.logger.error(`INVITE received while in state ${this.state}, dropping request`);return}this.pendingReinviteAck=!0;const t=["Contact: "+this._contact];if(e.message.hasHeader("P-Asserted-Identity")){const i=e.message.getHeader("P-Asserted-Identity");if(!i)throw new Error("Header undefined.");this._assertedIdentity=Pe.nameAddrHeaderParse(i)}const s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.generateResponseOfferAnswerInDialog(s).then(i=>{const n=e.accept({statusCode:200,extraHeaders:t,body:i});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,n.message,200)}).catch(i=>{if(this.logger.error(i.message),this.logger.error("Failed to handle to re-INVITE request"),!this.dialog)throw new Error("Dialog undefined.");if(this.logger.error(this.dialog.signalingState),this.dialog.signalingState===Y.Stable){const n=e.reject({statusCode:488});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,n.message,488);return}this.rollbackOffer().then(()=>{const n=e.reject({statusCode:488});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,n.message,488)}).catch(n=>{this.logger.error(n.message),this.logger.error("Failed to rollback offer on re-INVITE request");const a=e.reject({statusCode:488});if(this.state!==B.Terminated){if(!this.dialog)throw new Error("Dialog undefined.");const o=[];o.push("Reason: "+this.getReasonHeaderValue(500,"Internal Server Error")),this.dialog.bye(void 0,{extraHeaders:o}),this.stateTransition(B.Terminated)}this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,a.message,488)})})}onMessageRequest(e){if(this.logger.log("Session.onMessageRequest"),this.state!==B.Established){this.logger.error(`MESSAGE received while in state ${this.state}, dropping request`);return}if(this.delegate&&this.delegate.onMessage){const t=new Ta(e);this.delegate.onMessage(t)}else e.accept()}onNotifyRequest(e){if(this.logger.log("Session.onNotifyRequest"),this.state!==B.Established){this.logger.error(`NOTIFY received while in state ${this.state}, dropping request`);return}if(this.onNotify){const t=new $i(e);this.onNotify(t);return}if(this.delegate&&this.delegate.onNotify){const t=new $i(e);this.delegate.onNotify(t)}else e.accept()}onPrackRequest(e){if(this.logger.log("Session.onPrackRequest"),this.state!==B.Established){this.logger.error(`PRACK received while in state ${this.state}, dropping request`);return}throw new Error("Unimplemented.")}onReferRequest(e){if(this.logger.log("Session.onReferRequest"),this.state!==B.Established){this.logger.error(`REFER received while in state ${this.state}, dropping request`);return}if(!e.message.hasHeader("refer-to")){this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting."),e.reject();return}const t=new K0(e,this);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(t):(this.logger.log("No delegate available to handle REFER, automatically accepting and following."),t.accept().then(()=>t.makeInviter(this._referralInviterOptions).invite()).catch(s=>{this.logger.error(s.message)}))}generateResponseOfferAnswer(e,t){if(this.dialog)return this.generateResponseOfferAnswerInDialog(t);const s=Ur(e.message);return!s||s.contentDisposition!=="session"?this.getOffer(t):this.setOfferAndGetAnswer(s,t)}generateResponseOfferAnswerInDialog(e){if(!this.dialog)throw new Error("Dialog undefined.");switch(this.dialog.signalingState){case Y.Initial:return this.getOffer(e);case Y.HaveLocalOffer:return Promise.resolve(void 0);case Y.HaveRemoteOffer:if(!this.dialog.offer)throw new Error(`Session offer undefined in signaling state ${this.dialog.signalingState}.`);return this.setOfferAndGetAnswer(this.dialog.offer,e);case Y.Stable:return this.state!==B.Established?Promise.resolve(void 0):this.getOffer(e);case Y.Closed:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);default:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`)}}getOffer(e){const t=this.setupSessionDescriptionHandler(),s=e.sessionDescriptionHandlerOptions,i=e.sessionDescriptionHandlerModifiers;try{return t.getDescription(s,i).then(n=>ds(n)).catch(n=>{this.logger.error("Session.getOffer: SDH getDescription rejected...");const a=n instanceof Error?n:new Error("Session.getOffer unknown error.");throw this.logger.error(a.message),a})}catch(n){this.logger.error("Session.getOffer: SDH getDescription threw...");const a=n instanceof Error?n:new Error(n);return this.logger.error(a.message),Promise.reject(a)}}rollbackOffer(){const e=this.setupSessionDescriptionHandler();if(e.rollbackDescription===void 0)return Promise.resolve();try{return e.rollbackDescription().catch(t=>{this.logger.error("Session.rollbackOffer: SDH rollbackDescription rejected...");const s=t instanceof Error?t:new Error("Session.rollbackOffer unknown error.");throw this.logger.error(s.message),s})}catch(t){this.logger.error("Session.rollbackOffer: SDH rollbackDescription threw...");const s=t instanceof Error?t:new Error(t);return this.logger.error(s.message),Promise.reject(s)}}setAnswer(e,t){const s=this.setupSessionDescriptionHandler(),i=t.sessionDescriptionHandlerOptions,n=t.sessionDescriptionHandlerModifiers;try{if(!s.hasDescription(e.contentType))return Promise.reject(new Bi)}catch(a){this.logger.error("Session.setAnswer: SDH hasDescription threw...");const o=a instanceof Error?a:new Error(a);return this.logger.error(o.message),Promise.reject(o)}try{return s.setDescription(e.content,i,n).catch(a=>{this.logger.error("Session.setAnswer: SDH setDescription rejected...");const o=a instanceof Error?a:new Error("Session.setAnswer unknown error.");throw this.logger.error(o.message),o})}catch(a){this.logger.error("Session.setAnswer: SDH setDescription threw...");const o=a instanceof Error?a:new Error(a);return this.logger.error(o.message),Promise.reject(o)}}setOfferAndGetAnswer(e,t){const s=this.setupSessionDescriptionHandler(),i=t.sessionDescriptionHandlerOptions,n=t.sessionDescriptionHandlerModifiers;try{if(!s.hasDescription(e.contentType))return Promise.reject(new Bi)}catch(a){this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");const o=a instanceof Error?a:new Error(a);return this.logger.error(o.message),Promise.reject(o)}try{return s.setDescription(e.content,i,n).then(()=>s.getDescription(i,n)).then(a=>ds(a)).catch(a=>{this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription rejected...");const o=a instanceof Error?a:new Error("Session.setOfferAndGetAnswer unknown error.");throw this.logger.error(o.message),o})}catch(a){this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription threw...");const o=a instanceof Error?a:new Error(a);return this.logger.error(o.message),Promise.reject(o)}}setSessionDescriptionHandler(e){if(this._sessionDescriptionHandler)throw new Error("Session description handler defined.");this._sessionDescriptionHandler=e}setupSessionDescriptionHandler(){var e;return this._sessionDescriptionHandler?this._sessionDescriptionHandler:(this._sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions),!((e=this.delegate)===null||e===void 0)&&e.onSessionDescriptionHandler&&this.delegate.onSessionDescriptionHandler(this._sessionDescriptionHandler,!1),this._sessionDescriptionHandler)}stateTransition(e){const t=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case B.Initial:e!==B.Establishing&&e!==B.Established&&e!==B.Terminating&&e!==B.Terminated&&t();break;case B.Establishing:e!==B.Established&&e!==B.Terminating&&e!==B.Terminated&&t();break;case B.Established:e!==B.Terminating&&e!==B.Terminated&&t();break;case B.Terminating:e!==B.Terminated&&t();break;case B.Terminated:t();break;default:throw new Error("Unrecognized state.")}this._state=e,this.logger.log(`Session ${this.id} transitioned to state ${this._state}`),this._stateEventEmitter.emit(this._state),e===B.Terminated&&this.dispose()}copyRequestOptions(e={}){const t=e.extraHeaders?e.extraHeaders.slice():void 0,s=e.body?{contentDisposition:e.body.contentDisposition||"render",contentType:e.body.contentType||"text/plain",content:e.body.content||""}:void 0;return{extraHeaders:t,body:s}}getReasonHeaderValue(e,t){const s=e;let i=cs(e);return!i&&t&&(i=t),"SIP;cause="+s+';text="'+i+'"'}referExtraHeaders(e){const t=[];return t.push("Referred-By: <"+this.userAgent.configuration.uri+">"),t.push("Contact: "+this._contact),t.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),t.push("Refer-To: "+e),t}referToString(e){let t;if(e instanceof vt)t=e.toString();else{if(!e.dialog)throw new Error("Dialog undefined.");const s=e.remoteIdentity.friendlyName,i=e.dialog.remoteTarget.toString(),n=e.dialog.callId,a=e.dialog.remoteTag,o=e.dialog.localTag,d=encodeURIComponent(`${n};to-tag=${a};from-tag=${o}`);t=`"${s}" <${i}?Replaces=${d}>`}return t}}var dt;(function(r){r.Required="Required",r.Supported="Supported",r.Unsupported="Unsupported"})(dt=dt||(dt={}));const Z0={"100rel":!0,199:!0,answermode:!0,"early-session":!0,eventlist:!0,explicitsub:!0,"from-change":!0,"geolocation-http":!0,"geolocation-sip":!0,gin:!0,gruu:!0,histinfo:!0,ice:!0,join:!0,"multiple-refer":!0,norefersub:!0,nosub:!0,outbound:!0,path:!0,policy:!0,precondition:!0,pref:!0,privacy:!0,"recipient-list-invite":!0,"recipient-list-message":!0,"recipient-list-subscribe":!0,replaces:!0,"resource-priority":!0,"sdp-anat":!0,"sec-agree":!0,tdialog:!0,timer:!0,uui:!0};class X0 extends Lr{constructor(e,t){super(e),this.incomingInviteRequest=t,this.disposed=!1,this.expiresTimer=void 0,this.isCanceled=!1,this.rel100="none",this.rseq=Math.floor(Math.random()*1e4),this.userNoAnswerTimer=void 0,this.waitingForPrack=!1,this.logger=e.getLogger("sip.Invitation");const s=this.incomingInviteRequest.message,i=s.getHeader("require");i&&i.toLowerCase().includes("100rel")&&(this.rel100="required");const n=s.getHeader("supported");if(n&&n.toLowerCase().includes("100rel")&&(this.rel100="supported"),s.toTag=t.toTag,typeof s.toTag!="string")throw new TypeError("toTag should have been a string.");if(this.userNoAnswerTimer=setTimeout(()=>{t.reject({statusCode:480}),this.stateTransition(B.Terminated)},this.userAgent.configuration.noAnswerTimeout?this.userAgent.configuration.noAnswerTimeout*1e3:6e4),s.hasHeader("expires")){const d=Number(s.getHeader("expires")||0)*1e3;this.expiresTimer=setTimeout(()=>{this.state===B.Initial&&(t.reject({statusCode:487}),this.stateTransition(B.Terminated))},d)}const a=this.request.getHeader("P-Asserted-Identity");a&&(this._assertedIdentity=Pe.nameAddrHeaderParse(a)),this._contact=this.userAgent.contact.toString();const o=s.parseHeader("Content-Disposition");o&&o.type==="render"&&(this._renderbody=s.body,this._rendertype=s.getHeader("Content-Type")),this._id=s.callId+s.fromTag,this.userAgent._sessions[this._id]=this}dispose(){if(this.disposed)return Promise.resolve();switch(this.disposed=!0,this.expiresTimer&&(clearTimeout(this.expiresTimer),this.expiresTimer=void 0),this.userNoAnswerTimer&&(clearTimeout(this.userNoAnswerTimer),this.userNoAnswerTimer=void 0),this.prackNeverArrived(),this.state){case B.Initial:return this.reject().then(()=>super.dispose());case B.Establishing:return this.reject().then(()=>super.dispose());case B.Established:return super.dispose();case B.Terminating:return super.dispose();case B.Terminated:return super.dispose();default:throw new Error("Unknown state.")}}get autoSendAnInitialProvisionalResponse(){return this.rel100!=="required"&&this.userAgent.configuration.sendInitialProvisionalResponse}get body(){return this.incomingInviteRequest.message.body}get localIdentity(){return this.request.to}get remoteIdentity(){return this.request.from}get request(){return this.incomingInviteRequest.message}accept(e={}){if(this.logger.log("Invitation.accept"),this.state!==B.Initial){const t=new Error(`Invalid session state ${this.state}`);return this.logger.error(t.message),Promise.reject(t)}return e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),this.stateTransition(B.Establishing),this.sendAccept(e).then(({message:t,session:s})=>{s.delegate={onAck:i=>this.onAckRequest(i),onAckTimeout:()=>this.onAckTimeout(),onBye:i=>this.onByeRequest(i),onInfo:i=>this.onInfoRequest(i),onInvite:i=>this.onInviteRequest(i),onMessage:i=>this.onMessageRequest(i),onNotify:i=>this.onNotifyRequest(i),onPrack:i=>this.onPrackRequest(i),onRefer:i=>this.onReferRequest(i)},this._dialog=s,this.stateTransition(B.Established),this._replacee&&this._replacee._bye()}).catch(t=>this.handleResponseError(t))}progress(e={}){if(this.logger.log("Invitation.progress"),this.state!==B.Initial){const s=new Error(`Invalid session state ${this.state}`);return this.logger.error(s.message),Promise.reject(s)}const t=e.statusCode||180;if(t<100||t>199)throw new TypeError("Invalid statusCode: "+t);return e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),this.waitingForPrack?(this.logger.warn("Unexpected call for progress while waiting for prack, ignoring"),Promise.resolve()):e.statusCode===100?this.sendProgressTrying().then(()=>{}).catch(s=>this.handleResponseError(s)):this.rel100!=="required"&&!(this.rel100==="supported"&&e.rel100)&&!(this.rel100==="supported"&&this.userAgent.configuration.sipExtension100rel===dt.Required)?this.sendProgress(e).then(()=>{}).catch(s=>this.handleResponseError(s)):this.sendProgressReliableWaitForPrack(e).then(()=>{}).catch(s=>this.handleResponseError(s))}reject(e={}){if(this.logger.log("Invitation.reject"),this.state!==B.Initial&&this.state!==B.Establishing){const a=new Error(`Invalid session state ${this.state}`);return this.logger.error(a.message),Promise.reject(a)}const t=e.statusCode||480,s=e.reasonPhrase?e.reasonPhrase:cs(t),i=e.extraHeaders||[];if(t<300||t>699)throw new TypeError("Invalid statusCode: "+t);const n=e.body?ds(e.body):void 0;return t<400?this.incomingInviteRequest.redirect([],{statusCode:t,reasonPhrase:s,extraHeaders:i,body:n}):this.incomingInviteRequest.reject({statusCode:t,reasonPhrase:s,extraHeaders:i,body:n}),this.stateTransition(B.Terminated),Promise.resolve()}_onCancel(e){if(this.logger.log("Invitation._onCancel"),this.state!==B.Initial&&this.state!==B.Establishing){this.logger.error(`CANCEL received while in state ${this.state}, dropping request`);return}if(this.delegate&&this.delegate.onCancel){const t=new L0(e);this.delegate.onCancel(t)}this.isCanceled=!0,this.incomingInviteRequest.reject({statusCode:487}),this.stateTransition(B.Terminated)}handlePrackOfferAnswer(e){if(!this.dialog)throw new Error("Dialog undefined.");const t=Ur(e.message);if(!t||t.contentDisposition!=="session")return Promise.resolve(void 0);const s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};switch(this.dialog.signalingState){case Y.Initial:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);case Y.Stable:return this.setAnswer(t,s).then(()=>{});case Y.HaveLocalOffer:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);case Y.HaveRemoteOffer:return this.setOfferAndGetAnswer(t,s);case Y.Closed:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);default:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`)}}handleResponseError(e){let t=480;if(e instanceof Error?this.logger.error(e.message):this.logger.error(e),e instanceof Bi?(this.logger.error("A session description handler occurred while sending response (content type unsupported"),t=415):e instanceof j0?this.logger.error("A session description handler occurred while sending response"):e instanceof Pi?this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)"):e instanceof Vt&&this.logger.error("Session changed state before response could be formulated and sent"),this.state===B.Initial||this.state===B.Establishing)try{this.incomingInviteRequest.reject({statusCode:t}),this.stateTransition(B.Terminated)}catch(s){throw this.logger.error("An error occurred attempting to reject the request while handling another error"),s}if(this.isCanceled){this.logger.warn("An error occurred while attempting to formulate and send a response to an incoming INVITE. However a CANCEL was received and processed while doing so which can (and often does) result in errors occurring as the session terminates in the meantime. Said error is being ignored.");return}throw e}onAckTimeout(){if(this.logger.log("Invitation.onAckTimeout"),!this.dialog)throw new Error("Dialog undefined.");this.logger.log("No ACK received for an extended period of time, terminating session"),this.dialog.bye(),this.stateTransition(B.Terminated)}sendAccept(e={}){const t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.extraHeaders||[];return this.waitingForPrack?this.waitForArrivalOfPrack().then(()=>clearTimeout(this.userNoAnswerTimer)).then(()=>this.generateResponseOfferAnswer(this.incomingInviteRequest,t)).then(i=>this.incomingInviteRequest.accept({statusCode:200,body:i,extraHeaders:s})):(clearTimeout(this.userNoAnswerTimer),this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(i=>this.incomingInviteRequest.accept({statusCode:200,body:i,extraHeaders:s})))}sendProgress(e={}){const t=e.statusCode||180,s=e.reasonPhrase,i=(e.extraHeaders||[]).slice(),n=e.body?ds(e.body):void 0;if(t===183&&!n)return this.sendProgressWithSDP(e);try{const a=this.incomingInviteRequest.progress({statusCode:t,reasonPhrase:s,extraHeaders:i,body:n});return this._dialog=a.session,Promise.resolve(a)}catch(a){return Promise.reject(a)}}sendProgressWithSDP(e={}){const t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.statusCode||183,i=e.reasonPhrase,n=(e.extraHeaders||[]).slice();return this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(a=>this.incomingInviteRequest.progress({statusCode:s,reasonPhrase:i,extraHeaders:n,body:a})).then(a=>(this._dialog=a.session,a))}sendProgressReliable(e={}){return e.extraHeaders=(e.extraHeaders||[]).slice(),e.extraHeaders.push("Require: 100rel"),e.extraHeaders.push("RSeq: "+Math.floor(Math.random()*1e4)),this.sendProgressWithSDP(e)}sendProgressReliableWaitForPrack(e={}){const t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.statusCode||183,i=e.reasonPhrase,n=(e.extraHeaders||[]).slice();n.push("Require: 100rel"),n.push("RSeq: "+this.rseq++);let a;return new Promise((o,d)=>{this.waitingForPrack=!0,this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(c=>(a=c,this.incomingInviteRequest.progress({statusCode:s,reasonPhrase:i,extraHeaders:n,body:a}))).then(c=>{this._dialog=c.session;let l,g;c.session.delegate={onPrack:x=>{l=x,clearTimeout(y),clearTimeout(_),this.waitingForPrack&&(this.waitingForPrack=!1,this.handlePrackOfferAnswer(l).then(p=>{try{g=l.accept({statusCode:200,body:p}),this.prackArrived(),o({prackRequest:l,prackResponse:g,progressResponse:c})}catch(E){d(E)}}).catch(p=>d(p)))}};const y=setTimeout(()=>{this.waitingForPrack&&(this.waitingForPrack=!1,this.logger.warn("No PRACK received, rejecting INVITE."),clearTimeout(_),this.reject({statusCode:504}).then(()=>d(new Pi)).catch(x=>d(x)))},Oe.T1*64),w=()=>{try{this.incomingInviteRequest.progress({statusCode:s,reasonPhrase:i,extraHeaders:n,body:a})}catch(x){this.waitingForPrack=!1,d(x);return}_=setTimeout(w,b*=2)};let b=Oe.T1,_=setTimeout(w,b)}).catch(c=>{this.waitingForPrack=!1,d(c)})})}sendProgressTrying(){try{const e=this.incomingInviteRequest.trying();return Promise.resolve(e)}catch(e){return Promise.reject(e)}}waitForArrivalOfPrack(){if(this.waitingForPrackPromise)throw new Error("Already waiting for PRACK");return this.waitingForPrackPromise=new Promise((e,t)=>{this.waitingForPrackResolve=e,this.waitingForPrackReject=t}),this.waitingForPrackPromise}prackArrived(){this.waitingForPrackResolve&&this.waitingForPrackResolve(),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0}prackNeverArrived(){this.waitingForPrackReject&&this.waitingForPrackReject(new Pi),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0}}class Ra extends Lr{constructor(e,t,s={}){super(e,s),this.disposed=!1,this.earlyMedia=!1,this.earlyMediaSessionDescriptionHandlers=new Map,this.isCanceled=!1,this.inviteWithoutSdp=!1,this.logger=e.getLogger("sip.Inviter"),this.earlyMedia=s.earlyMedia!==void 0?s.earlyMedia:this.earlyMedia,this.fromTag=ls(),this.inviteWithoutSdp=s.inviteWithoutSdp!==void 0?s.inviteWithoutSdp:this.inviteWithoutSdp;const i=Object.assign({},s);i.params=Object.assign({},s.params);const n=s.anonymous||!1,a=e.contact.toString({anonymous:n,outbound:n?!e.contact.tempGruu:!e.contact.pubGruu});n&&e.configuration.uri&&(i.params.fromDisplayName="Anonymous",i.params.fromUri="sip:anonymous@anonymous.invalid");let o=e.userAgentCore.configuration.aor;if(i.params.fromUri&&(o=typeof i.params.fromUri=="string"?Pe.URIParse(i.params.fromUri):i.params.fromUri),!o)throw new TypeError("Invalid from URI: "+i.params.fromUri);let d=t;if(i.params.toUri&&(d=typeof i.params.toUri=="string"?Pe.URIParse(i.params.toUri):i.params.toUri),!d)throw new TypeError("Invalid to URI: "+i.params.toUri);const c=Object.assign({},i.params);c.fromTag=this.fromTag;const l=(i.extraHeaders||[]).slice();n&&e.configuration.uri&&(l.push("P-Preferred-Identity: "+e.configuration.uri.toString()),l.push("Privacy: id")),l.push("Contact: "+a),l.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),e.configuration.sipExtension100rel===dt.Required&&l.push("Require: 100rel"),e.configuration.sipExtensionReplaces===dt.Required&&l.push("Require: replaces"),i.extraHeaders=l;const g=void 0;this.outgoingRequestMessage=e.userAgentCore.makeOutgoingRequestMessage(K.INVITE,t,o,d,c,l,g),this._contact=a,this._referralInviterOptions=i,this._renderbody=s.renderbody,this._rendertype=s.rendertype,s.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=s.sessionDescriptionHandlerModifiers),s.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=s.sessionDescriptionHandlerOptions),s.sessionDescriptionHandlerModifiersReInvite&&(this.sessionDescriptionHandlerModifiersReInvite=s.sessionDescriptionHandlerModifiersReInvite),s.sessionDescriptionHandlerOptionsReInvite&&(this.sessionDescriptionHandlerOptionsReInvite=s.sessionDescriptionHandlerOptionsReInvite),this._id=this.outgoingRequestMessage.callId+this.fromTag,this.userAgent._sessions[this._id]=this}dispose(){if(this.disposed)return Promise.resolve();switch(this.disposed=!0,this.disposeEarlyMedia(),this.state){case B.Initial:return this.cancel().then(()=>super.dispose());case B.Establishing:return this.cancel().then(()=>super.dispose());case B.Established:return super.dispose();case B.Terminating:return super.dispose();case B.Terminated:return super.dispose();default:throw new Error("Unknown state.")}}get body(){return this.outgoingRequestMessage.body}get localIdentity(){return this.outgoingRequestMessage.from}get remoteIdentity(){return this.outgoingRequestMessage.to}get request(){return this.outgoingRequestMessage}cancel(e={}){if(this.logger.log("Inviter.cancel"),this.state!==B.Initial&&this.state!==B.Establishing){const s=new Error(`Invalid session state ${this.state}`);return this.logger.error(s.message),Promise.reject(s)}this.isCanceled=!0,this.stateTransition(B.Terminating);function t(s,i){if(s&&s<200||s>699)throw new TypeError("Invalid statusCode: "+s);if(s){const n=s,a=cs(s)||i;return"SIP;cause="+n+';text="'+a+'"'}}if(this.outgoingInviteRequest){let s;e.statusCode&&e.reasonPhrase&&(s=t(e.statusCode,e.reasonPhrase)),this.outgoingInviteRequest.cancel(s,e)}else this.logger.warn("Canceled session before INVITE was sent"),this.stateTransition(B.Terminated);return Promise.resolve()}invite(e={}){if(this.logger.log("Inviter.invite"),this.state!==B.Initial)return super.invite(e);if(e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),e.withoutSdp||this.inviteWithoutSdp)return this._renderbody&&this._rendertype&&(this.outgoingRequestMessage.body={contentType:this._rendertype,body:this._renderbody}),this.stateTransition(B.Establishing),Promise.resolve(this.sendInvite(e));const t={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.getOffer(t).then(s=>(this.outgoingRequestMessage.body={body:s.content,contentType:s.contentType},this.stateTransition(B.Establishing),this.sendInvite(e))).catch(s=>{throw this.logger.log(s.message),this.state!==B.Terminated&&this.stateTransition(B.Terminated),s})}sendInvite(e={}){return this.outgoingInviteRequest=this.userAgent.userAgentCore.invite(this.outgoingRequestMessage,{onAccept:t=>{if(this.dialog){this.logger.log("Additional confirmed dialog, sending ACK and BYE"),this.ackAndBye(t);return}if(this.isCanceled){this.logger.log("Canceled session accepted, sending ACK and BYE"),this.ackAndBye(t),this.stateTransition(B.Terminated);return}this.notifyReferer(t),this.onAccept(t).then(()=>{this.disposeEarlyMedia()}).catch(()=>{this.disposeEarlyMedia()}).then(()=>{e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t)})},onProgress:t=>{this.isCanceled||(this.notifyReferer(t),this.onProgress(t).catch(()=>{this.disposeEarlyMedia()}).then(()=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(t)}))},onRedirect:t=>{this.notifyReferer(t),this.onRedirect(t),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(t)},onReject:t=>{this.notifyReferer(t),this.onReject(t),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t)},onTrying:t=>{this.notifyReferer(t),this.onTrying(t),e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(t)}}),this.outgoingInviteRequest}disposeEarlyMedia(){this.earlyMediaSessionDescriptionHandlers.forEach(e=>{e.close()}),this.earlyMediaSessionDescriptionHandlers.clear()}notifyReferer(e){if(!this._referred)return;if(!(this._referred instanceof Lr))throw new Error("Referred session not instance of session");if(!this._referred.dialog)return;if(!e.message.statusCode)throw new Error("Status code undefined.");if(!e.message.reasonPhrase)throw new Error("Reason phrase undefined.");const t=e.message.statusCode,s=e.message.reasonPhrase,i=`SIP/2.0 ${t} ${s}`.trim(),n=this._referred.dialog.notify(void 0,{extraHeaders:["Event: refer","Subscription-State: terminated"],body:{contentDisposition:"render",contentType:"message/sipfrag",content:i}});n.delegate={onReject:()=>{this._referred=void 0}}}onAccept(e){if(this.logger.log("Inviter.onAccept"),this.state!==B.Establishing)return this.logger.error(`Accept received while in state ${this.state}, dropping response`),Promise.reject(new Error(`Invalid session state ${this.state}`));const t=e.message,s=e.session;switch(t.hasHeader("P-Asserted-Identity")&&(this._assertedIdentity=Pe.nameAddrHeaderParse(t.getHeader("P-Asserted-Identity"))),s.delegate={onAck:i=>this.onAckRequest(i),onBye:i=>this.onByeRequest(i),onInfo:i=>this.onInfoRequest(i),onInvite:i=>this.onInviteRequest(i),onMessage:i=>this.onMessageRequest(i),onNotify:i=>this.onNotifyRequest(i),onPrack:i=>this.onPrackRequest(i),onRefer:i=>this.onReferRequest(i)},this._dialog=s,s.signalingState){case Y.Initial:return this.logger.error("Received 2xx response to INVITE without a session description"),this.ackAndBye(e,400,"Missing session description"),this.stateTransition(B.Terminated),Promise.reject(new Error("Bad Media Description"));case Y.HaveLocalOffer:return this.logger.error("Received 2xx response to INVITE without a session description"),this.ackAndBye(e,400,"Missing session description"),this.stateTransition(B.Terminated),Promise.reject(new Error("Bad Media Description"));case Y.HaveRemoteOffer:{if(!this._dialog.offer)throw new Error(`Session offer undefined in signaling state ${this._dialog.signalingState}.`);const i={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setOfferAndGetAnswer(this._dialog.offer,i).then(n=>{e.ack({body:n}),this.stateTransition(B.Established)}).catch(n=>{throw this.ackAndBye(e,488,"Invalid session description"),this.stateTransition(B.Terminated),n})}case Y.Stable:{if(this.earlyMediaSessionDescriptionHandlers.size>0){const a=this.earlyMediaSessionDescriptionHandlers.get(s.id);if(!a)throw new Error("Session description handler undefined.");return this.setSessionDescriptionHandler(a),this.earlyMediaSessionDescriptionHandlers.delete(s.id),e.ack(),this.stateTransition(B.Established),Promise.resolve()}if(this.earlyMediaDialog){if(this.earlyMediaDialog!==s){this.earlyMedia&&this.logger.error("You have set the 'earlyMedia' option to 'true' which requires that your INVITE requests do not fork and yet this INVITE request did in fact fork. Consequentially and not surprisingly the end point which accepted the INVITE (confirmed dialog) does not match the end point with which early media has been setup (early dialog) and thus this session is unable to proceed. In accordance with the SIP specifications, the SIP servers your end point is connected to determine if an INVITE forks and the forking behavior of those servers cannot be controlled by this library. If you wish to use early media with this library you must configure those servers accordingly. Alternatively you may set the 'earlyMedia' to 'false' which will allow this library to function with any INVITE requests which do fork.");const a=new Error("Early media dialog does not equal confirmed dialog, terminating session");return this.logger.error(a.message),this.ackAndBye(e,488,"Not Acceptable Here"),this.stateTransition(B.Terminated),Promise.reject(a)}return e.ack(),this.stateTransition(B.Established),Promise.resolve()}const i=s.answer;if(!i)throw new Error("Answer is undefined.");const n={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setAnswer(i,n).then(()=>{let a;this._renderbody&&this._rendertype&&(a={body:{contentDisposition:"render",contentType:this._rendertype,content:this._renderbody}}),e.ack(a),this.stateTransition(B.Established)}).catch(a=>{throw this.logger.error(a.message),this.ackAndBye(e,488,"Not Acceptable Here"),this.stateTransition(B.Terminated),a})}case Y.Closed:return Promise.reject(new Error("Terminated."));default:throw new Error("Unknown session signaling state.")}}onProgress(e){var t;if(this.logger.log("Inviter.onProgress"),this.state!==B.Establishing)return this.logger.error(`Progress received while in state ${this.state}, dropping response`),Promise.reject(new Error(`Invalid session state ${this.state}`));if(!this.outgoingInviteRequest)throw new Error("Outgoing INVITE request undefined.");const s=e.message,i=e.session;s.hasHeader("P-Asserted-Identity")&&(this._assertedIdentity=Pe.nameAddrHeaderParse(s.getHeader("P-Asserted-Identity")));const n=s.getHeader("require"),a=s.getHeader("rseq"),d=!!(n&&n.includes("100rel")&&a?Number(a):void 0),c=[];switch(d&&c.push("RAck: "+s.getHeader("rseq")+" "+s.getHeader("cseq")),i.signalingState){case Y.Initial:return d&&(this.logger.warn("First reliable provisional response received MUST contain an offer when INVITE does not contain an offer."),e.prack({extraHeaders:c})),Promise.resolve();case Y.HaveLocalOffer:return d&&e.prack({extraHeaders:c}),Promise.resolve();case Y.HaveRemoteOffer:if(!d)return this.logger.warn("Non-reliable provisional response MUST NOT contain an initial offer, discarding response."),Promise.resolve();{const l=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions||{});return!((t=this.delegate)===null||t===void 0)&&t.onSessionDescriptionHandler&&this.delegate.onSessionDescriptionHandler(l,!0),this.earlyMediaSessionDescriptionHandlers.set(i.id,l),l.setDescription(s.body,this.sessionDescriptionHandlerOptions,this.sessionDescriptionHandlerModifiers).then(()=>l.getDescription(this.sessionDescriptionHandlerOptions,this.sessionDescriptionHandlerModifiers)).then(g=>{const f={contentDisposition:"session",contentType:g.contentType,content:g.body};e.prack({extraHeaders:c,body:f})}).catch(g=>{throw this.stateTransition(B.Terminated),g})}case Y.Stable:if(d&&e.prack({extraHeaders:c}),this.earlyMedia&&!this.earlyMediaDialog){this.earlyMediaDialog=i;const l=i.answer;if(!l)throw new Error("Answer is undefined.");const g={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setAnswer(l,g).catch(f=>{throw this.stateTransition(B.Terminated),f})}return Promise.resolve();case Y.Closed:return Promise.reject(new Error("Terminated."));default:throw new Error("Unknown session signaling state.")}}onRedirect(e){if(this.logger.log("Inviter.onRedirect"),this.state!==B.Establishing&&this.state!==B.Terminating){this.logger.error(`Redirect received while in state ${this.state}, dropping response`);return}this.stateTransition(B.Terminated)}onReject(e){if(this.logger.log("Inviter.onReject"),this.state!==B.Establishing&&this.state!==B.Terminating){this.logger.error(`Reject received while in state ${this.state}, dropping response`);return}this.stateTransition(B.Terminated)}onTrying(e){if(this.logger.log("Inviter.onTrying"),this.state!==B.Establishing){this.logger.error(`Trying received while in state ${this.state}, dropping response`);return}}}var me;(function(r){r.Initial="Initial",r.Registered="Registered",r.Unregistered="Unregistered",r.Terminated="Terminated"})(me=me||(me={}));class wt{constructor(e,t={}){this.disposed=!1,this._contacts=[],this._retryAfter=void 0,this._state=me.Initial,this._waiting=!1,this._stateEventEmitter=new jr,this._waitingEventEmitter=new jr,this.userAgent=e;const s=e.configuration.uri.clone();if(s.user=void 0,this.options=Object.assign(Object.assign(Object.assign({},wt.defaultOptions()),{registrar:s}),wt.stripUndefinedProperties(t)),this.options.extraContactHeaderParams=(this.options.extraContactHeaderParams||[]).slice(),this.options.extraHeaders=(this.options.extraHeaders||[]).slice(),!this.options.registrar)throw new Error("Registrar undefined.");if(this.options.registrar=this.options.registrar.clone(),this.options.regId&&!this.options.instanceId?this.options.instanceId=this.userAgent.instanceId:!this.options.regId&&this.options.instanceId&&(this.options.regId=1),this.options.instanceId&&Pe.parse(this.options.instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");if(this.options.regId&&this.options.regId<0)throw new Error("Invalid regId.");const i=this.options.registrar,n=this.options.params&&this.options.params.fromUri||e.userAgentCore.configuration.aor,a=this.options.params&&this.options.params.toUri||e.configuration.uri,o=this.options.params||{},d=(t.extraHeaders||[]).slice();if(this.request=e.userAgentCore.makeOutgoingRequestMessage(K.REGISTER,i,n,a,o,d,void 0),this.expires=this.options.expires||wt.defaultExpires,this.expires<0)throw new Error("Invalid expires.");if(this.refreshFrequency=this.options.refreshFrequency||wt.defaultRefreshFrequency,this.refreshFrequency<50||this.refreshFrequency>99)throw new Error("Invalid refresh frequency. The value represents a percentage of the expiration time and should be between 50 and 99.");this.logger=e.getLogger("sip.Registerer"),this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(c=>{const l=this.options[c];switch(c){case"registrar":this.logger.log("· "+c+": "+l);break;default:this.logger.log("· "+c+": "+JSON.stringify(l))}})),this.id=this.request.callId+this.request.from.parameters.tag,this.userAgent._registerers[this.id]=this}static defaultOptions(){return{expires:wt.defaultExpires,extraContactHeaderParams:[],extraHeaders:[],logConfiguration:!0,instanceId:"",params:{},regId:0,registrar:new vt("sip","anonymous","anonymous.invalid"),refreshFrequency:wt.defaultRefreshFrequency}}static stripUndefinedProperties(e){return Object.keys(e).reduce((t,s)=>(e[s]!==void 0&&(t[s]=e[s]),t),{})}get contacts(){return this._contacts.slice()}get retryAfter(){return this._retryAfter}get state(){return this._state}get stateChange(){return this._stateEventEmitter}dispose(){return this.disposed?Promise.resolve():(this.disposed=!0,this.logger.log(`Registerer ${this.id} in state ${this.state} is being disposed`),delete this.userAgent._registerers[this.id],new Promise(e=>{const t=()=>{if(!this.waiting&&this._state===me.Registered){this.stateChange.addListener(()=>{this.terminated(),e()},{once:!0}),this.unregister();return}this.terminated(),e()};this.waiting?this.waitingChange.addListener(()=>{t()},{once:!0}):t()}))}register(e={}){if(this.state===me.Terminated)throw this.stateError(),new Error("Registerer terminated. Unable to register.");if(this.disposed)throw this.stateError(),new Error("Registerer disposed. Unable to register.");if(this.waiting){this.waitingWarning();const i=new Ii("REGISTER request already in progress, waiting for final response");return Promise.reject(i)}e.requestOptions&&(this.options=Object.assign(Object.assign({},this.options),e.requestOptions));const t=(this.options.extraHeaders||[]).slice();t.push("Contact: "+this.generateContactHeader(this.expires)),t.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.request.extraHeaders=t,this.waitingToggle(!0);const s=this.userAgent.userAgentCore.register(this.request,{onAccept:i=>{let n;i.message.hasHeader("expires")&&(n=Number(i.message.getHeader("expires"))),this._contacts=i.message.getHeaders("contact");let a=this._contacts.length;if(!a){this.logger.error("No Contact header in response to REGISTER, dropping response."),this.unregistered();return}let o;for(;a--;){if(o=i.message.parseHeader("contact",a),!o)throw new Error("Contact undefined");if(this.userAgent.contact.pubGruu&&_a(o.uri,this.userAgent.contact.pubGruu)){n=Number(o.getParam("expires"));break}if(this.userAgent.configuration.contactName===""){if(o.uri.user===this.userAgent.contact.uri.user){n=Number(o.getParam("expires"));break}}else if(_a(o.uri,this.userAgent.contact.uri)){n=Number(o.getParam("expires"));break}o=void 0}if(o===void 0){this.logger.error("No Contact header pointing to us, dropping response"),this.unregistered(),this.waitingToggle(!1);return}if(n===void 0){this.logger.error("Contact pointing to us is missing expires parameter, dropping response"),this.unregistered(),this.waitingToggle(!1);return}if(o.hasParam("temp-gruu")){const d=o.getParam("temp-gruu");d&&(this.userAgent.contact.tempGruu=Pe.URIParse(d.replace(/"/g,"")))}if(o.hasParam("pub-gruu")){const d=o.getParam("pub-gruu");d&&(this.userAgent.contact.pubGruu=Pe.URIParse(d.replace(/"/g,"")))}this.registered(n),e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(i),this.waitingToggle(!1)},onProgress:i=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(i)},onRedirect:i=>{this.logger.error("Redirect received. Not supported."),this.unregistered(),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(i),this.waitingToggle(!1)},onReject:i=>{if(i.message.statusCode===423){if(!i.message.hasHeader("min-expires")){this.logger.error("423 response received for REGISTER without Min-Expires, dropping response"),this.unregistered(),this.waitingToggle(!1);return}this.expires=Number(i.message.getHeader("min-expires")),this.waitingToggle(!1),this.register();return}this.logger.warn(`Failed to register, status code ${i.message.statusCode}`);let n=NaN;if(i.message.statusCode===500||i.message.statusCode===503){const a=i.message.getHeader("retry-after");a&&(n=Number.parseInt(a,void 0))}this._retryAfter=isNaN(n)?void 0:n,this.unregistered(),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(i),this._retryAfter=void 0,this.waitingToggle(!1)},onTrying:i=>{e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(i)}});return Promise.resolve(s)}unregister(e={}){if(this.state===me.Terminated)throw this.stateError(),new Error("Registerer terminated. Unable to register.");if(this.disposed&&this.state!==me.Registered)throw this.stateError(),new Error("Registerer disposed. Unable to register.");if(this.waiting){this.waitingWarning();const i=new Ii("REGISTER request already in progress, waiting for final response");return Promise.reject(i)}this._state!==me.Registered&&!e.all&&this.logger.warn("Not currently registered, but sending an unregister anyway.");const t=(e.requestOptions&&e.requestOptions.extraHeaders||[]).slice();this.request.extraHeaders=t,e.all?(t.push("Contact: *"),t.push("Expires: 0")):t.push("Contact: "+this.generateContactHeader(0)),this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.registrationTimer!==void 0&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),this.waitingToggle(!0);const s=this.userAgent.userAgentCore.register(this.request,{onAccept:i=>{this._contacts=i.message.getHeaders("contact"),this.unregistered(),e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(i),this.waitingToggle(!1)},onProgress:i=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(i)},onRedirect:i=>{this.logger.error("Unregister redirected. Not currently supported."),this.unregistered(),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(i),this.waitingToggle(!1)},onReject:i=>{this.logger.error(`Unregister rejected with status code ${i.message.statusCode}`),this.unregistered(),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(i),this.waitingToggle(!1)},onTrying:i=>{e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(i)}});return Promise.resolve(s)}clearTimers(){this.registrationTimer!==void 0&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),this.registrationExpiredTimer!==void 0&&(clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=void 0)}generateContactHeader(e){let t=this.userAgent.contact.toString({register:!0});return this.options.regId&&this.options.instanceId&&(t+=";reg-id="+this.options.regId,t+=';+sip.instance="<urn:uuid:'+this.options.instanceId+'>"'),this.options.extraContactHeaderParams&&this.options.extraContactHeaderParams.forEach(s=>{t+=";"+s}),t+=";expires="+e,t}registered(e){this.clearTimers(),this.registrationTimer=setTimeout(()=>{this.registrationTimer=void 0,this.register()},this.refreshFrequency/100*e*1e3),this.registrationExpiredTimer=setTimeout(()=>{this.logger.warn("Registration expired"),this.unregistered()},e*1e3),this._state!==me.Registered&&this.stateTransition(me.Registered)}unregistered(){this.clearTimers(),this._state!==me.Unregistered&&this.stateTransition(me.Unregistered)}terminated(){this.clearTimers(),this._state!==me.Terminated&&this.stateTransition(me.Terminated)}stateTransition(e){const t=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case me.Initial:e!==me.Registered&&e!==me.Unregistered&&e!==me.Terminated&&t();break;case me.Registered:e!==me.Unregistered&&e!==me.Terminated&&t();break;case me.Unregistered:e!==me.Registered&&e!==me.Terminated&&t();break;case me.Terminated:t();break;default:throw new Error("Unrecognized state.")}this._state=e,this.logger.log(`Registration transitioned to state ${this._state}`),this._stateEventEmitter.emit(this._state),e===me.Terminated&&this.dispose()}get waiting(){return this._waiting}get waitingChange(){return this._waitingEventEmitter}waitingToggle(e){if(this._waiting===e)throw new Error(`Invalid waiting transition from ${this._waiting} to ${e}`);this._waiting=e,this.logger.log(`Waiting toggled to ${this._waiting}`),this._waitingEventEmitter.emit(this._waiting)}waitingWarning(){let e="An attempt was made to send a REGISTER request while a prior one was still in progress.";e+=" RFC 3261 requires UAs MUST NOT send a new registration until they have received a final response",e+=" from the registrar for the previous one or the previous REGISTER request has timed out.",e+=" Note that if the transport disconnects, you still must wait for the prior request to time out before",e+=" sending a new REGISTER request or alternatively dispose of the current Registerer and create a new Registerer.",this.logger.warn(e)}stateError(){let t=`An attempt was made to send a REGISTER request when the Registerer ${this.state===me.Terminated?"is in 'Terminated' state":"has been disposed"}.`;t+=" The Registerer transitions to 'Terminated' when Registerer.dispose() is called.",t+=" Perhaps you called UserAgent.stop() which dipsoses of all Registerers?",this.logger.error(t)}}wt.defaultExpires=600,wt.defaultRefreshFrequency=99;var fe;(function(r){r.Initial="Initial",r.NotifyWait="NotifyWait",r.Pending="Pending",r.Active="Active",r.Terminated="Terminated"})(fe=fe||(fe={}));var ee;(function(r){r.Connecting="Connecting",r.Connected="Connected",r.Disconnecting="Disconnecting",r.Disconnected="Disconnected"})(ee=ee||(ee={}));var je;(function(r){r.Started="Started",r.Stopped="Stopped"})(je=je||(je={}));class ke{constructor(){this._dataLength=0,this._bufferLength=0,this._state=new Int32Array(4),this._buffer=new ArrayBuffer(68),this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this._buffer,0,17),this.start()}static hashStr(e,t=!1){return this.onePassHasher.start().appendStr(e).end(t)}static hashAsciiStr(e,t=!1){return this.onePassHasher.start().appendAsciiStr(e).end(t)}static _hex(e){const t=ke.hexChars,s=ke.hexOut;let i,n,a,o;for(o=0;o<4;o+=1)for(n=o*8,i=e[o],a=0;a<8;a+=2)s[n+1+a]=t.charAt(i&15),i>>>=4,s[n+0+a]=t.charAt(i&15),i>>>=4;return s.join("")}static _md5cycle(e,t){let s=e[0],i=e[1],n=e[2],a=e[3];s+=(i&n|~i&a)+t[0]-680876936|0,s=(s<<7|s>>>25)+i|0,a+=(s&i|~s&n)+t[1]-389564586|0,a=(a<<12|a>>>20)+s|0,n+=(a&s|~a&i)+t[2]+606105819|0,n=(n<<17|n>>>15)+a|0,i+=(n&a|~n&s)+t[3]-1044525330|0,i=(i<<22|i>>>10)+n|0,s+=(i&n|~i&a)+t[4]-176418897|0,s=(s<<7|s>>>25)+i|0,a+=(s&i|~s&n)+t[5]+1200080426|0,a=(a<<12|a>>>20)+s|0,n+=(a&s|~a&i)+t[6]-1473231341|0,n=(n<<17|n>>>15)+a|0,i+=(n&a|~n&s)+t[7]-45705983|0,i=(i<<22|i>>>10)+n|0,s+=(i&n|~i&a)+t[8]+1770035416|0,s=(s<<7|s>>>25)+i|0,a+=(s&i|~s&n)+t[9]-1958414417|0,a=(a<<12|a>>>20)+s|0,n+=(a&s|~a&i)+t[10]-42063|0,n=(n<<17|n>>>15)+a|0,i+=(n&a|~n&s)+t[11]-1990404162|0,i=(i<<22|i>>>10)+n|0,s+=(i&n|~i&a)+t[12]+1804603682|0,s=(s<<7|s>>>25)+i|0,a+=(s&i|~s&n)+t[13]-40341101|0,a=(a<<12|a>>>20)+s|0,n+=(a&s|~a&i)+t[14]-1502002290|0,n=(n<<17|n>>>15)+a|0,i+=(n&a|~n&s)+t[15]+1236535329|0,i=(i<<22|i>>>10)+n|0,s+=(i&a|n&~a)+t[1]-165796510|0,s=(s<<5|s>>>27)+i|0,a+=(s&n|i&~n)+t[6]-1069501632|0,a=(a<<9|a>>>23)+s|0,n+=(a&i|s&~i)+t[11]+643717713|0,n=(n<<14|n>>>18)+a|0,i+=(n&s|a&~s)+t[0]-373897302|0,i=(i<<20|i>>>12)+n|0,s+=(i&a|n&~a)+t[5]-701558691|0,s=(s<<5|s>>>27)+i|0,a+=(s&n|i&~n)+t[10]+38016083|0,a=(a<<9|a>>>23)+s|0,n+=(a&i|s&~i)+t[15]-660478335|0,n=(n<<14|n>>>18)+a|0,i+=(n&s|a&~s)+t[4]-405537848|0,i=(i<<20|i>>>12)+n|0,s+=(i&a|n&~a)+t[9]+568446438|0,s=(s<<5|s>>>27)+i|0,a+=(s&n|i&~n)+t[14]-1019803690|0,a=(a<<9|a>>>23)+s|0,n+=(a&i|s&~i)+t[3]-187363961|0,n=(n<<14|n>>>18)+a|0,i+=(n&s|a&~s)+t[8]+1163531501|0,i=(i<<20|i>>>12)+n|0,s+=(i&a|n&~a)+t[13]-1444681467|0,s=(s<<5|s>>>27)+i|0,a+=(s&n|i&~n)+t[2]-51403784|0,a=(a<<9|a>>>23)+s|0,n+=(a&i|s&~i)+t[7]+1735328473|0,n=(n<<14|n>>>18)+a|0,i+=(n&s|a&~s)+t[12]-1926607734|0,i=(i<<20|i>>>12)+n|0,s+=(i^n^a)+t[5]-378558|0,s=(s<<4|s>>>28)+i|0,a+=(s^i^n)+t[8]-2022574463|0,a=(a<<11|a>>>21)+s|0,n+=(a^s^i)+t[11]+1839030562|0,n=(n<<16|n>>>16)+a|0,i+=(n^a^s)+t[14]-35309556|0,i=(i<<23|i>>>9)+n|0,s+=(i^n^a)+t[1]-1530992060|0,s=(s<<4|s>>>28)+i|0,a+=(s^i^n)+t[4]+1272893353|0,a=(a<<11|a>>>21)+s|0,n+=(a^s^i)+t[7]-155497632|0,n=(n<<16|n>>>16)+a|0,i+=(n^a^s)+t[10]-1094730640|0,i=(i<<23|i>>>9)+n|0,s+=(i^n^a)+t[13]+681279174|0,s=(s<<4|s>>>28)+i|0,a+=(s^i^n)+t[0]-358537222|0,a=(a<<11|a>>>21)+s|0,n+=(a^s^i)+t[3]-722521979|0,n=(n<<16|n>>>16)+a|0,i+=(n^a^s)+t[6]+76029189|0,i=(i<<23|i>>>9)+n|0,s+=(i^n^a)+t[9]-640364487|0,s=(s<<4|s>>>28)+i|0,a+=(s^i^n)+t[12]-421815835|0,a=(a<<11|a>>>21)+s|0,n+=(a^s^i)+t[15]+530742520|0,n=(n<<16|n>>>16)+a|0,i+=(n^a^s)+t[2]-995338651|0,i=(i<<23|i>>>9)+n|0,s+=(n^(i|~a))+t[0]-198630844|0,s=(s<<6|s>>>26)+i|0,a+=(i^(s|~n))+t[7]+1126891415|0,a=(a<<10|a>>>22)+s|0,n+=(s^(a|~i))+t[14]-1416354905|0,n=(n<<15|n>>>17)+a|0,i+=(a^(n|~s))+t[5]-57434055|0,i=(i<<21|i>>>11)+n|0,s+=(n^(i|~a))+t[12]+1700485571|0,s=(s<<6|s>>>26)+i|0,a+=(i^(s|~n))+t[3]-1894986606|0,a=(a<<10|a>>>22)+s|0,n+=(s^(a|~i))+t[10]-1051523|0,n=(n<<15|n>>>17)+a|0,i+=(a^(n|~s))+t[1]-2054922799|0,i=(i<<21|i>>>11)+n|0,s+=(n^(i|~a))+t[8]+1873313359|0,s=(s<<6|s>>>26)+i|0,a+=(i^(s|~n))+t[15]-30611744|0,a=(a<<10|a>>>22)+s|0,n+=(s^(a|~i))+t[6]-1560198380|0,n=(n<<15|n>>>17)+a|0,i+=(a^(n|~s))+t[13]+1309151649|0,i=(i<<21|i>>>11)+n|0,s+=(n^(i|~a))+t[4]-145523070|0,s=(s<<6|s>>>26)+i|0,a+=(i^(s|~n))+t[11]-1120210379|0,a=(a<<10|a>>>22)+s|0,n+=(s^(a|~i))+t[2]+718787259|0,n=(n<<15|n>>>17)+a|0,i+=(a^(n|~s))+t[9]-343485551|0,i=(i<<21|i>>>11)+n|0,e[0]=s+e[0]|0,e[1]=i+e[1]|0,e[2]=n+e[2]|0,e[3]=a+e[3]|0}start(){return this._dataLength=0,this._bufferLength=0,this._state.set(ke.stateIdentity),this}appendStr(e){const t=this._buffer8,s=this._buffer32;let i=this._bufferLength,n,a;for(a=0;a<e.length;a+=1){if(n=e.charCodeAt(a),n<128)t[i++]=n;else if(n<2048)t[i++]=(n>>>6)+192,t[i++]=n&63|128;else if(n<55296||n>56319)t[i++]=(n>>>12)+224,t[i++]=n>>>6&63|128,t[i++]=n&63|128;else{if(n=(n-55296)*1024+(e.charCodeAt(++a)-56320)+65536,n>1114111)throw new Error("Unicode standard supports code points up to U+10FFFF");t[i++]=(n>>>18)+240,t[i++]=n>>>12&63|128,t[i++]=n>>>6&63|128,t[i++]=n&63|128}i>=64&&(this._dataLength+=64,ke._md5cycle(this._state,s),i-=64,s[0]=s[16])}return this._bufferLength=i,this}appendAsciiStr(e){const t=this._buffer8,s=this._buffer32;let i=this._bufferLength,n,a=0;for(;;){for(n=Math.min(e.length-a,64-i);n--;)t[i++]=e.charCodeAt(a++);if(i<64)break;this._dataLength+=64,ke._md5cycle(this._state,s),i=0}return this._bufferLength=i,this}appendByteArray(e){const t=this._buffer8,s=this._buffer32;let i=this._bufferLength,n,a=0;for(;;){for(n=Math.min(e.length-a,64-i);n--;)t[i++]=e[a++];if(i<64)break;this._dataLength+=64,ke._md5cycle(this._state,s),i=0}return this._bufferLength=i,this}getState(){const e=this,t=e._state;return{buffer:String.fromCharCode.apply(null,e._buffer8),buflen:e._bufferLength,length:e._dataLength,state:[t[0],t[1],t[2],t[3]]}}setState(e){const t=e.buffer,s=e.state,i=this._state;let n;for(this._dataLength=e.length,this._bufferLength=e.buflen,i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],n=0;n<t.length;n+=1)this._buffer8[n]=t.charCodeAt(n)}end(e=!1){const t=this._bufferLength,s=this._buffer8,i=this._buffer32,n=(t>>2)+1;let a;if(this._dataLength+=t,s[t]=128,s[t+1]=s[t+2]=s[t+3]=0,i.set(ke.buffer32Identity.subarray(n),n),t>55&&(ke._md5cycle(this._state,i),i.set(ke.buffer32Identity)),a=this._dataLength*8,a<=4294967295)i[14]=a;else{const o=a.toString(16).match(/(.*?)(.{0,8})$/);if(o===null)return;const d=parseInt(o[2],16),c=parseInt(o[1],16)||0;i[14]=d,i[15]=c}return ke._md5cycle(this._state,i),e?this._state:ke._hex(this._state)}}ke.stateIdentity=new Int32Array([1732584193,-271733879,-1732584194,271733878]),ke.buffer32Identity=new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),ke.hexChars="0123456789abcdef",ke.hexOut=[],ke.onePassHasher=new ke,ke.hashStr("hello")!=="5d41402abc4b2a76b9719d911017c592"&&console.error("Md5 self test failed.");function Kt(r){return ke.hashStr(r)}class J0{constructor(e,t,s,i){this.logger=e.getLogger("sipjs.digestauthentication"),this.username=s,this.password=i,this.ha1=t,this.nc=0,this.ncHex="00000000"}authenticate(e,t,s){if(this.algorithm=t.algorithm,this.realm=t.realm,this.nonce=t.nonce,this.opaque=t.opaque,this.stale=t.stale,this.algorithm){if(this.algorithm!=="MD5")return this.logger.warn("challenge with Digest algorithm different than 'MD5', authentication aborted"),!1}else this.algorithm="MD5";if(!this.realm)return this.logger.warn("challenge without Digest realm, authentication aborted"),!1;if(!this.nonce)return this.logger.warn("challenge without Digest nonce, authentication aborted"),!1;if(t.qop)if(t.qop.indexOf("auth")>-1)this.qop="auth";else if(t.qop.indexOf("auth-int")>-1)this.qop="auth-int";else return this.logger.warn("challenge without Digest qop different than 'auth' or 'auth-int', authentication aborted"),!1;else this.qop=void 0;return this.method=e.method,this.uri=e.ruri,this.cnonce=or(12),this.nc+=1,this.updateNcHex(),this.nc===4294967296&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(s),!0}toString(){const e=[];if(!this.response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this.algorithm),e.push('username="'+this.username+'"'),e.push('realm="'+this.realm+'"'),e.push('nonce="'+this.nonce+'"'),e.push('uri="'+this.uri+'"'),e.push('response="'+this.response+'"'),this.opaque&&e.push('opaque="'+this.opaque+'"'),this.qop&&(e.push("qop="+this.qop),e.push('cnonce="'+this.cnonce+'"'),e.push("nc="+this.ncHex)),"Digest "+e.join(", ")}updateNcHex(){const e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e}calculateResponse(e){let t,s;t=this.ha1,(t===""||t===void 0)&&(t=Kt(this.username+":"+this.realm+":"+this.password)),this.qop==="auth"?(s=Kt(this.method+":"+this.uri),this.response=Kt(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+s)):this.qop==="auth-int"?(s=Kt(this.method+":"+this.uri+":"+Kt(e||"")),this.response=Kt(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+s)):this.qop===void 0&&(s=Kt(this.method+":"+this.uri),this.response=Kt(t+":"+this.nonce+":"+s))}}var Ne;(function(r){r[r.error=0]="error",r[r.warn=1]="warn",r[r.log=2]="log",r[r.debug=3]="debug"})(Ne=Ne||(Ne={}));class Fa{constructor(e,t,s){this.logger=e,this.category=t,this.label=s}error(e){this.genericLog(Ne.error,e)}warn(e){this.genericLog(Ne.warn,e)}log(e){this.genericLog(Ne.log,e)}debug(e){this.genericLog(Ne.debug,e)}genericLog(e,t){this.logger.genericLog(e,this.category,this.label,t)}get level(){return this.logger.level}set level(e){this.logger.level=e}}class Q0{constructor(){this.builtinEnabled=!0,this._level=Ne.log,this.loggers={},this.logger=this.getLogger("sip:loggerfactory")}get level(){return this._level}set level(e){e>=0&&e<=3?this._level=e:e>3?this._level=3:Ne.hasOwnProperty(e)?this._level=e:this.logger.error("invalid 'level' parameter value: "+JSON.stringify(e))}get connector(){return this._connector}set connector(e){e?typeof e=="function"?this._connector=e:this.logger.error("invalid 'connector' parameter value: "+JSON.stringify(e)):this._connector=void 0}getLogger(e,t){if(t&&this.level===3)return new Fa(this,e,t);if(this.loggers[e])return this.loggers[e];{const s=new Fa(this,e);return this.loggers[e]=s,s}}genericLog(e,t,s,i){this.level>=e&&this.builtinEnabled&&this.print(e,t,s,i),this.connector&&this.connector(Ne[e],t,s,i)}print(e,t,s,i){if(typeof i=="string"){const n=[new Date,t];s&&n.push(s),i=n.concat(i).join(" | ")}switch(e){case Ne.error:console.error(i);break;case Ne.warn:console.warn(i);break;case Ne.log:console.log(i);break;case Ne.debug:console.debug(i);break}}}var hs;(function(r){function e(i,n){let a=n,o=0,d=0;if(i.substring(a,a+2).match(/(^\r\n)/))return-2;for(;o===0;){if(d=i.indexOf(`\r
165
- `,a),d===-1)return d;!i.substring(d+2,d+4).match(/(^\r\n)/)&&i.charAt(d+2).match(/(^\s+)/)?a=d+2:o=d}return o}r.getHeader=e;function t(i,n,a,o){const d=n.indexOf(":",a),c=n.substring(a,d).trim(),l=n.substring(d+1,o).trim();let g;switch(c.toLowerCase()){case"via":case"v":i.addHeader("via",l),i.getHeaders("via").length===1?(g=i.parseHeader("Via"),g&&(i.via=g,i.viaBranch=g.branch)):g=0;break;case"from":case"f":i.setHeader("from",l),g=i.parseHeader("from"),g&&(i.from=g,i.fromTag=g.getParam("tag"));break;case"to":case"t":i.setHeader("to",l),g=i.parseHeader("to"),g&&(i.to=g,i.toTag=g.getParam("tag"));break;case"record-route":if(g=Pe.parse(l,"Record_Route"),g===-1){g=void 0;break}if(!(g instanceof Array)){g=void 0;break}g.forEach(f=>{i.addHeader("record-route",l.substring(f.position,f.offset)),i.headers["Record-Route"][i.getHeaders("record-route").length-1].parsed=f.parsed});break;case"call-id":case"i":i.setHeader("call-id",l),g=i.parseHeader("call-id"),g&&(i.callId=l);break;case"contact":case"m":if(g=Pe.parse(l,"Contact"),g===-1){g=void 0;break}if(!(g instanceof Array)){g=void 0;break}g.forEach(f=>{i.addHeader("contact",l.substring(f.position,f.offset)),i.headers.Contact[i.getHeaders("contact").length-1].parsed=f.parsed});break;case"content-length":case"l":i.setHeader("content-length",l),g=i.parseHeader("content-length");break;case"content-type":case"c":i.setHeader("content-type",l),g=i.parseHeader("content-type");break;case"cseq":i.setHeader("cseq",l),g=i.parseHeader("cseq"),g&&(i.cseq=g.value),i instanceof Gt&&(i.method=g.method);break;case"max-forwards":i.setHeader("max-forwards",l),g=i.parseHeader("max-forwards");break;case"www-authenticate":i.setHeader("www-authenticate",l),g=i.parseHeader("www-authenticate");break;case"proxy-authenticate":i.setHeader("proxy-authenticate",l),g=i.parseHeader("proxy-authenticate");break;case"refer-to":case"r":i.setHeader("refer-to",l),g=i.parseHeader("refer-to"),g&&(i.referTo=g);break;default:i.addHeader(c.toLowerCase(),l),g=0}return g===void 0?{error:"error parsing header '"+c+"'"}:!0}r.parseHeader=t;function s(i,n){let a=0,o=i.indexOf(`\r
166
- `);if(o===-1){n.warn("no CRLF found, not a SIP message, discarded");return}const d=i.substring(0,o),c=Pe.parse(d,"Request_Response");let l;if(c===-1){n.warn('error parsing first line of SIP message: "'+d+'"');return}else c.status_code?(l=new Gt,l.statusCode=c.status_code,l.reasonPhrase=c.reason_phrase):(l=new yr,l.method=c.method,l.ruri=c.uri);l.data=i,a=o+2;let g;for(;;){if(o=e(i,a),o===-2){g=a+2;break}else if(o===-1){n.error("malformed message");return}const f=t(l,i,a,o);if(f&&f!==!0){n.error(f.error);return}a=o+2}return l.hasHeader("content-length")?l.body=i.substr(g,Number(l.getHeader("content-length"))):l.body=i.substring(g),l}r.parseMessage=s})(hs=hs||(hs={}));function ka(r,e){const t=`\r
167
- `;if(e.statusCode<100||e.statusCode>699)throw new TypeError("Invalid statusCode: "+e.statusCode);const s=e.reasonPhrase?e.reasonPhrase:cs(e.statusCode);let i="SIP/2.0 "+e.statusCode+" "+s+t;e.statusCode>=100&&e.statusCode<200,e.statusCode;const n="From: "+r.getHeader("From")+t,a="Call-ID: "+r.callId+t,o="CSeq: "+r.cseq+" "+r.method+t,d=r.getHeaders("via").reduce((y,w)=>y+"Via: "+w+t,"");let c="To: "+r.getHeader("to");if(e.statusCode>100&&!r.parseHeader("to").hasParam("tag")){let y=e.toTag;y||(y=ls()),c+=";tag="+y}c+=t;let l="";e.supported&&(l="Supported: "+e.supported.join(", ")+t);let g="";e.userAgent&&(g="User-Agent: "+e.userAgent+t);let f="";return e.extraHeaders&&(f=e.extraHeaders.reduce((y,w)=>y+w.trim()+t,"")),i+=d,i+=n,i+=c,i+=o,i+=a,i+=l,i+=g,i+=f,e.body?(i+="Content-Type: "+e.body.contentType+t,i+="Content-Length: "+qr(e.body.content)+t+t,i+=e.body.content):i+="Content-Length: 0"+t+t,{message:i}}class Oi extends ar{constructor(e){super(e||"Unspecified transport error.")}}class Ba{constructor(e,t,s,i,n){this._transport=e,this._user=t,this._id=s,this._state=i,this.listeners=new Array,this.logger=t.loggerFactory.getLogger(n,s),this.logger.debug(`Constructing ${this.typeToString()} with id ${this.id}.`)}dispose(){this.logger.debug(`Destroyed ${this.typeToString()} with id ${this.id}.`)}get id(){return this._id}get kind(){throw new Error("Invalid kind.")}get state(){return this._state}get transport(){return this._transport}addStateChangeListener(e,t){const s=()=>{this.removeStateChangeListener(s),e()};(t==null?void 0:t.once)===!0?this.listeners.push(s):this.listeners.push(e)}notifyStateChangeListeners(){this.listeners.slice().forEach(e=>e())}removeStateChangeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}logTransportError(e,t){this.logger.error(e.message),this.logger.error(`Transport error occurred in ${this.typeToString()} with id ${this.id}.`),this.logger.error(t)}send(e){return this.transport.send(e).catch(t=>{if(t instanceof Oi)throw this.onTransportError(t),t;let s;throw t&&typeof t.message=="string"?s=new Oi(t.message):s=new Oi,this.onTransportError(s),s})}setState(e){this.logger.debug(`State change to "${e}" on ${this.typeToString()} with id ${this.id}.`),this._state=e,this._user.onStateChange&&this._user.onStateChange(e),this.notifyStateChangeListeners()}typeToString(){return"UnknownType"}}class Ia extends Ba{constructor(e,t,s,i,n){super(t,s,e.viaBranch,i,n),this._request=e,this.user=s}get request(){return this._request}}var k;(function(r){r.Accepted="Accepted",r.Calling="Calling",r.Completed="Completed",r.Confirmed="Confirmed",r.Proceeding="Proceeding",r.Terminated="Terminated",r.Trying="Trying"})(k=k||(k={}));class Ke extends Ia{constructor(e,t,s){super(e,t,s,k.Proceeding,"sip.transaction.ist")}dispose(){this.stopProgressExtensionTimer(),this.H&&(clearTimeout(this.H),this.H=void 0),this.I&&(clearTimeout(this.I),this.I=void 0),this.L&&(clearTimeout(this.L),this.L=void 0),super.dispose()}get kind(){return"ist"}receiveRequest(e){switch(this.state){case k.Proceeding:if(e.method===K.INVITE){this.lastProvisionalResponse&&this.send(this.lastProvisionalResponse).catch(s=>{this.logTransportError(s,"Failed to send retransmission of provisional response.")});return}break;case k.Accepted:if(e.method===K.INVITE)return;break;case k.Completed:if(e.method===K.INVITE){if(!this.lastFinalResponse)throw new Error("Last final response undefined.");this.send(this.lastFinalResponse).catch(s=>{this.logTransportError(s,"Failed to send retransmission of final response.")});return}if(e.method===K.ACK){this.stateTransition(k.Confirmed);return}break;case k.Confirmed:if(e.method===K.INVITE||e.method===K.ACK)return;break;case k.Terminated:if(e.method===K.INVITE||e.method===K.ACK)return;break;default:throw new Error(`Invalid state ${this.state}`)}const t=`INVITE server transaction received unexpected ${e.method} request while in state ${this.state}.`;this.logger.warn(t)}receiveResponse(e,t){if(e<100||e>699)throw new Error(`Invalid status code ${e}`);switch(this.state){case k.Proceeding:if(e>=100&&e<=199){this.lastProvisionalResponse=t,e>100&&this.startProgressExtensionTimer(),this.send(t).catch(i=>{this.logTransportError(i,"Failed to send 1xx response.")});return}if(e>=200&&e<=299){this.lastFinalResponse=t,this.stateTransition(k.Accepted),this.send(t).catch(i=>{this.logTransportError(i,"Failed to send 2xx response.")});return}if(e>=300&&e<=699){this.lastFinalResponse=t,this.stateTransition(k.Completed),this.send(t).catch(i=>{this.logTransportError(i,"Failed to send non-2xx final response.")});return}break;case k.Accepted:if(e>=200&&e<=299){this.send(t).catch(i=>{this.logTransportError(i,"Failed to send 2xx response.")});return}break;case k.Completed:break;case k.Confirmed:break;case k.Terminated:break;default:throw new Error(`Invalid state ${this.state}`)}const s=`INVITE server transaction received unexpected ${e} response from TU while in state ${this.state}.`;throw this.logger.error(s),new Error(s)}retransmitAcceptedResponse(){this.state===k.Accepted&&this.lastFinalResponse&&this.send(this.lastFinalResponse).catch(e=>{this.logTransportError(e,"Failed to send 2xx response.")})}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e)}typeToString(){return"INVITE server transaction"}stateTransition(e){const t=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case k.Proceeding:t();break;case k.Accepted:case k.Completed:this.state!==k.Proceeding&&t();break;case k.Confirmed:this.state!==k.Completed&&t();break;case k.Terminated:this.state!==k.Accepted&&this.state!==k.Completed&&this.state!==k.Confirmed&&t();break;default:t()}this.stopProgressExtensionTimer(),e===k.Accepted&&(this.L=setTimeout(()=>this.timerL(),Oe.TIMER_L)),e===k.Completed&&(this.H=setTimeout(()=>this.timerH(),Oe.TIMER_H)),e===k.Confirmed&&(this.I=setTimeout(()=>this.timerI(),Oe.TIMER_I)),e===k.Terminated&&this.dispose(),this.setState(e)}startProgressExtensionTimer(){this.progressExtensionTimer===void 0&&(this.progressExtensionTimer=setInterval(()=>{if(this.logger.debug(`Progress extension timer expired for INVITE server transaction ${this.id}.`),!this.lastProvisionalResponse)throw new Error("Last provisional response undefined.");this.send(this.lastProvisionalResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of provisional response.")})},Oe.PROVISIONAL_RESPONSE_INTERVAL))}stopProgressExtensionTimer(){this.progressExtensionTimer!==void 0&&(clearInterval(this.progressExtensionTimer),this.progressExtensionTimer=void 0)}timerG(){}timerH(){this.logger.debug(`Timer H expired for INVITE server transaction ${this.id}.`),this.state===k.Completed&&(this.logger.warn("ACK to negative final response was never received, terminating transaction."),this.stateTransition(k.Terminated))}timerI(){this.logger.debug(`Timer I expired for INVITE server transaction ${this.id}.`),this.stateTransition(k.Terminated)}timerL(){this.logger.debug(`Timer L expired for INVITE server transaction ${this.id}.`),this.state===k.Accepted&&this.stateTransition(k.Terminated)}}class us extends Ba{constructor(e,t,s,i,n){super(t,s,us.makeId(e),i,n),this._request=e,this.user=s,e.setViaHeader(this.id,t.protocol)}static makeId(e){if(e.method==="CANCEL"){if(!e.branch)throw new Error("Outgoing CANCEL request without a branch.");return e.branch}else return"z9hG4bK"+Math.floor(Math.random()*1e7)}get request(){return this._request}onRequestTimeout(){this.user.onRequestTimeout&&this.user.onRequestTimeout()}}class Qe extends us{constructor(e,t,s){super(e,t,s,k.Trying,"sip.transaction.nict"),this.F=setTimeout(()=>this.timerF(),Oe.TIMER_F),this.send(e.toString()).catch(i=>{this.logTransportError(i,"Failed to send initial outgoing request.")})}dispose(){this.F&&(clearTimeout(this.F),this.F=void 0),this.K&&(clearTimeout(this.K),this.K=void 0),super.dispose()}get kind(){return"nict"}receiveResponse(e){const t=e.statusCode;if(!t||t<100||t>699)throw new Error(`Invalid status code ${t}`);switch(this.state){case k.Trying:if(t>=100&&t<=199){this.stateTransition(k.Proceeding),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=200&&t<=699){if(this.stateTransition(k.Completed),t===408){this.onRequestTimeout();return}this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case k.Proceeding:if(t>=100&&t<=199&&this.user.receiveResponse)return this.user.receiveResponse(e);if(t>=200&&t<=699){if(this.stateTransition(k.Completed),t===408){this.onRequestTimeout();return}this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case k.Completed:return;case k.Terminated:return;default:throw new Error(`Invalid state ${this.state}`)}const s=`Non-INVITE client transaction received unexpected ${t} response while in state ${this.state}.`;this.logger.warn(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(k.Terminated,!0)}typeToString(){return"non-INVITE client transaction"}stateTransition(e,t=!1){const s=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case k.Trying:s();break;case k.Proceeding:this.state!==k.Trying&&s();break;case k.Completed:this.state!==k.Trying&&this.state!==k.Proceeding&&s();break;case k.Terminated:this.state!==k.Trying&&this.state!==k.Proceeding&&this.state!==k.Completed&&(t||s());break;default:s()}e===k.Completed&&(this.F&&(clearTimeout(this.F),this.F=void 0),this.K=setTimeout(()=>this.timerK(),Oe.TIMER_K)),e===k.Terminated&&this.dispose(),this.setState(e)}timerF(){this.logger.debug(`Timer F expired for non-INVITE client transaction ${this.id}.`),(this.state===k.Trying||this.state===k.Proceeding)&&(this.onRequestTimeout(),this.stateTransition(k.Terminated))}timerK(){this.state===k.Completed&&this.stateTransition(k.Terminated)}}class wr{constructor(e,t){this.core=e,this.dialogState=t,this.core.dialogs.set(this.id,this)}static initialDialogStateForUserAgentClient(e,t){const i=t.getHeaders("record-route").reverse(),n=t.parseHeader("contact");if(!n)throw new Error("Contact undefined.");if(!(n instanceof ze))throw new Error("Contact not instance of NameAddrHeader.");const a=n.uri,o=e.cseq,d=void 0,c=e.callId,l=e.fromTag,g=t.toTag;if(!c)throw new Error("Call id undefined.");if(!l)throw new Error("From tag undefined.");if(!g)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");const f=e.from.uri,y=e.to.uri;if(!t.statusCode)throw new Error("Incoming response status code undefined.");const w=t.statusCode<200;return{id:c+l+g,early:w,callId:c,localTag:l,remoteTag:g,localSequenceNumber:o,remoteSequenceNumber:d,localURI:f,remoteURI:y,remoteTarget:a,routeSet:i,secure:!1}}static initialDialogStateForUserAgentServer(e,t,s=!1){const n=e.getHeaders("record-route"),a=e.parseHeader("contact");if(!a)throw new Error("Contact undefined.");if(!(a instanceof ze))throw new Error("Contact not instance of NameAddrHeader.");const o=a.uri,d=e.cseq,c=void 0,l=e.callId,g=t,f=e.fromTag,y=e.from.uri,w=e.to.uri;return{id:l+g+f,early:s,callId:l,localTag:g,remoteTag:f,localSequenceNumber:c,remoteSequenceNumber:d,localURI:w,remoteURI:y,remoteTarget:o,routeSet:n,secure:!1}}dispose(){this.core.dialogs.delete(this.id)}get id(){return this.dialogState.id}get early(){return this.dialogState.early}get callId(){return this.dialogState.callId}get localTag(){return this.dialogState.localTag}get remoteTag(){return this.dialogState.remoteTag}get localSequenceNumber(){return this.dialogState.localSequenceNumber}get remoteSequenceNumber(){return this.dialogState.remoteSequenceNumber}get localURI(){return this.dialogState.localURI}get remoteURI(){return this.dialogState.remoteURI}get remoteTarget(){return this.dialogState.remoteTarget}get routeSet(){return this.dialogState.routeSet}get secure(){return this.dialogState.secure}get userAgentCore(){return this.core}confirm(){this.dialogState.early=!1}receiveRequest(e){if(e.method!==K.ACK){if(this.remoteSequenceNumber){if(e.cseq<=this.remoteSequenceNumber)throw new Error("Out of sequence in dialog request. Did you forget to call sequenceGuard()?");this.dialogState.remoteSequenceNumber=e.cseq}this.remoteSequenceNumber||(this.dialogState.remoteSequenceNumber=e.cseq)}}recomputeRouteSet(e){this.dialogState.routeSet=e.getHeaders("record-route").reverse()}createOutgoingRequestMessage(e,t){const s=this.remoteURI,i=this.remoteTag,n=this.localURI,a=this.localTag,o=this.callId;let d;t&&t.cseq?d=t.cseq:this.dialogState.localSequenceNumber?d=this.dialogState.localSequenceNumber+=1:d=this.dialogState.localSequenceNumber=1;const c=this.remoteTarget,l=this.routeSet,g=t&&t.extraHeaders,f=t&&t.body;return this.userAgentCore.makeOutgoingRequestMessage(e,c,n,s,{callId:o,cseq:d,fromTag:a,toTag:i,routeSet:l},g,f)}incrementLocalSequenceNumber(){if(!this.dialogState.localSequenceNumber)throw new Error("Local sequence number undefined.");this.dialogState.localSequenceNumber+=1}sequenceGuard(e){return e.method===K.ACK?!0:this.remoteSequenceNumber&&e.cseq<=this.remoteSequenceNumber?(this.core.replyStateless(e,{statusCode:500}),!1):!0}}class Zt extends us{constructor(e,t,s){super(e,t,s,k.Calling,"sip.transaction.ict"),this.ackRetransmissionCache=new Map,this.B=setTimeout(()=>this.timerB(),Oe.TIMER_B),this.send(e.toString()).catch(i=>{this.logTransportError(i,"Failed to send initial outgoing request.")})}dispose(){this.B&&(clearTimeout(this.B),this.B=void 0),this.D&&(clearTimeout(this.D),this.D=void 0),this.M&&(clearTimeout(this.M),this.M=void 0),super.dispose()}get kind(){return"ict"}ackResponse(e){const t=e.toTag;if(!t)throw new Error("To tag undefined.");const s="z9hG4bK"+Math.floor(Math.random()*1e7);e.setViaHeader(s,this.transport.protocol),this.ackRetransmissionCache.set(t,e),this.send(e.toString()).catch(i=>{this.logTransportError(i,"Failed to send ACK to 2xx response.")})}receiveResponse(e){const t=e.statusCode;if(!t||t<100||t>699)throw new Error(`Invalid status code ${t}`);switch(this.state){case k.Calling:if(t>=100&&t<=199){this.stateTransition(k.Proceeding),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=200&&t<=299){this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(k.Accepted),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=300&&t<=699){this.stateTransition(k.Completed),this.ack(e),this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case k.Proceeding:if(t>=100&&t<=199){this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=200&&t<=299){this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(k.Accepted),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=300&&t<=699){this.stateTransition(k.Completed),this.ack(e),this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case k.Accepted:if(t>=200&&t<=299){if(!this.ackRetransmissionCache.has(e.toTag)){this.ackRetransmissionCache.set(e.toTag,void 0),this.user.receiveResponse&&this.user.receiveResponse(e);return}const i=this.ackRetransmissionCache.get(e.toTag);if(i){this.send(i.toString()).catch(n=>{this.logTransportError(n,"Failed to send retransmission of ACK to 2xx response.")});return}return}break;case k.Completed:if(t>=300&&t<=699){this.ack(e);return}break;case k.Terminated:break;default:throw new Error(`Invalid state ${this.state}`)}const s=`Received unexpected ${t} response while in state ${this.state}.`;this.logger.warn(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(k.Terminated,!0)}typeToString(){return"INVITE client transaction"}ack(e){const t=this.request.ruri,s=this.request.callId,i=this.request.cseq,n=this.request.getHeader("from"),a=e.getHeader("to"),o=this.request.getHeader("via"),d=this.request.getHeader("route");if(!n)throw new Error("From undefined.");if(!a)throw new Error("To undefined.");if(!o)throw new Error("Via undefined.");let c=`ACK ${t} SIP/2.0\r
168
- `;d&&(c+=`Route: ${d}\r
169
- `),c+=`Via: ${o}\r
170
- `,c+=`To: ${a}\r
171
- `,c+=`From: ${n}\r
172
- `,c+=`Call-ID: ${s}\r
173
- `,c+=`CSeq: ${i} ACK\r
174
- `,c+=`Max-Forwards: 70\r
175
- `,c+=`Content-Length: 0\r
34
+ `;this.server_transaction.receiveResponse(n,T,t,d)}reply_sl(n=null,s=null){const o=this.getHeaders("via");if(!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(s&&typeof s!="string"&&!(s instanceof String))throw new TypeError(`Invalid reason_phrase: ${s}`);s=s||Ae.REASON_PHRASE[n]||"";let c=`SIP/2.0 ${n} ${s}\r
35
+ `;for(const d of o)c+=`Via: ${d}\r
36
+ `;let t=this.getHeader("To");if(!this.to_tag&&n>100?t+=`;tag=${me.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(t+=`;tag=${this.to_tag}`),c+=`To: ${t}\r
37
+ `,c+=`From: ${this.getHeader("From")}\r
38
+ `,c+=`Call-ID: ${this.call_id}\r
39
+ `,c+=`CSeq: ${this.cseq} ${this.method}\r
40
+ `,this.ua.configuration.extra_headers)for(const d of this.ua.configuration.extra_headers)c+=`${d.trim()}\r
41
+ `;c+=`Content-Length: 0\r
176
42
  \r
177
- `,this.send(c).catch(l=>{this.logTransportError(l,"Failed to send ACK to non-2xx response.")})}stateTransition(e,t=!1){const s=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case k.Calling:s();break;case k.Proceeding:this.state!==k.Calling&&s();break;case k.Accepted:case k.Completed:this.state!==k.Calling&&this.state!==k.Proceeding&&s();break;case k.Terminated:this.state!==k.Calling&&this.state!==k.Accepted&&this.state!==k.Completed&&(t||s());break;default:s()}this.B&&(clearTimeout(this.B),this.B=void 0),k.Proceeding,e===k.Completed&&(this.D=setTimeout(()=>this.timerD(),Oe.TIMER_D)),e===k.Accepted&&(this.M=setTimeout(()=>this.timerM(),Oe.TIMER_M)),e===k.Terminated&&this.dispose(),this.setState(e)}timerA(){}timerB(){this.logger.debug(`Timer B expired for INVITE client transaction ${this.id}.`),this.state===k.Calling&&(this.onRequestTimeout(),this.stateTransition(k.Terminated))}timerD(){this.logger.debug(`Timer D expired for INVITE client transaction ${this.id}.`),this.state===k.Completed&&this.stateTransition(k.Terminated)}timerM(){this.logger.debug(`Timer M expired for INVITE client transaction ${this.id}.`),this.state===k.Accepted&&this.stateTransition(k.Terminated)}}class Ue{constructor(e,t,s,i){this.transactionConstructor=e,this.core=t,this.message=s,this.delegate=i,this.challenged=!1,this.stale=!1,this.logger=this.loggerFactory.getLogger("sip.user-agent-client"),this.init()}dispose(){this.transaction.dispose()}get loggerFactory(){return this.core.loggerFactory}get transaction(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction}cancel(e,t={}){if(!this.transaction)throw new Error("Transaction undefined.");if(!this.message.to)throw new Error("To undefined.");if(!this.message.from)throw new Error("From undefined.");const s=this.core.makeOutgoingRequestMessage(K.CANCEL,this.message.ruri,this.message.from.uri,this.message.to.uri,{toTag:this.message.toTag,fromTag:this.message.fromTag,callId:this.message.callId,cseq:this.message.cseq},t.extraHeaders);return s.branch=this.message.branch,this.message.headers.Route&&(s.headers.Route=this.message.headers.Route),e&&s.setHeader("Reason",e),this.transaction.state===k.Proceeding?new Ue(Qe,this.core,s):this.transaction.addStateChangeListener(()=>{this.transaction&&this.transaction.state===k.Proceeding&&new Ue(Qe,this.core,s)},{once:!0}),s}authenticationGuard(e,t){const s=e.statusCode;if(!s)throw new Error("Response status code undefined.");if(s!==401&&s!==407)return!0;let i,n;if(s===401?(i=e.parseHeader("www-authenticate"),n="authorization"):(i=e.parseHeader("proxy-authenticate"),n="proxy-authorization"),!i)return this.logger.warn(s+" with wrong or missing challenge, cannot authenticate"),!0;if(this.challenged&&(this.stale||i.stale!==!0))return this.logger.warn(s+" apparently in authentication loop, cannot authenticate"),!0;if(!this.credentials&&(this.credentials=this.core.configuration.authenticationFactory(),!this.credentials))return this.logger.warn("Unable to obtain credentials, cannot authenticate"),!0;if(!this.credentials.authenticate(this.message,i))return!0;this.challenged=!0,i.stale&&(this.stale=!0);let a=this.message.cseq+=1;return t&&t.localSequenceNumber&&(t.incrementLocalSequenceNumber(),a=this.message.cseq=t.localSequenceNumber),this.message.setHeader("cseq",a+" "+this.message.method),this.message.setHeader(n,this.credentials.toString()),this.init(),!1}onRequestTimeout(){this.logger.warn("User agent client request timed out. Generating internal 408 Request Timeout.");const e=new Gt;e.statusCode=408,e.reasonPhrase="Request Timeout",this.receiveResponse(e)}onTransportError(e){this.logger.error(e.message),this.logger.error("User agent client request transport error. Generating internal 503 Service Unavailable.");const t=new Gt;t.statusCode=503,t.reasonPhrase="Service Unavailable",this.receiveResponse(t)}receiveResponse(e){if(!this.authenticationGuard(e))return;const t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e});break;case/^2[0-9]{2}$/.test(t):this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e});break;case/^3[0-9]{2}$/.test(t):this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error(`Invalid status code ${t}`)}}init(){const e={loggerFactory:this.loggerFactory,onRequestTimeout:()=>this.onRequestTimeout(),onStateChange:i=>{i===k.Terminated&&(this.core.userAgentClients.delete(s),t===this._transaction&&this.dispose())},onTransportError:i=>this.onTransportError(i),receiveResponse:i=>this.receiveResponse(i)},t=new this.transactionConstructor(this.message,this.core.transport,e);this._transaction=t;const s=t.id+t.request.method;this.core.userAgentClients.set(s,this)}}class ec extends Ue{constructor(e,t,s){const i=e.createOutgoingRequestMessage(K.BYE,s);super(Qe,e.userAgentCore,i,t),e.dispose()}}class et extends Ia{constructor(e,t,s){super(e,t,s,k.Trying,"sip.transaction.nist")}dispose(){this.J&&(clearTimeout(this.J),this.J=void 0),super.dispose()}get kind(){return"nist"}receiveRequest(e){switch(this.state){case k.Trying:break;case k.Proceeding:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch(t=>{this.logTransportError(t,"Failed to send retransmission of provisional response.")});break;case k.Completed:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch(t=>{this.logTransportError(t,"Failed to send retransmission of final response.")});break;case k.Terminated:break;default:throw new Error(`Invalid state ${this.state}`)}}receiveResponse(e,t){if(e<100||e>699)throw new Error(`Invalid status code ${e}`);if(e>100&&e<=199)throw new Error("Provisional response other than 100 not allowed.");switch(this.state){case k.Trying:if(this.lastResponse=t,e>=100&&e<200){this.stateTransition(k.Proceeding),this.send(t).catch(i=>{this.logTransportError(i,"Failed to send provisional response.")});return}if(e>=200&&e<=699){this.stateTransition(k.Completed),this.send(t).catch(i=>{this.logTransportError(i,"Failed to send final response.")});return}break;case k.Proceeding:if(this.lastResponse=t,e>=200&&e<=699){this.stateTransition(k.Completed),this.send(t).catch(i=>{this.logTransportError(i,"Failed to send final response.")});return}break;case k.Completed:return;case k.Terminated:break;default:throw new Error(`Invalid state ${this.state}`)}const s=`Non-INVITE server transaction received unexpected ${e} response from TU while in state ${this.state}.`;throw this.logger.error(s),new Error(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(k.Terminated,!0)}typeToString(){return"non-INVITE server transaction"}stateTransition(e,t=!1){const s=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case k.Trying:s();break;case k.Proceeding:this.state!==k.Trying&&s();break;case k.Completed:this.state!==k.Trying&&this.state!==k.Proceeding&&s();break;case k.Terminated:this.state!==k.Proceeding&&this.state!==k.Completed&&(t||s());break;default:s()}e===k.Completed&&(this.J=setTimeout(()=>this.timerJ(),Oe.TIMER_J)),e===k.Terminated&&this.dispose(),this.setState(e)}timerJ(){this.logger.debug(`Timer J expired for NON-INVITE server transaction ${this.id}.`),this.state===k.Completed&&this.stateTransition(k.Terminated)}}class Et{constructor(e,t,s,i){this.transactionConstructor=e,this.core=t,this.message=s,this.delegate=i,this.logger=this.loggerFactory.getLogger("sip.user-agent-server"),this.toTag=s.toTag?s.toTag:ls(),this.init()}dispose(){this.transaction.dispose()}get loggerFactory(){return this.core.loggerFactory}get transaction(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction}accept(e={statusCode:200}){if(!this.acceptable)throw new Vt(`${this.message.method} not acceptable in state ${this.transaction.state}.`);const t=e.statusCode;if(t<200||t>299)throw new TypeError(`Invalid statusCode: ${t}`);return this.reply(e)}progress(e={statusCode:180}){if(!this.progressable)throw new Vt(`${this.message.method} not progressable in state ${this.transaction.state}.`);const t=e.statusCode;if(t<101||t>199)throw new TypeError(`Invalid statusCode: ${t}`);return this.reply(e)}redirect(e,t={statusCode:302}){if(!this.redirectable)throw new Vt(`${this.message.method} not redirectable in state ${this.transaction.state}.`);const s=t.statusCode;if(s<300||s>399)throw new TypeError(`Invalid statusCode: ${s}`);const i=new Array;return e.forEach(a=>i.push(`Contact: ${a.toString()}`)),t.extraHeaders=(t.extraHeaders||[]).concat(i),this.reply(t)}reject(e={statusCode:480}){if(!this.rejectable)throw new Vt(`${this.message.method} not rejectable in state ${this.transaction.state}.`);const t=e.statusCode;if(t<400||t>699)throw new TypeError(`Invalid statusCode: ${t}`);return this.reply(e)}trying(e){if(!this.tryingable)throw new Vt(`${this.message.method} not tryingable in state ${this.transaction.state}.`);return this.reply({statusCode:100})}receiveCancel(e){this.delegate&&this.delegate.onCancel&&this.delegate.onCancel(e)}get acceptable(){if(this.transaction instanceof Ke)return this.transaction.state===k.Proceeding||this.transaction.state===k.Accepted;if(this.transaction instanceof et)return this.transaction.state===k.Trying||this.transaction.state===k.Proceeding;throw new Error("Unknown transaction type.")}get progressable(){if(this.transaction instanceof Ke)return this.transaction.state===k.Proceeding;if(this.transaction instanceof et)return!1;throw new Error("Unknown transaction type.")}get redirectable(){if(this.transaction instanceof Ke)return this.transaction.state===k.Proceeding;if(this.transaction instanceof et)return this.transaction.state===k.Trying||this.transaction.state===k.Proceeding;throw new Error("Unknown transaction type.")}get rejectable(){if(this.transaction instanceof Ke)return this.transaction.state===k.Proceeding;if(this.transaction instanceof et)return this.transaction.state===k.Trying||this.transaction.state===k.Proceeding;throw new Error("Unknown transaction type.")}get tryingable(){if(this.transaction instanceof Ke)return this.transaction.state===k.Proceeding;if(this.transaction instanceof et)return this.transaction.state===k.Trying;throw new Error("Unknown transaction type.")}reply(e){!e.toTag&&e.statusCode!==100&&(e.toTag=this.toTag),e.userAgent=e.userAgent||this.core.configuration.userAgentHeaderFieldValue,e.supported=e.supported||this.core.configuration.supportedOptionTagsResponse;const t=ka(this.message,e);return this.transaction.receiveResponse(e.statusCode,t.message),t}init(){const e={loggerFactory:this.loggerFactory,onStateChange:i=>{i===k.Terminated&&(this.core.userAgentServers.delete(s),this.dispose())},onTransportError:i=>{this.logger.error(i.message),this.delegate&&this.delegate.onTransportError?this.delegate.onTransportError(i):this.logger.error("User agent server response transport error.")}},t=new this.transactionConstructor(this.message,this.core.transport,e);this._transaction=t;const s=t.id;this.core.userAgentServers.set(t.id,this)}}class tc extends Et{constructor(e,t,s){super(et,e.userAgentCore,t,s)}}class rc extends Ue{constructor(e,t,s){const i=e.createOutgoingRequestMessage(K.INFO,s);super(Qe,e.userAgentCore,i,t)}}class sc extends Et{constructor(e,t,s){super(et,e.userAgentCore,t,s)}}class Pa extends Ue{constructor(e,t,s){super(Qe,e,t,s)}}class Ha extends Et{constructor(e,t,s){super(et,e,t,s)}}class ic extends Ue{constructor(e,t,s){const i=e.createOutgoingRequestMessage(K.NOTIFY,s);super(Qe,e.userAgentCore,i,t)}}function nc(r){return r.userAgentCore!==void 0}class fs extends Et{constructor(e,t,s){const i=nc(e)?e.userAgentCore:e;super(et,i,t,s)}}class ac extends Ue{constructor(e,t,s){const i=e.createOutgoingRequestMessage(K.PRACK,s);super(Qe,e.userAgentCore,i,t),e.signalingStateTransition(i)}}class oc extends Et{constructor(e,t,s){super(et,e.userAgentCore,t,s),e.signalingStateTransition(t),this.dialog=e}accept(e={statusCode:200}){return e.body&&this.dialog.signalingStateTransition(e.body),super.accept(e)}}class cc extends Ue{constructor(e,t,s){const i=e.createOutgoingRequestMessage(K.INVITE,s);super(Zt,e.userAgentCore,i,t),this.delegate=t,e.signalingStateTransition(i),e.reinviteUserAgentClient=this,this.dialog=e}receiveResponse(e){if(!this.authenticationGuard(e,this.dialog))return;const t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:this.dialog,prack:s=>{throw new Error("Unimplemented.")}});break;case/^2[0-9]{2}$/.test(t):this.dialog.signalingStateTransition(e),this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e,session:this.dialog,ack:s=>this.dialog.ack(s)});break;case/^3[0-9]{2}$/.test(t):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error(`Invalid status code ${t}`)}}}class lc extends Et{constructor(e,t,s){super(Ke,e.userAgentCore,t,s),e.reinviteUserAgentServer=this,this.dialog=e}accept(e={statusCode:200}){e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(this.dialog.routeSet.map(n=>`Record-Route: ${n}`));const t=super.accept(e),s=this.dialog,i=Object.assign(Object.assign({},t),{session:s});return e.body&&this.dialog.signalingStateTransition(e.body),this.dialog.reConfirm(),i}progress(e={statusCode:180}){const t=super.progress(e),s=this.dialog,i=Object.assign(Object.assign({},t),{session:s});return e.body&&this.dialog.signalingStateTransition(e.body),i}redirect(e,t={statusCode:302}){throw this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,new Error("Unimplemented.")}reject(e={statusCode:488}){return this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,super.reject(e)}}class dc extends Ue{constructor(e,t,s){const i=e.createOutgoingRequestMessage(K.REFER,s);super(Qe,e.userAgentCore,i,t)}}function hc(r){return r.userAgentCore!==void 0}class $a extends Et{constructor(e,t,s){const i=hc(e)?e.userAgentCore:e;super(et,i,t,s)}}class gs extends wr{constructor(e,t,s,i){super(t,s),this.initialTransaction=e,this._signalingState=Y.Initial,this.ackWait=!1,this.ackProcessing=!1,this.delegate=i,e instanceof Ke&&(this.ackWait=!0),this.early||this.start2xxRetransmissionTimer(),this.signalingStateTransition(e.request),this.logger=t.loggerFactory.getLogger("sip.invite-dialog"),this.logger.log(`INVITE dialog ${this.id} constructed`)}dispose(){super.dispose(),this._signalingState=Y.Closed,this._offer=void 0,this._answer=void 0,this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.logger.log(`INVITE dialog ${this.id} destroyed`)}get sessionState(){return this.early?st.Early:this.ackWait?st.AckWait:this._signalingState===Y.Closed?st.Terminated:st.Confirmed}get signalingState(){return this._signalingState}get offer(){return this._offer}get answer(){return this._answer}confirm(){this.early&&this.start2xxRetransmissionTimer(),super.confirm()}reConfirm(){this.reinviteUserAgentServer&&this.startReInvite2xxRetransmissionTimer()}ack(e={}){this.logger.log(`INVITE dialog ${this.id} sending ACK request`);let t;if(this.reinviteUserAgentClient){if(!(this.reinviteUserAgentClient.transaction instanceof Zt))throw new Error("Transaction not instance of InviteClientTransaction.");t=this.reinviteUserAgentClient.transaction,this.reinviteUserAgentClient=void 0}else{if(!(this.initialTransaction instanceof Zt))throw new Error("Initial transaction not instance of InviteClientTransaction.");t=this.initialTransaction}const s=this.createOutgoingRequestMessage(K.ACK,{cseq:t.request.cseq,extraHeaders:e.extraHeaders,body:e.body});return t.ackResponse(s),this.signalingStateTransition(s),{message:s}}bye(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending BYE request`),this.initialTransaction instanceof Ke){if(this.early)throw new Error("UAS MUST NOT send a BYE on early dialogs.");if(this.ackWait&&this.initialTransaction.state!==k.Terminated)throw new Error("UAS MUST NOT send a BYE on a confirmed dialog until it has received an ACK for its 2xx response or until the server transaction times out.")}return new ec(this,e,t)}info(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending INFO request`),this.early)throw new Error("Dialog not confirmed.");return new rc(this,e,t)}invite(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending INVITE request`),this.early)throw new Error("Dialog not confirmed.");if(this.reinviteUserAgentClient)throw new Error("There is an ongoing re-INVITE client transaction.");if(this.reinviteUserAgentServer)throw new Error("There is an ongoing re-INVITE server transaction.");return new cc(this,e,t)}message(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending MESSAGE request`),this.early)throw new Error("Dialog not confirmed.");const s=this.createOutgoingRequestMessage(K.MESSAGE,t);return new Pa(this.core,s,e)}notify(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending NOTIFY request`),this.early)throw new Error("Dialog not confirmed.");return new ic(this,e,t)}prack(e,t){return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`),new ac(this,e,t)}refer(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending REFER request`),this.early)throw new Error("Dialog not confirmed.");return new dc(this,e,t)}receiveRequest(e){if(this.logger.log(`INVITE dialog ${this.id} received ${e.method} request`),e.method===K.ACK){if(this.ackWait){if(this.initialTransaction instanceof Zt){this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);return}if(this.initialTransaction.request.cseq!==e.cseq){this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);return}this.ackWait=!1}else{if(!this.reinviteUserAgentServer){this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);return}if(this.reinviteUserAgentServer.transaction.request.cseq!==e.cseq){this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);return}this.reinviteUserAgentServer=void 0}if(this.signalingStateTransition(e),this.delegate&&this.delegate.onAck){const t=this.delegate.onAck({message:e});t instanceof Promise&&(this.ackProcessing=!0,t.then(()=>this.ackProcessing=!1).catch(()=>this.ackProcessing=!1))}return}if(!this.sequenceGuard(e)){this.logger.log(`INVITE dialog ${this.id} rejected out of order ${e.method} request.`);return}if(super.receiveRequest(e),e.method===K.INVITE){const t=()=>{const n=this.ackWait?"waiting for initial ACK":"processing initial ACK";this.logger.warn(`INVITE dialog ${this.id} received re-INVITE while ${n}`);let a="RFC 5407 suggests the following to avoid this race condition... ";a+=" Note: Implementation issues are outside the scope of this document,",a+=" but the following tip is provided for avoiding race conditions of",a+=" this type. The caller can delay sending re-INVITE F6 for some period",a+=" of time (2 seconds, perhaps), after which the caller can reasonably",a+=" assume that its ACK has been received. Implementors can decouple the",a+=" actions of the user (e.g., pressing the hold button) from the actions",a+=" of the protocol (the sending of re-INVITE F6), so that the UA can",a+=" behave like this. In this case, it is the implementor's choice as to",a+=" how long to wait. In most cases, such an implementation may be",a+=" useful to prevent the type of race condition shown in this section.",a+=" This document expresses no preference about whether or not they",a+=" should wait for an ACK to be delivered. After considering the impact",a+=" on user experience, implementors should decide whether or not to wait",a+=" for a while, because the user experience depends on the",a+=" implementation and has no direct bearing on protocol behavior.",this.logger.warn(a)},i=[`Retry-After: ${Math.floor(Math.random()*10)+1}`];if(this.ackProcessing){this.core.replyStateless(e,{statusCode:500,extraHeaders:i}),t();return}if(this.ackWait&&this.signalingState!==Y.Stable){this.core.replyStateless(e,{statusCode:500,extraHeaders:i}),t();return}if(this.reinviteUserAgentServer){this.core.replyStateless(e,{statusCode:500,extraHeaders:i});return}if(this.reinviteUserAgentClient){this.core.replyStateless(e,{statusCode:491});return}}if(e.method===K.INVITE){const t=e.parseHeader("contact");if(!t)throw new Error("Contact undefined.");if(!(t instanceof ze))throw new Error("Contact not instance of NameAddrHeader.");this.dialogState.remoteTarget=t.uri}switch(e.method){case K.BYE:{const t=new tc(this,e);this.delegate&&this.delegate.onBye?this.delegate.onBye(t):t.accept(),this.dispose()}break;case K.INFO:{const t=new sc(this,e);this.delegate&&this.delegate.onInfo?this.delegate.onInfo(t):t.reject({statusCode:469,extraHeaders:["Recv-Info:"]})}break;case K.INVITE:{const t=new lc(this,e);this.signalingStateTransition(e),this.delegate&&this.delegate.onInvite?this.delegate.onInvite(t):t.reject({statusCode:488})}break;case K.MESSAGE:{const t=new Ha(this.core,e);this.delegate&&this.delegate.onMessage?this.delegate.onMessage(t):t.accept()}break;case K.NOTIFY:{const t=new fs(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(t):t.accept()}break;case K.PRACK:{const t=new oc(this,e);this.delegate&&this.delegate.onPrack?this.delegate.onPrack(t):t.accept()}break;case K.REFER:{const t=new $a(this,e);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(t):t.reject()}break;default:this.logger.log(`INVITE dialog ${this.id} received unimplemented ${e.method} request`),this.core.replyStateless(e,{statusCode:501});break}}reliableSequenceGuard(e){const t=e.statusCode;if(!t)throw new Error("Status code undefined");if(t>100&&t<200){const s=e.getHeader("require"),i=e.getHeader("rseq"),n=s&&s.includes("100rel")&&i?Number(i):void 0;if(n){if(this.rseq&&this.rseq+1!==n)return!1;this.rseq=this.rseq?this.rseq+1:n}}return!0}signalingStateRollback(){(this._signalingState===Y.HaveLocalOffer||this.signalingState===Y.HaveRemoteOffer)&&this._rollbackOffer&&this._rollbackAnswer&&(this._signalingState=Y.Stable,this._offer=this._rollbackOffer,this._answer=this._rollbackAnswer)}signalingStateTransition(e){const t=Ur(e);if(!(!t||t.contentDisposition!=="session")){if(this._signalingState===Y.Stable&&(this._rollbackOffer=this._offer,this._rollbackAnswer=this._answer),e instanceof yr)switch(this._signalingState){case Y.Initial:case Y.Stable:this._signalingState=Y.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case Y.HaveLocalOffer:this._signalingState=Y.Stable,this._answer=t;break;case Y.HaveRemoteOffer:break;case Y.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof Gt)switch(this._signalingState){case Y.Initial:case Y.Stable:this._signalingState=Y.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case Y.HaveLocalOffer:this._signalingState=Y.Stable,this._answer=t;break;case Y.HaveRemoteOffer:break;case Y.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof cr)switch(this._signalingState){case Y.Initial:case Y.Stable:this._signalingState=Y.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case Y.HaveLocalOffer:break;case Y.HaveRemoteOffer:this._signalingState=Y.Stable,this._answer=t;break;case Y.Closed:break;default:throw new Error("Unexpected signaling state.")}if(Aa(e))switch(this._signalingState){case Y.Initial:case Y.Stable:this._signalingState=Y.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case Y.HaveLocalOffer:break;case Y.HaveRemoteOffer:this._signalingState=Y.Stable,this._answer=t;break;case Y.Closed:break;default:throw new Error("Unexpected signaling state.")}}}start2xxRetransmissionTimer(){if(this.initialTransaction instanceof Ke){const e=this.initialTransaction;let t=Oe.T1;const s=()=>{if(!this.ackWait){this.invite2xxTimer=void 0;return}this.logger.log("No ACK for 2xx response received, attempting retransmission"),e.retransmitAcceptedResponse(),t=Math.min(t*2,Oe.T2),this.invite2xxTimer=setTimeout(s,t)};this.invite2xxTimer=setTimeout(s,t);const i=()=>{e.state===k.Terminated&&(e.removeStateChangeListener(i),this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.ackWait&&(this.delegate&&this.delegate.onAckTimeout?this.delegate.onAckTimeout():this.bye()))};e.addStateChangeListener(i)}}startReInvite2xxRetransmissionTimer(){if(this.reinviteUserAgentServer&&this.reinviteUserAgentServer.transaction instanceof Ke){const e=this.reinviteUserAgentServer.transaction;let t=Oe.T1;const s=()=>{if(!this.reinviteUserAgentServer){this.invite2xxTimer=void 0;return}this.logger.log("No ACK for 2xx response received, attempting retransmission"),e.retransmitAcceptedResponse(),t=Math.min(t*2,Oe.T2),this.invite2xxTimer=setTimeout(s,t)};this.invite2xxTimer=setTimeout(s,t);const i=()=>{e.state===k.Terminated&&(e.removeStateChangeListener(i),this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.reinviteUserAgentServer)};e.addStateChangeListener(i)}}}class uc extends Ue{constructor(e,t,s){super(Zt,e,t,s),this.confirmedDialogAcks=new Map,this.confirmedDialogs=new Map,this.earlyDialogs=new Map,this.delegate=s}dispose(){this.earlyDialogs.forEach(e=>e.dispose()),this.earlyDialogs.clear(),super.dispose()}onTransportError(e){if(this.transaction.state===k.Calling)return super.onTransportError(e);this.logger.error(e.message),this.logger.error("User agent client request transport error while sending ACK.")}receiveResponse(e){if(!this.authenticationGuard(e))return;const t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});return;case/^1[0-9]{2}$/.test(t):{if(!e.toTag){this.logger.warn("Non-100 1xx INVITE response received without a to tag, dropping.");return}if(!e.parseHeader("contact")){this.logger.error("Non-100 1xx INVITE response received without a Contact header field, dropping.");return}const i=wr.initialDialogStateForUserAgentClient(this.message,e);let n=this.earlyDialogs.get(i.id);if(!n){const o=this.transaction;if(!(o instanceof Zt))throw new Error("Transaction not instance of InviteClientTransaction.");n=new gs(o,this.core,i),this.earlyDialogs.set(n.id,n)}if(!n.reliableSequenceGuard(e)){this.logger.warn("1xx INVITE reliable response received out of order or is a retransmission, dropping.");return}(n.signalingState===Y.Initial||n.signalingState===Y.HaveLocalOffer)&&n.signalingStateTransition(e);const a=n;this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:a,prack:o=>a.prack(void 0,o)})}return;case/^2[0-9]{2}$/.test(t):{if(!e.toTag){this.logger.error("2xx INVITE response received without a to tag, dropping.");return}if(!e.parseHeader("contact")){this.logger.error("2xx INVITE response received without a Contact header field, dropping.");return}const i=wr.initialDialogStateForUserAgentClient(this.message,e);let n=this.confirmedDialogs.get(i.id);if(n){const o=this.confirmedDialogAcks.get(i.id);if(o){const d=this.transaction;if(!(d instanceof Zt))throw new Error("Client transaction not instance of InviteClientTransaction.");d.ackResponse(o.message)}return}if(n=this.earlyDialogs.get(i.id),n)n.confirm(),n.recomputeRouteSet(e),this.earlyDialogs.delete(n.id),this.confirmedDialogs.set(n.id,n);else{const o=this.transaction;if(!(o instanceof Zt))throw new Error("Transaction not instance of InviteClientTransaction.");n=new gs(o,this.core,i),this.confirmedDialogs.set(n.id,n)}(n.signalingState===Y.Initial||n.signalingState===Y.HaveLocalOffer)&&n.signalingStateTransition(e);const a=n;if(this.delegate&&this.delegate.onAccept)this.delegate.onAccept({message:e,session:a,ack:o=>{const d=a.ack(o);return this.confirmedDialogAcks.set(a.id,d),d}});else{const o=a.ack();this.confirmedDialogAcks.set(a.id,o)}}return;case/^3[0-9]{2}$/.test(t):this.earlyDialogs.forEach(s=>s.dispose()),this.earlyDialogs.clear(),this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});return;case/^[4-6][0-9]{2}$/.test(t):this.earlyDialogs.forEach(s=>s.dispose()),this.earlyDialogs.clear(),this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});return;default:throw new Error(`Invalid status code ${t}`)}}}class Ni extends Et{constructor(e,t,s){super(Ke,e,t,s),this.core=e}dispose(){this.earlyDialog&&this.earlyDialog.dispose(),super.dispose()}accept(e={statusCode:200}){if(!this.acceptable)throw new Vt(`${this.message.method} not acceptable in state ${this.transaction.state}.`);if(!this.confirmedDialog)if(this.earlyDialog)this.earlyDialog.confirm(),this.confirmedDialog=this.earlyDialog,this.earlyDialog=void 0;else{const d=this.transaction;if(!(d instanceof Ke))throw new Error("Transaction not instance of InviteClientTransaction.");const c=wr.initialDialogStateForUserAgentServer(this.message,this.toTag);this.confirmedDialog=new gs(d,this.core,c)}const t=this.message.getHeaders("record-route").map(d=>`Record-Route: ${d}`),s=`Contact: ${this.core.configuration.contact.toString()}`,i="Allow: "+zt.toString();if(!e.body){if(this.confirmedDialog.signalingState===Y.Stable)e.body=this.confirmedDialog.answer;else if(this.confirmedDialog.signalingState===Y.Initial||this.confirmedDialog.signalingState===Y.HaveRemoteOffer)throw new Error("Response must have a body.")}e.statusCode=e.statusCode||200,e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(t),e.extraHeaders.push(i),e.extraHeaders.push(s);const n=super.accept(e),a=this.confirmedDialog,o=Object.assign(Object.assign({},n),{session:a});return e.body&&this.confirmedDialog.signalingState!==Y.Stable&&this.confirmedDialog.signalingStateTransition(e.body),o}progress(e={statusCode:180}){if(!this.progressable)throw new Vt(`${this.message.method} not progressable in state ${this.transaction.state}.`);if(!this.earlyDialog){const o=this.transaction;if(!(o instanceof Ke))throw new Error("Transaction not instance of InviteClientTransaction.");const d=wr.initialDialogStateForUserAgentServer(this.message,this.toTag,!0);this.earlyDialog=new gs(o,this.core,d)}const t=this.message.getHeaders("record-route").map(o=>`Record-Route: ${o}`),s=`Contact: ${this.core.configuration.contact}`;e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(t),e.extraHeaders.push(s);const i=super.progress(e),n=this.earlyDialog,a=Object.assign(Object.assign({},i),{session:n});return e.body&&this.earlyDialog.signalingState!==Y.Stable&&this.earlyDialog.signalingStateTransition(e.body),a}redirect(e,t={statusCode:302}){return super.redirect(e,t)}reject(e={statusCode:486}){return super.reject(e)}}class fc extends Ue{constructor(e,t,s){super(Qe,e,t,s)}}class gc extends Ue{constructor(e,t,s){super(Qe,e,t,s)}}class xc extends Et{constructor(e,t,s){super(et,e,t,s),this.core=e}}class pc extends Ue{constructor(e,t,s){const i=e.createOutgoingRequestMessage(K.SUBSCRIBE,s);super(Qe,e.userAgentCore,i,t),this.dialog=e}waitNotifyStop(){}receiveResponse(e){if(e.statusCode&&e.statusCode>=200&&e.statusCode<300){const t=e.getHeader("Expires");if(!t)this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE");else{const s=Number(t);this.dialog.subscriptionExpires>s&&(this.dialog.subscriptionExpires=s)}}e.statusCode&&e.statusCode>=400&&e.statusCode<700&&[404,405,410,416,480,481,482,483,484,485,489,501,604].includes(e.statusCode)&&this.dialog.terminate(),super.receiveResponse(e)}}class Oa extends wr{constructor(e,t,s,i,n,a){super(i,n),this.delegate=a,this._autoRefresh=!1,this._subscriptionEvent=e,this._subscriptionExpires=t,this._subscriptionExpiresInitial=t,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this._subscriptionRefresh=void 0,this._subscriptionRefreshLastSet=void 0,this._subscriptionState=s,this.logger=i.loggerFactory.getLogger("sip.subscribe-dialog"),this.logger.log(`SUBSCRIBE dialog ${this.id} constructed`)}static initialDialogStateForSubscription(e,t){const i=t.getHeaders("record-route"),n=t.parseHeader("contact");if(!n)throw new Error("Contact undefined.");if(!(n instanceof ze))throw new Error("Contact not instance of NameAddrHeader.");const a=n.uri,o=e.cseq,d=void 0,c=e.callId,l=e.fromTag,g=t.fromTag;if(!c)throw new Error("Call id undefined.");if(!l)throw new Error("From tag undefined.");if(!g)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");const f=e.from.uri,y=e.to.uri;return{id:c+l+g,early:!1,callId:c,localTag:l,remoteTag:g,localSequenceNumber:o,remoteSequenceNumber:d,localURI:f,remoteURI:y,remoteTarget:a,routeSet:i,secure:!1}}dispose(){super.dispose(),this.N&&(clearTimeout(this.N),this.N=void 0),this.refreshTimerClear(),this.logger.log(`SUBSCRIBE dialog ${this.id} destroyed`)}get autoRefresh(){return this._autoRefresh}set autoRefresh(e){this._autoRefresh=!0,this.refreshTimerSet()}get subscriptionEvent(){return this._subscriptionEvent}get subscriptionExpires(){const e=Math.floor(Date.now()/1e3)-this._subscriptionExpiresLastSet,t=this._subscriptionExpires-e;return Math.max(t,0)}set subscriptionExpires(e){if(e<0)throw new Error("Expires must be greater than or equal to zero.");if(this._subscriptionExpires=e,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this.autoRefresh){const t=this.subscriptionRefresh;(t===void 0||t>=e)&&this.refreshTimerSet()}}get subscriptionExpiresInitial(){return this._subscriptionExpiresInitial}get subscriptionRefresh(){if(this._subscriptionRefresh===void 0||this._subscriptionRefreshLastSet===void 0)return;const e=Math.floor(Date.now()/1e3)-this._subscriptionRefreshLastSet,t=this._subscriptionRefresh-e;return Math.max(t,0)}get subscriptionState(){return this._subscriptionState}receiveRequest(e){if(this.logger.log(`SUBSCRIBE dialog ${this.id} received ${e.method} request`),!this.sequenceGuard(e)){this.logger.log(`SUBSCRIBE dialog ${this.id} rejected out of order ${e.method} request.`);return}switch(super.receiveRequest(e),e.method){case K.NOTIFY:this.onNotify(e);break;default:this.logger.log(`SUBSCRIBE dialog ${this.id} received unimplemented ${e.method} request`),this.core.replyStateless(e,{statusCode:501});break}}refresh(){const e="Allow: "+zt.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: "+this.subscriptionExpiresInitial),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)}subscribe(e,t={}){var s;if(this.subscriptionState!==fe.Pending&&this.subscriptionState!==fe.Active)throw new Error(`Invalid state ${this.subscriptionState}. May only re-subscribe while in state "pending" or "active".`);this.logger.log(`SUBSCRIBE dialog ${this.id} sending SUBSCRIBE request`);const i=new pc(this,e,t);return this.N&&(clearTimeout(this.N),this.N=void 0),!((s=t.extraHeaders)===null||s===void 0)&&s.includes("Expires: 0")||(this.N=setTimeout(()=>this.timerN(),Oe.TIMER_N)),i}terminate(){this.stateTransition(fe.Terminated),this.onTerminated()}unsubscribe(){const e="Allow: "+zt.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: 0"),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)}onNotify(e){const t=e.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent){this.core.replyStateless(e,{statusCode:489});return}this.N&&(clearTimeout(this.N),this.N=void 0);const s=e.parseHeader("Subscription-State");if(!s||!s.state){this.core.replyStateless(e,{statusCode:489});return}const i=s.state,n=s.expires?Math.max(s.expires,0):void 0;switch(i){case"pending":this.stateTransition(fe.Pending,n);break;case"active":this.stateTransition(fe.Active,n);break;case"terminated":this.stateTransition(fe.Terminated,n);break;default:this.logger.warn("Unrecognized subscription state.");break}const a=new fs(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(a):a.accept()}onRefresh(e){this.delegate&&this.delegate.onRefresh&&this.delegate.onRefresh(e)}onTerminated(){this.delegate&&this.delegate.onTerminated&&this.delegate.onTerminated()}refreshTimerClear(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=void 0)}refreshTimerSet(){if(this.refreshTimerClear(),this.autoRefresh&&this.subscriptionExpires>0){const e=this.subscriptionExpires*900;this._subscriptionRefresh=Math.floor(e/1e3),this._subscriptionRefreshLastSet=Math.floor(Date.now()/1e3),this.refreshTimer=setTimeout(()=>{this.refreshTimer=void 0,this._subscriptionRefresh=void 0,this._subscriptionRefreshLastSet=void 0,this.onRefresh(this.refresh())},e)}}stateTransition(e,t){const s=()=>{this.logger.warn(`Invalid subscription state transition from ${this.subscriptionState} to ${e}`)};switch(e){case fe.Initial:s();return;case fe.NotifyWait:s();return;case fe.Pending:if(this.subscriptionState!==fe.NotifyWait&&this.subscriptionState!==fe.Pending){s();return}break;case fe.Active:if(this.subscriptionState!==fe.NotifyWait&&this.subscriptionState!==fe.Pending&&this.subscriptionState!==fe.Active){s();return}break;case fe.Terminated:if(this.subscriptionState!==fe.NotifyWait&&this.subscriptionState!==fe.Pending&&this.subscriptionState!==fe.Active){s();return}break;default:s();return}e===fe.Pending&&t&&(this.subscriptionExpires=t),e===fe.Active&&t&&(this.subscriptionExpires=t),e===fe.Terminated&&this.dispose(),this._subscriptionState=e}timerN(){this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."),this.subscriptionState!==fe.Terminated&&(this.stateTransition(fe.Terminated),this.onTerminated())}}class mc extends Ue{constructor(e,t,s){const i=t.getHeader("Event");if(!i)throw new Error("Event undefined");const n=t.getHeader("Expires");if(!n)throw new Error("Expires undefined");super(Qe,e,t,s),this.delegate=s,this.subscriberId=t.callId+t.fromTag+i,this.subscriptionExpiresRequested=this.subscriptionExpires=Number(n),this.subscriptionEvent=i,this.subscriptionState=fe.NotifyWait,this.waitNotifyStart()}dispose(){super.dispose()}onNotify(e){const t=e.message.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent){this.logger.warn("Failed to parse event."),e.reject({statusCode:489});return}const s=e.message.parseHeader("Subscription-State");if(!s||!s.state){this.logger.warn("Failed to parse subscription state."),e.reject({statusCode:489});return}const i=s.state;switch(i){case"pending":break;case"active":break;case"terminated":break;default:this.logger.warn(`Invalid subscription state ${i}`),e.reject({statusCode:489});return}if(i!=="terminated"&&!e.message.parseHeader("contact")){this.logger.warn("Failed to parse contact."),e.reject({statusCode:489});return}if(this.dialog)throw new Error("Dialog already created. This implementation only supports install of single subscriptions.");switch(this.waitNotifyStop(),this.subscriptionExpires=s.expires?Math.min(this.subscriptionExpires,Math.max(s.expires,0)):this.subscriptionExpires,i){case"pending":this.subscriptionState=fe.Pending;break;case"active":this.subscriptionState=fe.Active;break;case"terminated":this.subscriptionState=fe.Terminated;break;default:throw new Error(`Unrecognized state ${i}.`)}if(this.subscriptionState!==fe.Terminated){const n=Oa.initialDialogStateForSubscription(this.message,e.message);this.dialog=new Oa(this.subscriptionEvent,this.subscriptionExpires,this.subscriptionState,this.core,n)}if(this.delegate&&this.delegate.onNotify){const n=e,a=this.dialog;this.delegate.onNotify({request:n,subscription:a})}else e.accept()}waitNotifyStart(){this.N||(this.core.subscribers.set(this.subscriberId,this),this.N=setTimeout(()=>this.timerN(),Oe.TIMER_N))}waitNotifyStop(){this.N&&(this.core.subscribers.delete(this.subscriberId),clearTimeout(this.N),this.N=void 0)}receiveResponse(e){if(this.authenticationGuard(e)){if(e.statusCode&&e.statusCode>=200&&e.statusCode<300){const t=e.getHeader("Expires");if(!t)this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE");else{const s=Number(t);s>this.subscriptionExpiresRequested&&this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),s<this.subscriptionExpires&&(this.subscriptionExpires=s)}this.dialog&&this.dialog.subscriptionExpires>this.subscriptionExpires&&(this.dialog.subscriptionExpires=this.subscriptionExpires)}e.statusCode&&e.statusCode>=300&&e.statusCode<700&&this.waitNotifyStop(),super.receiveResponse(e)}}timerN(){this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."),this.waitNotifyStop(),this.delegate&&this.delegate.onNotifyTimeout&&this.delegate.onNotifyTimeout()}}class vc extends Et{constructor(e,t,s){super(et,e,t,s),this.core=e}}const Na=["application/sdp","application/dtmf-relay"];class yc{constructor(e,t={}){this.userAgentClients=new Map,this.userAgentServers=new Map,this.configuration=e,this.delegate=t,this.dialogs=new Map,this.subscribers=new Map,this.logger=e.loggerFactory.getLogger("sip.user-agent-core")}dispose(){this.reset()}reset(){this.dialogs.forEach(e=>e.dispose()),this.dialogs.clear(),this.subscribers.forEach(e=>e.dispose()),this.subscribers.clear(),this.userAgentClients.forEach(e=>e.dispose()),this.userAgentClients.clear(),this.userAgentServers.forEach(e=>e.dispose()),this.userAgentServers.clear()}get loggerFactory(){return this.configuration.loggerFactory}get transport(){const e=this.configuration.transportAccessor();if(!e)throw new Error("Transport undefined.");return e}invite(e,t){return new uc(this,e,t)}message(e,t){return new Pa(this,e,t)}publish(e,t){return new fc(this,e,t)}register(e,t){return new gc(this,e,t)}subscribe(e,t){return new mc(this,e,t)}request(e,t){return new Ue(Qe,this,e,t)}makeOutgoingRequestMessage(e,t,s,i,n,a,o){const d=this.configuration.sipjsId,c=this.configuration.displayName,l=this.configuration.viaForceRport,g=this.configuration.hackViaTcp,f=this.configuration.supportedOptionTags.slice();e===K.REGISTER&&f.push("path","gruu"),e===K.INVITE&&(this.configuration.contact.pubGruu||this.configuration.contact.tempGruu)&&f.push("gruu");const y=this.configuration.routeSet,w=this.configuration.userAgentHeaderFieldValue,b=this.configuration.viaHost,x=Object.assign(Object.assign({},{callIdPrefix:d,forceRport:l,fromDisplayName:c,hackViaTcp:g,optionTags:f,routeSet:y,userAgentString:w,viaHost:b}),n);return new cr(e,t,s,i,x,a,o)}receiveIncomingRequestFromTransport(e){this.receiveRequestFromTransport(e)}receiveIncomingResponseFromTransport(e){this.receiveResponseFromTransport(e)}replyStateless(e,t){const s=this.configuration.userAgentHeaderFieldValue,i=this.configuration.supportedOptionTagsResponse;t=Object.assign(Object.assign({},t),{userAgent:s,supported:i});const n=ka(e,t);return this.transport.send(n.message).catch(a=>{a instanceof Error&&this.logger.error(a.message),this.logger.error(`Transport error occurred sending stateless reply to ${e.method} request.`)}),n}receiveRequestFromTransport(e){const t=e.viaBranch,s=this.userAgentServers.get(t);if(e.method===K.ACK&&s&&s.transaction.state===k.Accepted&&s instanceof Ni){this.logger.warn(`Discarding out of dialog ACK after 2xx response sent on transaction ${t}.`);return}if(e.method===K.CANCEL){s?(this.replyStateless(e,{statusCode:200}),s.transaction instanceof Ke&&s.transaction.state===k.Proceeding&&s instanceof Ni&&s.receiveCancel(e)):this.replyStateless(e,{statusCode:481});return}if(s){s.transaction.receiveRequest(e);return}this.receiveRequest(e)}receiveRequest(e){if(!zt.includes(e.method)){const i="Allow: "+zt.toString();this.replyStateless(e,{statusCode:405,extraHeaders:[i]});return}if(!e.ruri)throw new Error("Request-URI undefined.");if(e.ruri.scheme!=="sip"){this.replyStateless(e,{statusCode:416});return}const t=e.ruri,s=i=>!!i&&i.user===t.user;if(!s(this.configuration.aor)&&!(s(this.configuration.contact.uri)||s(this.configuration.contact.pubGruu)||s(this.configuration.contact.tempGruu))){this.logger.warn("Request-URI does not point to us."),e.method!==K.ACK&&this.replyStateless(e,{statusCode:404});return}if(e.method===K.INVITE&&!e.hasHeader("Contact")){this.replyStateless(e,{statusCode:400,reasonPhrase:"Missing Contact Header"});return}if(!e.toTag){const i=e.viaBranch;if(!this.userAgentServers.has(i)&&Array.from(this.userAgentServers.values()).some(a=>a.transaction.request.fromTag===e.fromTag&&a.transaction.request.callId===e.callId&&a.transaction.request.cseq===e.cseq)){this.replyStateless(e,{statusCode:482});return}}e.toTag?this.receiveInsideDialogRequest(e):this.receiveOutsideDialogRequest(e)}receiveInsideDialogRequest(e){if(e.method===K.NOTIFY){const i=e.parseHeader("Event");if(!i||!i.event){this.replyStateless(e,{statusCode:489});return}const n=e.callId+e.toTag+i.event,a=this.subscribers.get(n);if(a){const o=new fs(this,e);a.onNotify(o);return}}const t=e.callId+e.toTag+e.fromTag,s=this.dialogs.get(t);if(s){if(e.method===K.OPTIONS){const i="Allow: "+zt.toString(),n="Accept: "+Na.toString();this.replyStateless(e,{statusCode:200,extraHeaders:[i,n]});return}s.receiveRequest(e);return}e.method!==K.ACK&&this.replyStateless(e,{statusCode:481})}receiveOutsideDialogRequest(e){switch(e.method){case K.ACK:break;case K.BYE:this.replyStateless(e,{statusCode:481});break;case K.CANCEL:throw new Error(`Unexpected out of dialog request method ${e.method}.`);case K.INFO:this.replyStateless(e,{statusCode:405});break;case K.INVITE:{const t=new Ni(this,e);this.delegate.onInvite?this.delegate.onInvite(t):t.reject()}break;case K.MESSAGE:{const t=new Ha(this,e);this.delegate.onMessage?this.delegate.onMessage(t):t.accept()}break;case K.NOTIFY:{const t=new fs(this,e);this.delegate.onNotify?this.delegate.onNotify(t):t.reject({statusCode:405})}break;case K.OPTIONS:{const t="Allow: "+zt.toString(),s="Accept: "+Na.toString();this.replyStateless(e,{statusCode:200,extraHeaders:[t,s]})}break;case K.REFER:{const t=new $a(this,e);this.delegate.onRefer?this.delegate.onRefer(t):t.reject({statusCode:405})}break;case K.REGISTER:{const t=new xc(this,e);this.delegate.onRegister?this.delegate.onRegister(t):t.reject({statusCode:405})}break;case K.SUBSCRIBE:{const t=new vc(this,e);this.delegate.onSubscribe?this.delegate.onSubscribe(t):t.reject({statusCode:480})}break;default:throw new Error(`Unexpected out of dialog request method ${e.method}.`)}}receiveResponseFromTransport(e){if(e.getHeaders("via").length>1){this.logger.warn("More than one Via header field present in the response, dropping");return}const t=e.viaBranch+e.method,s=this.userAgentClients.get(t);s?s.transaction.receiveResponse(e):this.logger.warn(`Discarding unmatched ${e.statusCode} response to ${e.method} ${t}.`)}}function wc(){return r=>!r.audio&&!r.video?Promise.resolve(new MediaStream):navigator.mediaDevices===void 0?Promise.reject(new Error("Media devices not available in insecure contexts.")):navigator.mediaDevices.getUserMedia.call(navigator.mediaDevices,r)}function Ec(){return{bundlePolicy:"balanced",certificates:void 0,iceCandidatePoolSize:0,iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all",rtcpMuxPolicy:"require"}}class Bt{constructor(e,t,s){e.debug("SessionDescriptionHandler.constructor"),this.logger=e,this.mediaStreamFactory=t,this.sessionDescriptionHandlerConfiguration=s,this._localMediaStream=new MediaStream,this._remoteMediaStream=new MediaStream,this._peerConnection=new RTCPeerConnection(s==null?void 0:s.peerConnectionConfiguration),this.initPeerConnectionEventHandlers()}get localMediaStream(){return this._localMediaStream}get remoteMediaStream(){return this._remoteMediaStream}get dataChannel(){return this._dataChannel}get peerConnection(){return this._peerConnection}get peerConnectionDelegate(){return this._peerConnectionDelegate}set peerConnectionDelegate(e){this._peerConnectionDelegate=e}static dispatchAddTrackEvent(e,t){e.dispatchEvent(new MediaStreamTrackEvent("addtrack",{track:t}))}static dispatchRemoveTrackEvent(e,t){e.dispatchEvent(new MediaStreamTrackEvent("removetrack",{track:t}))}close(){this.logger.debug("SessionDescriptionHandler.close"),this._peerConnection!==void 0&&(this._peerConnection.getReceivers().forEach(e=>{e.track&&e.track.stop()}),this._peerConnection.getSenders().forEach(e=>{e.track&&e.track.stop()}),this._dataChannel&&this._dataChannel.close(),this._peerConnection.close(),this._peerConnection=void 0)}enableReceiverTracks(e){const t=this.peerConnection;if(!t)throw new Error("Peer connection closed.");t.getReceivers().forEach(s=>{s.track&&(s.track.enabled=e)})}enableSenderTracks(e){const t=this.peerConnection;if(!t)throw new Error("Peer connection closed.");t.getSenders().forEach(s=>{s.track&&(s.track.enabled=e)})}getDescription(e,t){var s,i;if(this.logger.debug("SessionDescriptionHandler.getDescription"),this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));this.onDataChannel=e==null?void 0:e.onDataChannel;const n=(s=e==null?void 0:e.offerOptions)===null||s===void 0?void 0:s.iceRestart,a=(e==null?void 0:e.iceGatheringTimeout)===void 0?(i=this.sessionDescriptionHandlerConfiguration)===null||i===void 0?void 0:i.iceGatheringTimeout:e==null?void 0:e.iceGatheringTimeout;return this.getLocalMediaStream(e).then(()=>this.updateDirection(e)).then(()=>this.createDataChannel(e)).then(()=>this.createLocalOfferOrAnswer(e)).then(o=>this.applyModifiers(o,t)).then(o=>this.setLocalSessionDescription(o)).then(()=>this.waitForIceGatheringComplete(n,a)).then(()=>this.getLocalSessionDescription()).then(o=>({body:o.sdp,contentType:"application/sdp"})).catch(o=>{throw this.logger.error("SessionDescriptionHandler.getDescription failed - "+o),o})}hasDescription(e){return this.logger.debug("SessionDescriptionHandler.hasDescription"),e==="application/sdp"}iceGatheringComplete(){this.logger.debug("SessionDescriptionHandler.iceGatheringComplete"),this.iceGatheringCompleteTimeoutId!==void 0&&(this.logger.debug("SessionDescriptionHandler.iceGatheringComplete - clearing timeout"),clearTimeout(this.iceGatheringCompleteTimeoutId),this.iceGatheringCompleteTimeoutId=void 0),this.iceGatheringCompletePromise!==void 0&&(this.logger.debug("SessionDescriptionHandler.iceGatheringComplete - resolving promise"),this.iceGatheringCompleteResolve&&this.iceGatheringCompleteResolve(),this.iceGatheringCompletePromise=void 0,this.iceGatheringCompleteResolve=void 0,this.iceGatheringCompleteReject=void 0)}sendDtmf(e,t){if(this.logger.debug("SessionDescriptionHandler.sendDtmf"),this._peerConnection===void 0)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - peer connection closed"),!1;const s=this._peerConnection.getSenders();if(s.length===0)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - no senders"),!1;const i=s[0].dtmf;if(!i)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - no DTMF sender"),!1;const n=t==null?void 0:t.duration,a=t==null?void 0:t.interToneGap;try{i.insertDTMF(e,n,a)}catch(o){return this.logger.error(o.toString()),!1}return this.logger.log("SessionDescriptionHandler.sendDtmf sent via RTP: "+e.toString()),!0}setDescription(e,t,s){if(this.logger.debug("SessionDescriptionHandler.setDescription"),this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));this.onDataChannel=t==null?void 0:t.onDataChannel;const i=this._peerConnection.signalingState==="have-local-offer"?"answer":"offer";return this.getLocalMediaStream(t).then(()=>this.applyModifiers({sdp:e,type:i},s)).then(n=>this.setRemoteSessionDescription(n)).catch(n=>{throw this.logger.error("SessionDescriptionHandler.setDescription failed - "+n),n})}applyModifiers(e,t){return this.logger.debug("SessionDescriptionHandler.applyModifiers"),!t||t.length===0?Promise.resolve(e):t.reduce((s,i)=>s.then(i),Promise.resolve(e)).then(s=>{if(this.logger.debug("SessionDescriptionHandler.applyModifiers - modified sdp"),!s.sdp||!s.type)throw new Error("Invalid SDP.");return{sdp:s.sdp,type:s.type}})}createDataChannel(e){if(this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));if((e==null?void 0:e.dataChannel)!==!0||this._dataChannel)return Promise.resolve();switch(this._peerConnection.signalingState){case"stable":this.logger.debug("SessionDescriptionHandler.createDataChannel - creating data channel");try{return this._dataChannel=this._peerConnection.createDataChannel((e==null?void 0:e.dataChannelLabel)||"",e==null?void 0:e.dataChannelOptions),this.onDataChannel&&this.onDataChannel(this._dataChannel),Promise.resolve()}catch(t){return Promise.reject(t)}case"have-remote-offer":return Promise.resolve();case"have-local-offer":case"have-local-pranswer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}}createLocalOfferOrAnswer(e){if(this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));switch(this._peerConnection.signalingState){case"stable":return this.logger.debug("SessionDescriptionHandler.createLocalOfferOrAnswer - creating SDP offer"),this._peerConnection.createOffer(e==null?void 0:e.offerOptions);case"have-remote-offer":return this.logger.debug("SessionDescriptionHandler.createLocalOfferOrAnswer - creating SDP answer"),this._peerConnection.createAnswer(e==null?void 0:e.answerOptions);case"have-local-offer":case"have-local-pranswer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}}getLocalMediaStream(e){if(this.logger.debug("SessionDescriptionHandler.getLocalMediaStream"),this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));let t=Object.assign({},e==null?void 0:e.constraints);if(this.localMediaStreamConstraints){if(t.audio=t.audio||this.localMediaStreamConstraints.audio,t.video=t.video||this.localMediaStreamConstraints.video,JSON.stringify(this.localMediaStreamConstraints.audio)===JSON.stringify(t.audio)&&JSON.stringify(this.localMediaStreamConstraints.video)===JSON.stringify(t.video))return Promise.resolve()}else t.audio===void 0&&t.video===void 0&&(t={audio:!0});return this.localMediaStreamConstraints=t,this.mediaStreamFactory(t,this,e).then(s=>this.setLocalMediaStream(s))}setLocalMediaStream(e){if(this.logger.debug("SessionDescriptionHandler.setLocalMediaStream"),!this._peerConnection)throw new Error("Peer connection undefined.");const t=this._peerConnection,s=this._localMediaStream,i=[],n=d=>{const c=d.kind;if(c!=="audio"&&c!=="video")throw new Error(`Unknown new track kind ${c}.`);const l=t.getSenders().find(g=>g.track&&g.track.kind===c);l?i.push(new Promise(g=>{this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${c} track`),g()}).then(()=>l.replaceTrack(d).then(()=>{const g=s.getTracks().find(f=>f.kind===c);g&&(g.stop(),s.removeTrack(g),Bt.dispatchRemoveTrackEvent(s,g)),s.addTrack(d),Bt.dispatchAddTrackEvent(s,d)}).catch(g=>{throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to replace sender ${c} track`),g}))):i.push(new Promise(g=>{this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - adding sender ${c} track`),g()}).then(()=>{try{t.addTrack(d,s)}catch(g){throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${c} track`),g}s.addTrack(d),Bt.dispatchAddTrackEvent(s,d)}))},a=e.getAudioTracks();a.length&&n(a[0]);const o=e.getVideoTracks();return o.length&&n(o[0]),i.reduce((d,c)=>d.then(()=>c),Promise.resolve())}getLocalSessionDescription(){if(this.logger.debug("SessionDescriptionHandler.getLocalSessionDescription"),this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));const e=this._peerConnection.localDescription;return e?Promise.resolve(e):Promise.reject(new Error("Failed to get local session description"))}setLocalSessionDescription(e){return this.logger.debug("SessionDescriptionHandler.setLocalSessionDescription"),this._peerConnection===void 0?Promise.reject(new Error("Peer connection closed.")):this._peerConnection.setLocalDescription(e)}setRemoteSessionDescription(e){if(this.logger.debug("SessionDescriptionHandler.setRemoteSessionDescription"),this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));const t=e.sdp;let s;switch(this._peerConnection.signalingState){case"stable":s="offer";break;case"have-local-offer":s="answer";break;case"have-local-pranswer":case"have-remote-offer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}return t?this._peerConnection.setRemoteDescription({sdp:t,type:s}):(this.logger.error("SessionDescriptionHandler.setRemoteSessionDescription failed - cannot set null sdp"),Promise.reject(new Error("SDP is undefined")))}setRemoteTrack(e){this.logger.debug("SessionDescriptionHandler.setRemoteTrack");const t=this._remoteMediaStream;t.getTrackById(e.id)?this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - have remote ${e.kind} track`):e.kind==="audio"?(this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind} track`),t.getAudioTracks().forEach(s=>{s.stop(),t.removeTrack(s),Bt.dispatchRemoveTrackEvent(t,s)}),t.addTrack(e),Bt.dispatchAddTrackEvent(t,e)):e.kind==="video"&&(this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind} track`),t.getVideoTracks().forEach(s=>{s.stop(),t.removeTrack(s),Bt.dispatchRemoveTrackEvent(t,s)}),t.addTrack(e),Bt.dispatchAddTrackEvent(t,e))}updateDirection(e){if(this._peerConnection===void 0)return Promise.reject(new Error("Peer connection closed."));switch(this._peerConnection.signalingState){case"stable":this.logger.debug("SessionDescriptionHandler.updateDirection - setting offer direction");{const t=s=>{switch(s){case"inactive":return e!=null&&e.hold?"inactive":"recvonly";case"recvonly":return e!=null&&e.hold?"inactive":"recvonly";case"sendonly":return e!=null&&e.hold?"sendonly":"sendrecv";case"sendrecv":return e!=null&&e.hold?"sendonly":"sendrecv";case"stopped":return"stopped";default:throw new Error("Should never happen")}};this._peerConnection.getTransceivers().forEach(s=>{if(s.direction){const i=t(s.direction);s.direction!==i&&(s.direction=i)}})}break;case"have-remote-offer":this.logger.debug("SessionDescriptionHandler.updateDirection - setting answer direction");{const t=(()=>{const i=this._peerConnection.remoteDescription;if(!i)throw new Error("Failed to read remote offer");const n=/a=sendrecv\r\n|a=sendonly\r\n|a=recvonly\r\n|a=inactive\r\n/.exec(i.sdp);if(n)switch(n[0]){case`a=inactive\r
178
- `:return"inactive";case`a=recvonly\r
179
- `:return"recvonly";case`a=sendonly\r
180
- `:return"sendonly";case`a=sendrecv\r
181
- `:return"sendrecv";default:throw new Error("Should never happen")}return"sendrecv"})(),s=(()=>{switch(t){case"inactive":return"inactive";case"recvonly":return"sendonly";case"sendonly":return e!=null&&e.hold?"inactive":"recvonly";case"sendrecv":return e!=null&&e.hold?"sendonly":"sendrecv";default:throw new Error("Should never happen")}})();this._peerConnection.getTransceivers().forEach(i=>{i.direction&&i.direction!=="stopped"&&i.direction!==s&&(i.direction=s)})}break;case"have-local-offer":case"have-local-pranswer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}return Promise.resolve()}waitForIceGatheringComplete(e=!1,t=0){return this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete"),this._peerConnection===void 0?Promise.reject("Peer connection closed."):!e&&this._peerConnection.iceGatheringState==="complete"?(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - already complete"),Promise.resolve()):(this.iceGatheringCompletePromise!==void 0&&(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - rejecting prior waiting promise"),this.iceGatheringCompleteReject&&this.iceGatheringCompleteReject(new Error("Promise superseded.")),this.iceGatheringCompletePromise=void 0,this.iceGatheringCompleteResolve=void 0,this.iceGatheringCompleteReject=void 0),this.iceGatheringCompletePromise=new Promise((s,i)=>{this.iceGatheringCompleteResolve=s,this.iceGatheringCompleteReject=i,t>0&&(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - timeout in "+t),this.iceGatheringCompleteTimeoutId=setTimeout(()=>{this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - timeout"),this.iceGatheringComplete()},t))}),this.iceGatheringCompletePromise)}initPeerConnectionEventHandlers(){if(this.logger.debug("SessionDescriptionHandler.initPeerConnectionEventHandlers"),!this._peerConnection)throw new Error("Peer connection undefined.");const e=this._peerConnection;e.onconnectionstatechange=t=>{var s;const i=e.connectionState;this.logger.debug(`SessionDescriptionHandler.onconnectionstatechange ${i}`),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.onconnectionstatechange&&this._peerConnectionDelegate.onconnectionstatechange(t)},e.ondatachannel=t=>{var s;this.logger.debug("SessionDescriptionHandler.ondatachannel"),this._dataChannel=t.channel,this.onDataChannel&&this.onDataChannel(this._dataChannel),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.ondatachannel&&this._peerConnectionDelegate.ondatachannel(t)},e.onicecandidate=t=>{var s;this.logger.debug("SessionDescriptionHandler.onicecandidate"),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.onicecandidate&&this._peerConnectionDelegate.onicecandidate(t)},e.onicecandidateerror=t=>{var s;this.logger.debug("SessionDescriptionHandler.onicecandidateerror"),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.onicecandidateerror&&this._peerConnectionDelegate.onicecandidateerror(t)},e.oniceconnectionstatechange=t=>{var s;const i=e.iceConnectionState;this.logger.debug(`SessionDescriptionHandler.oniceconnectionstatechange ${i}`),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.oniceconnectionstatechange&&this._peerConnectionDelegate.oniceconnectionstatechange(t)},e.onicegatheringstatechange=t=>{var s;const i=e.iceGatheringState;this.logger.debug(`SessionDescriptionHandler.onicegatheringstatechange ${i}`),i==="complete"&&this.iceGatheringComplete(),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.onicegatheringstatechange&&this._peerConnectionDelegate.onicegatheringstatechange(t)},e.onnegotiationneeded=t=>{var s;this.logger.debug("SessionDescriptionHandler.onnegotiationneeded"),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.onnegotiationneeded&&this._peerConnectionDelegate.onnegotiationneeded(t)},e.onsignalingstatechange=t=>{var s;const i=e.signalingState;this.logger.debug(`SessionDescriptionHandler.onsignalingstatechange ${i}`),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.onsignalingstatechange&&this._peerConnectionDelegate.onsignalingstatechange(t)},e.ontrack=t=>{var s;const i=t.track.kind,n=t.track.enabled?"enabled":"disabled";this.logger.debug(`SessionDescriptionHandler.ontrack ${i} ${n}`),this.setRemoteTrack(t.track),!((s=this._peerConnectionDelegate)===null||s===void 0)&&s.ontrack&&this._peerConnectionDelegate.ontrack(t)}}}function bc(r){return(e,t)=>{r===void 0&&(r=wc());const i={iceGatheringTimeout:(t==null?void 0:t.iceGatheringTimeout)!==void 0?t==null?void 0:t.iceGatheringTimeout:5e3,peerConnectionConfiguration:Object.assign(Object.assign({},Ec()),t==null?void 0:t.peerConnectionConfiguration)},n=e.userAgent.getLogger("sip.SessionDescriptionHandler");return new Bt(n,r,i)}}class xs{constructor(e,t){if(this._state=ee.Disconnected,this.transitioningState=!1,this._stateEventEmitter=new jr,this.logger=e,t){const n=t,a=n==null?void 0:n.wsServers,o=n==null?void 0:n.maxReconnectionAttempts;a!==void 0&&this.logger.warn('The transport option "wsServers" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),o!==void 0&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),a&&!t.server&&(typeof a=="string"&&(t.server=a),a instanceof Array&&(t.server=a[0]))}this.configuration=Object.assign(Object.assign({},xs.defaultOptions),t);const s=this.configuration.server,i=Pe.parse(s,"absoluteURI");if(i===-1)throw this.logger.error(`Invalid WebSocket Server URL "${s}"`),new Error("Invalid WebSocket Server URL");if(!["wss","ws","udp"].includes(i.scheme))throw this.logger.error(`Invalid scheme in WebSocket Server URL "${s}"`),new Error("Invalid scheme in WebSocket Server URL");this._protocol=i.scheme.toUpperCase()}dispose(){return this.disconnect()}get protocol(){return this._protocol}get server(){return this.configuration.server}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get ws(){return this._ws}connect(){return this._connect()}disconnect(){return this._disconnect()}isConnected(){return this.state===ee.Connected}send(e){return this._send(e)}_connect(){switch(this.logger.log(`Connecting ${this.server}`),this.state){case ee.Connecting:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(ee.Connecting));if(!this.connectPromise)throw new Error("Connect promise must be defined.");return this.connectPromise;case ee.Connected:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(ee.Connecting));if(this.connectPromise)throw new Error("Connect promise must not be defined.");return Promise.resolve();case ee.Disconnecting:if(this.connectPromise)throw new Error("Connect promise must not be defined.");try{this.transitionState(ee.Connecting)}catch(t){if(t instanceof Mr)return Promise.reject(t);throw t}break;case ee.Disconnected:if(this.connectPromise)throw new Error("Connect promise must not be defined.");try{this.transitionState(ee.Connecting)}catch(t){if(t instanceof Mr)return Promise.reject(t);throw t}break;default:throw new Error("Unknown state")}let e;try{e=new WebSocket(this.server,"sip"),e.binaryType="arraybuffer",e.addEventListener("close",t=>this.onWebSocketClose(t,e)),e.addEventListener("error",t=>this.onWebSocketError(t,e)),e.addEventListener("open",t=>this.onWebSocketOpen(t,e)),e.addEventListener("message",t=>this.onWebSocketMessage(t,e)),this._ws=e}catch(t){return this._ws=void 0,this.logger.error("WebSocket construction failed."),this.logger.error(t.toString()),new Promise((s,i)=>{this.connectResolve=s,this.connectReject=i,this.transitionState(ee.Disconnected,t)})}return this.connectPromise=new Promise((t,s)=>{this.connectResolve=t,this.connectReject=s,this.connectTimeout=setTimeout(()=>{this.logger.warn("Connect timed out. Exceeded time set in configuration.connectionTimeout: "+this.configuration.connectionTimeout+"s."),e.close(1e3)},this.configuration.connectionTimeout*1e3)}),this.connectPromise}_disconnect(){switch(this.logger.log(`Disconnecting ${this.server}`),this.state){case ee.Connecting:if(this.disconnectPromise)throw new Error("Disconnect promise must not be defined.");try{this.transitionState(ee.Disconnecting)}catch(t){if(t instanceof Mr)return Promise.reject(t);throw t}break;case ee.Connected:if(this.disconnectPromise)throw new Error("Disconnect promise must not be defined.");try{this.transitionState(ee.Disconnecting)}catch(t){if(t instanceof Mr)return Promise.reject(t);throw t}break;case ee.Disconnecting:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(ee.Disconnecting));if(!this.disconnectPromise)throw new Error("Disconnect promise must be defined.");return this.disconnectPromise;case ee.Disconnected:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(ee.Disconnecting));if(this.disconnectPromise)throw new Error("Disconnect promise must not be defined.");return Promise.resolve();default:throw new Error("Unknown state")}if(!this._ws)throw new Error("WebSocket must be defined.");const e=this._ws;return this.disconnectPromise=new Promise((t,s)=>{this.disconnectResolve=t,this.disconnectReject=s;try{e.close(1e3)}catch(i){throw this.logger.error("WebSocket close failed."),this.logger.error(i.toString()),i}}),this.disconnectPromise}_send(e){if(this.configuration.traceSip===!0&&this.logger.log(`Sending WebSocket message:
43
+ `,this.transport.send(c)}}class Ca extends Tn{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var ke={OutgoingRequest:ns,InitialOutgoingInviteRequest:Vs,IncomingRequest:Sa,IncomingResponse:Ca};const Aa=pe,je=Ce(),Me=new Aa("DigestAuthentication");var va=class{constructor(n){this._credentials=n,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:{Me.warn('get() | cannot get "%s" parameter',n);return}}}authenticate({method:n,ruri:s,body:o},c,t=null){if(this._algorithm=c.algorithm,this._realm=c.realm,this._nonce=c.nonce,this._opaque=c.opaque,this._stale=c.stale,this._algorithm){if(this._algorithm!=="MD5")return Me.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Me.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Me.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Me.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Me.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(c.qop)if(c.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(c.qop.indexOf("auth")>-1)this._qop="auth";else return Me.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=n,this._uri=s,this._cnonce=t||je.createRandomToken(12),this._nc+=1;const d=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-d.length)+d,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=je.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,a;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${a}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${je.calculateMD5(o||"")}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${a}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${a}`)),Me.debug("authenticate() | response generated"),!0}toString(){const n=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return n.push(`algorithm=${this._algorithm}`),n.push(`username="${this._credentials.username}"`),n.push(`realm="${this._realm}"`),n.push(`nonce="${this._nonce}"`),n.push(`uri="${this._uri}"`),n.push(`response="${this._response}"`),this._opaque&&n.push(`opaque="${this._opaque}"`),this._qop&&(n.push(`qop=${this._qop}`),n.push(`cnonce="${this._cnonce}"`),n.push(`nc=${this._ncHex}`)),`Digest ${n.join(", ")}`}};const Ye=500;var En={T1:Ye,T2:4e3,TIMER_B:64*Ye,TIMER_D:0*Ye,TIMER_F:64*Ye,TIMER_H:64*Ye,TIMER_I:0*Ye,TIMER_J:0*Ye,TIMER_K:0*5e3,TIMER_L:64*Ye,TIMER_M:64*Ye,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Dt=Fe.EventEmitter,Ut=pe,$t=oe,Sn=ke,qe=En,Cn=new Ut("NonInviteClientTransaction"),ls=new Ut("InviteClientTransaction"),Ra=new Ut("AckClientTransaction"),An=new Ut("NonInviteServerTransaction"),is=new Ut("InviteServerTransaction"),D={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"};class Ia extends Dt{constructor(n,s,o,c){super(),this.type=D.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=s,this.request=o,this.eventHandlers=c;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(D.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},qe.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){Cn.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){Cn.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(n){const s=n.status_code;if(s<200)switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}}else switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(n),this.K=setTimeout(()=>{this.timer_K()},qe.TIMER_K);break}case D.STATUS_COMPLETED:break}}}class ba extends Dt{constructor(n,s,o,c){super(),this.type=D.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=s,this.request=o,this.eventHandlers=c,o.transaction=this;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(D.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},qe.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==D.STATUS_ACCEPTED&&(ls.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){ls.debug(`Timer M expired for transaction ${this.id}`),this.state===D.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){ls.debug(`Timer B expired for transaction ${this.id}`),this.state===D.STATUS_CALLING&&(this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){ls.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(n){const s=new Sn.OutgoingRequest($t.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",n.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},qe.TIMER_D),this.transport.send(s)}cancel(n){if(this.state!==D.STATUS_PROCEEDING)return;const s=new Sn.OutgoingRequest($t.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",this.request.getHeader("to")),n&&s.setHeader("reason",n),this.transport.send(s)}receiveResponse(n){const s=n.status_code;if(s>=100&&s<=199)switch(this.state){case D.STATUS_CALLING:{this.stateChanged(D.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_PROCEEDING:{this.eventHandlers.onReceiveResponse(n);break}}else if(s>=200&&s<=299)switch(this.state){case D.STATUS_CALLING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},qe.TIMER_M),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_ACCEPTED:{this.eventHandlers.onReceiveResponse(n);break}}else if(s>=300&&s<=699)switch(this.state){case D.STATUS_CALLING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),this.sendACK(n),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_COMPLETED:{this.sendACK(n);break}}}}class wa extends Dt{constructor(n,s,o,c){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=s,this.request=o,this.eventHandlers=c;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return D}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Ra.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class ya extends Dt{constructor(n,s,o){super(),this.type=D.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=s,this.request=o,this.last_response="",o.server_transaction=this,this.state=D.STATUS_TRYING,n.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_J(){An.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,An.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(n,s,o,c){if(n===100)switch(this.state){case D.STATUS_TRYING:{this.stateChanged(D.STATUS_PROCEEDING),this.transport.send(s)||this.onTransportError();break}case D.STATUS_PROCEEDING:{this.last_response=s,this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}}else if(n>=200&&n<=699)switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),this.last_response=s,this.J=setTimeout(()=>{this.timer_J()},qe.TIMER_J),this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}case D.STATUS_COMPLETED:break}}}class Na extends Dt{constructor(n,s,o){super(),this.type=D.INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=s,this.request=o,this.last_response="",o.server_transaction=this,this.state=D.STATUS_PROCEEDING,n.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_H(){is.debug(`Timer H expired for transaction ${this.id}`),this.state===D.STATUS_COMPLETED&&is.debug("ACK not received, dialog will be terminated"),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){is.debug(`Timer L expired for transaction ${this.id}`),this.state===D.STATUS_ACCEPTED&&(this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,is.debug(`transport error occurred, deleting transaction ${this.id}`),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(n,s,o,c){if(n>=100&&n<=199)switch(this.state){case D.STATUS_PROCEEDING:{this.transport.send(s)||this.onTransportError(),this.last_response=s;break}}if(n>100&&n<=199&&this.state===D.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},qe.PROVISIONAL_RESPONSE_INTERVAL));else if(n>=200&&n<=299)switch(this.state){case D.STATUS_PROCEEDING:this.stateChanged(D.STATUS_ACCEPTED),this.last_response=s,this.L=setTimeout(()=>{this.timer_L()},qe.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case D.STATUS_ACCEPTED:{this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}}else if(n>=300&&n<=699)switch(this.state){case D.STATUS_PROCEEDING:{this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(s)?(this.stateChanged(D.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},qe.TIMER_H),o&&o()):(this.onTransportError(),c&&c());break}}}}function Oa({_transactions:f},n){let s;switch(n.method){case $t.INVITE:{if(s=f.ist[n.via_branch],s){switch(s.state){case D.STATUS_PROCEEDING:{s.transport.send(s.last_response);break}case D.STATUS_ACCEPTED:break}return!0}break}case $t.ACK:{if(s=f.ist[n.via_branch],s){if(s.state===D.STATUS_ACCEPTED)return!1;if(s.state===D.STATUS_COMPLETED)return s.state=D.STATUS_CONFIRMED,s.I=setTimeout(()=>{s.timer_I()},qe.TIMER_I),!0}else return!1;break}case $t.CANCEL:return s=f.ist[n.via_branch],s?(n.reply_sl(200),s.state!==D.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:{if(s=f.nist[n.via_branch],s){switch(s.state){case D.STATUS_TRYING:break;case D.STATUS_PROCEEDING:case D.STATUS_COMPLETED:{s.transport.send(s.last_response);break}}return!0}break}}}var Pt={C:D,NonInviteClientTransaction:Ia,InviteClientTransaction:ba,AckClientTransaction:wa,NonInviteServerTransaction:ya,InviteServerTransaction:Na,checkTransaction:Oa};const xa=pe,vn=oe,Da=va,js=Pt,Ua=new xa("RequestSender"),Ys={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var At=class{constructor(n,s,o){this._ua=n,this._eventHandlers=o,this._method=s.method,this._request=s,this._auth=null,this._challenged=!1,this._staled=!1;for(const c in Ys)Object.prototype.hasOwnProperty.call(Ys,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=Ys[c]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==vn.BYE||this._method!==vn.ACK)&&this._eventHandlers.onTransportError()}send(){const n={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:s=>{this._receiveResponse(s)}};switch(this._method){case"INVITE":{this.clientTransaction=new js.InviteClientTransaction(this._ua,this._ua.transport,this._request,n);break}case"ACK":{this.clientTransaction=new js.AckClientTransaction(this._ua,this._ua.transport,this._request,n);break}default:this.clientTransaction=new js.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,n)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(n){let s,o;const c=n.status_code;if((c===401||c===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(s=n.parseHeader("www-authenticate"),o="authorization"):(s=n.parseHeader("proxy-authenticate"),o="proxy-authorization"),!s){Ua.debug(`${n.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&s.stale===!0){if(this._auth||(this._auth=new Da({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,s)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),s.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(n)}else this._eventHandlers.onReceiveResponse(n)}};const $a=pe,vt=Ce(),it=oe,Rn=ke,In=At,Mt=new $a("Registrator"),as=10;var Pa=class{constructor(n,s){this._reg_id=1,this._ua=n,this._transport=s,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=vt.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)){const o=n[s];this._extraContactParams+=`;${s}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Mt.debug("Register request in progress...");return}const n=vt.cloneArray(this._extraHeaders);let s;this._expires?(s=`${this._contact};expires=${this._expires}${this._extraContactParams}`,n.push(`Expires: ${this._expires}`)):s=`${this._contact}${this._extraContactParams}`,n.push(`Contact: ${s}`);let o=vt.newTag();this._ua.configuration.register_from_tag_trail&&(typeof this._ua.configuration.register_from_tag_trail=="function"?o+=this._ua.configuration.register_from_tag_trail():o+=this._ua.configuration.register_from_tag_trail);const c=new Rn.OutgoingRequest(it.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1,from_tag:o},n),t=new In(this._ua,c,{onRequestTimeout:()=>{this._registrationFailure(null,it.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,it.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:d=>{if(d.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(d.status_code):break;case/^2[0-9]{2}$/.test(d.status_code):{if(this._registering=!1,!d.hasHeader("Contact")){Mt.debug("no Contact header in response to REGISTER, response ignored");break}const p=d.headers.Contact.reduce((S,O)=>S.concat(O.parsed),[]);let a=p.find(S=>this._sipInstance===S.getParam("+sip.instance")&&this._reg_id===parseInt(S.getParam("reg-id")));if(a||(a=p.find(S=>S.uri.user===this._ua.contact.uri.user)),!a){Mt.debug("no Contact header pointing to us, response ignored");break}let T=a.getParam("expires");!T&&d.hasHeader("expires")&&(T=d.getHeader("expires")),T||(T=this._expires),T=Number(T),T<as&&(T=as);const m=T>64?T*1e3/2+Math.floor((T/2-32)*1e3*Math.random()):T*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},m),a.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=a.getParam("temp-gruu").replace(/"/g,"")),a.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=a.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:d}));break}case/^423$/.test(d.status_code):{d.hasHeader("min-expires")?(this._expires=Number(d.getHeader("min-expires")),this._expires<as&&(this._expires=as),this._registering=!1,this.register()):(Mt.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(d,it.causes.SIP_FAILURE_CODE));break}default:{const p=vt.sipErrorCause(d.status_code);this._registrationFailure(d,p)}}}});this._registering=!0,t.send()}unregister(n={}){if(!this._registered){Mt.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const s=vt.cloneArray(this._extraHeaders);n.all?s.push(`Contact: *${this._extraContactParams}`):s.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),s.push("Expires: 0");const o=new Rn.OutgoingRequest(it.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s);new In(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,it.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,it.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:t=>{switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):{this._unregistered(t);break}default:{const d=vt.sipErrorCause(t.status_code);this._unregistered(t,d)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(n,s){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:s}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:s}))}_unregistered(n,s){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:s||null})}};const Ks=oe,os=Pt,Ma=At,zs={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var La=class{constructor(n,s,o){this._dialog=n,this._ua=n._ua,this._request=s,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(const c in zs)Object.prototype.hasOwnProperty.call(zs,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=zs[c]))}get request(){return this._request}send(){const n=new Ma(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:s=>{this._eventHandlers.onAuthenticated(s)},onReceiveResponse:s=>{this._receiveResponse(s)}});if(n.send(),(this._request.method===Ks.INVITE||this._request.method===Ks.UPDATE&&this._request.body)&&n.clientTransaction.state!==os.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const s=()=>{(n.clientTransaction.state===os.C.STATUS_ACCEPTED||n.clientTransaction.state===os.C.STATUS_COMPLETED||n.clientTransaction.state===os.C.STATUS_TERMINATED)&&(n.clientTransaction.removeListener("stateChanged",s),this._dialog.uac_pending_reply=!1)};n.clientTransaction.on("stateChanged",s)}}_receiveResponse(n){n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===Ks.INVITE&&n.status_code===491?this._reattempt?this._eventHandlers.onErrorResponse(n):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n)}};const Ha=pe,bn=ke,Ge=oe,Lt=Pt,Fa=La,Xs=Ce(),Js=new Ha("Dialog"),et={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var Qs=class{static get C(){return et}constructor(n,s,o,c=et.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!s.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};s instanceof bn.IncomingResponse&&(c=s.status_code<200?et.STATUS_EARLY:et.STATUS_CONFIRMED);const t=s.parseHeader("contact");o==="UAS"?(this._id={call_id:s.call_id,local_tag:s.to_tag,remote_tag:s.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=c,this._remote_seqnum=s.cseq,this._local_uri=s.parseHeader("to").uri,this._remote_uri=s.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=s.getHeaders("record-route"),this._incoming_ack_seqnum=s.cseq,this._outgoing_ack_seqnum=null):o==="UAC"&&(this._id={call_id:s.call_id,local_tag:s.from_tag,remote_tag:s.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=c,this._local_seqnum=s.cseq,this._local_uri=s.parseHeader("from").uri,this._remote_uri=s.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=s.getHeaders("record-route").reverse(),this._incoming_ack_seqnum=null,this._outgoing_ack_seqnum=this._local_seqnum),this._ua.newDialog(this),Js.debug(`new ${o} dialog created with status ${this._state===et.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(n){this._local_seqnum=n}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(n){this._uac_pending_reply=n}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===et.STATUS_TERMINATED}update(n,s){this._state=et.STATUS_CONFIRMED,Js.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),s==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){Js.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=et.STATUS_TERMINATED}sendRequest(n,s={}){const o=Xs.cloneArray(s.extraHeaders),c=Xs.cloneObject(s.eventHandlers),t=s.body||null,d=this._createRequest(n,o,t),p=c.onAuthenticated||(()=>{});return c.onAuthenticated=T=>{this._local_seqnum+=1,d.method===Ge.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum),p(T)},new Fa(this,d,c).send(),d}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===Ge.ACK&&this._incoming_ack_seqnum!==null?this._incoming_ack_seqnum=null:n.method===Ge.INVITE&&(this._incoming_ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,s,o){s=Xs.cloneArray(s),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const c=n===Ge.CANCEL||n===Ge.ACK?this._outgoing_ack_seqnum:this._local_seqnum+=1;return n===Ge.INVITE&&(this._outgoing_ack_seqnum=c),new bn.OutgoingRequest(n,this._remote_target,this._ua,{cseq:c,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},s,o)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===Ge.ACK){if(this._incoming_ack_seqnum===null||n.cseq!==this._incoming_ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===Ge.INVITE||n.method===Ge.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const s=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${s}`]),!1}else{this._uas_pending_reply=!0;const s=()=>{(n.server_transaction.state===Lt.C.STATUS_ACCEPTED||n.server_transaction.state===Lt.C.STATUS_COMPLETED||n.server_transaction.state===Lt.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",s),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",s)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Lt.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===Ge.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Lt.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}},Zs={exports:{}};const ka=Fe.EventEmitter,qa=pe,Ga=oe,Ba=He,wn=Ce(),Wa=new qa("RTCSession:DTMF"),yn={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Zs.exports=class extends ka{constructor(n){super(),this._session=n,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(n,s={}){if(n===void 0)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK&&this._session.status!==this._session.C.STATUS_1XX_RECEIVED)throw new Ba.InvalidStateError(this._session.status);const o=wn.cloneArray(s.extraHeaders);if(this.eventHandlers=wn.cloneObject(s.eventHandlers),typeof n=="string")n=n.toUpperCase();else if(typeof n=="number")n=n.toString();else throw new TypeError(`Invalid tone: ${n}`);if(n.match(/^[0-9A-DR#*]$/))this._tone=n;else throw new TypeError(`Invalid tone: ${n}`);this._duration=s.duration,o.push("Content-Type: application/dtmf-relay");let c=`Signal=${this._tone}\r
44
+ `;c+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(Ga.INFO,{extraHeaders:o,eventHandlers:{onSuccessResponse:t=>{this.emit("succeeded",{originator:"remote",response:t})},onErrorResponse:t=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:t})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:c})}init_incoming(n){const s=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,o=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=n,n.reply(200),n.body){const c=n.body.split(`
45
+ `);c.length>=1&&s.test(c[0])&&(this._tone=c[0].replace(s,"$2")),c.length>=2&&o.test(c[1])&&(this._duration=parseInt(c[1].replace(o,"$2"),10))}this._duration||(this._duration=yn.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:n}):Wa.debug("invalid INFO DTMF received, discarded")}},Zs.exports.C=yn;var Va=Zs.exports;const ja=Fe.EventEmitter,Ya=oe,Ka=He,za=Ce();var Xa=class extends ja{constructor(n){super(),this._session=n,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(n,s,o={}){if(this._direction="outgoing",n===void 0)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new Ka.InvalidStateError(this._session.status);this._contentType=n,this._body=s;const c=za.cloneArray(o.extraHeaders);c.push(`Content-Type: ${n}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(Ya.INFO,{extraHeaders:c,eventHandlers:{onSuccessResponse:t=>{this.emit("succeeded",{originator:"remote",response:t})},onErrorResponse:t=>{this.emit("failed",{originator:"remote",response:t})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:s})}init_incoming(n){this._direction="incoming",this.request=n,n.reply(200),this._contentType=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,this._body=n.body,this._session.newInfo({originator:"remote",info:this,request:n})}};const Ja=pe,Nn=oe,Qa=new Ja("RTCSession:ReferNotifier"),er={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var Za=class{constructor(n,s,o){this._session=n,this._id=s,this._expires=o||er.expires,this._active=!0,this.notify(100)}notify(n,s){if(Qa.debug("notify()"),this._active===!1)return;s=s||Nn.REASON_PHRASE[n]||"";let o;n>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(Nn.NOTIFY,{extraHeaders:[`Event: ${er.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${er.body_type}`],body:`SIP/2.0 ${n} ${s}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const eo=Fe.EventEmitter,to=pe,Ht=oe,so=$e(),On=Ce(),at=new to("RTCSession:ReferSubscriber");var ro=class extends eo{constructor(n){super(),this._id=null,this._session=n}get id(){return this._id}sendRefer(n,s={}){at.debug("sendRefer()");const o=On.cloneArray(s.extraHeaders),c=On.cloneObject(s.eventHandlers);for(const a in c)Object.prototype.hasOwnProperty.call(c,a)&&this.on(a,c[a]);let t=null;s.replaces&&(t=s.replaces._request.call_id,t+=`;to-tag=${s.replaces._to_tag}`,t+=`;from-tag=${s.replaces._from_tag}`,t=encodeURIComponent(t));const d=`Refer-To: <${n}${t?`?Replaces=${t}`:""}>`;if(o.push(d),!o.some(a=>a.toLowerCase().startsWith("referred-by:"))){const a=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;o.push(a)}o.push(`Contact: ${this._session.contact}`);const p=this._session.sendRequest(Ht.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:a=>{this._requestSucceeded(a)},onErrorResponse:a=>{this._requestFailed(a,Ht.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Ht.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Ht.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Ht.causes.DIALOG_ERROR)},onAuthenticated:a=>{this._id=a.cseq,this.emit("authenticated")}}});this._id=p.cseq}receiveNotify(n){if(at.debug("receiveNotify()"),!n.body)return;const s=so.parse(n.body.trim().split(`\r
46
+ `,1)[0],"Status_Line");if(s===-1){at.debug(`receiveNotify() | error parsing NOTIFY body: "${n.body}"`);return}switch(!0){case/^100$/.test(s.status_code):{this.emit("trying",{request:n,status_line:s});break}case/^1[0-9]{2}$/.test(s.status_code):{this.emit("progress",{request:n,status_line:s});break}case/^2[0-9]{2}$/.test(s.status_code):{this.emit("accepted",{request:n,status_line:s});break}default:{this.emit("failed",{request:n,status_line:s});break}}}_requestSucceeded(n){at.debug("REFER succeeded"),at.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:n})}_requestFailed(n,s){at.debug("REFER failed"),at.debug('emit "requestFailed"'),this.emit("requestFailed",{response:n||null,cause:s})}};const no=Fe.EventEmitter,xn=Pe,lo=pe,x=oe,ot=He,Dn=Pt,ie=Ce(),Ft=En,io=ke,us=Qs,ao=At,ye=Va,Un=Xa,oo=Za,uo=ro,$n=Ze(),A=new lo("RTCSession"),R={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},cs=["audio","video"];var Pn=class Yr extends no{static get C(){return R}constructor(n){A.debug("new"),super(),this._id=null,this._ua=n,this._status=R.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:x.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return R}get causes(){return x.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(n){this._data=n}get status(){return this._status}isInProgress(){switch(this._status){case R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:case R.STATUS_INVITE_RECEIVED:case R.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case R.STATUS_ANSWERED:case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case R.STATUS_CANCELED:case R.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(n,s={},o){A.debug("connect()");const c=n,t=ie.cloneObject(s.eventHandlers),d=ie.cloneArray(s.extraHeaders),p=ie.cloneObject(s.mediaConstraints,{audio:!0,video:!0}),a=s.mediaStream||null,T=ie.cloneObject(s.pcConfig,{iceServers:[]}),m=s.rtcConstraints||null,S=s.rtcOfferConstraints||null;if(this._rtcOfferConstraints=S,this._rtcAnswerConstraints=s.rtcAnswerConstraints||null,this._data=s.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==R.STATUS_NULL)throw new ot.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new ot.NotSupportedError("WebRTC not supported");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${c}`);this._sessionTimers.enabled&&ie.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=x.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=x.SESSION_EXPIRES);for(const B in t)Object.prototype.hasOwnProperty.call(t,B)&&this.on(B,t[B]);this._from_tag=ie.newTag();const O=s.anonymous||!1,H={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:O,outbound:!0}),O?(H.from_display_name="Anonymous",H.from_uri=new $n("sip","anonymous","anonymous.invalid"),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),d.push("Privacy: id")):s.fromUserName&&(H.from_uri=new $n("sip",s.fromUserName,this._ua.configuration.uri.host),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),s.fromDisplayName&&(H.from_display_name=s.fromDisplayName),d.push(`Contact: ${this._contact}`),d.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&d.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new io.InitialOutgoingInviteRequest(n,this._ua,H,d),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(T,m),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,o&&o(this),this._newRTCSession("local",this._request),this._sendInitialRequest(p,S,a)}init_incoming(n,s){A.debug("init_incoming()");let o;const c=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&c!=="application/sdp"){n.reply(415);return}if(this._status=R.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(o=n.getHeader("expires")*1e3),n.to_tag=ie.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=R.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,x.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===R.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,x.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,s&&s(this),this._newRTCSession("remote",n),this._status!==R.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){A.debug("answer()");const s=this._request,o=ie.cloneArray(n.extraHeaders),c=ie.cloneObject(n.mediaConstraints),t=n.mediaStream||null,d=ie.cloneObject(n.pcConfig,{iceServers:[]}),p=n.rtcConstraints||null,a=n.rtcAnswerConstraints||null,T=ie.cloneObject(n.rtcOfferConstraints);let m,S=!1,O=!1,H=!1,B=!1;if(this._rtcAnswerConstraints=a,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new ot.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==R.STATUS_WAITING_FOR_ANSWER)throw new ot.InvalidStateError(this._status);if(this._sessionTimers.enabled&&ie.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=x.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=x.SESSION_EXPIRES),this._status=R.STATUS_ANSWERED,!this._createDialog(s,"UAS")){s.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const k=s.parseSDP();Array.isArray(k.media)||(k.media=[k.media]);for(const U of k.media)U.type==="audio"&&(S=!0,(!U.direction||U.direction==="sendrecv")&&(H=!0)),U.type==="video"&&(O=!0,(!U.direction||U.direction==="sendrecv")&&(B=!0));if(t&&c.audio===!1){m=t.getAudioTracks();for(const U of m)t.removeTrack(U)}if(t&&c.video===!1){m=t.getVideoTracks();for(const U of m)t.removeTrack(U)}!t&&c.audio===void 0&&(c.audio=H),!t&&c.video===void 0&&(c.video=B),!t&&!S&&!T.offerToReceiveAudio&&(c.audio=!1),!t&&!O&&!T.offerToReceiveVideo&&(c.video=!1),this._createRTCConnection(d,p),Promise.resolve().then(()=>{if(t)return t;if(c.audio||c.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(c).catch(U=>{throw this._status===R.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),this._failed("local",null,x.causes.USER_DENIED_MEDIA_ACCESS),A.warn('emit "getusermediafailed" [error:%o]',U),this.emit("getusermediafailed",U),new Error("getUserMedia() failed"))})}).then(U=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=U,U&&U.getTracks().forEach(de=>{this._connection.addTrack(de,U)})}).then(()=>{if(this._late_sdp)return;const U={originator:"remote",type:"offer",sdp:s.body};A.debug('emit "sdp"'),this.emit("sdp",U);const de=new RTCSessionDescription({type:"offer",sdp:U.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(de)).catch(ne=>{throw s.reply(488),this._failed("system",null,x.causes.WEBRTC_ERROR),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',ne),this.emit("peerconnection:setremotedescriptionfailed",ne),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(s),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw s.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",a).catch(()=>{throw s.reply(500),new Error("_createLocalDescription() failed")})}).then(U=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(s,o),s.reply(200,null,o,U,()=>{this._status=R.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,U),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,x.causes.CONNECTION_ERROR)})}).catch(U=>{this._status!==R.STATUS_TERMINATED&&(A.warn(`answer() failed: ${U.message}`),this._failed("system",U.message,x.causes.INTERNAL_ERROR))})}terminate(n={}){A.debug("terminate()");const s=n.cause||x.causes.BYE,o=ie.cloneArray(n.extraHeaders),c=n.body;let t,d=n.status_code,p=n.reason_phrase;if(this._status===R.STATUS_TERMINATED)throw new ot.InvalidStateError(this._status);switch(this._status){case R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:{if(A.debug("canceling session"),d&&(d<200||d>=700))throw new TypeError(`Invalid status_code: ${d}`);d&&(p=p||x.REASON_PHRASE[d]||"",t=`SIP ;cause=${d} ;text="${p}"`),this._status===R.STATUS_NULL||this._status===R.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===R.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=R.STATUS_CANCELED,this._failed("local",null,x.causes.CANCELED);break}case R.STATUS_WAITING_FOR_ANSWER:case R.STATUS_ANSWERED:{if(A.debug("rejecting session"),d=d||480,d<300||d>=700)throw new TypeError(`Invalid status_code: ${d}`);this._request.reply(d,p,o,c),this._failed("local",null,x.causes.REJECTED);break}case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:{if(A.debug("terminating session"),p=n.reason_phrase||x.REASON_PHRASE[d]||"",d&&(d<200||d>=700))throw new TypeError(`Invalid status_code: ${d}`);if(d&&o.push(`Reason: SIP ;cause=${d}; text="${p}"`),this._status===R.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Dn.C.STATUS_TERMINATED){const a=this._dialog;this.receiveRequest=({method:T})=>{T===x.ACK&&(this.sendRequest(x.BYE,{extraHeaders:o,body:c}),a.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Dn.C.STATUS_TERMINATED&&(this.sendRequest(x.BYE,{extraHeaders:o,body:c}),a.terminate())}),this._ended("local",null,s),this._dialog=a,this._ua.newDialog(a)}else this.sendRequest(x.BYE,{extraHeaders:o,body:c}),this._ended("local",null,s)}}}sendDTMF(n,s={}){A.debug("sendDTMF() | tones: %s",n);let o=s.duration||null,c=s.interToneGap||null;const t=s.transportType||x.DTMF_TRANSPORT.INFO;if(n===void 0)throw new TypeError("Not enough arguments");if(this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new ot.InvalidStateError(this._status);if(t!==x.DTMF_TRANSPORT.INFO&&t!==x.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${t}`);if(typeof n=="number"&&(n=n.toString()),!n||typeof n!="string"||!n.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${n}`);if(o&&!ie.isDecimal(o))throw new TypeError(`Invalid tone duration: ${o}`);if(o?o<ye.C.MIN_DURATION?(A.debug(`"duration" value is lower than the minimum allowed, setting it to ${ye.C.MIN_DURATION} milliseconds`),o=ye.C.MIN_DURATION):o>ye.C.MAX_DURATION?(A.debug(`"duration" value is greater than the maximum allowed, setting it to ${ye.C.MAX_DURATION} milliseconds`),o=ye.C.MAX_DURATION):o=Math.abs(o):o=ye.C.DEFAULT_DURATION,s.duration=o,c&&!ie.isDecimal(c))throw new TypeError(`Invalid interToneGap: ${c}`);if(c?c<ye.C.MIN_INTER_TONE_GAP?(A.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${ye.C.MIN_INTER_TONE_GAP} milliseconds`),c=ye.C.MIN_INTER_TONE_GAP):c=Math.abs(c):c=ye.C.DEFAULT_INTER_TONE_GAP,t===x.DTMF_TRANSPORT.RFC2833){const p=this._getDTMFRTPSender();p&&(n=p.toneBuffer+n,p.insertDTMF(n,o,c));return}if(this._tones){this._tones+=n;return}this._tones=n,d.call(this);function d(){let p;if(this._status===R.STATUS_TERMINATED||!this._tones){this._tones=null;return}const a=this._tones[0];if(this._tones=this._tones.substring(1),a===",")p=2e3;else{const T=new ye(this);s.eventHandlers={onFailed:()=>{this._tones=null}},T.send(a,s),p=o+c}setTimeout(d.bind(this),p)}}sendInfo(n,s,o={}){if(A.debug("sendInfo()"),this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new ot.InvalidStateError(this._status);new Un(this).send(n,s,o)}mute(n={audio:!0,video:!1}){A.debug("mute()");let s=!1,o=!1;this._audioMuted===!1&&n.audio&&(s=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(s===!0||o===!0)&&this._onmute({audio:s,video:o})}unmute(n={audio:!0,video:!0}){A.debug("unmute()");let s=!1,o=!1;this._audioMuted===!0&&n.audio&&(s=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(s===!0||o===!0)&&this._onunmute({audio:s,video:o})}hold(n={},s){if(A.debug("hold()"),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!0||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}unhold(n={},s){if(A.debug("unhold()"),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!1||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},s){A.debug("renegotiate()");const o=n.rtcOfferConstraints||null;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;const c={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:c,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:c,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}),!0}refer(n,s){A.debug("refer()");const o=n;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const c=new uo(this);c.sendRefer(n,s);let t=c.id;return this._referSubscribers[t]=c,c.on("requestFailed",()=>{delete this._referSubscribers[t]}),c.on("accepted",()=>{delete this._referSubscribers[t]}),c.on("failed",()=>{delete this._referSubscribers[t]}),c.on("authenticated",()=>{delete this._referSubscribers[t],t=c.id,this._referSubscribers[t]=c}),c}sendRequest(n,s){if(A.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(n,s);{const o=Object.values(this._earlyDialogs);if(o.length>0)return o[0].sendRequest(n,s);A.warn("sendRequest() | no valid early dialog found");return}}receiveRequest(n){if(A.debug("receiveRequest()"),n.method===x.CANCEL)(this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED)&&(this._status=R.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,x.causes.CANCELED));else switch(n.method){case x.ACK:{if(this._status!==R.STATUS_WAITING_FOR_ACK)return;if(this._status=R.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:x.causes.MISSING_SDP,status_code:400});break}const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(c=>{this.terminate({cause:x.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)})}else this._is_confirmed||this._confirmed("remote",n);break}case x.BYE:{this._status===R.STATUS_CONFIRMED||this._status===R.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,x.causes.BYE)):this._status===R.STATUS_INVITE_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,x.causes.BYE)):n.reply(403,"Wrong Status");break}case x.INVITE:{this._status===R.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break}case x.INFO:{if(this._status===R.STATUS_1XX_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED||this._status===R.STATUS_WAITING_FOR_ACK||this._status===R.STATUS_CONFIRMED){const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;s&&s.match(/^application\/dtmf-relay/i)?new ye(this).init_incoming(n):s!==void 0?new Un(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break}case x.UPDATE:{this._status===R.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break}case x.REFER:{this._status===R.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break}case x.NOTIFY:{this._status===R.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break}default:n.reply(501)}}onTransportError(){A.warn("onTransportError()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:x.causes.CONNECTION_ERROR,cause:x.causes.CONNECTION_ERROR})}onRequestTimeout(){A.warn("onRequestTimeout()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:x.causes.REQUEST_TIMEOUT,cause:x.causes.REQUEST_TIMEOUT})}onDialogError(){A.warn("onDialogError()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:x.causes.DIALOG_ERROR,cause:x.causes.DIALOG_ERROR})}newDTMF(n){A.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){A.debug("newInfo()"),this.emit("newInfo",n)}isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(A.debug("isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(A.debug("isReadyToReOffer() | session not established yet"),!1):(A.debug("isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(A.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(A.debug("close() | closing local MediaStream"),ie.closeMediaStream(this._localMediaStream)),this._status!==R.STATUS_TERMINATED){if(this._status=R.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){A.warn("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(n,s){let o=Ft.T1;function c(){this._status===R.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],s),o<Ft.T2&&(o=o*2,o>Ft.T2&&(o=Ft.T2)),this._timers.invite2xxTimer=setTimeout(c.bind(this),o))}this._timers.invite2xxTimer=setTimeout(c.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===R.STATUS_WAITING_FOR_ACK&&(A.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(x.BYE),this._ended("remote",null,x.causes.NO_ACK))},Ft.TIMER_H)}_createRTCConnection(n,s){this._connection=new RTCPeerConnection(n,s),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:x.causes.RTP_TIMEOUT,status_code:408,reason_phrase:x.causes.RTP_TIMEOUT})}),A.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,s){if(A.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?o.createOffer(s).catch(c=>(A.warn('emit "peerconnection:createofferfailed" [error:%o]',c),this.emit("peerconnection:createofferfailed",c),Promise.reject(c))):o.createAnswer(s).catch(c=>(A.warn('emit "peerconnection:createanswerfailed" [error:%o]',c),this.emit("peerconnection:createanswerfailed",c),Promise.reject(c)))).then(c=>o.setLocalDescription(c).catch(t=>(this._rtcReady=!0,A.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const c=s&&s.iceRestart;if(o.iceGatheringState==="complete"&&!c||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:n,sdp:o.localDescription.sdp};return A.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let d=!1,p,a;this._iceReady=!1;const T=()=>{if(d)return;o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",a),d=!0,this._rtcReady=!0,this._iceReady=!0;const m={originator:"local",type:n,sdp:o.localDescription.sdp};A.debug('emit "sdp"'),this.emit("sdp",m),t(m.sdp)};o.addEventListener("icecandidate",p=m=>{const S=m.candidate;S?this.emit("icecandidate",{candidate:S,ready:T}):T()}),o.addEventListener("icegatheringstatechange",a=()=>{o.iceGatheringState==="complete"&&T()})})})}_createDialog(n,s,o){const c=s==="UAS"?n.to_tag:n.from_tag,t=s==="UAS"?n.from_tag:n.to_tag,d=n.call_id+c+t;let p=this._earlyDialogs[d];if(o)return p?!0:(p=new us(this,n,s,us.C.STATUS_EARLY),p.error?(A.debug(p.error),this._failed("remote",n,x.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[d]=p,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,p)return p.update(n,s),this._dialog=p,delete this._earlyDialogs[d],!0;const a=new us(this,n,s);return a.error?(A.debug(a.error),this._failed("remote",n,x.causes.INTERNAL_ERROR),!1):(this._dialog=a,!0)}}_receiveReinvite(n){A.debug("receiveReinvite()");const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let c=!1;function t(p={}){c=!0;const a=p.status_code||403,T=p.reason_phrase||"",m=ie.cloneArray(p.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);n.reply(a,T,m)}if(this.emit("reinvite",o),c)return;if(this._late_sdp=!1,!n.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(p=>{d.call(this,p)}).catch(()=>{n.reply(500)});return}if(s!=="application/sdp"){A.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==R.STATUS_TERMINATED&&d.call(this,p)}).catch(p=>{A.warn(p)});function d(p){const a=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,a),this._late_sdp&&(p=this._mangleOffer(p)),n.reply(200,null,a,p,()=>{this._status=R.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(n){A.debug("receiveUpdate()");const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let c=!1;function t(p={}){c=!0;const a=p.status_code||403,T=p.reason_phrase||"",m=ie.cloneArray(p.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);n.reply(a,T,m)}if(this.emit("update",o),c)return;if(!n.body){d.call(this,null);return}if(s!=="application/sdp"){A.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==R.STATUS_TERMINATED&&d.call(this,p)}).catch(p=>{A.warn(p)});function d(p){const a=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,a),n.reply(200,null,a,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(n){A.debug("_processInDialogSdpOffer()");const s=n.parseSDP();let o=!1;for(const d of s.media){if(cs.indexOf(d.type)===-1)continue;const p=d.direction||s.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const c={originator:"remote",type:"offer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",c);const t=new RTCSessionDescription({type:"offer",sdp:c.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(d=>{throw n.reply(488),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),this.emit("peerconnection:setremotedescriptionfailed",d),d})}).then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&o===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&o===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(d=>{throw n.reply(500),A.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',d),d})}).catch(d=>{A.warn("_processInDialogSdpOffer() failed [error: %o]",d)}),this._connectionPromiseQueue}_receiveRefer(n){if(A.debug("receiveRefer()"),!n.refer_to){A.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==x.SIP){A.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const s=new oo(this,n.cseq);A.debug('emit "refer"'),this.emit("refer",{request:n,accept:(t,d)=>{o.call(this,t,d)},reject:()=>{c.call(this)}});function o(t,d={}){if(t=typeof t=="function"?t:null,this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;const p=new Yr(this._ua);if(p.on("progress",({response:T})=>{s.notify(T.status_code,T.reason_phrase)}),p.on("accepted",({response:T})=>{s.notify(T.status_code,T.reason_phrase)}),p.on("_failed",({message:T,cause:m})=>{T?s.notify(T.status_code,T.reason_phrase):s.notify(487,m)}),n.refer_to.uri.hasHeader("replaces")){const T=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));d.extraHeaders=ie.cloneArray(d.extraHeaders),d.extraHeaders.push(`Replaces: ${T}`)}const a=n.refer_to.uri.clone();a.clearHeaders(),p.connect(a,d,t)}function c(){s.notify(603)}}_receiveNotify(n){switch(A.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let s,o;if(n.event.params&&n.event.params.id)s=n.event.params.id,o=this._referSubscribers[s];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!o){n.reply(481,"Subscription does not exist");return}o.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){A.debug("receiveReplaces()");function s(c){if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;const t=new Yr(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(n,c)}function o(){A.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:c=>{s.call(this,c)},reject:()=>{o.call(this)}})}_sendInitialRequest(n,s,o){const c=new ao(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t)}});Promise.resolve().then(()=>{if(o)return o;if(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(t=>{throw this._status===R.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,x.causes.USER_DENIED_MEDIA_ACCESS),A.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=t,t&&t.getTracks().forEach(d=>{this._connection.addTrack(d,t)}),this._connecting(this._request),this._createLocalDescription("offer",s).catch(d=>{throw this._failed("local",null,x.causes.WEBRTC_ERROR),d})}).then(t=>{if(this._is_canceled||this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=R.STATUS_INVITE_SENT,A.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),c.send()}).catch(t=>{this._status!==R.STATUS_TERMINATED&&A.warn(t)})}_getDTMFRTPSender(){const n=this._connection.getSenders().find(s=>s.track&&s.track.kind==="audio");if(!(n&&n.dtmf)){A.warn("sendDTMF() | no local audio track to send DTMF with");return}return n.dtmf}_receiveInviteResponse(n){if(A.debug("receiveInviteResponse()"),this._dialog&&n.status_code>=200&&n.status_code<=299)if(this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.sendRequest(x.ACK);return}else{const s=new us(this,n,"UAC");if(s.error!==void 0){A.debug(s.error);return}this.sendRequest(x.ACK),this.sendRequest(x.BYE);return}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==R.STATUS_INVITE_SENT&&this._status!==R.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):{this._status=R.STATUS_1XX_RECEIVED;break}case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){A.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=R.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",n)).catch(c=>{A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=R.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,x.causes.MISSING_SDP),this._failed("remote",n,x.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(c=>this._connection.setLocalDescription(c)).catch(c=>{this._acceptAndTerminate(n,500,c.toString()),this._failed("local",n,x.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(x.ACK),this._confirmed("local",null)}).catch(c=>{this._acceptAndTerminate(n,488,"Not Acceptable Here"),this._failed("remote",n,x.causes.BAD_MEDIA_DESCRIPTION),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)})});break}default:{const s=ie.sipErrorCause(n.status_code);this._failed("remote",n,s)}}}_sendReinvite(n={}){A.debug("sendReinvite()");const s=ie.cloneArray(n.extraHeaders),o=ie.cloneObject(n.eventHandlers),c=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;s.push(`Contact: ${this._contact}`),s.push("Content-Type: application/sdp"),this._sessionTimers.running&&s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",c)).then(a=>{a=this._mangleOffer(a);const T={originator:"local",type:"offer",sdp:a};A.debug('emit "sdp"'),this.emit("sdp",T),this.sendRequest(x.INVITE,{extraHeaders:s,body:a,eventHandlers:{onSuccessResponse:m=>{d.call(this,m),t=!0},onErrorResponse:m=>{p.call(this,m)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function d(a){if(this._status===R.STATUS_TERMINATED||(this.sendRequest(x.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(a),a.body){if(!a.hasHeader("Content-Type")||a.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const T={originator:"remote",type:"answer",sdp:a.body};A.debug('emit "sdp"'),this.emit("sdp",T);const m=new RTCSessionDescription({type:"answer",sdp:T.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(m)).then(()=>{o.succeeded&&o.succeeded(a)}).catch(S=>{p.call(this),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',S),this.emit("peerconnection:setremotedescriptionfailed",S)})}function p(a){o.failed&&o.failed(a)}}_sendUpdate(n={}){A.debug("sendUpdate()");const s=ie.cloneArray(n.extraHeaders),o=ie.cloneObject(n.eventHandlers),c=n.rtcOfferConstraints||this._rtcOfferConstraints||null,t=n.sdpOffer||!1;let d=!1;s.push(`Contact: ${this._contact}`),this._sessionTimers.running&&s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(s.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",c)).then(T=>{T=this._mangleOffer(T);const m={originator:"local",type:"offer",sdp:T};A.debug('emit "sdp"'),this.emit("sdp",m),this.sendRequest(x.UPDATE,{extraHeaders:s,body:T,eventHandlers:{onSuccessResponse:S=>{p.call(this,S),d=!0},onErrorResponse:S=>{a.call(this,S)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{a.call(this)})):this.sendRequest(x.UPDATE,{extraHeaders:s,eventHandlers:{onSuccessResponse:T=>{p.call(this,T)},onErrorResponse:T=>{a.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(T){if(this._status!==R.STATUS_TERMINATED&&!d)if(this._handleSessionTimersInIncomingResponse(T),t){if(T.body){if(!T.hasHeader("Content-Type")||T.getHeader("Content-Type").toLowerCase()!=="application/sdp"){a.call(this);return}}else{a.call(this);return}const m={originator:"remote",type:"answer",sdp:T.body};A.debug('emit "sdp"'),this.emit("sdp",m);const S=new RTCSessionDescription({type:"answer",sdp:m.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(S)).then(()=>{o.succeeded&&o.succeeded(T)}).catch(O=>{a.call(this),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',O),this.emit("peerconnection:setremotedescriptionfailed",O)})}else o.succeeded&&o.succeeded(T)}function a(T){o.failed&&o.failed(T)}}_acceptAndTerminate(n,s,o){A.debug("acceptAndTerminate()");const c=[];s&&(o=o||x.REASON_PHRASE[s]||"",c.push(`Reason: SIP ;cause=${s}; text="${o}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(x.ACK),this.sendRequest(x.BYE,{extraHeaders:c})),this._status=R.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=xn.parse(n),this._localHold&&!this._remoteHold){A.debug("mangleOffer() | me on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction?s.direction==="sendrecv"?s.direction="sendonly":s.direction==="recvonly"&&(s.direction="inactive"):s.direction="sendonly")}else if(this._localHold&&this._remoteHold){A.debug("mangleOffer() | both on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction="inactive")}else if(this._remoteHold){A.debug("mangleOffer() | remote on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction?s.direction==="sendrecv"?s.direction="recvonly":s.direction==="recvonly"&&(s.direction="inactive"):s.direction="recvonly")}return xn.write(n)}_setLocalMediaStatus(){let n=!0,s=!0;(this._localHold||this._remoteHold)&&(n=!1,s=!1),this._audioMuted&&(n=!1),this._videoMuted&&(s=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!s)}_handleSessionTimersInIncomingRequest(n,s){if(!this._sessionTimers.enabled)return;let o;n.session_expires&&n.session_expires>=x.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,o=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let s;n.session_expires&&n.session_expires>=x.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,s=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,s="uac"),this._sessionTimers.refresher=s==="uac",this._runSessionTimer()}_runSessionTimer(){const n=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==R.STATUS_TERMINATED&&this.isReadyToReOffer()&&(A.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===x.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==R.STATUS_TERMINATED&&(A.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:x.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const s=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of s)o.track.enabled=!n}_toggleMuteVideo(n){const s=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of s)o.track.enabled=!n}_newRTCSession(n,s){A.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:n,session:this,request:s})}_connecting(n){A.debug("session connecting"),A.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,s){A.debug("session progress"),A.debug('emit "progress"'),this.emit("progress",{originator:n,response:s||null})}_accepted(n,s){A.debug("session accepted"),this._start_time=new Date,A.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:s||null})}_confirmed(n,s){A.debug("session confirmed"),this._is_confirmed=!0,A.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:s||null})}_ended(n,s,o){A.debug("session ended"),this._end_time=new Date,this._close(),A.debug('emit "ended"'),this.emit("ended",{originator:n,message:s||null,cause:o})}_failed(n,s,o){A.debug("session failed"),A.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:s||null,cause:o}),this._close(),A.debug('emit "failed"'),this.emit("failed",{originator:n,message:s||null,cause:o})}_onhold(n){A.debug("session onhold"),this._setLocalMediaStatus(),A.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){A.debug("session onunhold"),this._setLocalMediaStatus(),A.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:s}){A.debug("session onmute"),this._setLocalMediaStatus(),A.debug('emit "muted"'),this.emit("muted",{audio:n,video:s})}_onunmute({audio:n,video:s}){A.debug("session onunmute"),this._setLocalMediaStatus(),A.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:s})}};const co=Fe.EventEmitter,fo=He,ho=pe,tr=oe,Ke=Ce(),_o=$e(),po=ke,mo=At,go=Qs,Te=new ho("Subscriber"),Y={SUBSCRIBE_RESPONSE_TIMEOUT:0,SUBSCRIBE_TRANSPORT_ERROR:1,SUBSCRIBE_NON_OK_RESPONSE:2,SUBSCRIBE_WRONG_OK_RESPONSE:3,SUBSCRIBE_AUTHENTICATION_FAILED:4,UNSUBSCRIBE_TIMEOUT:5,FINAL_NOTIFY_RECEIVED:6,WRONG_NOTIFY_RECEIVED:7,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,STATE_INIT:3,STATE_WAITING_NOTIFY:4,DEFAULT_EXPIRES_SEC:900};var To=class extends co{static get C(){return Y}constructor(n,s,o,c,{expires:t,contentType:d,allowEvents:p,params:a,extraHeaders:T}){if(Te.debug("new"),super(),!s)throw new TypeError("Not enough arguments: Missing target");if(!o)throw new TypeError("Not enough arguments: Missing eventName");if(!c)throw new TypeError("Not enough arguments: Missing accept");const m=_o.parse(o,"Event");if(m===-1)throw new TypeError("Missing Event header field");this._ua=n,this._target=s,(!Ke.isDecimal(t)||t<=0)&&(t=Y.DEFAULT_EXPIRES_SEC),this._expires=t,this._content_type=d,this._params=Ke.cloneObject(a),this._params.from_uri||(this._params.from_uri=this._ua.configuration.uri),this._params.from_tag=Ke.newTag(),this._params.to_tag=null,this._params.call_id=Ke.createRandomToken(20),this._params.cseq===void 0&&(this._params.cseq=Math.floor(Math.random()*1e4+1)),this._state=Y.STATE_INIT,this._dialog=null,this._expires_timer=null,this._expires_timestamp=null,this._terminated=!1,this._event_name=m.event,this._event_id=m.params&&m.params.id;let S=this._event_name;if(this._event_id&&(S+=`;id=${this._event_id}`),this._headers=Ke.cloneArray(T),this._headers=this._headers.concat([`Event: ${S}`,`Expires: ${this._expires}`,`Accept: ${c}`]),!this._headers.find(O=>O.startsWith("Contact"))){const O=`Contact: ${this._ua._contact.toString()}`;this._headers.push(O)}p&&this._headers.push(`Allow-Events: ${p}`),this._queue=[],this._data={}}get C(){return Y}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(n){this._data=n}onRequestTimeout(){this._terminateDialog(Y.SUBSCRIBE_RESPONSE_TIMEOUT)}onTransportError(){this._terminateDialog(Y.SUBSCRIBE_TRANSPORT_ERROR)}receiveRequest(n){if(n.method!==tr.NOTIFY){Te.warn("received non-NOTIFY request"),n.reply(405);return}const s=n.parseHeader("Event");if(!s){Te.warn("missing Event header"),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const o=s.event,c=s.params&&s.params.id;if(o!==this._event_name||c!==this._event_id){Te.warn("Event header does not match the one in SUBSCRIBE request"),n.reply(489),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const t=n.parseHeader("subscription-state");if(!t){Te.warn("missing Subscription-State header"),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const d=this._parseSubscriptionState(t.state);if(d===void 0){Te.warn(`Invalid Subscription-State header value: ${t.state}`),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}n.reply(200);const p=this._state;if(p!==Y.STATE_TERMINATED&&d!==Y.STATE_TERMINATED&&(this._state=d,t.expires!==void 0)){const m=t.expires,S=new Date().getTime()+m*1e3;this._expires_timestamp-S>2e3&&(Te.debug("update sending re-SUBSCRIBE time"),this._scheduleSubscribe(m))}p!==Y.STATE_PENDING&&d===Y.STATE_PENDING?(Te.debug('emit "pending"'),this.emit("pending")):p!==Y.STATE_ACTIVE&&d===Y.STATE_ACTIVE&&(Te.debug('emit "active"'),this.emit("active"));const a=n.body,T=d===Y.STATE_TERMINATED;if(a){const m=n.getHeader("content-type");Te.debug('emit "notify"'),this.emit("notify",T,n,a,m)}if(T){const m=t.reason;let S;t.params&&t.params["retry-after"]!==void 0&&(S=parseInt(t.params["retry-after"])),this._terminateDialog(Y.FINAL_NOTIFY_RECEIVED,m,S)}}subscribe(n=null){Te.debug("subscribe()"),this._state===Y.STATE_INIT?this._sendInitialSubscribe(n,this._headers):this._sendSubsequentSubscribe(n,this._headers)}terminate(n=null){if(Te.debug("terminate()"),this._state===Y.STATE_INIT)throw new fo.InvalidStateError(this._state);if(this._terminated)return;this._terminated=!0;const s=this._headers.map(o=>o.startsWith("Expires")?"Expires: 0":o);this._sendSubsequentSubscribe(n,s)}_terminateDialog(n,s=void 0,o=void 0){this._state!==Y.STATE_TERMINATED&&(this._state=Y.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),Te.debug(`emit "terminated" code=${n}`),this.emit("terminated",n,s,o))}_sendInitialSubscribe(n,s){if(n){if(!this._content_type)throw new TypeError("content_type is undefined");s=Ke.cloneArray(s),s.push(`Content-Type: ${this._content_type}`)}this._state=Y.STATE_WAITING_NOTIFY;const o=new po.OutgoingRequest(tr.SUBSCRIBE,this._ua.normalizeTarget(this._target),this._ua,this._params,s,n);new mo(this._ua,o,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onReceiveResponse:t=>{this._receiveSubscribeResponse(t)}}).send()}_sendSubsequentSubscribe(n,s){if(this._state!==Y.STATE_TERMINATED){if(!this._dialog){Te.debug("enqueue subscribe"),this._queue.push({body:n,headers:Ke.cloneArray(s)});return}if(n){if(!this._content_type)throw new TypeError("content_type is undefined");s=Ke.cloneArray(s),s.push(`Content-Type: ${this._content_type}`)}this._dialog.sendRequest(tr.SUBSCRIBE,{body:n,extraHeaders:s,eventHandlers:{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onSuccessResponse:o=>{this._receiveSubscribeResponse(o)},onErrorResponse:o=>{this._receiveSubscribeResponse(o)},onDialogError:o=>{this._receiveSubscribeResponse(o)}}})}}_receiveSubscribeResponse(n){if(this._state!==Y.STATE_TERMINATED)if(n.status_code>=200&&n.status_code<300){if(this._dialog===null){const c=new go(this,n,"UAC");if(c.error){Te.warn(c.error),this._terminateDialog(Y.SUBSCRIBE_WRONG_OK_RESPONSE);return}this._dialog=c,Te.debug('emit "accepted"'),this.emit("accepted");for(const t of this._queue)Te.debug("dequeue subscribe"),this._sendSubsequentSubscribe(t.body,t.headers)}const s=n.getHeader("expires");let o=parseInt(s);(!Ke.isDecimal(o)||o<=0)&&(Te.warn(`response without Expires header, setting a default value of ${Y.DEFAULT_EXPIRES_SEC}`),o=Y.DEFAULT_EXPIRES_SEC),o>0&&this._scheduleSubscribe(o)}else n.status_code===401||n.status_code===407?this._terminateDialog(Y.SUBSCRIBE_AUTHENTICATION_FAILED):n.status_code>=300&&this._terminateDialog(Y.SUBSCRIBE_NON_OK_RESPONSE)}_scheduleSubscribe(n){const s=n>=140?n*1e3/2+Math.floor((n/2-70)*1e3*Math.random()):n*1e3-5e3;this._expires_timestamp=new Date().getTime()+n*1e3,Te.debug(`next SUBSCRIBE will be sent in ${Math.floor(s/1e3)} sec`),clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._expires_timer=null,this._sendSubsequentSubscribe(null,this._headers)},s)}_parseSubscriptionState(n){switch(n){case"pending":return Y.STATE_PENDING;case"active":return Y.STATE_ACTIVE;case"terminated":return Y.STATE_TERMINATED;case"init":return Y.STATE_INIT;case"notify_wait":return Y.STATE_WAITING_NOTIFY;default:return}}};const Eo=Fe.EventEmitter,sr=He,So=pe,rr=oe,fs=Ce(),Co=Qs,De=new So("Notifier"),se={NOTIFY_RESPONSE_TIMEOUT:0,NOTIFY_TRANSPORT_ERROR:1,NOTIFY_NON_OK_RESPONSE:2,NOTIFY_AUTHENTICATION_FAILED:3,FINAL_NOTIFY_SENT:4,UNSUBSCRIBE_RECEIVED:5,SUBSCRIPTION_EXPIRED:6,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,DEFAULT_EXPIRES_SEC:900};var Ao=class Kr extends Eo{static get C(){return se}static init_incoming(n,s){try{Kr.checkSubscribe(n)}catch(o){De.warn("Notifier.init_incoming: invalid request. Error: ",o.message),n.reply(405);return}s()}static checkSubscribe(n){if(!n)throw new TypeError("Not enough arguments. Missing subscribe request");if(n.method!==rr.SUBSCRIBE)throw new TypeError("Invalid method for Subscribe request");if(!n.hasHeader("contact"))throw new TypeError("Missing Contact header in subscribe request");if(!n.hasHeader("event"))throw new TypeError("Missing Event header in subscribe request");const s=n.getHeader("expires");if(s){const o=parseInt(s);if(!fs.isDecimal(o)||o<0)throw new TypeError("Invalid Expires header field in subscribe request")}}constructor(n,s,o,{extraHeaders:c,allowEvents:t,pending:d,defaultExpires:p}){if(De.debug("new"),super(),!o)throw new TypeError("Not enough arguments. Missing contentType");Kr.checkSubscribe(s);const a=s.getHeader("event");this._ua=n,this._initial_subscribe=s,this._expires_timestamp=null,this._expires_timer=null,this._defaultExpires=p||se.DEFAULT_EXPIRES_SEC,this._state=d?se.STATE_PENDING:se.STATE_ACTIVE,this._content_type=o,this._headers=fs.cloneArray(c),this._headers.push(`Event: ${a}`),this._contact=this._headers.find(T=>T.startsWith("Contact")),this._contact||(this._contact=`Contact: ${this._ua._contact.toString()}`,this._headers.push(this._contact)),t&&this._headers.push(`Allow-Events: ${t}`),this._target=s.from.uri.user,s.to_tag=fs.newTag(),this._data={}}get C(){return se}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(n){this._data=n}receiveRequest(n){if(n.method!==rr.SUBSCRIBE){n.reply(405);return}this._setExpires(n),this._dialog||(this._dialog=new Co(this,n,"UAS")),n.reply(200,null,[`Expires: ${this._expires}`,`${this._contact}`]);const s=n.body,o=n.getHeader("content-type"),c=this._expires===0;c||this._setExpiresTimer(),De.debug('emit "subscribe"'),this.emit("subscribe",c,n,s,o),c&&this._terminateDialog(se.UNSUBSCRIBE_RECEIVED)}start(){if(De.debug("start()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);this.receiveRequest(this._initial_subscribe)}setActiveState(){if(De.debug("setActiveState()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);this._state===se.STATE_PENDING&&(this._state=se.STATE_ACTIVE)}notify(n=null){if(De.debug("notify()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);const s=Math.floor((this._expires_timestamp-new Date().getTime())/1e3);s<=0?(this._expires_timer||De.error("expires timer is not set"),clearTimeout(this._expires_timer),this.terminate(n,"timeout")):this._sendNotify([`;expires=${s}`],n)}terminate(n=null,s=null,o=null){if(De.debug("terminate()"),this._state===se.STATE_TERMINATED)return;const c=[];s&&c.push(`;reason=${s}`),o!==null&&c.push(`;retry-after=${o}`),this._sendNotify(c,n,null,"terminated"),this._terminateDialog(s==="timeout"?se.SUBSCRIPTION_EXPIRED:se.FINAL_NOTIFY_SENT)}_terminateDialog(n){this._state!==se.STATE_TERMINATED&&(this._state=se.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),De.debug(`emit "terminated" code=${n}`),this.emit("terminated",n))}_setExpires(n){n.hasHeader("expires")?this._expires=parseInt(n.getHeader("expires")):(this._expires=this._defaultExpires,De.debug(`missing Expires header field, default value set: ${this._expires}`))}_sendNotify(n,s=null,o=null,c=null){if(this._state===se.STATE_TERMINATED){De.warn("final notify already sent");return}let t=`Subscription-State: ${c||this._parseState()}`;for(const p of n)t+=p;let d=fs.cloneArray(this._headers);d.push(t),o&&(d=d.concat(o)),s&&d.push(`Content-Type: ${this._content_type}`),this._dialog.sendRequest(rr.NOTIFY,{body:s,extraHeaders:d,eventHandlers:{onRequestTimeout:()=>{this._terminateDialog(se.NOTIFY_RESPONSE_TIMEOUT)},onTransportError:()=>{this._terminateDialog(se.NOTIFY_TRANSPORT_ERROR)},onErrorResponse:p=>{p.status_code===401||p.status_code===407?this._terminateDialog(se.NOTIFY_AUTHENTICATION_FAILED):this._terminateDialog(se.NOTIFY_NON_OK_RESPONSE)},onDialogError:()=>{this._terminateDialog(se.NOTIFY_NON_OK_RESPONSE)}}})}_setExpiresTimer(){this._expires_timestamp=new Date().getTime()+this._expires*1e3,clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._state!==se.STATE_TERMINATED&&(De.debug('emit "expired"'),this.emit("expired"),this.terminate(null,"timeout"))},this._expires*1e3)}_parseState(){switch(this._state){case se.STATE_PENDING:return"pending";case se.STATE_ACTIVE:return"active";case se.STATE_TERMINATED:return"terminated";default:throw new TypeError("wrong state value")}}};const vo=Fe.EventEmitter,Ro=pe,nr=oe,Io=ke,kt=Ce(),bo=At,Mn=He,wo=Ze(),hs=new Ro("Message");var yo=class extends vo{constructor(n){super(),this._ua=n,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(n,s,o={}){const c=n;if(n===void 0||s===void 0)throw new TypeError("Not enough arguments");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${c}`);const t=kt.cloneArray(o.extraHeaders),d=kt.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",a={};o.fromUserName&&(a.from_uri=new wo("sip",o.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(a.from_display_name=o.fromDisplayName);for(const m in d)Object.prototype.hasOwnProperty.call(d,m)&&this.on(m,d[m]);t.push(`Content-Type: ${p}`),this._request=new Io.OutgoingRequest(nr.MESSAGE,n,this._ua,a,t),s&&(this._request.body=s);const T=new bo(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:m=>{this._receiveResponse(m)}});this._newMessage("local",this._request),T.send()}init_incoming(n){this._request=n,this._newMessage("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const s=kt.cloneArray(n.extraHeaders),o=n.body;if(this._direction!=="incoming")throw new Mn.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,s,o)}reject(n={}){const s=n.status_code||480,o=n.reason_phrase,c=kt.cloneArray(n.extraHeaders),t=n.body;if(this._direction!=="incoming")throw new Mn.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._is_replied=!0,this._request.reply(s,o,c,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):{this._succeeded("remote",n);break}default:{const s=kt.sipErrorCause(n.status_code);this._failed("remote",n,s);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,nr.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,nr.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(n,s){n==="remote"?(this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from):n==="local"&&(this._direction="outgoing",this._local_identity=s.from,this._remote_identity=s.to),this._ua.newMessage(this,{originator:n,message:this,request:s})}_failed(n,s,o){hs.debug("MESSAGE failed"),this._close(),hs.debug('emit "failed"'),this.emit("failed",{originator:n,response:s||null,cause:o})}_succeeded(n,s){hs.debug("MESSAGE succeeded"),this._close(),hs.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:s})}};const No=Fe.EventEmitter,Oo=pe,lr=oe,xo=ke,qt=Ce(),Do=At,Ln=He,ds=new Oo("Options");var Uo=class extends No{constructor(n){super(),this._ua=n,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(n,s,o={}){const c=n;if(n===void 0)throw new TypeError("A target is required for OPTIONS");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${c}`);const t=qt.cloneArray(o.extraHeaders),d=qt.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const T in d)Object.prototype.hasOwnProperty.call(d,T)&&this.on(T,d[T]);t.push(`Content-Type: ${p}`),this._request=new xo.OutgoingRequest(lr.OPTIONS,n,this._ua,null,t),s&&(this._request.body=s);const a=new Do(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:T=>{this._receiveResponse(T)}});this._newOptions("local",this._request),a.send()}init_incoming(n){this._request=n,this._newOptions("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const s=qt.cloneArray(n.extraHeaders),o=n.body;if(this._direction!=="incoming")throw new Ln.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,s,o)}reject(n={}){const s=n.status_code||480,o=n.reason_phrase,c=qt.cloneArray(n.extraHeaders),t=n.body;if(this._direction!=="incoming")throw new Ln.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._is_replied=!0,this._request.reply(s,o,c,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):{this._succeeded("remote",n);break}default:{const s=qt.sipErrorCause(n.status_code);this._failed("remote",n,s);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,lr.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,lr.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(n,s){n==="remote"?(this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from):n==="local"&&(this._direction="outgoing",this._local_identity=s.from,this._remote_identity=s.to),this._ua.newOptions(this,{originator:n,message:this,request:s})}_failed(n,s,o){ds.debug("OPTIONS failed"),this._close(),ds.debug('emit "failed"'),this.emit("failed",{originator:n,response:s||null,cause:o})}_succeeded(n,s){ds.debug("OPTIONS succeeded"),this._close(),ds.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:s})}},ir={};const $o=pe,ar=Ce(),Po=$e(),Gt=new $o("Socket");ir.isSocket=f=>{if(Array.isArray(f))return!1;if(typeof f>"u")return Gt.warn("undefined JsSIP.Socket instance"),!1;try{if(!ar.isString(f.url))throw Gt.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ar.isString(f.via_transport))throw Gt.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Po.parse(f.sip_uri,"SIP_URI")===-1)throw Gt.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(n=>{if(!ar.isFunction(f[n]))throw Gt.warn(`missing or invalid JsSIP.Socket method: ${n}`),new Error(`Missing or invalid JsSIP.Socket method: ${n}`)})}catch{return!1}return!0};const Mo=pe,Lo=ir,Hn=oe,Re=new Mo("Transport"),Ue={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Hn.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Hn.CONNECTION_RECOVERY_MAX_INTERVAL}};var Ho=class{constructor(n,s=Ue.recovery_options){Re.debug("new()"),this.status=Ue.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=s,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){Re.warn(`cannot use TextDecoder: ${o}`)}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(o){if(!Lo.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:Ue.SOCKET_STATUS_READY})},this),this._getSocket()}get via_transport(){return this.socket.via_transport}get url(){return this.socket.url}get sip_uri(){return this.socket.sip_uri}connect(){if(Re.debug("connect()"),this.isConnected()){Re.debug("Transport is already connected");return}else if(this.isConnecting()){Re.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ue.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect())}disconnect(){Re.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ue.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(n){if(Re.debug("send()"),!this.isConnected())return Re.warn("unable to send message, transport is not connected"),!1;const s=n.toString();return Re.debug(`sending message:
182
47
 
183
- `+e+`
184
- `),this._state!==ee.Connected)return Promise.reject(new Error("Not connected."));if(!this._ws)throw new Error("WebSocket undefined.");try{this._ws.send(e)}catch(t){return t instanceof Error?Promise.reject(t):Promise.reject(new Error("WebSocket send failed."))}return Promise.resolve()}onWebSocketClose(e,t){if(t!==this._ws)return;const s=`WebSocket closed ${this.server} (code: ${e.code})`,i=this.disconnectPromise?void 0:new Error(s);i&&this.logger.warn("WebSocket closed unexpectedly"),this.logger.log(s),this._ws=void 0,this.transitionState(ee.Disconnected,i)}onWebSocketError(e,t){t===this._ws&&this.logger.error("WebSocket error occurred.")}onWebSocketMessage(e,t){if(t!==this._ws)return;const s=e.data;let i;if(/^(\r\n)+$/.test(s)){this.clearKeepAliveTimeout(),this.configuration.traceSip===!0&&this.logger.log("Received WebSocket message with CRLF Keep Alive response");return}if(!s){this.logger.warn("Received empty message, discarding...");return}if(typeof s!="string"){try{i=new TextDecoder().decode(new Uint8Array(s))}catch(n){this.logger.error(n.toString()),this.logger.error("Received WebSocket binary message failed to be converted into string, message discarded");return}this.configuration.traceSip===!0&&this.logger.log(`Received WebSocket binary message:
48
+ ${s}
49
+ `),this.socket.send(s)}isConnected(){return this.status===Ue.STATUS_CONNECTED}isConnecting(){return this.status===Ue.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let n=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);n<this.recovery_options.min_interval?n=this.recovery_options.min_interval:n>this.recovery_options.max_interval&&(n=this.recovery_options.max_interval),Re.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${n} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},n*1e3)}_getSocket(){let n=[];if(this.sockets.forEach(o=>{o.status!==Ue.SOCKET_STATUS_ERROR&&(n.length===0?n.push(o):o.weight>n[0].weight?n=[o]:o.weight===n[0].weight&&n.push(o))}),n.length===0){this.sockets.forEach(o=>{o.status=Ue.SOCKET_STATUS_READY}),this._getSocket();return}const s=Math.floor(Math.random()*n.length);this.socket=n[s].socket}_onConnect(){this.recover_attempts=0,this.status=Ue.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(n,s,o){this.status=Ue.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:n,code:s,reason:o}),!this.close_requested&&(this.sockets.forEach(function(c){this.socket===c.socket&&(c.status=Ue.SOCKET_STATUS_ERROR)},this),this._reconnect(n))}_onData(n){if(n===`\r
50
+ \r
51
+ `){Re.debug("received message with double-CRLF Keep Alive request");try{this.socket.send(`\r
52
+ `)}catch(s){Re.warn(`error sending Keep Alive response: ${s}`)}return}if(n===`\r
53
+ `){Re.debug("received message with CRLF Keep Alive response");return}else if(typeof n!="string"){try{this.textDecoder?n=this.textDecoder.decode(n):n=String.fromCharCode.apply(null,new Uint8Array(n))}catch(s){Re.debug(`received binary message failed to be converted into string: ${s}`);return}Re.debug(`received binary message:
185
54
 
186
- `+i+`
187
- `)}else i=s,this.configuration.traceSip===!0&&this.logger.log(`Received WebSocket text message:
55
+ ${n}
56
+ `)}else Re.debug(`received text message:
188
57
 
189
- `+i+`
190
- `);if(this.state!==ee.Connected){this.logger.warn("Received message while not connected, discarding...");return}if(this.onMessage)try{this.onMessage(i)}catch(n){throw this.logger.error(n.toString()),this.logger.error("Exception thrown by onMessage callback"),n}}onWebSocketOpen(e,t){t===this._ws&&this._state===ee.Connecting&&(this.logger.log(`WebSocket opened ${this.server}`),this.transitionState(ee.Connected))}transitionLoopDetectedError(e){let t="A state transition loop has been detected.";return t+=` An attempt to transition from ${this._state} to ${e} before the prior transition completed.`,t+=" Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?",this.logger.error(t),new Mr("Loop detected.")}transitionState(e,t){const s=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};if(this.transitioningState)throw this.transitionLoopDetectedError(e);switch(this.transitioningState=!0,this._state){case ee.Connecting:e!==ee.Connected&&e!==ee.Disconnecting&&e!==ee.Disconnected&&s();break;case ee.Connected:e!==ee.Disconnecting&&e!==ee.Disconnected&&s();break;case ee.Disconnecting:e!==ee.Connecting&&e!==ee.Disconnected&&s();break;case ee.Disconnected:e!==ee.Connecting&&s();break;default:throw new Error("Unknown state.")}const i=this._state;this._state=e;const n=this.connectResolve,a=this.connectReject;i===ee.Connecting&&(this.connectPromise=void 0,this.connectResolve=void 0,this.connectReject=void 0);const o=this.disconnectResolve,d=this.disconnectReject;if(i===ee.Disconnecting&&(this.disconnectPromise=void 0,this.disconnectResolve=void 0,this.disconnectReject=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),this.logger.log(`Transitioned from ${i} to ${this._state}`),this._stateEventEmitter.emit(this._state),e===ee.Connected&&(this.startSendingKeepAlives(),this.onConnect))try{this.onConnect()}catch(c){throw this.logger.error(c.toString()),this.logger.error("Exception thrown by onConnect callback"),c}if(i===ee.Connected&&(this.stopSendingKeepAlives(),this.onDisconnect))try{t?this.onDisconnect(t):this.onDisconnect()}catch(c){throw this.logger.error(c.toString()),this.logger.error("Exception thrown by onDisconnect callback"),c}if(i===ee.Connecting){if(!n)throw new Error("Connect resolve undefined.");if(!a)throw new Error("Connect reject undefined.");e===ee.Connected?n():a(t||new Error("Connect aborted."))}if(i===ee.Disconnecting){if(!o)throw new Error("Disconnect resolve undefined.");if(!d)throw new Error("Disconnect reject undefined.");e===ee.Disconnected?o():d(t||new Error("Disconnect aborted."))}this.transitioningState=!1}clearKeepAliveTimeout(){this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveDebounceTimeout=void 0}sendKeepAlive(){return this.keepAliveDebounceTimeout?Promise.resolve():(this.keepAliveDebounceTimeout=setTimeout(()=>{this.clearKeepAliveTimeout()},this.configuration.keepAliveDebounce*1e3),this.send(`\r
191
- \r
192
- `))}startSendingKeepAlives(){const e=t=>{const s=t*.8;return 1e3*(Math.random()*(t-s)+s)};this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},e(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}}xs.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0};class lr{constructor(e={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=je.Stopped,this._stateEventEmitter=new jr,this.delegate=e.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},lr.defaultOptions()),{sipjsId:or(5)}),{uri:new vt("sip","anonymous."+or(6),"anonymous.invalid")}),{viaHost:or(12)+".invalid"}),lr.stripUndefinedProperties(e)),this.options.hackIpInContact)if(typeof this.options.hackIpInContact=="boolean"&&this.options.hackIpInContact){const i=Math.floor(Math.random()*254+1);this.options.viaHost="192.0.2."+i}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new Q0,this.logger=this.loggerFactory.getLogger("sip.UserAgent"),this.loggerFactory.builtinEnabled=this.options.logBuiltinEnabled,this.loggerFactory.connector=this.options.logConnector,this.options.logLevel){case"error":this.loggerFactory.level=Ne.error;break;case"warn":this.loggerFactory.level=Ne.warn;break;case"log":this.loggerFactory.level=Ne.log;break;case"debug":this.loggerFactory.level=Ne.debug;break}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(t=>{const s=this.options[t];switch(t){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+t+": "+s);break;case"authorizationPassword":this.logger.log("· "+t+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+t+": "+s.name);break;default:this.logger.log("· "+t+": "+JSON.stringify(s))}})),this.options.transportOptions){const t=this.options.transportOptions,s=t.maxReconnectionAttempts,i=t.reconnectionTimeout;s!==void 0&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),i!==void 0&&this.logger.warn('The transport option "reconnectionTimeout" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),e.reconnectionDelay===void 0&&i!==void 0&&(this.options.reconnectionDelay=i),e.reconnectionAttempts===void 0&&s!==void 0&&(this.options.reconnectionAttempts=s)}if(e.reconnectionDelay!==void 0&&this.logger.warn('The user agent option "reconnectionDelay" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),e.reconnectionAttempts!==void 0&&this.logger.warn('The user agent option "reconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),this._transport=new this.options.transportConstructor(this.getLogger("sip.Transport"),this.options.transportOptions),this.initTransportCallbacks(),this._contact=this.initContact(),this._instanceId=this.options.instanceId?this.options.instanceId:lr.newUUID(),Pe.parse(this._instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");this._userAgentCore=this.initCore()}static makeURI(e){return Pe.URIParse(e)}static defaultOptions(){return{allowLegacyNotifications:!1,authorizationHa1:"",authorizationPassword:"",authorizationUsername:"",delegate:{},contactName:"",contactParams:{transport:"ws"},displayName:"",forceRport:!1,gracefulShutdown:!0,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,instanceId:"",instanceIdAlwaysAdded:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:()=>{},logLevel:"log",noAnswerTimeout:60,preloadedRouteSet:[],reconnectionAttempts:0,reconnectionDelay:4,sendInitialProvisionalResponse:!0,sessionDescriptionHandlerFactory:bc(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:dt.Unsupported,sipExtensionReplaces:dt.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:xs,transportOptions:{},uri:new vt("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/"+M0,viaHost:""}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const s=Math.floor(Math.random()*16);return(t==="x"?s:s%4+8).toString(16)})}static stripUndefinedProperties(e){return Object.keys(e).reduce((t,s)=>(e[s]!==void 0&&(t[s]=e[s]),t),{})}get configuration(){return this.options}get contact(){return this._contact}get instanceId(){return this._instanceId}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get transport(){return this._transport}get userAgentCore(){return this._userAgentCore}getLogger(e,t){return this.loggerFactory.getLogger(e,t)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===je.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){return this.state===je.Started?(this.logger.warn("User agent already started"),Promise.resolve()):(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(je.Started),this.transport.connect())}async stop(){if(this.state===je.Stopped)return this.logger.warn("User agent already stopped"),Promise.resolve();if(this.logger.log(`Stopping ${this.configuration.uri}`),!this.options.gracefulShutdown)return this.logger.log("Dispose of transport"),this.transport.dispose().catch(o=>{throw this.logger.error(o.message),o}),this.logger.log("Dispose of core"),this.userAgentCore.dispose(),this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this.transitionState(je.Stopped),Promise.resolve();const e=Object.assign({},this._publishers),t=Object.assign({},this._registerers),s=Object.assign({},this._sessions),i=Object.assign({},this._subscriptions),n=this.transport,a=this.userAgentCore;this.logger.log("Dispose of registerers");for(const o in t)t[o]&&await t[o].dispose().catch(d=>{throw this.logger.error(d.message),delete this._registerers[o],d});this.logger.log("Dispose of sessions");for(const o in s)s[o]&&await s[o].dispose().catch(d=>{throw this.logger.error(d.message),delete this._sessions[o],d});this.logger.log("Dispose of subscriptions");for(const o in i)i[o]&&await i[o].dispose().catch(d=>{throw this.logger.error(d.message),delete this._subscriptions[o],d});this.logger.log("Dispose of publishers");for(const o in e)e[o]&&await e[o].dispose().catch(d=>{throw this.logger.error(d.message),delete this._publishers[o],d});this.logger.log("Dispose of transport"),await n.dispose().catch(o=>{throw this.logger.error(o.message),o}),this.logger.log("Dispose of core"),a.dispose(),this.transitionState(je.Stopped)}_makeInviter(e,t){return new Ra(this,e,t)}attemptReconnection(e=1){const t=this.options.reconnectionAttempts,s=this.options.reconnectionDelay;if(e>t){this.logger.log("Maximum reconnection attempts reached");return}this.logger.log(`Reconnection attempt ${e} of ${t} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${e} of ${t} - succeeded`)}).catch(i=>{this.logger.error(i.message),this.logger.log(`Reconnection attempt ${e} of ${t} - failed`),this.attemptReconnection(++e)})},e===1?0:s*1e3)}initContact(){const e=this.options.contactName!==""?this.options.contactName:or(8),t=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new vt("sip",e,this.options.viaHost,void 0,t),toString:(i={})=>{const n=i.anonymous||!1,a=i.outbound||!1,o=i.register||!1;let d="<";return n?d+=this.contact.tempGruu||`sip:anonymous@anonymous.invalid;transport=${t.transport?t.transport:"ws"}`:o?d+=this.contact.uri:d+=this.contact.pubGruu||this.contact.uri,a&&(d+=";ob"),d+=">",this.options.instanceIdAlwaysAdded&&(d+=';+sip.instance="<urn:uuid:'+this._instanceId+'>"'),d}}}initCore(){let e=[];e.push("outbound"),this.options.sipExtension100rel===dt.Supported&&e.push("100rel"),this.options.sipExtensionReplaces===dt.Supported&&e.push("replaces"),this.options.sipExtensionExtraSupported&&e.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(e=e.filter(n=>Z0[n])),e=Array.from(new Set(e));const t=e.slice();(this.contact.pubGruu||this.contact.tempGruu)&&t.push("gruu");const s={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:e,supportedOptionTagsResponse:t,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const n=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,a=this.options.authorizationPassword?this.options.authorizationPassword:void 0,o=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new J0(this.getLoggerFactory(),o,n,a)},transportAccessor:()=>this.transport},i={onInvite:n=>{var a;const o=new X0(this,n);if(n.delegate={onCancel:d=>{o._onCancel(d)},onTransportError:d=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},n.trying(),this.options.sipExtensionReplaces!==dt.Unsupported){const c=n.message.parseHeader("replaces");if(c){const l=c.call_id;if(typeof l!="string")throw new Error("Type of call id is not string");const g=c.replaces_to_tag;if(typeof g!="string")throw new Error("Type of to tag is not string");const f=c.replaces_from_tag;if(typeof f!="string")throw new Error("type of from tag is not string");const y=l+g+f,w=this.userAgentCore.dialogs.get(y);if(!w){o.reject({statusCode:481});return}if(!w.early&&c.early_only===!0){o.reject({statusCode:486});return}const b=this._sessions[l+f]||this._sessions[l+g]||void 0;if(!b)throw new Error("Session does not exist.");o._replacee=b}}if(!((a=this.delegate)===null||a===void 0)&&a.onInvite){if(o.autoSendAnInitialProvisionalResponse){o.progress().then(()=>{var d;if(((d=this.delegate)===null||d===void 0?void 0:d.onInvite)===void 0)throw new Error("onInvite undefined.");this.delegate.onInvite(o)});return}this.delegate.onInvite(o);return}o.reject({statusCode:486})},onMessage:n=>{if(this.delegate&&this.delegate.onMessage){const a=new Ta(n);this.delegate.onMessage(a)}else n.accept()},onNotify:n=>{if(this.delegate&&this.delegate.onNotify){const a=new $i(n);this.delegate.onNotify(a)}else this.options.allowLegacyNotifications?n.accept():n.reject({statusCode:481})},onRefer:n=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(n):n.reject({statusCode:405})},onRegister:n=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(n):n.reject({statusCode:405})},onSubscribe:n=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(n):n.reject({statusCode:405})}};return new yc(s,i)}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=e=>this.onTransportDisconnect(e),this.transport.onMessage=e=>this.onTransportMessage(e)}onTransportConnect(){this.state!==je.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(e){this.state!==je.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(e),e&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(e){const t=hs.parseMessage(e,this.getLogger("sip.Parser"));if(!t){this.logger.warn("Failed to parse incoming message. Dropping.");return}if(this.state===je.Stopped&&t instanceof yr){this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);return}const s=()=>{const i=["from","to","call_id","cseq","via"];for(const n of i)if(!t.hasHeader(n))return this.logger.warn(`Missing mandatory header field : ${n}.`),!1;return!0};if(t instanceof yr){if(!s()){this.logger.warn("Request missing mandatory header field. Dropping.");return}if(!t.toTag&&t.callId.substr(0,5)===this.options.sipjsId){this.userAgentCore.replyStateless(t,{statusCode:482});return}const i=qr(t.body),n=t.getHeader("content-length");if(n&&i<Number(n)){this.userAgentCore.replyStateless(t,{statusCode:400});return}}if(t instanceof Gt){if(!s()){this.logger.warn("Response missing mandatory header field. Dropping.");return}if(t.getHeaders("via").length>1){this.logger.warn("More than one Via header field present in the response. Dropping.");return}if(t.via.host!==this.options.viaHost||t.via.port!==void 0){this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");return}const i=qr(t.body),n=t.getHeader("content-length");if(n&&i<Number(n)){this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.");return}}if(t instanceof yr){this.userAgentCore.receiveIncomingRequestFromTransport(t);return}if(t instanceof Gt){this.userAgentCore.receiveIncomingResponseFromTransport(t);return}throw new Error("Invalid message type.")}transitionState(e,t){const s=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case je.Started:e!==je.Stopped&&s();break;case je.Stopped:e!==je.Started&&s();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${e}`),this._state=e,this._stateEventEmitter.emit(this._state)}}//! moment.js
193
- //! version : 2.30.1
194
- //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
195
- //! license : MIT
196
- //! momentjs.com
197
- var Ma;function W(){return Ma.apply(null,arguments)}function _c(r){Ma=r}function ht(r){return r instanceof Array||Object.prototype.toString.call(r)==="[object Array]"}function dr(r){return r!=null&&Object.prototype.toString.call(r)==="[object Object]"}function ge(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Mi(r){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(r).length===0;var e;for(e in r)if(ge(r,e))return!1;return!0}function Ze(r){return r===void 0}function It(r){return typeof r=="number"||Object.prototype.toString.call(r)==="[object Number]"}function Yr(r){return r instanceof Date||Object.prototype.toString.call(r)==="[object Date]"}function ja(r,e){var t=[],s,i=r.length;for(s=0;s<i;++s)t.push(e(r[s],s));return t}function Xt(r,e){for(var t in e)ge(e,t)&&(r[t]=e[t]);return ge(e,"toString")&&(r.toString=e.toString),ge(e,"valueOf")&&(r.valueOf=e.valueOf),r}function bt(r,e,t,s){return go(r,e,t,s,!0).utc()}function Cc(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function re(r){return r._pf==null&&(r._pf=Cc()),r._pf}var ji;Array.prototype.some?ji=Array.prototype.some:ji=function(r){var e=Object(this),t=e.length>>>0,s;for(s=0;s<t;s++)if(s in e&&r.call(this,e[s],s,e))return!0;return!1};function qi(r){var e=null,t=!1,s=r._d&&!isNaN(r._d.getTime());if(s&&(e=re(r),t=ji.call(e.parsedDateParts,function(i){return i!=null}),s=e.overflow<0&&!e.empty&&!e.invalidEra&&!e.invalidMonth&&!e.invalidWeekday&&!e.weekdayMismatch&&!e.nullInput&&!e.invalidFormat&&!e.userInvalidated&&(!e.meridiem||e.meridiem&&t),r._strict&&(s=s&&e.charsLeftOver===0&&e.unusedTokens.length===0&&e.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(r))r._isValid=s;else return s;return r._isValid}function ps(r){var e=bt(NaN);return r!=null?Xt(re(e),r):re(e).userInvalidated=!0,e}var qa=W.momentProperties=[],Ui=!1;function Li(r,e){var t,s,i,n=qa.length;if(Ze(e._isAMomentObject)||(r._isAMomentObject=e._isAMomentObject),Ze(e._i)||(r._i=e._i),Ze(e._f)||(r._f=e._f),Ze(e._l)||(r._l=e._l),Ze(e._strict)||(r._strict=e._strict),Ze(e._tzm)||(r._tzm=e._tzm),Ze(e._isUTC)||(r._isUTC=e._isUTC),Ze(e._offset)||(r._offset=e._offset),Ze(e._pf)||(r._pf=re(e)),Ze(e._locale)||(r._locale=e._locale),n>0)for(t=0;t<n;t++)s=qa[t],i=e[s],Ze(i)||(r[s]=i);return r}function Wr(r){Li(this,r),this._d=new Date(r._d!=null?r._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),Ui===!1&&(Ui=!0,W.updateOffset(this),Ui=!1)}function ut(r){return r instanceof Wr||r!=null&&r._isAMomentObject!=null}function Ua(r){W.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+r)}function it(r,e){var t=!0;return Xt(function(){if(W.deprecationHandler!=null&&W.deprecationHandler(null,r),t){var s=[],i,n,a,o=arguments.length;for(n=0;n<o;n++){if(i="",typeof arguments[n]=="object"){i+=`
198
- [`+n+"] ";for(a in arguments[0])ge(arguments[0],a)&&(i+=a+": "+arguments[0][a]+", ");i=i.slice(0,-2)}else i=arguments[n];s.push(i)}Ua(r+`
199
- Arguments: `+Array.prototype.slice.call(s).join("")+`
200
- `+new Error().stack),t=!1}return e.apply(this,arguments)},e)}var La={};function Ya(r,e){W.deprecationHandler!=null&&W.deprecationHandler(r,e),La[r]||(Ua(e),La[r]=!0)}W.suppressDeprecationWarnings=!1,W.deprecationHandler=null;function _t(r){return typeof Function<"u"&&r instanceof Function||Object.prototype.toString.call(r)==="[object Function]"}function Dc(r){var e,t;for(t in r)ge(r,t)&&(e=r[t],_t(e)?this[t]=e:this["_"+t]=e);this._config=r,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function Yi(r,e){var t=Xt({},r),s;for(s in e)ge(e,s)&&(dr(r[s])&&dr(e[s])?(t[s]={},Xt(t[s],r[s]),Xt(t[s],e[s])):e[s]!=null?t[s]=e[s]:delete t[s]);for(s in r)ge(r,s)&&!ge(e,s)&&dr(r[s])&&(t[s]=Xt({},t[s]));return t}function Wi(r){r!=null&&this.set(r)}var Gi;Object.keys?Gi=Object.keys:Gi=function(r){var e,t=[];for(e in r)ge(r,e)&&t.push(e);return t};var Ac={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function Sc(r,e,t){var s=this._calendar[r]||this._calendar.sameElse;return _t(s)?s.call(e,t):s}function Ct(r,e,t){var s=""+Math.abs(r),i=e-s.length,n=r>=0;return(n?t?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+s}var Vi=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,ms=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,zi={},Er={};function Q(r,e,t,s){var i=s;typeof s=="string"&&(i=function(){return this[s]()}),r&&(Er[r]=i),e&&(Er[e[0]]=function(){return Ct(i.apply(this,arguments),e[1],e[2])}),t&&(Er[t]=function(){return this.localeData().ordinal(i.apply(this,arguments),r)})}function Tc(r){return r.match(/\[[\s\S]/)?r.replace(/^\[|\]$/g,""):r.replace(/\\/g,"")}function Rc(r){var e=r.match(Vi),t,s;for(t=0,s=e.length;t<s;t++)Er[e[t]]?e[t]=Er[e[t]]:e[t]=Tc(e[t]);return function(i){var n="",a;for(a=0;a<s;a++)n+=_t(e[a])?e[a].call(i,r):e[a];return n}}function vs(r,e){return r.isValid()?(e=Wa(e,r.localeData()),zi[e]=zi[e]||Rc(e),zi[e](r)):r.localeData().invalidDate()}function Wa(r,e){var t=5;function s(i){return e.longDateFormat(i)||i}for(ms.lastIndex=0;t>=0&&ms.test(r);)r=r.replace(ms,s),ms.lastIndex=0,t-=1;return r}var Fc={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function kc(r){var e=this._longDateFormat[r],t=this._longDateFormat[r.toUpperCase()];return e||!t?e:(this._longDateFormat[r]=t.match(Vi).map(function(s){return s==="MMMM"||s==="MM"||s==="DD"||s==="dddd"?s.slice(1):s}).join(""),this._longDateFormat[r])}var Bc="Invalid date";function Ic(){return this._invalidDate}var Pc="%d",Hc=/\d{1,2}/;function $c(r){return this._ordinal.replace("%d",r)}var Oc={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function Nc(r,e,t,s){var i=this._relativeTime[t];return _t(i)?i(r,e,t,s):i.replace(/%d/i,r)}function Mc(r,e){var t=this._relativeTime[r>0?"future":"past"];return _t(t)?t(e):t.replace(/%s/i,e)}var Ga={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function nt(r){return typeof r=="string"?Ga[r]||Ga[r.toLowerCase()]:void 0}function Ki(r){var e={},t,s;for(s in r)ge(r,s)&&(t=nt(s),t&&(e[t]=r[s]));return e}var jc={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function qc(r){var e=[],t;for(t in r)ge(r,t)&&e.push({unit:t,priority:jc[t]});return e.sort(function(s,i){return s.priority-i.priority}),e}var Va=/\d/,tt=/\d\d/,za=/\d{3}/,Zi=/\d{4}/,ys=/[+-]?\d{6}/,_e=/\d\d?/,Ka=/\d\d\d\d?/,Za=/\d\d\d\d\d\d?/,ws=/\d{1,3}/,Xi=/\d{1,4}/,Es=/[+-]?\d{1,6}/,br=/\d+/,bs=/[+-]?\d+/,Uc=/Z|[+-]\d\d:?\d\d/gi,_s=/Z|[+-]\d\d(?::?\d\d)?/gi,Lc=/[+-]?\d+(\.\d{1,3})?/,Gr=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,_r=/^[1-9]\d?/,Ji=/^([1-9]\d|\d)/,Cs;Cs={};function X(r,e,t){Cs[r]=_t(e)?e:function(s,i){return s&&t?t:e}}function Yc(r,e){return ge(Cs,r)?Cs[r](e._strict,e._locale):new RegExp(Wc(r))}function Wc(r){return Pt(r.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,s,i,n){return t||s||i||n}))}function Pt(r){return r.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function at(r){return r<0?Math.ceil(r)||0:Math.floor(r)}function ae(r){var e=+r,t=0;return e!==0&&isFinite(e)&&(t=at(e)),t}var Qi={};function ye(r,e){var t,s=e,i;for(typeof r=="string"&&(r=[r]),It(e)&&(s=function(n,a){a[e]=ae(n)}),i=r.length,t=0;t<i;t++)Qi[r[t]]=s}function Vr(r,e){ye(r,function(t,s,i,n){i._w=i._w||{},e(t,i._w,i,n)})}function Gc(r,e,t){e!=null&&ge(Qi,r)&&Qi[r](e,t._a,t,r)}function Ds(r){return r%4===0&&r%100!==0||r%400===0}var Le=0,Ht=1,Dt=2,He=3,ft=4,$t=5,hr=6,Vc=7,zc=8;Q("Y",0,0,function(){var r=this.year();return r<=9999?Ct(r,4):"+"+r}),Q(0,["YY",2],0,function(){return this.year()%100}),Q(0,["YYYY",4],0,"year"),Q(0,["YYYYY",5],0,"year"),Q(0,["YYYYYY",6,!0],0,"year"),X("Y",bs),X("YY",_e,tt),X("YYYY",Xi,Zi),X("YYYYY",Es,ys),X("YYYYYY",Es,ys),ye(["YYYYY","YYYYYY"],Le),ye("YYYY",function(r,e){e[Le]=r.length===2?W.parseTwoDigitYear(r):ae(r)}),ye("YY",function(r,e){e[Le]=W.parseTwoDigitYear(r)}),ye("Y",function(r,e){e[Le]=parseInt(r,10)});function zr(r){return Ds(r)?366:365}W.parseTwoDigitYear=function(r){return ae(r)+(ae(r)>68?1900:2e3)};var Xa=Cr("FullYear",!0);function Kc(){return Ds(this.year())}function Cr(r,e){return function(t){return t!=null?(Ja(this,r,t),W.updateOffset(this,e),this):Kr(this,r)}}function Kr(r,e){if(!r.isValid())return NaN;var t=r._d,s=r._isUTC;switch(e){case"Milliseconds":return s?t.getUTCMilliseconds():t.getMilliseconds();case"Seconds":return s?t.getUTCSeconds():t.getSeconds();case"Minutes":return s?t.getUTCMinutes():t.getMinutes();case"Hours":return s?t.getUTCHours():t.getHours();case"Date":return s?t.getUTCDate():t.getDate();case"Day":return s?t.getUTCDay():t.getDay();case"Month":return s?t.getUTCMonth():t.getMonth();case"FullYear":return s?t.getUTCFullYear():t.getFullYear();default:return NaN}}function Ja(r,e,t){var s,i,n,a,o;if(!(!r.isValid()||isNaN(t))){switch(s=r._d,i=r._isUTC,e){case"Milliseconds":return void(i?s.setUTCMilliseconds(t):s.setMilliseconds(t));case"Seconds":return void(i?s.setUTCSeconds(t):s.setSeconds(t));case"Minutes":return void(i?s.setUTCMinutes(t):s.setMinutes(t));case"Hours":return void(i?s.setUTCHours(t):s.setHours(t));case"Date":return void(i?s.setUTCDate(t):s.setDate(t));case"FullYear":break;default:return}n=t,a=r.month(),o=r.date(),o=o===29&&a===1&&!Ds(n)?28:o,i?s.setUTCFullYear(n,a,o):s.setFullYear(n,a,o)}}function Zc(r){return r=nt(r),_t(this[r])?this[r]():this}function Xc(r,e){if(typeof r=="object"){r=Ki(r);var t=qc(r),s,i=t.length;for(s=0;s<i;s++)this[t[s].unit](r[t[s].unit])}else if(r=nt(r),_t(this[r]))return this[r](e);return this}function Jc(r,e){return(r%e+e)%e}var Re;Array.prototype.indexOf?Re=Array.prototype.indexOf:Re=function(r){var e;for(e=0;e<this.length;++e)if(this[e]===r)return e;return-1};function en(r,e){if(isNaN(r)||isNaN(e))return NaN;var t=Jc(e,12);return r+=(e-t)/12,t===1?Ds(r)?29:28:31-t%7%2}Q("M",["MM",2],"Mo",function(){return this.month()+1}),Q("MMM",0,0,function(r){return this.localeData().monthsShort(this,r)}),Q("MMMM",0,0,function(r){return this.localeData().months(this,r)}),X("M",_e,_r),X("MM",_e,tt),X("MMM",function(r,e){return e.monthsShortRegex(r)}),X("MMMM",function(r,e){return e.monthsRegex(r)}),ye(["M","MM"],function(r,e){e[Ht]=ae(r)-1}),ye(["MMM","MMMM"],function(r,e,t,s){var i=t._locale.monthsParse(r,s,t._strict);i!=null?e[Ht]=i:re(t).invalidMonth=r});var Qc="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Qa="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),eo=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,el=Gr,tl=Gr;function rl(r,e){return r?ht(this._months)?this._months[r.month()]:this._months[(this._months.isFormat||eo).test(e)?"format":"standalone"][r.month()]:ht(this._months)?this._months:this._months.standalone}function sl(r,e){return r?ht(this._monthsShort)?this._monthsShort[r.month()]:this._monthsShort[eo.test(e)?"format":"standalone"][r.month()]:ht(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function il(r,e,t){var s,i,n,a=r.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],s=0;s<12;++s)n=bt([2e3,s]),this._shortMonthsParse[s]=this.monthsShort(n,"").toLocaleLowerCase(),this._longMonthsParse[s]=this.months(n,"").toLocaleLowerCase();return t?e==="MMM"?(i=Re.call(this._shortMonthsParse,a),i!==-1?i:null):(i=Re.call(this._longMonthsParse,a),i!==-1?i:null):e==="MMM"?(i=Re.call(this._shortMonthsParse,a),i!==-1?i:(i=Re.call(this._longMonthsParse,a),i!==-1?i:null)):(i=Re.call(this._longMonthsParse,a),i!==-1?i:(i=Re.call(this._shortMonthsParse,a),i!==-1?i:null))}function nl(r,e,t){var s,i,n;if(this._monthsParseExact)return il.call(this,r,e,t);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),s=0;s<12;s++){if(i=bt([2e3,s]),t&&!this._longMonthsParse[s]&&(this._longMonthsParse[s]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[s]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),!t&&!this._monthsParse[s]&&(n="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[s]=new RegExp(n.replace(".",""),"i")),t&&e==="MMMM"&&this._longMonthsParse[s].test(r))return s;if(t&&e==="MMM"&&this._shortMonthsParse[s].test(r))return s;if(!t&&this._monthsParse[s].test(r))return s}}function to(r,e){if(!r.isValid())return r;if(typeof e=="string"){if(/^\d+$/.test(e))e=ae(e);else if(e=r.localeData().monthsParse(e),!It(e))return r}var t=e,s=r.date();return s=s<29?s:Math.min(s,en(r.year(),t)),r._isUTC?r._d.setUTCMonth(t,s):r._d.setMonth(t,s),r}function ro(r){return r!=null?(to(this,r),W.updateOffset(this,!0),this):Kr(this,"Month")}function al(){return en(this.year(),this.month())}function ol(r){return this._monthsParseExact?(ge(this,"_monthsRegex")||so.call(this),r?this._monthsShortStrictRegex:this._monthsShortRegex):(ge(this,"_monthsShortRegex")||(this._monthsShortRegex=el),this._monthsShortStrictRegex&&r?this._monthsShortStrictRegex:this._monthsShortRegex)}function cl(r){return this._monthsParseExact?(ge(this,"_monthsRegex")||so.call(this),r?this._monthsStrictRegex:this._monthsRegex):(ge(this,"_monthsRegex")||(this._monthsRegex=tl),this._monthsStrictRegex&&r?this._monthsStrictRegex:this._monthsRegex)}function so(){function r(d,c){return c.length-d.length}var e=[],t=[],s=[],i,n,a,o;for(i=0;i<12;i++)n=bt([2e3,i]),a=Pt(this.monthsShort(n,"")),o=Pt(this.months(n,"")),e.push(a),t.push(o),s.push(o),s.push(a);e.sort(r),t.sort(r),s.sort(r),this._monthsRegex=new RegExp("^("+s.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+t.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+e.join("|")+")","i")}function ll(r,e,t,s,i,n,a){var o;return r<100&&r>=0?(o=new Date(r+400,e,t,s,i,n,a),isFinite(o.getFullYear())&&o.setFullYear(r)):o=new Date(r,e,t,s,i,n,a),o}function Zr(r){var e,t;return r<100&&r>=0?(t=Array.prototype.slice.call(arguments),t[0]=r+400,e=new Date(Date.UTC.apply(null,t)),isFinite(e.getUTCFullYear())&&e.setUTCFullYear(r)):e=new Date(Date.UTC.apply(null,arguments)),e}function As(r,e,t){var s=7+e-t,i=(7+Zr(r,0,s).getUTCDay()-e)%7;return-i+s-1}function io(r,e,t,s,i){var n=(7+t-s)%7,a=As(r,s,i),o=1+7*(e-1)+n+a,d,c;return o<=0?(d=r-1,c=zr(d)+o):o>zr(r)?(d=r+1,c=o-zr(r)):(d=r,c=o),{year:d,dayOfYear:c}}function Xr(r,e,t){var s=As(r.year(),e,t),i=Math.floor((r.dayOfYear()-s-1)/7)+1,n,a;return i<1?(a=r.year()-1,n=i+Ot(a,e,t)):i>Ot(r.year(),e,t)?(n=i-Ot(r.year(),e,t),a=r.year()+1):(a=r.year(),n=i),{week:n,year:a}}function Ot(r,e,t){var s=As(r,e,t),i=As(r+1,e,t);return(zr(r)-s+i)/7}Q("w",["ww",2],"wo","week"),Q("W",["WW",2],"Wo","isoWeek"),X("w",_e,_r),X("ww",_e,tt),X("W",_e,_r),X("WW",_e,tt),Vr(["w","ww","W","WW"],function(r,e,t,s){e[s.substr(0,1)]=ae(r)});function dl(r){return Xr(r,this._week.dow,this._week.doy).week}var hl={dow:0,doy:6};function ul(){return this._week.dow}function fl(){return this._week.doy}function gl(r){var e=this.localeData().week(this);return r==null?e:this.add((r-e)*7,"d")}function xl(r){var e=Xr(this,1,4).week;return r==null?e:this.add((r-e)*7,"d")}Q("d",0,"do","day"),Q("dd",0,0,function(r){return this.localeData().weekdaysMin(this,r)}),Q("ddd",0,0,function(r){return this.localeData().weekdaysShort(this,r)}),Q("dddd",0,0,function(r){return this.localeData().weekdays(this,r)}),Q("e",0,0,"weekday"),Q("E",0,0,"isoWeekday"),X("d",_e),X("e",_e),X("E",_e),X("dd",function(r,e){return e.weekdaysMinRegex(r)}),X("ddd",function(r,e){return e.weekdaysShortRegex(r)}),X("dddd",function(r,e){return e.weekdaysRegex(r)}),Vr(["dd","ddd","dddd"],function(r,e,t,s){var i=t._locale.weekdaysParse(r,s,t._strict);i!=null?e.d=i:re(t).invalidWeekday=r}),Vr(["d","e","E"],function(r,e,t,s){e[s]=ae(r)});function pl(r,e){return typeof r!="string"?r:isNaN(r)?(r=e.weekdaysParse(r),typeof r=="number"?r:null):parseInt(r,10)}function ml(r,e){return typeof r=="string"?e.weekdaysParse(r)%7||7:isNaN(r)?null:r}function tn(r,e){return r.slice(e,7).concat(r.slice(0,e))}var vl="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),no="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),yl="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),wl=Gr,El=Gr,bl=Gr;function _l(r,e){var t=ht(this._weekdays)?this._weekdays:this._weekdays[r&&r!==!0&&this._weekdays.isFormat.test(e)?"format":"standalone"];return r===!0?tn(t,this._week.dow):r?t[r.day()]:t}function Cl(r){return r===!0?tn(this._weekdaysShort,this._week.dow):r?this._weekdaysShort[r.day()]:this._weekdaysShort}function Dl(r){return r===!0?tn(this._weekdaysMin,this._week.dow):r?this._weekdaysMin[r.day()]:this._weekdaysMin}function Al(r,e,t){var s,i,n,a=r.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],s=0;s<7;++s)n=bt([2e3,1]).day(s),this._minWeekdaysParse[s]=this.weekdaysMin(n,"").toLocaleLowerCase(),this._shortWeekdaysParse[s]=this.weekdaysShort(n,"").toLocaleLowerCase(),this._weekdaysParse[s]=this.weekdays(n,"").toLocaleLowerCase();return t?e==="dddd"?(i=Re.call(this._weekdaysParse,a),i!==-1?i:null):e==="ddd"?(i=Re.call(this._shortWeekdaysParse,a),i!==-1?i:null):(i=Re.call(this._minWeekdaysParse,a),i!==-1?i:null):e==="dddd"?(i=Re.call(this._weekdaysParse,a),i!==-1||(i=Re.call(this._shortWeekdaysParse,a),i!==-1)?i:(i=Re.call(this._minWeekdaysParse,a),i!==-1?i:null)):e==="ddd"?(i=Re.call(this._shortWeekdaysParse,a),i!==-1||(i=Re.call(this._weekdaysParse,a),i!==-1)?i:(i=Re.call(this._minWeekdaysParse,a),i!==-1?i:null)):(i=Re.call(this._minWeekdaysParse,a),i!==-1||(i=Re.call(this._weekdaysParse,a),i!==-1)?i:(i=Re.call(this._shortWeekdaysParse,a),i!==-1?i:null))}function Sl(r,e,t){var s,i,n;if(this._weekdaysParseExact)return Al.call(this,r,e,t);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),s=0;s<7;s++){if(i=bt([2e3,1]).day(s),t&&!this._fullWeekdaysParse[s]&&(this._fullWeekdaysParse[s]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[s]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[s]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[s]||(n="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[s]=new RegExp(n.replace(".",""),"i")),t&&e==="dddd"&&this._fullWeekdaysParse[s].test(r))return s;if(t&&e==="ddd"&&this._shortWeekdaysParse[s].test(r))return s;if(t&&e==="dd"&&this._minWeekdaysParse[s].test(r))return s;if(!t&&this._weekdaysParse[s].test(r))return s}}function Tl(r){if(!this.isValid())return r!=null?this:NaN;var e=Kr(this,"Day");return r!=null?(r=pl(r,this.localeData()),this.add(r-e,"d")):e}function Rl(r){if(!this.isValid())return r!=null?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return r==null?e:this.add(r-e,"d")}function Fl(r){if(!this.isValid())return r!=null?this:NaN;if(r!=null){var e=ml(r,this.localeData());return this.day(this.day()%7?e:e-7)}else return this.day()||7}function kl(r){return this._weekdaysParseExact?(ge(this,"_weekdaysRegex")||rn.call(this),r?this._weekdaysStrictRegex:this._weekdaysRegex):(ge(this,"_weekdaysRegex")||(this._weekdaysRegex=wl),this._weekdaysStrictRegex&&r?this._weekdaysStrictRegex:this._weekdaysRegex)}function Bl(r){return this._weekdaysParseExact?(ge(this,"_weekdaysRegex")||rn.call(this),r?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(ge(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=El),this._weekdaysShortStrictRegex&&r?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Il(r){return this._weekdaysParseExact?(ge(this,"_weekdaysRegex")||rn.call(this),r?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(ge(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=bl),this._weekdaysMinStrictRegex&&r?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function rn(){function r(l,g){return g.length-l.length}var e=[],t=[],s=[],i=[],n,a,o,d,c;for(n=0;n<7;n++)a=bt([2e3,1]).day(n),o=Pt(this.weekdaysMin(a,"")),d=Pt(this.weekdaysShort(a,"")),c=Pt(this.weekdays(a,"")),e.push(o),t.push(d),s.push(c),i.push(o),i.push(d),i.push(c);e.sort(r),t.sort(r),s.sort(r),i.sort(r),this._weekdaysRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+t.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+e.join("|")+")","i")}function sn(){return this.hours()%12||12}function Pl(){return this.hours()||24}Q("H",["HH",2],0,"hour"),Q("h",["hh",2],0,sn),Q("k",["kk",2],0,Pl),Q("hmm",0,0,function(){return""+sn.apply(this)+Ct(this.minutes(),2)}),Q("hmmss",0,0,function(){return""+sn.apply(this)+Ct(this.minutes(),2)+Ct(this.seconds(),2)}),Q("Hmm",0,0,function(){return""+this.hours()+Ct(this.minutes(),2)}),Q("Hmmss",0,0,function(){return""+this.hours()+Ct(this.minutes(),2)+Ct(this.seconds(),2)});function ao(r,e){Q(r,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}ao("a",!0),ao("A",!1);function oo(r,e){return e._meridiemParse}X("a",oo),X("A",oo),X("H",_e,Ji),X("h",_e,_r),X("k",_e,_r),X("HH",_e,tt),X("hh",_e,tt),X("kk",_e,tt),X("hmm",Ka),X("hmmss",Za),X("Hmm",Ka),X("Hmmss",Za),ye(["H","HH"],He),ye(["k","kk"],function(r,e,t){var s=ae(r);e[He]=s===24?0:s}),ye(["a","A"],function(r,e,t){t._isPm=t._locale.isPM(r),t._meridiem=r}),ye(["h","hh"],function(r,e,t){e[He]=ae(r),re(t).bigHour=!0}),ye("hmm",function(r,e,t){var s=r.length-2;e[He]=ae(r.substr(0,s)),e[ft]=ae(r.substr(s)),re(t).bigHour=!0}),ye("hmmss",function(r,e,t){var s=r.length-4,i=r.length-2;e[He]=ae(r.substr(0,s)),e[ft]=ae(r.substr(s,2)),e[$t]=ae(r.substr(i)),re(t).bigHour=!0}),ye("Hmm",function(r,e,t){var s=r.length-2;e[He]=ae(r.substr(0,s)),e[ft]=ae(r.substr(s))}),ye("Hmmss",function(r,e,t){var s=r.length-4,i=r.length-2;e[He]=ae(r.substr(0,s)),e[ft]=ae(r.substr(s,2)),e[$t]=ae(r.substr(i))});function Hl(r){return(r+"").toLowerCase().charAt(0)==="p"}var $l=/[ap]\.?m?\.?/i,Ol=Cr("Hours",!0);function Nl(r,e,t){return r>11?t?"pm":"PM":t?"am":"AM"}var co={calendar:Ac,longDateFormat:Fc,invalidDate:Bc,ordinal:Pc,dayOfMonthOrdinalParse:Hc,relativeTime:Oc,months:Qc,monthsShort:Qa,week:hl,weekdays:vl,weekdaysMin:yl,weekdaysShort:no,meridiemParse:$l},De={},Jr={},Qr;function Ml(r,e){var t,s=Math.min(r.length,e.length);for(t=0;t<s;t+=1)if(r[t]!==e[t])return t;return s}function lo(r){return r&&r.toLowerCase().replace("_","-")}function jl(r){for(var e=0,t,s,i,n;e<r.length;){for(n=lo(r[e]).split("-"),t=n.length,s=lo(r[e+1]),s=s?s.split("-"):null;t>0;){if(i=Ss(n.slice(0,t).join("-")),i)return i;if(s&&s.length>=t&&Ml(n,s)>=t-1)break;t--}e++}return Qr}function ql(r){return!!(r&&r.match("^[^/\\\\]*$"))}function Ss(r){var e=null,t;if(De[r]===void 0&&typeof module<"u"&&module&&module.exports&&ql(r))try{e=Qr._abbr,t=require,t("./locale/"+r),Jt(e)}catch{De[r]=null}return De[r]}function Jt(r,e){var t;return r&&(Ze(e)?t=Nt(r):t=nn(r,e),t?Qr=t:typeof console<"u"&&console.warn&&console.warn("Locale "+r+" not found. Did you forget to load it?")),Qr._abbr}function nn(r,e){if(e!==null){var t,s=co;if(e.abbr=r,De[r]!=null)Ya("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=De[r]._config;else if(e.parentLocale!=null)if(De[e.parentLocale]!=null)s=De[e.parentLocale]._config;else if(t=Ss(e.parentLocale),t!=null)s=t._config;else return Jr[e.parentLocale]||(Jr[e.parentLocale]=[]),Jr[e.parentLocale].push({name:r,config:e}),null;return De[r]=new Wi(Yi(s,e)),Jr[r]&&Jr[r].forEach(function(i){nn(i.name,i.config)}),Jt(r),De[r]}else return delete De[r],null}function Ul(r,e){if(e!=null){var t,s,i=co;De[r]!=null&&De[r].parentLocale!=null?De[r].set(Yi(De[r]._config,e)):(s=Ss(r),s!=null&&(i=s._config),e=Yi(i,e),s==null&&(e.abbr=r),t=new Wi(e),t.parentLocale=De[r],De[r]=t),Jt(r)}else De[r]!=null&&(De[r].parentLocale!=null?(De[r]=De[r].parentLocale,r===Jt()&&Jt(r)):De[r]!=null&&delete De[r]);return De[r]}function Nt(r){var e;if(r&&r._locale&&r._locale._abbr&&(r=r._locale._abbr),!r)return Qr;if(!ht(r)){if(e=Ss(r),e)return e;r=[r]}return jl(r)}function Ll(){return Gi(De)}function an(r){var e,t=r._a;return t&&re(r).overflow===-2&&(e=t[Ht]<0||t[Ht]>11?Ht:t[Dt]<1||t[Dt]>en(t[Le],t[Ht])?Dt:t[He]<0||t[He]>24||t[He]===24&&(t[ft]!==0||t[$t]!==0||t[hr]!==0)?He:t[ft]<0||t[ft]>59?ft:t[$t]<0||t[$t]>59?$t:t[hr]<0||t[hr]>999?hr:-1,re(r)._overflowDayOfYear&&(e<Le||e>Dt)&&(e=Dt),re(r)._overflowWeeks&&e===-1&&(e=Vc),re(r)._overflowWeekday&&e===-1&&(e=zc),re(r).overflow=e),r}var Yl=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Wl=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Gl=/Z|[+-]\d\d(?::?\d\d)?/,Ts=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],on=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Vl=/^\/?Date\((-?\d+)/i,zl=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Kl={UT:0,GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function ho(r){var e,t,s=r._i,i=Yl.exec(s)||Wl.exec(s),n,a,o,d,c=Ts.length,l=on.length;if(i){for(re(r).iso=!0,e=0,t=c;e<t;e++)if(Ts[e][1].exec(i[1])){a=Ts[e][0],n=Ts[e][2]!==!1;break}if(a==null){r._isValid=!1;return}if(i[3]){for(e=0,t=l;e<t;e++)if(on[e][1].exec(i[3])){o=(i[2]||" ")+on[e][0];break}if(o==null){r._isValid=!1;return}}if(!n&&o!=null){r._isValid=!1;return}if(i[4])if(Gl.exec(i[4]))d="Z";else{r._isValid=!1;return}r._f=a+(o||"")+(d||""),ln(r)}else r._isValid=!1}function Zl(r,e,t,s,i,n){var a=[Xl(r),Qa.indexOf(e),parseInt(t,10),parseInt(s,10),parseInt(i,10)];return n&&a.push(parseInt(n,10)),a}function Xl(r){var e=parseInt(r,10);return e<=49?2e3+e:e<=999?1900+e:e}function Jl(r){return r.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function Ql(r,e,t){if(r){var s=no.indexOf(r),i=new Date(e[0],e[1],e[2]).getDay();if(s!==i)return re(t).weekdayMismatch=!0,t._isValid=!1,!1}return!0}function ed(r,e,t){if(r)return Kl[r];if(e)return 0;var s=parseInt(t,10),i=s%100,n=(s-i)/100;return n*60+i}function uo(r){var e=zl.exec(Jl(r._i)),t;if(e){if(t=Zl(e[4],e[3],e[2],e[5],e[6],e[7]),!Ql(e[1],t,r))return;r._a=t,r._tzm=ed(e[8],e[9],e[10]),r._d=Zr.apply(null,r._a),r._d.setUTCMinutes(r._d.getUTCMinutes()-r._tzm),re(r).rfc2822=!0}else r._isValid=!1}function td(r){var e=Vl.exec(r._i);if(e!==null){r._d=new Date(+e[1]);return}if(ho(r),r._isValid===!1)delete r._isValid;else return;if(uo(r),r._isValid===!1)delete r._isValid;else return;r._strict?r._isValid=!1:W.createFromInputFallback(r)}W.createFromInputFallback=it("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(r){r._d=new Date(r._i+(r._useUTC?" UTC":""))});function Dr(r,e,t){return r??e??t}function rd(r){var e=new Date(W.now());return r._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function cn(r){var e,t,s=[],i,n,a;if(!r._d){for(i=rd(r),r._w&&r._a[Dt]==null&&r._a[Ht]==null&&sd(r),r._dayOfYear!=null&&(a=Dr(r._a[Le],i[Le]),(r._dayOfYear>zr(a)||r._dayOfYear===0)&&(re(r)._overflowDayOfYear=!0),t=Zr(a,0,r._dayOfYear),r._a[Ht]=t.getUTCMonth(),r._a[Dt]=t.getUTCDate()),e=0;e<3&&r._a[e]==null;++e)r._a[e]=s[e]=i[e];for(;e<7;e++)r._a[e]=s[e]=r._a[e]==null?e===2?1:0:r._a[e];r._a[He]===24&&r._a[ft]===0&&r._a[$t]===0&&r._a[hr]===0&&(r._nextDay=!0,r._a[He]=0),r._d=(r._useUTC?Zr:ll).apply(null,s),n=r._useUTC?r._d.getUTCDay():r._d.getDay(),r._tzm!=null&&r._d.setUTCMinutes(r._d.getUTCMinutes()-r._tzm),r._nextDay&&(r._a[He]=24),r._w&&typeof r._w.d<"u"&&r._w.d!==n&&(re(r).weekdayMismatch=!0)}}function sd(r){var e,t,s,i,n,a,o,d,c;e=r._w,e.GG!=null||e.W!=null||e.E!=null?(n=1,a=4,t=Dr(e.GG,r._a[Le],Xr(Ce(),1,4).year),s=Dr(e.W,1),i=Dr(e.E,1),(i<1||i>7)&&(d=!0)):(n=r._locale._week.dow,a=r._locale._week.doy,c=Xr(Ce(),n,a),t=Dr(e.gg,r._a[Le],c.year),s=Dr(e.w,c.week),e.d!=null?(i=e.d,(i<0||i>6)&&(d=!0)):e.e!=null?(i=e.e+n,(e.e<0||e.e>6)&&(d=!0)):i=n),s<1||s>Ot(t,n,a)?re(r)._overflowWeeks=!0:d!=null?re(r)._overflowWeekday=!0:(o=io(t,s,i,n,a),r._a[Le]=o.year,r._dayOfYear=o.dayOfYear)}W.ISO_8601=function(){},W.RFC_2822=function(){};function ln(r){if(r._f===W.ISO_8601){ho(r);return}if(r._f===W.RFC_2822){uo(r);return}r._a=[],re(r).empty=!0;var e=""+r._i,t,s,i,n,a,o=e.length,d=0,c,l;for(i=Wa(r._f,r._locale).match(Vi)||[],l=i.length,t=0;t<l;t++)n=i[t],s=(e.match(Yc(n,r))||[])[0],s&&(a=e.substr(0,e.indexOf(s)),a.length>0&&re(r).unusedInput.push(a),e=e.slice(e.indexOf(s)+s.length),d+=s.length),Er[n]?(s?re(r).empty=!1:re(r).unusedTokens.push(n),Gc(n,s,r)):r._strict&&!s&&re(r).unusedTokens.push(n);re(r).charsLeftOver=o-d,e.length>0&&re(r).unusedInput.push(e),r._a[He]<=12&&re(r).bigHour===!0&&r._a[He]>0&&(re(r).bigHour=void 0),re(r).parsedDateParts=r._a.slice(0),re(r).meridiem=r._meridiem,r._a[He]=id(r._locale,r._a[He],r._meridiem),c=re(r).era,c!==null&&(r._a[Le]=r._locale.erasConvertYear(c,r._a[Le])),cn(r),an(r)}function id(r,e,t){var s;return t==null?e:r.meridiemHour!=null?r.meridiemHour(e,t):(r.isPM!=null&&(s=r.isPM(t),s&&e<12&&(e+=12),!s&&e===12&&(e=0)),e)}function nd(r){var e,t,s,i,n,a,o=!1,d=r._f.length;if(d===0){re(r).invalidFormat=!0,r._d=new Date(NaN);return}for(i=0;i<d;i++)n=0,a=!1,e=Li({},r),r._useUTC!=null&&(e._useUTC=r._useUTC),e._f=r._f[i],ln(e),qi(e)&&(a=!0),n+=re(e).charsLeftOver,n+=re(e).unusedTokens.length*10,re(e).score=n,o?n<s&&(s=n,t=e):(s==null||n<s||a)&&(s=n,t=e,a&&(o=!0));Xt(r,t||e)}function ad(r){if(!r._d){var e=Ki(r._i),t=e.day===void 0?e.date:e.day;r._a=ja([e.year,e.month,t,e.hour,e.minute,e.second,e.millisecond],function(s){return s&&parseInt(s,10)}),cn(r)}}function od(r){var e=new Wr(an(fo(r)));return e._nextDay&&(e.add(1,"d"),e._nextDay=void 0),e}function fo(r){var e=r._i,t=r._f;return r._locale=r._locale||Nt(r._l),e===null||t===void 0&&e===""?ps({nullInput:!0}):(typeof e=="string"&&(r._i=e=r._locale.preparse(e)),ut(e)?new Wr(an(e)):(Yr(e)?r._d=e:ht(t)?nd(r):t?ln(r):cd(r),qi(r)||(r._d=null),r))}function cd(r){var e=r._i;Ze(e)?r._d=new Date(W.now()):Yr(e)?r._d=new Date(e.valueOf()):typeof e=="string"?td(r):ht(e)?(r._a=ja(e.slice(0),function(t){return parseInt(t,10)}),cn(r)):dr(e)?ad(r):It(e)?r._d=new Date(e):W.createFromInputFallback(r)}function go(r,e,t,s,i){var n={};return(e===!0||e===!1)&&(s=e,e=void 0),(t===!0||t===!1)&&(s=t,t=void 0),(dr(r)&&Mi(r)||ht(r)&&r.length===0)&&(r=void 0),n._isAMomentObject=!0,n._useUTC=n._isUTC=i,n._l=t,n._i=r,n._f=e,n._strict=s,od(n)}function Ce(r,e,t,s){return go(r,e,t,s,!1)}var ld=it("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var r=Ce.apply(null,arguments);return this.isValid()&&r.isValid()?r<this?this:r:ps()}),dd=it("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var r=Ce.apply(null,arguments);return this.isValid()&&r.isValid()?r>this?this:r:ps()});function xo(r,e){var t,s;if(e.length===1&&ht(e[0])&&(e=e[0]),!e.length)return Ce();for(t=e[0],s=1;s<e.length;++s)(!e[s].isValid()||e[s][r](t))&&(t=e[s]);return t}function hd(){var r=[].slice.call(arguments,0);return xo("isBefore",r)}function ud(){var r=[].slice.call(arguments,0);return xo("isAfter",r)}var fd=function(){return Date.now?Date.now():+new Date},es=["year","quarter","month","week","day","hour","minute","second","millisecond"];function gd(r){var e,t=!1,s,i=es.length;for(e in r)if(ge(r,e)&&!(Re.call(es,e)!==-1&&(r[e]==null||!isNaN(r[e]))))return!1;for(s=0;s<i;++s)if(r[es[s]]){if(t)return!1;parseFloat(r[es[s]])!==ae(r[es[s]])&&(t=!0)}return!0}function xd(){return this._isValid}function pd(){return gt(NaN)}function Rs(r){var e=Ki(r),t=e.year||0,s=e.quarter||0,i=e.month||0,n=e.week||e.isoWeek||0,a=e.day||0,o=e.hour||0,d=e.minute||0,c=e.second||0,l=e.millisecond||0;this._isValid=gd(e),this._milliseconds=+l+c*1e3+d*6e4+o*1e3*60*60,this._days=+a+n*7,this._months=+i+s*3+t*12,this._data={},this._locale=Nt(),this._bubble()}function Fs(r){return r instanceof Rs}function dn(r){return r<0?Math.round(-1*r)*-1:Math.round(r)}function md(r,e,t){var s=Math.min(r.length,e.length),i=Math.abs(r.length-e.length),n=0,a;for(a=0;a<s;a++)ae(r[a])!==ae(e[a])&&n++;return n+i}function po(r,e){Q(r,0,0,function(){var t=this.utcOffset(),s="+";return t<0&&(t=-t,s="-"),s+Ct(~~(t/60),2)+e+Ct(~~t%60,2)})}po("Z",":"),po("ZZ",""),X("Z",_s),X("ZZ",_s),ye(["Z","ZZ"],function(r,e,t){t._useUTC=!0,t._tzm=hn(_s,r)});var vd=/([\+\-]|\d\d)/gi;function hn(r,e){var t=(e||"").match(r),s,i,n;return t===null?null:(s=t[t.length-1]||[],i=(s+"").match(vd)||["-",0,0],n=+(i[1]*60)+ae(i[2]),n===0?0:i[0]==="+"?n:-n)}function un(r,e){var t,s;return e._isUTC?(t=e.clone(),s=(ut(r)||Yr(r)?r.valueOf():Ce(r).valueOf())-t.valueOf(),t._d.setTime(t._d.valueOf()+s),W.updateOffset(t,!1),t):Ce(r).local()}function fn(r){return-Math.round(r._d.getTimezoneOffset())}W.updateOffset=function(){};function yd(r,e,t){var s=this._offset||0,i;if(!this.isValid())return r!=null?this:NaN;if(r!=null){if(typeof r=="string"){if(r=hn(_s,r),r===null)return this}else Math.abs(r)<16&&!t&&(r=r*60);return!this._isUTC&&e&&(i=fn(this)),this._offset=r,this._isUTC=!0,i!=null&&this.add(i,"m"),s!==r&&(!e||this._changeInProgress?wo(this,gt(r-s,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,W.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?s:fn(this)}function wd(r,e){return r!=null?(typeof r!="string"&&(r=-r),this.utcOffset(r,e),this):-this.utcOffset()}function Ed(r){return this.utcOffset(0,r)}function bd(r){return this._isUTC&&(this.utcOffset(0,r),this._isUTC=!1,r&&this.subtract(fn(this),"m")),this}function _d(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var r=hn(Uc,this._i);r!=null?this.utcOffset(r):this.utcOffset(0,!0)}return this}function Cd(r){return this.isValid()?(r=r?Ce(r).utcOffset():0,(this.utcOffset()-r)%60===0):!1}function Dd(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Ad(){if(!Ze(this._isDSTShifted))return this._isDSTShifted;var r={},e;return Li(r,this),r=fo(r),r._a?(e=r._isUTC?bt(r._a):Ce(r._a),this._isDSTShifted=this.isValid()&&md(r._a,e.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Sd(){return this.isValid()?!this._isUTC:!1}function Td(){return this.isValid()?this._isUTC:!1}function mo(){return this.isValid()?this._isUTC&&this._offset===0:!1}var Rd=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,Fd=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function gt(r,e){var t=r,s=null,i,n,a;return Fs(r)?t={ms:r._milliseconds,d:r._days,M:r._months}:It(r)||!isNaN(+r)?(t={},e?t[e]=+r:t.milliseconds=+r):(s=Rd.exec(r))?(i=s[1]==="-"?-1:1,t={y:0,d:ae(s[Dt])*i,h:ae(s[He])*i,m:ae(s[ft])*i,s:ae(s[$t])*i,ms:ae(dn(s[hr]*1e3))*i}):(s=Fd.exec(r))?(i=s[1]==="-"?-1:1,t={y:ur(s[2],i),M:ur(s[3],i),w:ur(s[4],i),d:ur(s[5],i),h:ur(s[6],i),m:ur(s[7],i),s:ur(s[8],i)}):t==null?t={}:typeof t=="object"&&("from"in t||"to"in t)&&(a=kd(Ce(t.from),Ce(t.to)),t={},t.ms=a.milliseconds,t.M=a.months),n=new Rs(t),Fs(r)&&ge(r,"_locale")&&(n._locale=r._locale),Fs(r)&&ge(r,"_isValid")&&(n._isValid=r._isValid),n}gt.fn=Rs.prototype,gt.invalid=pd;function ur(r,e){var t=r&&parseFloat(r.replace(",","."));return(isNaN(t)?0:t)*e}function vo(r,e){var t={};return t.months=e.month()-r.month()+(e.year()-r.year())*12,r.clone().add(t.months,"M").isAfter(e)&&--t.months,t.milliseconds=+e-+r.clone().add(t.months,"M"),t}function kd(r,e){var t;return r.isValid()&&e.isValid()?(e=un(e,r),r.isBefore(e)?t=vo(r,e):(t=vo(e,r),t.milliseconds=-t.milliseconds,t.months=-t.months),t):{milliseconds:0,months:0}}function yo(r,e){return function(t,s){var i,n;return s!==null&&!isNaN(+s)&&(Ya(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),n=t,t=s,s=n),i=gt(t,s),wo(this,i,r),this}}function wo(r,e,t,s){var i=e._milliseconds,n=dn(e._days),a=dn(e._months);r.isValid()&&(s=s??!0,a&&to(r,Kr(r,"Month")+a*t),n&&Ja(r,"Date",Kr(r,"Date")+n*t),i&&r._d.setTime(r._d.valueOf()+i*t),s&&W.updateOffset(r,n||a))}var Bd=yo(1,"add"),Id=yo(-1,"subtract");function Eo(r){return typeof r=="string"||r instanceof String}function Pd(r){return ut(r)||Yr(r)||Eo(r)||It(r)||$d(r)||Hd(r)||r===null||r===void 0}function Hd(r){var e=dr(r)&&!Mi(r),t=!1,s=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],i,n,a=s.length;for(i=0;i<a;i+=1)n=s[i],t=t||ge(r,n);return e&&t}function $d(r){var e=ht(r),t=!1;return e&&(t=r.filter(function(s){return!It(s)&&Eo(r)}).length===0),e&&t}function Od(r){var e=dr(r)&&!Mi(r),t=!1,s=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],i,n;for(i=0;i<s.length;i+=1)n=s[i],t=t||ge(r,n);return e&&t}function Nd(r,e){var t=r.diff(e,"days",!0);return t<-6?"sameElse":t<-1?"lastWeek":t<0?"lastDay":t<1?"sameDay":t<2?"nextDay":t<7?"nextWeek":"sameElse"}function Md(r,e){arguments.length===1&&(arguments[0]?Pd(arguments[0])?(r=arguments[0],e=void 0):Od(arguments[0])&&(e=arguments[0],r=void 0):(r=void 0,e=void 0));var t=r||Ce(),s=un(t,this).startOf("day"),i=W.calendarFormat(this,s)||"sameElse",n=e&&(_t(e[i])?e[i].call(this,t):e[i]);return this.format(n||this.localeData().calendar(i,this,Ce(t)))}function jd(){return new Wr(this)}function qd(r,e){var t=ut(r)?r:Ce(r);return this.isValid()&&t.isValid()?(e=nt(e)||"millisecond",e==="millisecond"?this.valueOf()>t.valueOf():t.valueOf()<this.clone().startOf(e).valueOf()):!1}function Ud(r,e){var t=ut(r)?r:Ce(r);return this.isValid()&&t.isValid()?(e=nt(e)||"millisecond",e==="millisecond"?this.valueOf()<t.valueOf():this.clone().endOf(e).valueOf()<t.valueOf()):!1}function Ld(r,e,t,s){var i=ut(r)?r:Ce(r),n=ut(e)?e:Ce(e);return this.isValid()&&i.isValid()&&n.isValid()?(s=s||"()",(s[0]==="("?this.isAfter(i,t):!this.isBefore(i,t))&&(s[1]===")"?this.isBefore(n,t):!this.isAfter(n,t))):!1}function Yd(r,e){var t=ut(r)?r:Ce(r),s;return this.isValid()&&t.isValid()?(e=nt(e)||"millisecond",e==="millisecond"?this.valueOf()===t.valueOf():(s=t.valueOf(),this.clone().startOf(e).valueOf()<=s&&s<=this.clone().endOf(e).valueOf())):!1}function Wd(r,e){return this.isSame(r,e)||this.isAfter(r,e)}function Gd(r,e){return this.isSame(r,e)||this.isBefore(r,e)}function Vd(r,e,t){var s,i,n;if(!this.isValid())return NaN;if(s=un(r,this),!s.isValid())return NaN;switch(i=(s.utcOffset()-this.utcOffset())*6e4,e=nt(e),e){case"year":n=ks(this,s)/12;break;case"month":n=ks(this,s);break;case"quarter":n=ks(this,s)/3;break;case"second":n=(this-s)/1e3;break;case"minute":n=(this-s)/6e4;break;case"hour":n=(this-s)/36e5;break;case"day":n=(this-s-i)/864e5;break;case"week":n=(this-s-i)/6048e5;break;default:n=this-s}return t?n:at(n)}function ks(r,e){if(r.date()<e.date())return-ks(e,r);var t=(e.year()-r.year())*12+(e.month()-r.month()),s=r.clone().add(t,"months"),i,n;return e-s<0?(i=r.clone().add(t-1,"months"),n=(e-s)/(s-i)):(i=r.clone().add(t+1,"months"),n=(e-s)/(i-s)),-(t+n)||0}W.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",W.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function zd(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function Kd(r){if(!this.isValid())return null;var e=r!==!0,t=e?this.clone().utc():this;return t.year()<0||t.year()>9999?vs(t,e?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):_t(Date.prototype.toISOString)?e?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",vs(t,"Z")):vs(t,e?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Zd(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var r="moment",e="",t,s,i,n;return this.isLocal()||(r=this.utcOffset()===0?"moment.utc":"moment.parseZone",e="Z"),t="["+r+'("]',s=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i="-MM-DD[T]HH:mm:ss.SSS",n=e+'[")]',this.format(t+s+i+n)}function Xd(r){r||(r=this.isUtc()?W.defaultFormatUtc:W.defaultFormat);var e=vs(this,r);return this.localeData().postformat(e)}function Jd(r,e){return this.isValid()&&(ut(r)&&r.isValid()||Ce(r).isValid())?gt({to:this,from:r}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function Qd(r){return this.from(Ce(),r)}function eh(r,e){return this.isValid()&&(ut(r)&&r.isValid()||Ce(r).isValid())?gt({from:this,to:r}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function th(r){return this.to(Ce(),r)}function bo(r){var e;return r===void 0?this._locale._abbr:(e=Nt(r),e!=null&&(this._locale=e),this)}var _o=it("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(r){return r===void 0?this.localeData():this.locale(r)});function Co(){return this._locale}var Bs=1e3,Ar=60*Bs,Is=60*Ar,Do=(365*400+97)*24*Is;function Sr(r,e){return(r%e+e)%e}function Ao(r,e,t){return r<100&&r>=0?new Date(r+400,e,t)-Do:new Date(r,e,t).valueOf()}function So(r,e,t){return r<100&&r>=0?Date.UTC(r+400,e,t)-Do:Date.UTC(r,e,t)}function rh(r){var e,t;if(r=nt(r),r===void 0||r==="millisecond"||!this.isValid())return this;switch(t=this._isUTC?So:Ao,r){case"year":e=t(this.year(),0,1);break;case"quarter":e=t(this.year(),this.month()-this.month()%3,1);break;case"month":e=t(this.year(),this.month(),1);break;case"week":e=t(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":e=t(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":e=t(this.year(),this.month(),this.date());break;case"hour":e=this._d.valueOf(),e-=Sr(e+(this._isUTC?0:this.utcOffset()*Ar),Is);break;case"minute":e=this._d.valueOf(),e-=Sr(e,Ar);break;case"second":e=this._d.valueOf(),e-=Sr(e,Bs);break}return this._d.setTime(e),W.updateOffset(this,!0),this}function sh(r){var e,t;if(r=nt(r),r===void 0||r==="millisecond"||!this.isValid())return this;switch(t=this._isUTC?So:Ao,r){case"year":e=t(this.year()+1,0,1)-1;break;case"quarter":e=t(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":e=t(this.year(),this.month()+1,1)-1;break;case"week":e=t(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":e=t(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":e=t(this.year(),this.month(),this.date()+1)-1;break;case"hour":e=this._d.valueOf(),e+=Is-Sr(e+(this._isUTC?0:this.utcOffset()*Ar),Is)-1;break;case"minute":e=this._d.valueOf(),e+=Ar-Sr(e,Ar)-1;break;case"second":e=this._d.valueOf(),e+=Bs-Sr(e,Bs)-1;break}return this._d.setTime(e),W.updateOffset(this,!0),this}function ih(){return this._d.valueOf()-(this._offset||0)*6e4}function nh(){return Math.floor(this.valueOf()/1e3)}function ah(){return new Date(this.valueOf())}function oh(){var r=this;return[r.year(),r.month(),r.date(),r.hour(),r.minute(),r.second(),r.millisecond()]}function ch(){var r=this;return{years:r.year(),months:r.month(),date:r.date(),hours:r.hours(),minutes:r.minutes(),seconds:r.seconds(),milliseconds:r.milliseconds()}}function lh(){return this.isValid()?this.toISOString():null}function dh(){return qi(this)}function hh(){return Xt({},re(this))}function uh(){return re(this).overflow}function fh(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}Q("N",0,0,"eraAbbr"),Q("NN",0,0,"eraAbbr"),Q("NNN",0,0,"eraAbbr"),Q("NNNN",0,0,"eraName"),Q("NNNNN",0,0,"eraNarrow"),Q("y",["y",1],"yo","eraYear"),Q("y",["yy",2],0,"eraYear"),Q("y",["yyy",3],0,"eraYear"),Q("y",["yyyy",4],0,"eraYear"),X("N",gn),X("NN",gn),X("NNN",gn),X("NNNN",Ch),X("NNNNN",Dh),ye(["N","NN","NNN","NNNN","NNNNN"],function(r,e,t,s){var i=t._locale.erasParse(r,s,t._strict);i?re(t).era=i:re(t).invalidEra=r}),X("y",br),X("yy",br),X("yyy",br),X("yyyy",br),X("yo",Ah),ye(["y","yy","yyy","yyyy"],Le),ye(["yo"],function(r,e,t,s){var i;t._locale._eraYearOrdinalRegex&&(i=r.match(t._locale._eraYearOrdinalRegex)),t._locale.eraYearOrdinalParse?e[Le]=t._locale.eraYearOrdinalParse(r,i):e[Le]=parseInt(r,10)});function gh(r,e){var t,s,i,n=this._eras||Nt("en")._eras;for(t=0,s=n.length;t<s;++t){switch(typeof n[t].since){case"string":i=W(n[t].since).startOf("day"),n[t].since=i.valueOf();break}switch(typeof n[t].until){case"undefined":n[t].until=1/0;break;case"string":i=W(n[t].until).startOf("day").valueOf(),n[t].until=i.valueOf();break}}return n}function xh(r,e,t){var s,i,n=this.eras(),a,o,d;for(r=r.toUpperCase(),s=0,i=n.length;s<i;++s)if(a=n[s].name.toUpperCase(),o=n[s].abbr.toUpperCase(),d=n[s].narrow.toUpperCase(),t)switch(e){case"N":case"NN":case"NNN":if(o===r)return n[s];break;case"NNNN":if(a===r)return n[s];break;case"NNNNN":if(d===r)return n[s];break}else if([a,o,d].indexOf(r)>=0)return n[s]}function ph(r,e){var t=r.since<=r.until?1:-1;return e===void 0?W(r.since).year():W(r.since).year()+(e-r.offset)*t}function mh(){var r,e,t,s=this.localeData().eras();for(r=0,e=s.length;r<e;++r)if(t=this.clone().startOf("day").valueOf(),s[r].since<=t&&t<=s[r].until||s[r].until<=t&&t<=s[r].since)return s[r].name;return""}function vh(){var r,e,t,s=this.localeData().eras();for(r=0,e=s.length;r<e;++r)if(t=this.clone().startOf("day").valueOf(),s[r].since<=t&&t<=s[r].until||s[r].until<=t&&t<=s[r].since)return s[r].narrow;return""}function yh(){var r,e,t,s=this.localeData().eras();for(r=0,e=s.length;r<e;++r)if(t=this.clone().startOf("day").valueOf(),s[r].since<=t&&t<=s[r].until||s[r].until<=t&&t<=s[r].since)return s[r].abbr;return""}function wh(){var r,e,t,s,i=this.localeData().eras();for(r=0,e=i.length;r<e;++r)if(t=i[r].since<=i[r].until?1:-1,s=this.clone().startOf("day").valueOf(),i[r].since<=s&&s<=i[r].until||i[r].until<=s&&s<=i[r].since)return(this.year()-W(i[r].since).year())*t+i[r].offset;return this.year()}function Eh(r){return ge(this,"_erasNameRegex")||xn.call(this),r?this._erasNameRegex:this._erasRegex}function bh(r){return ge(this,"_erasAbbrRegex")||xn.call(this),r?this._erasAbbrRegex:this._erasRegex}function _h(r){return ge(this,"_erasNarrowRegex")||xn.call(this),r?this._erasNarrowRegex:this._erasRegex}function gn(r,e){return e.erasAbbrRegex(r)}function Ch(r,e){return e.erasNameRegex(r)}function Dh(r,e){return e.erasNarrowRegex(r)}function Ah(r,e){return e._eraYearOrdinalRegex||br}function xn(){var r=[],e=[],t=[],s=[],i,n,a,o,d,c=this.eras();for(i=0,n=c.length;i<n;++i)a=Pt(c[i].name),o=Pt(c[i].abbr),d=Pt(c[i].narrow),e.push(a),r.push(o),t.push(d),s.push(a),s.push(o),s.push(d);this._erasRegex=new RegExp("^("+s.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+e.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+r.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+t.join("|")+")","i")}Q(0,["gg",2],0,function(){return this.weekYear()%100}),Q(0,["GG",2],0,function(){return this.isoWeekYear()%100});function Ps(r,e){Q(0,[r,r.length],0,e)}Ps("gggg","weekYear"),Ps("ggggg","weekYear"),Ps("GGGG","isoWeekYear"),Ps("GGGGG","isoWeekYear"),X("G",bs),X("g",bs),X("GG",_e,tt),X("gg",_e,tt),X("GGGG",Xi,Zi),X("gggg",Xi,Zi),X("GGGGG",Es,ys),X("ggggg",Es,ys),Vr(["gggg","ggggg","GGGG","GGGGG"],function(r,e,t,s){e[s.substr(0,2)]=ae(r)}),Vr(["gg","GG"],function(r,e,t,s){e[s]=W.parseTwoDigitYear(r)});function Sh(r){return To.call(this,r,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function Th(r){return To.call(this,r,this.isoWeek(),this.isoWeekday(),1,4)}function Rh(){return Ot(this.year(),1,4)}function Fh(){return Ot(this.isoWeekYear(),1,4)}function kh(){var r=this.localeData()._week;return Ot(this.year(),r.dow,r.doy)}function Bh(){var r=this.localeData()._week;return Ot(this.weekYear(),r.dow,r.doy)}function To(r,e,t,s,i){var n;return r==null?Xr(this,s,i).year:(n=Ot(r,s,i),e>n&&(e=n),Ih.call(this,r,e,t,s,i))}function Ih(r,e,t,s,i){var n=io(r,e,t,s,i),a=Zr(n.year,0,n.dayOfYear);return this.year(a.getUTCFullYear()),this.month(a.getUTCMonth()),this.date(a.getUTCDate()),this}Q("Q",0,"Qo","quarter"),X("Q",Va),ye("Q",function(r,e){e[Ht]=(ae(r)-1)*3});function Ph(r){return r==null?Math.ceil((this.month()+1)/3):this.month((r-1)*3+this.month()%3)}Q("D",["DD",2],"Do","date"),X("D",_e,_r),X("DD",_e,tt),X("Do",function(r,e){return r?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient}),ye(["D","DD"],Dt),ye("Do",function(r,e){e[Dt]=ae(r.match(_e)[0])});var Ro=Cr("Date",!0);Q("DDD",["DDDD",3],"DDDo","dayOfYear"),X("DDD",ws),X("DDDD",za),ye(["DDD","DDDD"],function(r,e,t){t._dayOfYear=ae(r)});function Hh(r){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return r==null?e:this.add(r-e,"d")}Q("m",["mm",2],0,"minute"),X("m",_e,Ji),X("mm",_e,tt),ye(["m","mm"],ft);var $h=Cr("Minutes",!1);Q("s",["ss",2],0,"second"),X("s",_e,Ji),X("ss",_e,tt),ye(["s","ss"],$t);var Oh=Cr("Seconds",!1);Q("S",0,0,function(){return~~(this.millisecond()/100)}),Q(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Q(0,["SSS",3],0,"millisecond"),Q(0,["SSSS",4],0,function(){return this.millisecond()*10}),Q(0,["SSSSS",5],0,function(){return this.millisecond()*100}),Q(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),Q(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),Q(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),Q(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),X("S",ws,Va),X("SS",ws,tt),X("SSS",ws,za);var Qt,Fo;for(Qt="SSSS";Qt.length<=9;Qt+="S")X(Qt,br);function Nh(r,e){e[hr]=ae(("0."+r)*1e3)}for(Qt="S";Qt.length<=9;Qt+="S")ye(Qt,Nh);Fo=Cr("Milliseconds",!1),Q("z",0,0,"zoneAbbr"),Q("zz",0,0,"zoneName");function Mh(){return this._isUTC?"UTC":""}function jh(){return this._isUTC?"Coordinated Universal Time":""}var M=Wr.prototype;M.add=Bd,M.calendar=Md,M.clone=jd,M.diff=Vd,M.endOf=sh,M.format=Xd,M.from=Jd,M.fromNow=Qd,M.to=eh,M.toNow=th,M.get=Zc,M.invalidAt=uh,M.isAfter=qd,M.isBefore=Ud,M.isBetween=Ld,M.isSame=Yd,M.isSameOrAfter=Wd,M.isSameOrBefore=Gd,M.isValid=dh,M.lang=_o,M.locale=bo,M.localeData=Co,M.max=dd,M.min=ld,M.parsingFlags=hh,M.set=Xc,M.startOf=rh,M.subtract=Id,M.toArray=oh,M.toObject=ch,M.toDate=ah,M.toISOString=Kd,M.inspect=Zd,typeof Symbol<"u"&&Symbol.for!=null&&(M[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),M.toJSON=lh,M.toString=zd,M.unix=nh,M.valueOf=ih,M.creationData=fh,M.eraName=mh,M.eraNarrow=vh,M.eraAbbr=yh,M.eraYear=wh,M.year=Xa,M.isLeapYear=Kc,M.weekYear=Sh,M.isoWeekYear=Th,M.quarter=M.quarters=Ph,M.month=ro,M.daysInMonth=al,M.week=M.weeks=gl,M.isoWeek=M.isoWeeks=xl,M.weeksInYear=kh,M.weeksInWeekYear=Bh,M.isoWeeksInYear=Rh,M.isoWeeksInISOWeekYear=Fh,M.date=Ro,M.day=M.days=Tl,M.weekday=Rl,M.isoWeekday=Fl,M.dayOfYear=Hh,M.hour=M.hours=Ol,M.minute=M.minutes=$h,M.second=M.seconds=Oh,M.millisecond=M.milliseconds=Fo,M.utcOffset=yd,M.utc=Ed,M.local=bd,M.parseZone=_d,M.hasAlignedHourOffset=Cd,M.isDST=Dd,M.isLocal=Sd,M.isUtcOffset=Td,M.isUtc=mo,M.isUTC=mo,M.zoneAbbr=Mh,M.zoneName=jh,M.dates=it("dates accessor is deprecated. Use date instead.",Ro),M.months=it("months accessor is deprecated. Use month instead",ro),M.years=it("years accessor is deprecated. Use year instead",Xa),M.zone=it("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",wd),M.isDSTShifted=it("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Ad);function qh(r){return Ce(r*1e3)}function Uh(){return Ce.apply(null,arguments).parseZone()}function ko(r){return r}var xe=Wi.prototype;xe.calendar=Sc,xe.longDateFormat=kc,xe.invalidDate=Ic,xe.ordinal=$c,xe.preparse=ko,xe.postformat=ko,xe.relativeTime=Nc,xe.pastFuture=Mc,xe.set=Dc,xe.eras=gh,xe.erasParse=xh,xe.erasConvertYear=ph,xe.erasAbbrRegex=bh,xe.erasNameRegex=Eh,xe.erasNarrowRegex=_h,xe.months=rl,xe.monthsShort=sl,xe.monthsParse=nl,xe.monthsRegex=cl,xe.monthsShortRegex=ol,xe.week=dl,xe.firstDayOfYear=fl,xe.firstDayOfWeek=ul,xe.weekdays=_l,xe.weekdaysMin=Dl,xe.weekdaysShort=Cl,xe.weekdaysParse=Sl,xe.weekdaysRegex=kl,xe.weekdaysShortRegex=Bl,xe.weekdaysMinRegex=Il,xe.isPM=Hl,xe.meridiem=Nl;function Hs(r,e,t,s){var i=Nt(),n=bt().set(s,e);return i[t](n,r)}function Bo(r,e,t){if(It(r)&&(e=r,r=void 0),r=r||"",e!=null)return Hs(r,e,t,"month");var s,i=[];for(s=0;s<12;s++)i[s]=Hs(r,s,t,"month");return i}function pn(r,e,t,s){typeof r=="boolean"?(It(e)&&(t=e,e=void 0),e=e||""):(e=r,t=e,r=!1,It(e)&&(t=e,e=void 0),e=e||"");var i=Nt(),n=r?i._week.dow:0,a,o=[];if(t!=null)return Hs(e,(t+n)%7,s,"day");for(a=0;a<7;a++)o[a]=Hs(e,(a+n)%7,s,"day");return o}function Lh(r,e){return Bo(r,e,"months")}function Yh(r,e){return Bo(r,e,"monthsShort")}function Wh(r,e,t){return pn(r,e,t,"weekdays")}function Gh(r,e,t){return pn(r,e,t,"weekdaysShort")}function Vh(r,e,t){return pn(r,e,t,"weekdaysMin")}Jt("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(r){var e=r%10,t=ae(r%100/10)===1?"th":e===1?"st":e===2?"nd":e===3?"rd":"th";return r+t}}),W.lang=it("moment.lang is deprecated. Use moment.locale instead.",Jt),W.langData=it("moment.langData is deprecated. Use moment.localeData instead.",Nt);var Mt=Math.abs;function zh(){var r=this._data;return this._milliseconds=Mt(this._milliseconds),this._days=Mt(this._days),this._months=Mt(this._months),r.milliseconds=Mt(r.milliseconds),r.seconds=Mt(r.seconds),r.minutes=Mt(r.minutes),r.hours=Mt(r.hours),r.months=Mt(r.months),r.years=Mt(r.years),this}function Io(r,e,t,s){var i=gt(e,t);return r._milliseconds+=s*i._milliseconds,r._days+=s*i._days,r._months+=s*i._months,r._bubble()}function Kh(r,e){return Io(this,r,e,1)}function Zh(r,e){return Io(this,r,e,-1)}function Po(r){return r<0?Math.floor(r):Math.ceil(r)}function Xh(){var r=this._milliseconds,e=this._days,t=this._months,s=this._data,i,n,a,o,d;return r>=0&&e>=0&&t>=0||r<=0&&e<=0&&t<=0||(r+=Po(mn(t)+e)*864e5,e=0,t=0),s.milliseconds=r%1e3,i=at(r/1e3),s.seconds=i%60,n=at(i/60),s.minutes=n%60,a=at(n/60),s.hours=a%24,e+=at(a/24),d=at(Ho(e)),t+=d,e-=Po(mn(d)),o=at(t/12),t%=12,s.days=e,s.months=t,s.years=o,this}function Ho(r){return r*4800/146097}function mn(r){return r*146097/4800}function Jh(r){if(!this.isValid())return NaN;var e,t,s=this._milliseconds;if(r=nt(r),r==="month"||r==="quarter"||r==="year")switch(e=this._days+s/864e5,t=this._months+Ho(e),r){case"month":return t;case"quarter":return t/3;case"year":return t/12}else switch(e=this._days+Math.round(mn(this._months)),r){case"week":return e/7+s/6048e5;case"day":return e+s/864e5;case"hour":return e*24+s/36e5;case"minute":return e*1440+s/6e4;case"second":return e*86400+s/1e3;case"millisecond":return Math.floor(e*864e5)+s;default:throw new Error("Unknown unit "+r)}}function jt(r){return function(){return this.as(r)}}var $o=jt("ms"),Qh=jt("s"),eu=jt("m"),tu=jt("h"),ru=jt("d"),su=jt("w"),iu=jt("M"),nu=jt("Q"),au=jt("y"),ou=$o;function cu(){return gt(this)}function lu(r){return r=nt(r),this.isValid()?this[r+"s"]():NaN}function fr(r){return function(){return this.isValid()?this._data[r]:NaN}}var du=fr("milliseconds"),hu=fr("seconds"),uu=fr("minutes"),fu=fr("hours"),gu=fr("days"),xu=fr("months"),pu=fr("years");function mu(){return at(this.days()/7)}var qt=Math.round,Tr={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function vu(r,e,t,s,i){return i.relativeTime(e||1,!!t,r,s)}function yu(r,e,t,s){var i=gt(r).abs(),n=qt(i.as("s")),a=qt(i.as("m")),o=qt(i.as("h")),d=qt(i.as("d")),c=qt(i.as("M")),l=qt(i.as("w")),g=qt(i.as("y")),f=n<=t.ss&&["s",n]||n<t.s&&["ss",n]||a<=1&&["m"]||a<t.m&&["mm",a]||o<=1&&["h"]||o<t.h&&["hh",o]||d<=1&&["d"]||d<t.d&&["dd",d];return t.w!=null&&(f=f||l<=1&&["w"]||l<t.w&&["ww",l]),f=f||c<=1&&["M"]||c<t.M&&["MM",c]||g<=1&&["y"]||["yy",g],f[2]=e,f[3]=+r>0,f[4]=s,vu.apply(null,f)}function wu(r){return r===void 0?qt:typeof r=="function"?(qt=r,!0):!1}function Eu(r,e){return Tr[r]===void 0?!1:e===void 0?Tr[r]:(Tr[r]=e,r==="s"&&(Tr.ss=e-1),!0)}function bu(r,e){if(!this.isValid())return this.localeData().invalidDate();var t=!1,s=Tr,i,n;return typeof r=="object"&&(e=r,r=!1),typeof r=="boolean"&&(t=r),typeof e=="object"&&(s=Object.assign({},Tr,e),e.s!=null&&e.ss==null&&(s.ss=e.s-1)),i=this.localeData(),n=yu(this,!t,s,i),t&&(n=i.pastFuture(+this,n)),i.postformat(n)}var vn=Math.abs;function Rr(r){return(r>0)-(r<0)||+r}function $s(){if(!this.isValid())return this.localeData().invalidDate();var r=vn(this._milliseconds)/1e3,e=vn(this._days),t=vn(this._months),s,i,n,a,o=this.asSeconds(),d,c,l,g;return o?(s=at(r/60),i=at(s/60),r%=60,s%=60,n=at(t/12),t%=12,a=r?r.toFixed(3).replace(/\.?0+$/,""):"",d=o<0?"-":"",c=Rr(this._months)!==Rr(o)?"-":"",l=Rr(this._days)!==Rr(o)?"-":"",g=Rr(this._milliseconds)!==Rr(o)?"-":"",d+"P"+(n?c+n+"Y":"")+(t?c+t+"M":"")+(e?l+e+"D":"")+(i||s||r?"T":"")+(i?g+i+"H":"")+(s?g+s+"M":"")+(r?g+a+"S":"")):"P0D"}var le=Rs.prototype;le.isValid=xd,le.abs=zh,le.add=Kh,le.subtract=Zh,le.as=Jh,le.asMilliseconds=$o,le.asSeconds=Qh,le.asMinutes=eu,le.asHours=tu,le.asDays=ru,le.asWeeks=su,le.asMonths=iu,le.asQuarters=nu,le.asYears=au,le.valueOf=ou,le._bubble=Xh,le.clone=cu,le.get=lu,le.milliseconds=du,le.seconds=hu,le.minutes=uu,le.hours=fu,le.days=gu,le.weeks=mu,le.months=xu,le.years=pu,le.humanize=bu,le.toISOString=$s,le.toString=$s,le.toJSON=$s,le.locale=bo,le.localeData=Co,le.toIsoString=it("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",$s),le.lang=_o,Q("X",0,0,"unix"),Q("x",0,0,"valueOf"),X("x",bs),X("X",Lc),ye("X",function(r,e,t){t._d=new Date(parseFloat(r)*1e3)}),ye("x",function(r,e,t){t._d=new Date(ae(r))});//! moment.js
201
- W.version="2.30.1",_c(Ce),W.fn=M,W.min=hd,W.max=ud,W.now=fd,W.utc=bt,W.unix=qh,W.months=Lh,W.isDate=Yr,W.locale=Jt,W.invalid=ps,W.duration=gt,W.isMoment=ut,W.weekdays=Wh,W.parseZone=Uh,W.localeData=Nt,W.isDuration=Fs,W.monthsShort=Yh,W.weekdaysMin=Vh,W.defineLocale=nn,W.updateLocale=Ul,W.locales=Ll,W.weekdaysShort=Gh,W.normalizeUnits=nt,W.relativeTimeRounding=wu,W.relativeTimeThreshold=Eu,W.calendarFormat=Nd,W.prototype=M,W.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};let Os=null,yn=null,Se=null,Oo=null,At=null;function _u(r,e){if(!r||!r.sessionDescriptionHandler)return;const t=r.sessionDescriptionHandler.peerConnection;t&&t.getSenders().forEach(s=>{s.track&&s.track.kind==="audio"&&(s.track.enabled=e)})}function No(r){At||(At=document.createElement("audio"),At.id="voxnix-remote-audio",At.autoplay=!0,document.body.appendChild(At));const e=new MediaStream;if(r.sessionDescriptionHandler&&r.sessionDescriptionHandler.peerConnection){r.sessionDescriptionHandler.peerConnection.getReceivers().forEach(s=>{s.track&&e.addTrack(s.track)});const t=r.sessionDescriptionHandler.peerConnection;if(!t._isSetRemoteDescPatched){const s=t.setRemoteDescription.bind(t);t.setRemoteDescription=function(i){if(i&&i.sdp&&i.type==="answer"){const a=(((t.localDescription||{}).sdp||"").match(/^m=/gm)||[]).length,o=(i.sdp.match(/^m=/gm)||[]).length;if(console.log("[RTC Patch] local offer m-lines:",a,"| remote answer m-lines:",o),a>0&&o>a){const d=i.sdp.split(/\r?\n/);let c=0,l=!1;const g=[];for(const y of d)y.startsWith("m=")&&(c++,l=c>a),l||g.push(y);let f=g.join(`\r
202
- `);f.endsWith(`\r
203
- `)||(f+=`\r
204
- `),console.log("[RTC Patch] filtered to",(f.match(/^m=/gm)||[]).length,"m-lines. Applying to Chrome."),i={type:"answer",sdp:f}}}return s(i)},t._isSetRemoteDescPatched=!0}}At.srcObject=e,At.play().catch(t=>console.error("Error playing media:",t))}function Mo(){At&&(At.srcObject=null,At.pause())}const Cu=()=>{G.on("incoming_call",()=>{Te.pushSound()}),G.on("local_dial",({number:r})=>{if(Os){const e=lr.makeURI(`sip:${r}@${Os.configuration.uri.domain}`),t=new Ra(Os,e);t.stateChange.addListener(s=>{s===B.Establishing?G.emitLocal("call_status","Calling..."):s===B.Established?(No(t),Se=t,G.emitLocal("call_status","InCall")):s===B.Terminated&&(Mo(),G.emitLocal("call_status","Idle"),Se=null)}),t.invite()}}),G.on("local_hangup",()=>{Te.stopSound(),Se&&(Se.state===B.Established?Se.bye():typeof Se.reject=="function"?Se.reject():Se.cancel()),G.emitLocal("call_status","Idle"),G.emitLocal("call_duration","00:00"),G.emitToParent("sync_call_ended")}),G.on("local_reject",()=>{Te.stopSound(),Se&&(typeof Se.reject=="function"?Se.reject():Se.cancel()),G.emitLocal("call_status","Idle"),G.emitLocal("call_duration","00:00"),G.emitToParent("sync_call_ended")}),G.on("local_answer",()=>{Te.stopSound();const r={sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}}};Se&&Se.accept(r)}),G.on("local_toggle_mute",({muted:r})=>{Se&&_u(Se,!r)}),G.on("local_toggle_hold",({isOnHold:r,setIsOnHold:e})=>{if(Se)try{const t=!r,s={sessionDescriptionHandlerOptions:{hold:t}};Se.invite(s).then(()=>{e(t),console.log(t?"Call successfully put on hold":"Call successfully resumed")}).catch(i=>{console.error("Hold/Unhold failed",i)})}catch(t){console.error("Gagal mengubah status hold:",t)}}),G.on("local_dtmf",({key:r})=>{Se&&Se.sessionDescriptionHandler&&Se.sessionDescriptionHandler.sendDtmf(r)})},Du=()=>new Promise(r=>{if(!yn)return r(!1);yn.register({requestDelegate:{onAccept:()=>r(!0),onReject:e=>{var t;console.error("SIP re-register rejected:",(t=e==null?void 0:e.message)==null?void 0:t.statusCode),r(!1)}}}).catch(e=>{console.error("SIP re-register failed:",e),r(!1)})}),Au=3,Su=1e3,jo=async r=>{let e=await Te.fetchExtensionStatus(r);if(!e||Number(e.is_register)!==0)return{ext:e,registered:!0};if(!await Du())return{ext:e,registered:!1};for(let t=0;t<Au;t++)if(await new Promise(s=>setTimeout(s,Su)),e=await Te.fetchExtensionStatus(r),e&&Number(e.is_register)===1)return{ext:e,registered:!0};return console.warn("[ExtStatus] is_register still 0 after SIP re-register"),{ext:e,registered:!1}},Tu=async()=>{const{ext:r,registered:e}=await jo(Te.getExtensionUsername());if(!e){G.emitLocal("register_status",{status:"FAILED",reason:"Extension not registered after SIP re-register"});return}const t=r==null?void 0:r.extension_status;if(t==="Ready"){G.emitLocal("register_status","REGISTERED"),G.emitLocal("agent_status","READY");return}const s=typeof t=="string"&&t.toLowerCase().startsWith("aux");G.emitLocal("register_status","SIP_CONNECTED"),G.emitLocal("agent_status",s?"AUX":"NOT_READY")},qo=async(r,e)=>{const t=Te.getExtensionUsername(),{ext:s,registered:i}=await jo(t);return i?r==="Ready"&&(s==null?void 0:s.extension_status)==="Ready"?!0:Te.updateExtensionStatus(t,r,e):!1},Ru=async r=>{window.__sipjsEventsBound||(Cu(),window.__sipjsEventsBound=!0);const{auth:e}=r;if(!e)return;const t=e.user_pbx||e.username,s=e.pwd_pbx||e.secret,i=Te.getSipHost(),n=Te.getWssHost(),a=e.port||8089;if(!(!t||!i)){console.log("[SIP Debug] globalConfig:",Te.getConfig()),console.log("[SIP Debug] sipHost:",i),console.log("[SIP Debug] wssHost:",n);try{const o=lr.makeURI(`sip:${t}@${i}`);if(!o)throw new Error("Failed to create SIP URI");const d=`wss://${n}:${a}`,c=new lr({uri:o,transportOptions:{server:d,useSSL:!0,keepAliveInterval:15},authorizationUsername:t,authorizationPassword:s,sessionDescriptionHandlerFactoryOptions:{peerConnectionConfiguration:{iceServers:[]},constraints:{audio:!0,video:!1}},logLevel:"warn",contactParams:{transport:"tls"},registererOptions:{expires:600,refreshFrequency:90}});Os=c;const l=new wt(c);yn=l,l.stateChange.addListener(async g=>{var f;console.log("NEW STATE",g),g===me.Registered?((f=Te.getConfig())==null?void 0:f.autoReady)!==!1?await qo("Ready","ready")?(G.emitLocal("register_status","REGISTERED"),G.emitLocal("agent_status","READY")):G.emitLocal("register_status",{status:"FAILED",reason:"Failed to hit extension ready API"}):await Tu():(g===me.Unregistered||g===me.Terminated)&&G.emitLocal("register_status",{status:"FAILED",reason:"SIP Unregistered or Terminated"})}),c.delegate={onInvite(g){let f=!1;Se=g,G.emitLocal("sipjsSession",g),Te.pushSound(),Te.pushNotification(`New incoming call from ${g.remoteIdentity.uri.user}`),G.emitLocal("incoming_call",g),G.emitToParent("sync_incoming_call",g),g.stateChange.addListener(y=>{if(y===B.Established){No(g),f=!0,G.emitLocal("call_status","InCall"),G.emitToParent("sync_call_answered",g);const w=W();Oo=setInterval(()=>{const b=W.duration(W().diff(w));G.emitLocal("call_duration",Te.toHHMMSS(b.asSeconds()))},1e3)}else y===B.Terminated&&(Mo(),clearInterval(Oo),Te.stopSound(),G.emitLocal("call_duration","00:00"),G.emitLocal("call_status","Idle"),f?G.emitToParent("sync_call_ended",g):G.emitToParent("sync_call_unanswered"),Se=null)})}},await c.start(),await l.register()}catch(o){console.error("SipJS init error:",o),G.emitLocal("register_status",{status:"FAILED",reason:o.message||"Failed to connect to SIP server"})}}};function Fu({initialRegisterStatus:r="CONNECTING",autoReady:e=!0,showAuxButton:t=!1,auxOptions:s=[]}){const[i,n]=se.useState(""),[a,o]=se.useState("Idle"),[d,c]=se.useState("00:00"),[l,g]=se.useState(!1),[f,y]=se.useState(!1),[w,b]=se.useState(!1),[_,x]=se.useState(""),[p,E]=se.useState(""),[C,R]=se.useState(""),[S,F]=se.useState(r),[h,N]=se.useState(""),[A,u]=se.useState(e&&r==="REGISTERED"?"READY":"NOT_READY"),[v,m]=se.useState(!1),[U,j]=se.useState(null),J=se.useCallback(q=>{E(q),setTimeout(()=>E(""),4e3)},[]);se.useEffect(()=>{const q=[G.on("call_status",V=>{o(V),V!=="InCall"&&(b(!1),x(""),y(!1),g(!1))}),G.on("call_duration",c),G.on("incoming_call",V=>{var xt,Ye,Me,ct,Xe,Tt,pt,mt;const Ee=((Ye=(xt=V==null?void 0:V.remoteIdentity)==null?void 0:xt.uri)==null?void 0:Ye.user)||(V==null?void 0:V.from_id)||"Unknown",St=((Me=V==null?void 0:V.remoteIdentity)==null?void 0:Me.displayName)||((Xe=(ct=V==null?void 0:V.request)==null?void 0:ct.from)==null?void 0:Xe.displayName)||((mt=(pt=(Tt=V==null?void 0:V.incomingInviteRequest)==null?void 0:Tt.message)==null?void 0:pt.from)==null?void 0:mt.displayName)||(V==null?void 0:V.from_name)||Te.getContactName(Ee)||"";n(Ee),R(St),o("Ringing")}),G.on("register_status",V=>{const Ee=typeof V=="string"?V:(V==null?void 0:V.status)??"FAILED",St=typeof V=="object"?V==null?void 0:V.reason:"";F(Ee),N(Ee==="FAILED"?St||"Failed to connect to Voice Platform":""),Ee!=="REGISTERED"&&Ee!=="SIP_CONNECTED"&&u("NOT_READY")}),G.on("agent_status",V=>{u(V),V!=="AUX"&&j(null)}),G.on("call_failed",V=>J(V||"Call Failed"))];return()=>q.forEach(V=>V())},[J]),se.useEffect(()=>{a==="Idle"&&R(Te.getContactName(i)||"")},[i,a]),se.useEffect(()=>{const q=V=>{V.metaKey||V.ctrlKey||V.altKey||(a==="InCall"&&/^[0-9*#]$/.test(V.key)?H(V.key):a==="Idle"&&S==="REGISTERED"&&/^[0-9+*#]$/.test(V.key)?n(Ee=>Ee+V.key):a==="Idle"&&V.key==="Backspace"?n(Ee=>Ee.slice(0,-1)):a==="Idle"&&V.key==="Enter"&&I())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[a,S,i]);const z=async(q,V)=>{if(!Te.getExtensionUsername())return!1;m(!0);const Ee=await qo(q,V);return m(!1),Ee},ne=async()=>{await z("Ready","ready")&&(u("READY"),j(null),G.emitLocal("register_status","REGISTERED"),G.emitLocal("agent_status","READY"))},he=async()=>{await z("Logout","not_ready")&&(u("NOT_READY"),j(null),G.emitLocal("register_status","SIP_CONNECTED"),G.emitLocal("agent_status","NOT_READY"))},ue=async(q=null)=>{const V=(q==null?void 0:q.code)||"AUX",Ee=(q==null?void 0:q.label)||"AUX";await z("AUX",V)&&(u("AUX"),j({code:V,label:Ee}),G.emitLocal("agent_status","AUX")),setShowAuxMenu(!1)},I=()=>{const q=i.trim();q&&G.emitLocal("local_dial",{number:q})},H=q=>{x(V=>V+q),G.emitLocal("local_dtmf",{key:q})},$=()=>G.emitLocal("local_hangup"),P=()=>G.emitLocal("local_answer"),we=()=>G.emitLocal("local_reject"),pe=()=>{const q=!l;g(q),G.emitLocal("local_toggle_mute",{muted:q})},Be=()=>{G.emitLocal("local_toggle_hold",{isOnHold:f,setIsOnHold:y})};if(a==="Ringing")return T.jsxs(Fr,{error:p,children:[T.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-10 gap-7 min-h-[300px] animate-fadeIn",children:[T.jsx(wn,{color:"green",pulse:!0,children:T.jsx($n,{className:"w-9 h-9 text-green-600"})}),T.jsxs("div",{className:"text-center space-y-1",children:[T.jsx("p",{className:"text-lg font-bold text-gray-800 leading-tight",children:C||i||"Unknown"}),C&&T.jsx("p",{className:"text-sm font-mono text-gray-400 tracking-wider",children:i}),T.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-green-50 border border-green-100 mt-1",children:[T.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),T.jsx("span",{className:"text-[11px] font-semibold text-green-600 uppercase tracking-widest",children:"Incoming Call"})]})]})]}),T.jsxs(Uo,{children:[T.jsx(En,{color:"red",size:"lg",onClick:we,title:"Reject",children:T.jsx(as,{className:"w-6 h-6"})}),T.jsx(En,{color:"green",size:"lg",onClick:P,title:"Answer",pulse:!0,children:T.jsx(Nr,{className:"w-6 h-6 fill-white"})})]})]});if(a==="Calling...")return T.jsxs(Fr,{error:p,children:[T.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-10 gap-7 min-h-[300px] animate-fadeIn",children:[T.jsx(wn,{color:"primary",pulse:!0,children:T.jsx(a0,{className:"w-9 h-9 text-primary"})}),T.jsxs("div",{className:"text-center space-y-1",children:[T.jsx("p",{className:"text-lg font-bold text-gray-800 leading-tight",children:C||i}),C&&T.jsx("p",{className:"text-xs font-mono text-gray-400 tracking-wider",children:i}),T.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-primary/8 border border-primary/15 mt-1",children:[T.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-pulse"}),T.jsx("span",{className:"text-[11px] font-semibold text-primary uppercase tracking-widest",children:"Dialing..."})]})]})]}),T.jsx(Uo,{children:T.jsx(En,{color:"red",size:"lg",onClick:$,title:"Cancel",children:T.jsx(as,{className:"w-6 h-6"})})})]});if(a==="InCall")return T.jsxs(Fr,{error:p,children:[w?T.jsxs("div",{className:"animate-fadeIn",children:[T.jsxs("div",{className:"px-6 pt-5 pb-2 text-center",children:[T.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-[0.2em] mb-2",children:"DTMF"}),T.jsx("div",{className:"min-h-[44px] flex items-center justify-center",children:T.jsx("span",{className:"text-3xl font-light text-gray-700 tracking-[0.25em] font-mono",children:_||T.jsx("span",{className:"text-gray-200",children:"—"})})})]}),T.jsx(On,{onKeyPress:H})]}):T.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-10 gap-7 min-h-[300px] animate-fadeIn",children:[T.jsx(wn,{color:f?"primary":"green",pulse:!f,children:f?T.jsx(Hn,{className:"w-9 h-9 text-primary"}):T.jsx($n,{className:"w-9 h-9 text-green-600"})}),T.jsxs("div",{className:"text-center space-y-1",children:[T.jsx("p",{className:"text-base font-bold text-gray-800 leading-tight",children:C||i||"Connected"}),C&&T.jsx("p",{className:"text-xs font-mono text-gray-400 tracking-wider",children:i}),T.jsxs("div",{className:"flex items-center justify-center gap-2 mt-1",children:[!f&&T.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),T.jsx("span",{className:`text-sm font-mono font-semibold ${f?"text-primary":"text-green-600"}`,children:f?"On Hold":d})]})]})]}),T.jsx("div",{className:"border-t border-gray-100 bg-gray-50/60 px-6 py-4",children:T.jsxs("div",{className:"flex items-center justify-between gap-2 max-w-[260px] mx-auto",children:[T.jsx(bn,{onClick:pe,active:l,activeColor:"red",title:l?"Unmute":"Mute",children:l?T.jsx(i0,{className:"w-[18px] h-[18px]"}):T.jsx(n0,{className:"w-[18px] h-[18px]"})}),T.jsx(bn,{onClick:Be,active:f,activeColor:"primary",title:f?"Resume":"Hold",children:f?T.jsx(o0,{className:"w-[18px] h-[18px]"}):T.jsx(Hn,{className:"w-[18px] h-[18px]"})}),T.jsx(bn,{onClick:()=>b(q=>!q),active:w,activeColor:"primary",title:"Keypad",children:T.jsx(s0,{className:"w-[18px] h-[18px]"})}),T.jsx("button",{onClick:$,title:"End Call",className:"w-12 h-12 rounded-full bg-red-500 hover:bg-red-600 text-white flex items-center justify-center shadow-[0_4px_14px_rgba(239,68,68,0.4)] hover:shadow-[0_6px_18px_rgba(239,68,68,0.5)] transition-all active:scale-95",children:T.jsx(as,{className:"w-5 h-5"})})]})})]});if(S==="REGISTERED")return T.jsxs(Fr,{error:p,children:[T.jsxs("div",{className:"px-5 pt-5 pb-1",children:[T.jsxs("div",{className:"relative flex items-center justify-center min-h-[56px] bg-gray-50 rounded-2xl border border-gray-100 px-10",children:[T.jsx("input",{type:"text",value:i,onChange:q=>n(q.target.value.replace(/[^0-9+*#]/g,"")),onKeyDown:q=>q.key==="Enter"&&I(),className:"w-full text-center text-[28px] font-light text-gray-800 tracking-[0.12em] bg-transparent outline-none placeholder:text-gray-300 placeholder:text-2xl placeholder:font-normal",placeholder:"Enter number"}),i&&T.jsx("button",{onClick:()=>n(q=>q.slice(0,-1)),onMouseDown:q=>q.preventDefault(),className:"absolute right-3 p-1.5 rounded-full text-gray-300 hover:text-gray-500 hover:bg-gray-200 transition-all",children:T.jsx(r0,{className:"w-4 h-4"})})]}),C&&T.jsx("p",{className:"text-center text-xs text-primary/70 font-medium mt-1.5 tracking-wide",children:C})]}),T.jsx(On,{onKeyPress:q=>n(V=>V+q)}),T.jsx("div",{className:"px-5 pb-4 pt-1 flex justify-center",children:T.jsxs("button",{onClick:I,disabled:!i.trim(),className:`
205
- flex items-center gap-3 px-10 py-3.5 rounded-full
206
- bg-gradient-to-r from-green-500 to-green-600
207
- hover:from-green-600 hover:to-green-700
208
- disabled:from-gray-200 disabled:to-gray-200 disabled:text-gray-400 disabled:cursor-not-allowed
209
- text-white font-semibold text-sm tracking-wide
210
- shadow-[0_4px_14px_rgba(34,197,94,0.4)]
211
- hover:shadow-[0_6px_20px_rgba(34,197,94,0.5)]
212
- disabled:shadow-none
213
- transition-all active:scale-95
214
- `,children:[T.jsx(Nr,{className:"w-4 h-4 fill-white"}),"Call"]})}),T.jsx(ku,{agentStatus:A,currentAux:U,loading:v,autoReady:e,showAuxButton:t,auxOptions:s,onReady:ne,onNotReady:he,onAux:ue})]});if(S==="SIP_CONNECTED"){const q={READY:{label:"Ready",dot:"bg-green-500",text:"text-green-600"},NOT_READY:{label:"Not Ready",dot:"bg-blue-400",text:"text-blue-500"},AUX:{label:(U==null?void 0:U.label)||"AUX",dot:"bg-amber-400",text:"text-amber-600"}},V=q[A]||q.NOT_READY;return T.jsx(Fr,{error:p,children:T.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-10 gap-6 min-h-[300px] animate-fadeIn",children:[T.jsxs("div",{className:"relative w-16 h-16",children:[T.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-primary/20"}),T.jsx("div",{className:"absolute inset-2 rounded-full bg-primary/10 flex items-center justify-center",children:T.jsx(Nr,{className:"w-5 h-5 text-primary",style:{transform:"rotate(90deg)"}})})]}),T.jsxs("div",{className:"text-center space-y-2",children:[T.jsx("p",{className:"text-sm font-semibold text-gray-700",children:"SIP Connected"}),T.jsx("p",{className:"text-xs text-gray-400",children:"Click Ready to activate your session"}),T.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-gray-50 border border-gray-200 mt-1",children:[T.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${V.dot}`}),T.jsx("span",{className:`text-[11px] font-semibold ${V.text} uppercase tracking-wider`,children:V.label})]})]}),T.jsxs("button",{onClick:ne,disabled:v,className:"flex items-center gap-2 px-6 py-2.5 rounded-full bg-primary text-white text-sm font-semibold shadow-md shadow-primary/30 hover:bg-primary-hover transition-all active:scale-95 disabled:opacity-60 disabled:cursor-not-allowed",children:[T.jsx(In,{className:"w-4 h-4"}),v?"Setting Ready...":"Set Ready"]})]})})}return T.jsx(Fr,{error:p,children:T.jsx("div",{className:"flex flex-col items-center justify-center px-6 py-12 gap-4 min-h-[280px] animate-fadeIn",children:S==="CONNECTING"?T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"relative w-16 h-16",children:[T.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-primary/20"}),T.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-transparent border-t-primary animate-spin"}),T.jsx("div",{className:"absolute inset-2 rounded-full bg-primary/10 flex items-center justify-center",children:T.jsx(Nr,{className:"w-5 h-5 text-primary",style:{transform:"rotate(90deg)"}})})]}),T.jsxs("div",{className:"text-center space-y-1",children:[T.jsx("p",{className:"text-sm font-semibold text-gray-700",children:"Connecting to server"}),T.jsx("p",{className:"text-xs text-gray-400",children:"Please wait..."})]})]}):T.jsxs(T.Fragment,{children:[T.jsx("div",{className:"w-16 h-16 rounded-full bg-red-50 border-2 border-red-100 flex items-center justify-center",children:T.jsx(as,{className:"w-7 h-7 text-red-400"})}),T.jsxs("div",{className:"text-center space-y-1.5",children:[T.jsx("p",{className:"text-sm font-bold text-red-600",children:"Not Registered"}),h&&T.jsx("p",{className:"text-xs text-gray-400 max-w-[220px] leading-relaxed",children:h})]})]})})})}function Fr({children:r,error:e}){return T.jsxs("div",{className:"w-full relative select-none",children:[e&&T.jsxs("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 px-4 py-2 rounded-full bg-red-500 text-white text-xs font-semibold shadow-lg animate-slideUp whitespace-nowrap",children:[T.jsx(Qo,{className:"w-3.5 h-3.5 shrink-0"}),e]}),r]})}function Uo({children:r}){return T.jsx("div",{className:"border-t border-gray-100 bg-gray-50/60 px-6 py-5 flex items-center justify-center gap-10 animate-slideUp",children:r})}function wn({children:r,color:e="green",pulse:t=!1}){const s={green:{ring:"bg-green-500/15",ring2:"bg-green-500/8",wrap:"bg-green-50 border-green-200"},primary:{ring:"bg-primary/15",ring2:"bg-primary/8",wrap:"bg-primary/10 border-primary/20"},red:{ring:"bg-red-500/15",ring2:"bg-red-500/8",wrap:"bg-red-50 border-red-200"}},i=s[e]||s.green;return T.jsxs("div",{className:"relative flex items-center justify-center w-20 h-20",children:[t&&T.jsxs(T.Fragment,{children:[T.jsx("span",{className:`absolute w-20 h-20 rounded-full ${i.ring} animate-ping opacity-75`}),T.jsx("span",{className:`absolute w-28 h-28 rounded-full ${i.ring2} animate-pulse`})]}),T.jsx("div",{className:`relative z-10 w-16 h-16 rounded-full ${i.wrap} border-2 flex items-center justify-center shadow-sm`,children:r})]})}function En({children:r,onClick:e,color:t="gray",size:s="md",title:i,pulse:n=!1}){const a={md:"w-12 h-12",lg:"w-14 h-14"},o={green:"bg-green-500 hover:bg-green-600 shadow-[0_4px_14px_rgba(34,197,94,0.4)] hover:shadow-[0_6px_20px_rgba(34,197,94,0.5)]",red:"bg-red-500 hover:bg-red-600 shadow-[0_4px_14px_rgba(239,68,68,0.4)] hover:shadow-[0_6px_20px_rgba(239,68,68,0.5)]",gray:"bg-white border border-gray-200 text-gray-600 hover:bg-gray-50 shadow-sm"};return T.jsx("button",{onClick:e,title:i,className:`${a[s]} rounded-full text-white flex items-center justify-center transition-all active:scale-95 ${o[t]} ${n?"animate-pulse":""}`,children:r})}const Lo={READY:{dot:"bg-green-500",label:"Ready",text:"text-green-700",bg:"bg-green-50 border-green-200"},NOT_READY:{dot:"bg-gray-400",label:"Not Ready",text:"text-gray-600",bg:"bg-gray-50 border-gray-200"},AUX:{dot:"bg-amber-400",label:"AUX",text:"text-amber-700",bg:"bg-amber-50 border-amber-200"}};function ku({agentStatus:r,currentAux:e,loading:t,autoReady:s,showAuxButton:i,auxOptions:n,onReady:a,onNotReady:o,onAux:d}){const[c,l]=se.useState(!1),g=se.useRef(null);se.useEffect(()=>{const p=E=>{g.current&&!g.current.contains(E.target)&&l(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]);const f=Lo[r]||Lo.NOT_READY,y=r==="AUX"&&e?`AUX: ${e.label}`:f.label,w=!s||i,b=()=>{l(!1),a()},_=()=>{l(!1),o()},x=p=>{l(!1),d(p)};return T.jsx("div",{className:"border-t border-gray-100 bg-gray-50/70 px-4 py-3",children:T.jsxs("div",{className:"flex items-center justify-between gap-2",children:[T.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full border text-xs font-semibold ${f.bg} ${f.text}`,children:[T.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.dot}`}),y]}),w&&T.jsxs("div",{className:"relative",ref:g,children:[T.jsxs("button",{onClick:()=>!t&&l(p=>!p),disabled:t,className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[11px] font-semibold bg-white border border-gray-200 text-gray-600 hover:bg-gray-50 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",children:[t?T.jsx("span",{className:"w-3 h-3 border-2 border-gray-300 border-t-gray-600 rounded-full animate-spin"}):T.jsx(t0,{className:`w-3 h-3 transition-transform duration-150 ${c?"":"rotate-180"}`}),"Status"]}),c&&T.jsxs("div",{className:"absolute bottom-full mb-1.5 right-0 w-48 bg-white rounded-xl shadow-xl border border-gray-100 overflow-hidden z-50 animate-slideUp",children:[!s&&T.jsxs(T.Fragment,{children:[T.jsxs("button",{onClick:b,disabled:r==="READY",className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left text-xs font-medium text-gray-700 hover:bg-green-50 hover:text-green-800 transition-colors disabled:opacity-40 disabled:cursor-not-allowed border-b border-gray-50",children:[T.jsx(In,{className:"w-3.5 h-3.5 text-green-500 shrink-0"}),"Ready",r==="READY"&&T.jsx("span",{className:"ml-auto text-[10px] text-green-500 font-semibold",children:"✓ Active"})]}),T.jsxs("button",{onClick:_,disabled:r==="NOT_READY",className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left text-xs font-medium text-gray-700 hover:bg-gray-100 transition-colors disabled:opacity-40 disabled:cursor-not-allowed border-b border-gray-50",children:[T.jsx(c0,{className:"w-3.5 h-3.5 text-gray-400 shrink-0"}),"Not Ready",r==="NOT_READY"&&T.jsx("span",{className:"ml-auto text-[10px] text-gray-400 font-semibold",children:"✓ Active"})]})]}),!s&&i&&n.length>0&&T.jsxs("div",{className:"px-3.5 py-1.5 flex items-center gap-2",children:[T.jsx("div",{className:"flex-1 h-px bg-gray-100"}),T.jsx("span",{className:"text-[10px] text-gray-400 font-semibold uppercase tracking-wider",children:"AUX"}),T.jsx("div",{className:"flex-1 h-px bg-gray-100"})]}),i&&n.map(p=>T.jsxs("button",{onClick:()=>x(p),disabled:r==="AUX"&&(e==null?void 0:e.code)===p.code,className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left text-xs font-medium text-gray-700 hover:bg-amber-50 hover:text-amber-800 transition-colors border-b border-gray-50 last:border-0 disabled:opacity-40 disabled:cursor-not-allowed",children:[T.jsx(Pn,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),p.label,r==="AUX"&&(e==null?void 0:e.code)===p.code&&T.jsx("span",{className:"ml-auto text-[10px] text-amber-500 font-semibold",children:"✓ Active"})]},p.code)),i&&n.length===0&&T.jsxs("button",{onClick:()=>x(null),disabled:r==="AUX",className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left text-xs font-medium text-gray-700 hover:bg-amber-50 hover:text-amber-800 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[T.jsx(Pn,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),"AUX",r==="AUX"&&T.jsx("span",{className:"ml-auto text-[10px] text-amber-500 font-semibold",children:"✓ Active"})]})]})]})]})})}function bn({children:r,onClick:e,active:t,activeColor:s="primary",title:i}){const n={red:"bg-red-500 border-red-500 text-white shadow-[0_2px_8px_rgba(239,68,68,0.35)]",primary:"bg-primary border-primary text-white shadow-[0_2px_8px_rgba(63,49,146,0.35)]"};return T.jsx("button",{onClick:e,title:i,className:`
215
- w-11 h-11 rounded-full flex items-center justify-center
216
- border transition-all active:scale-95
217
- ${t?n[s]:"bg-white border-gray-200 text-gray-500 hover:bg-gray-100 hover:text-gray-700"}
218
- `,children:r})}const Yo={"bottom-left":"bottom-6 left-3 items-start","bottom-right":"bottom-6 right-3 items-end","top-left":"top-6 left-3 items-start","top-right":"top-6 right-3 items-end"};function Bu({config:r,placement:e="bottom-left",offset:t,onIncomingCall:s,onCallAnswered:i,onCallEnded:n,onCallUnanswered:a,onRegisterStatus:o,onAgentStatus:d}){const[c,l]=se.useState(!1),[g,f]=se.useState("CONNECTING"),[y,w]=se.useState("NOT_READY"),[b,_]=se.useState(!1),x=se.useRef(!1),p=se.useRef({}),E=(r==null?void 0:r.autoReady)!==!1,C=(r==null?void 0:r.showAuxButton)===!0,R=(r==null?void 0:r.auxOptions)||[];se.useEffect(()=>{p.current={onIncomingCall:s,onCallAnswered:i,onCallEnded:n,onCallUnanswered:a,onRegisterStatus:o,onAgentStatus:d}}),se.useEffect(()=>{var u;r&&Te.setConfig(r);const A=(r==null?void 0:r.auth)||((u=r==null?void 0:r.pabxConfig)==null?void 0:u.auth)||{};!x.current&&(A.username||A.user_pbx)&&(A.pwd_pbx||A.secret)&&(A.pabx_host||A.pbxurl||A.host)&&(x.current=!0,Ru({auth:A}))},[r]),se.useEffect(()=>{const A=[G.on("register_status",u=>{var m,U;const v=typeof u=="string"?u:(u==null?void 0:u.status)??"FAILED";f(v),(v==="REGISTERED"||v==="SIP_CONNECTED")&&l(!0),v!=="SIP_CONNECTED"&&((U=(m=p.current).onRegisterStatus)==null||U.call(m,v==="FAILED"?u:v))}),G.on("agent_status",u=>{var v,m;w(u),(m=(v=p.current).onAgentStatus)==null||m.call(v,u)}),G.on("sync_incoming_call",u=>{var v,m;_(!0),l(!0),(m=(v=p.current).onIncomingCall)==null||m.call(v,u)}),G.on("sync_call_answered",u=>{var v,m;_(!1),(m=(v=p.current).onCallAnswered)==null||m.call(v,u)}),G.on("sync_call_ended",u=>{var v,m;_(!1),(m=(v=p.current).onCallEnded)==null||m.call(v,u)}),G.on("sync_call_unanswered",u=>{var v,m;_(!1),(m=(v=p.current).onCallUnanswered)==null||m.call(v,u)})];return()=>A.forEach(u=>u())},[]);const S=Yo[e]||Yo["bottom-left"],F=g!=="REGISTERED"?g==="FAILED"?"bg-red-500":"bg-blue-400":y==="READY"?"bg-green-500":y==="AUX"?"bg-amber-400":"bg-gray-400",h=t?{position:"fixed",zIndex:9999,...t}:void 0,N=e!=null&&e.includes("right")?"origin-bottom-right":"origin-bottom-left";return T.jsxs("div",{className:t?void 0:`fixed ${S} z-[9999] flex flex-col gap-3`,style:h,children:[T.jsxs("div",{className:`w-[360px] bg-white rounded-3xl overflow-hidden ${N} shadow-[0_20px_60px_rgba(0,0,0,0.18),0_4px_16px_rgba(0,0,0,0.08)] ${c?"animate-slideUp":"hidden"}`,children:[T.jsxs("div",{className:"flex items-center justify-between px-4 py-3.5 bg-gradient-to-r from-[#3f3192] to-[#5240c2]",children:[T.jsx("div",{className:"flex items-center gap-2.5",children:T.jsx("span",{className:"text-white font-semibold text-sm tracking-wide",children:"Voice Widget"})}),T.jsx("button",{onClick:()=>l(!1),className:"text-white/50 hover:text-white transition-colors p-1 rounded-lg",title:"Minimize",children:T.jsx(e0,{className:"w-4 h-4"})})]}),T.jsx(Fu,{initialRegisterStatus:g,autoReady:E,showAuxButton:C,auxOptions:R})]}),T.jsxs("button",{onClick:()=>l(A=>!A),className:"w-12 h-12 rounded-full bg-primary hover:bg-primary-hover text-white shadow-lg shadow-primary/30 flex items-center justify-center transition-all active:scale-95 relative",title:"Voice Widget",children:[T.jsx(Nr,{className:"w-5 h-5"}),b&&T.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-green-500 border-2 border-white animate-ping"}),T.jsx("span",{className:`absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-white ${F}`})]})]})}let er=null,ot=null;function Iu(r,e){if(Hr.createRoot){const t=Hr.createRoot(e);return t.render(r),{render:s=>t.render(s),unmount:()=>t.unmount()}}return Hr.render(r,e),{render:t=>Hr.render(t,e),unmount:()=>Hr.unmountComponentAtNode(e)}}const Pu={init(r={}){const{container:e,placement:t="bottom-left",offset:s,platform:i="sipjs",auth:n,pabxConfig:a,autoReady:o=!0,showAuxButton:d=!1,auxOptions:c=[],onIncomingCall:l,onCallAnswered:g,onCallEnded:f,onCallUnanswered:y,onRegisterStatus:w,onAgentStatus:b,..._}=r;typeof e=="string"?ot=document.querySelector(e):e instanceof HTMLElement&&(ot=e),ot||(ot=document.createElement("div"),ot.id="omnix-widget-root",document.body.appendChild(ot)),er&&(er.unmount(),er=null);const x=se.createElement(Bu,{config:{platform:i,auth:n,pabxConfig:a,autoReady:o,showAuxButton:d,auxOptions:c,..._},placement:t,offset:s,onIncomingCall:l,onCallAnswered:g,onCallEnded:f,onCallUnanswered:y,onRegisterStatus:w,onAgentStatus:b});return er=Iu(x,ot),{answer:()=>G.emitLocal("local_answer"),hangup:()=>G.emitLocal("local_hangup"),reject:()=>G.emitLocal("local_reject"),mute:p=>G.emitLocal("local_toggle_mute",{muted:p}),hold:p=>G.emitLocal("local_toggle_hold",{isOnHold:p,setIsOnHold:()=>{}}),dial:p=>G.emitLocal("local_dial",{number:p}),destroy:()=>{er==null||er.unmount(),er=null,(ot==null?void 0:ot.id)==="omnix-widget-root"&&ot.remove(),ot=null}}}};Yt.OmnixWidget=Pu,Object.defineProperty(Yt,Symbol.toStringTag,{value:"Module"})});
58
+ ${n}
59
+ `);this.ondata({transport:this,message:n})}},Fn={};const Fo=pe,or=$e(),ur=ke,_s=new Fo("Parser");Fn.parseMessage=(f,n)=>{let s,o,c=f.indexOf(`\r
60
+ `);if(c===-1){_s.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=f.substring(0,c);let d=or.parse(t,"Request_Response");if(d===-1){_s.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else d.status_code?(s=new ur.IncomingResponse,s.status_code=d.status_code,s.reason_phrase=d.reason_phrase):(s=new ur.IncomingRequest(n),s.method=d.method,s.ruri=d.uri);s.data=f;let p=c+2;for(;;){if(c=ko(f,p),c===-2){o=p+2;break}else if(c===-1){_s.warn("parseMessage() | malformed message");return}if(d=qo(s,f,p,c),d!==!0){_s.warn("parseMessage() |",d.error);return}p=c+2}if(s.hasHeader("content-length")){const a=s.getHeader("content-length");s.body=f.substr(o,a)}else s.body=f.substring(o);return s};function ko(f,n){let s=n,o=0,c=0;if(f.substring(s,s+2).match(/(^\r\n)/))return-2;for(;o===0;){if(c=f.indexOf(`\r
61
+ `,s),c===-1)return c;!f.substring(c+2,c+4).match(/(^\r\n)/)&&f.charAt(c+2).match(/(^\s+)/)?s=c+2:o=c}return o}function qo(f,n,s,o){let c;const t=n.indexOf(":",s),d=n.substring(s,t).trim(),p=n.substring(t+1,o).trim();switch(d.toLowerCase()){case"via":case"v":{f.addHeader("via",p),f.getHeaders("via").length===1?(c=f.parseHeader("Via"),c&&(f.via=c,f.via_branch=c.branch)):c=0;break}case"from":case"f":{f.setHeader("from",p),c=f.parseHeader("from"),c&&(f.from=c,f.from_tag=c.getParam("tag"));break}case"to":case"t":{f.setHeader("to",p),c=f.parseHeader("to"),c&&(f.to=c,f.to_tag=c.getParam("tag"));break}case"record-route":{if(c=or.parse(p,"Record_Route"),c===-1)c=void 0;else for(const a of c)f.addHeader("record-route",p.substring(a.possition,a.offset)),f.headers["Record-Route"][f.getHeaders("record-route").length-1].parsed=a.parsed;break}case"call-id":case"i":{f.setHeader("call-id",p),c=f.parseHeader("call-id"),c&&(f.call_id=p);break}case"contact":case"m":{if(c=or.parse(p,"Contact"),c===-1)c=void 0;else for(const a of c)f.addHeader("contact",p.substring(a.possition,a.offset)),f.headers.Contact[f.getHeaders("contact").length-1].parsed=a.parsed;break}case"content-length":case"l":{f.setHeader("content-length",p),c=f.parseHeader("content-length");break}case"content-type":case"c":{f.setHeader("content-type",p),c=f.parseHeader("content-type");break}case"cseq":{f.setHeader("cseq",p),c=f.parseHeader("cseq"),c&&(f.cseq=c.value),f instanceof ur.IncomingResponse&&(f.method=c.method);break}case"max-forwards":{f.setHeader("max-forwards",p),c=f.parseHeader("max-forwards");break}case"www-authenticate":{f.setHeader("www-authenticate",p),c=f.parseHeader("www-authenticate");break}case"proxy-authenticate":{f.setHeader("proxy-authenticate",p),c=f.parseHeader("proxy-authenticate");break}case"session-expires":case"x":{f.setHeader("session-expires",p),c=f.parseHeader("session-expires"),c&&(f.session_expires=c.expires,f.session_expires_refresher=c.refresher);break}case"refer-to":case"r":{f.setHeader("refer-to",p),c=f.parseHeader("refer-to"),c&&(f.refer_to=c);break}case"replaces":{f.setHeader("replaces",p),c=f.parseHeader("replaces"),c&&(f.replaces=c);break}case"event":case"o":{f.setHeader("event",p),c=f.parseHeader("event"),c&&(f.event=c);break}default:f.addHeader(d,p),c=0}return c===void 0?{error:`error parsing header "${d}"`}:!0}const Go=pe,kn=oe,qn=ke,cr=Ce(),fr=new Go("sanityCheck"),Bo=[Zo],Wo=[Yo,Ko,zo,Xo],Vo=[Jo,Qo];let re,Be,Gn;var jo=(f,n,s)=>{re=f,Be=n,Gn=s;for(const o of Bo)if(o()===!1)return!1;if(re instanceof qn.IncomingRequest){for(const o of Wo)if(o()===!1)return!1}else if(re instanceof qn.IncomingResponse){for(const o of Vo)if(o()===!1)return!1}return!0};function Yo(){if(re.s("to").uri.scheme!=="sip")return Bt(416),!1}function Ko(){if(!re.to_tag&&re.call_id.substr(0,5)===Be.configuration.jssip_id)return Bt(482),!1}function zo(){const f=cr.str_utf8_length(re.body),n=re.getHeader("content-length");if(f<n)return Bt(400),!1}function Xo(){const f=re.from_tag,n=re.call_id,s=re.cseq;let o;if(!re.to_tag)if(re.method===kn.INVITE){if(Be._transactions.ist[re.via_branch])return!1;for(const c in Be._transactions.ist)if(Object.prototype.hasOwnProperty.call(Be._transactions.ist,c)&&(o=Be._transactions.ist[c],o.request.from_tag===f&&o.request.call_id===n&&o.request.cseq===s))return Bt(482),!1}else{if(Be._transactions.nist[re.via_branch])return!1;for(const c in Be._transactions.nist)if(Object.prototype.hasOwnProperty.call(Be._transactions.nist,c)&&(o=Be._transactions.nist[c],o.request.from_tag===f&&o.request.call_id===n&&o.request.cseq===s))return Bt(482),!1}}function Jo(){if(re.getHeaders("via").length>1)return fr.debug("more than one Via header field present in the response, dropping the response"),!1}function Qo(){const f=cr.str_utf8_length(re.body),n=re.getHeader("content-length");if(f<n)return fr.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function Zo(){const f=["from","to","call_id","cseq","via"];for(const n of f)if(!re.hasHeader(n))return fr.debug(`missing mandatory header field : ${n}, dropping the response`),!1}function Bt(f){const n=re.getHeaders("via");let s,o=`SIP/2.0 ${f} ${kn.REASON_PHRASE[f]}\r
62
+ `;for(const c of n)o+=`Via: ${c}\r
63
+ `;s=re.getHeader("To"),re.to_tag||(s+=`;tag=${cr.newTag()}`),o+=`To: ${s}\r
64
+ `,o+=`From: ${re.getHeader("From")}\r
65
+ `,o+=`Call-ID: ${re.call_id}\r
66
+ `,o+=`CSeq: ${re.cseq} ${re.method}\r
67
+ `,o+=`\r
68
+ `,Gn.send(o)}var hr={};const Rt=Ce(),ut=oe,dr=$e(),Bn=Ze(),_r=ir,pr=He;hr.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:ut.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,register_from_tag_trail:"",registrar_server:null,sockets:null,connection_recovery_max_interval:ut.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:ut.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${Rt.createRandomToken(12)}.invalid`};const ps={mandatory:{sockets(f){const n=[];if(_r.isSocket(f))n.push({socket:f});else if(Array.isArray(f)&&f.length)for(const s of f)Object.prototype.hasOwnProperty.call(s,"socket")&&_r.isSocket(s.socket)?n.push(s):_r.isSocket(s)&&n.push({socket:s});else return;return n},uri(f){/^sip:/i.test(f)||(f=`${ut.SIP}:${f}`);const n=Bn.parse(f);if(n)return n.user?n:void 0}},optional:{authorization_user(f){if(dr.parse(`"${f}"`,"quoted_string")!==-1)return f},authorization_jwt(f){if(typeof f=="string")return f},user_agent(f){if(typeof f=="string")return f},connection_recovery_max_interval(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},connection_recovery_min_interval(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},contact_uri(f){if(typeof f=="string"){const n=dr.parse(f,"SIP_URI");if(n!==-1)return n}},display_name(f){return f},instance_id(f){if(/^uuid:/i.test(f)&&(f=f.substr(5)),dr.parse(f,"uuid")!==-1)return f},no_answer_timeout(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},session_timers(f){if(typeof f=="boolean")return f},session_timers_refresh_method(f){if(typeof f=="string"&&(f=f.toUpperCase(),f===ut.INVITE||f===ut.UPDATE))return f},session_timers_force_refresher(f){if(typeof f=="boolean")return f},password(f){return String(f)},realm(f){return String(f)},ha1(f){return String(f)},register(f){if(typeof f=="boolean")return f},register_expires(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>=0)return n}},register_from_tag_trail(f){return typeof f=="function"?f:String(f)},registrar_server(f){/^sip:/i.test(f)||(f=`${ut.SIP}:${f}`);const n=Bn.parse(f);if(n)return n.user?void 0:n},use_preloaded_route(f){if(typeof f=="boolean")return f},extra_headers(f){const n=[];if(Array.isArray(f)&&f.length)for(const s of f)typeof s=="string"&&n.push(s);else return;return n}}};hr.load=(f,n)=>{for(const s in ps.mandatory)if(n.hasOwnProperty(s)){const o=n[s],c=ps.mandatory[s](o);if(c!==void 0)f[s]=c;else throw new pr.ConfigurationError(s,o)}else throw new pr.ConfigurationError(s);for(const s in ps.optional)if(n.hasOwnProperty(s)){const o=n[s];if(Rt.isEmpty(o))continue;const c=ps.optional[s](o);if(c!==void 0)f[s]=c;else throw new pr.ConfigurationError(s,o)}};const eu=Fe.EventEmitter,tu=pe,Ee=oe,su=Pa,Wn=Pn,ru=To,Vn=Ao,jn=yo,Yn=Uo,mr=Pt,nu=Ho,ms=Ce(),lu=He,iu=Ze(),au=Fn,gr=ke,ou=jo,Tr=hr,Z=new tu("UA"),ve={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var uu=class extends eu{static get C(){return ve}constructor(n){if(!n)throw new TypeError("Not enough arguments");const s=["password","ha1","authorization_jwt"];Z.debug("new() [configuration:%o]",Object.entries(n).filter(([o])=>!s.includes(o))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Tr.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=ve.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(n)}catch(o){throw this._status=ve.STATUS_NOT_READY,this._error=ve.CONFIGURATION_ERROR,o}this._registrator=new su(this)}get C(){return ve}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){Z.debug("start()"),this._status===ve.STATUS_INIT?this._transport.connect():this._status===ve.STATUS_USER_CLOSED?(Z.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ve.STATUS_INIT,this._transport.connect()):this._status===ve.STATUS_READY?Z.debug("UA is in READY status, not restarted"):Z.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){Z.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(n){Z.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(n)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(n,s){Z.debug("call()");const o=new Wn(this);return o.connect(n,s),o}sendMessage(n,s,o){Z.debug("sendMessage()");const c=new jn(this);return c.send(n,s,o),c}subscribe(n,s,o,c){return Z.debug("subscribe()"),new ru(this,n,s,o,c)}notify(n,s,o){return Z.debug("notify()"),new Vn(this,n,s,o)}sendOptions(n,s,o){Z.debug("sendOptions()");const c=new Yn(this);return c.send(n,s,o),c}terminateSessions(n){Z.debug("terminateSessions()");for(const s in this._sessions)this._sessions[s].isEnded()||this._sessions[s].terminate(n)}stop(){if(Z.debug("stop()"),this._dynConfiguration={},this._status===ve.STATUS_USER_CLOSED){Z.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){Z.debug(`closing session ${o}`);try{this._sessions[o].terminate()}catch{}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch{}this._status=ve.STATUS_USER_CLOSED,Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length===0&&n===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(n){return ms.normalizeTarget(n,this._configuration.hostport_params)}get(n){switch(n){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:{Z.warn('get() | cannot get "%s" parameter in runtime',n);return}}}set(n,s){switch(n){case"authorization_user":{this._configuration.authorization_user=String(s);break}case"password":{this._configuration.password=String(s);break}case"realm":{this._configuration.realm=String(s);break}case"ha1":{this._configuration.ha1=String(s),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(s);break}case"display_name":{this._configuration.display_name=s;break}case"extra_headers":{this._configuration.extra_headers=s;break}default:return Z.warn('set() | cannot set "%s" parameter in runtime',n),!1}return!0}newTransaction(n){this._transactions[n.type][n.id]=n,this.emit("newTransaction",{transaction:n})}destroyTransaction(n){delete this._transactions[n.type][n.id],this.emit("transactionDestroyed",{transaction:n})}newDialog(n){this._dialogs[n.id]=n}destroyDialog(n){delete this._dialogs[n.id]}newMessage(n,s){this._applicants[n]=n,this.emit("newMessage",s)}newOptions(n,s){this._applicants[n]=n,this.emit("newOptions",s)}destroyMessage(n){delete this._applicants[n]}newRTCSession(n,s){this._sessions[n.id]=n,this.emit("newRTCSession",s)}destroyRTCSession(n){delete this._sessions[n.id]}registered(n){this.emit("registered",n)}unregistered(n){this.emit("unregistered",n)}registrationFailed(n){this.emit("registrationFailed",n)}receiveRequest(n){const s=n.method;if(n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){Z.debug("Request-URI does not point to us"),n.method!==Ee.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===Ee.SIPS){n.reply_sl(416);return}if(mr.checkTransaction(this,n))return;if(s===Ee.INVITE?new mr.InviteServerTransaction(this,this._transport,n):s!==Ee.ACK&&s!==Ee.CANCEL&&new mr.NonInviteServerTransaction(this,this._transport,n),s===Ee.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new Yn(this).init_incoming(n)}else if(s===Ee.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new jn(this).init_incoming(n)}else if(s===Ee.SUBSCRIBE){if(this.listeners("newSubscribe").length===0){n.reply(405);return}}else if(s===Ee.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let o,c;if(n.to_tag)o=this._findDialog(n.call_id,n.from_tag,n.to_tag),o?o.receiveRequest(n):s===Ee.NOTIFY?(c=this._findSession(n),c?c.receiveRequest(n):(Z.debug("received NOTIFY request for a non existent subscription"),n.reply(481,"Subscription does not exist"))):s!==Ee.ACK&&n.reply(481);else switch(s){case Ee.INVITE:{if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const t=n.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(c=o.owner,c.isEnded()?n.reply(603):c.receiveRequest(n)):n.reply(481)}else c=new Wn(this),c.init_incoming(n);else Z.warn("INVITE received but WebRTC is not supported"),n.reply(488);break}case Ee.BYE:{n.reply(481);break}case Ee.CANCEL:{c=this._findSession(n),c?c.receiveRequest(n):Z.debug("received CANCEL request for a non existent session");break}case Ee.ACK:break;case Ee.NOTIFY:{this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break}case Ee.SUBSCRIBE:{Vn.init_incoming(n,()=>{this.emit("newSubscribe",{event:n.event,request:n})});break}default:{n.reply(405);break}}}_findSession({call_id:n,from_tag:s,to_tag:o}){const c=n+s,t=this._sessions[c],d=n+o,p=this._sessions[d];return t||p||null}_findDialog(n,s,o){let c=n+s+o,t=this._dialogs[c];return t||(c=n+o+s,t=this._dialogs[c],t||null)}_loadConfig(n){Tr.load(this._configuration,n),this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=ms.newUUID()),this._configuration.jssip_id=ms.createRandomToken(5);const s=this._configuration.uri.clone();s.user=null,this._configuration.hostport_params=s.toString().replace(/^sip:/i,"");try{this._transport=new nu(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=cu.bind(this),this._transport.onconnect=fu.bind(this),this._transport.ondisconnect=hu.bind(this),this._transport.ondata=du.bind(this)}catch(c){throw Z.warn(c),new lu.ConfigurationError("sockets",this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){const c=this._configuration.uri.clone();c.user=null,c.clearParams(),c.clearHeaders(),this._configuration.registrar_server=c}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new iu("sip",ms.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(c={}){const t=c.anonymous||null,d=c.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),d&&(t?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(const c in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,c)&&(o.indexOf(c)!==-1?Object.defineProperty(this._configuration,c,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,c,{writable:!1,configurable:!1}));Z.debug("configuration parameters after validation:");for(const c in this._configuration)if(Object.prototype.hasOwnProperty.call(Tr.settings,c))switch(c){case"uri":case"registrar_server":{Z.debug(`- ${c}: ${this._configuration[c]}`);break}case"password":case"ha1":case"authorization_jwt":{Z.debug(`- ${c}: NOT SHOWN`);break}default:Z.debug(`- ${c}: ${JSON.stringify(this._configuration[c])}`)}}};function cu(f){this.emit("connecting",f)}function fu(f){this._status!==ve.STATUS_USER_CLOSED&&(this._status=ve.STATUS_READY,this._error=null,this.emit("connected",f),this._dynConfiguration.register&&this._registrator.register())}function hu(f){const n=["nict","ict","nist","ist"];for(const s of n)for(const o in this._transactions[s])Object.prototype.hasOwnProperty.call(this._transactions[s],o)&&this._transactions[s][o].onTransportError();this.emit("disconnected",f),this._registrator.onTransportClosed(),this._status!==ve.STATUS_USER_CLOSED&&(this._status=ve.STATUS_NOT_READY,this._error=ve.NETWORK_ERROR)}function du(f){const n=f.transport;let s=f.message;if(s=au.parseMessage(s,this),!!s&&!(this._status===ve.STATUS_USER_CLOSED&&s instanceof gr.IncomingRequest)&&ou(s,this,n)){if(s instanceof gr.IncomingRequest)s.transport=n,this.receiveRequest(s);else if(s instanceof gr.IncomingResponse){let o;switch(s.method){case Ee.INVITE:{o=this._transactions.ict[s.via_branch],o&&o.receiveResponse(s);break}case Ee.ACK:break;default:{o=this._transactions.nict[s.via_branch],o&&o.receiveResponse(s);break}}}}}const _u=pe,pu=$e(),be=new _u("WebSocketInterface");var mu=class{constructor(n){be.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;const s=pu.parse(n,"absoluteURI");if(s===-1)throw be.warn(`invalid WebSocket URI: ${n}`),new TypeError(`Invalid argument: ${n}`);if(s.scheme!=="wss"&&s.scheme!=="ws")throw be.warn(`invalid WebSocket URI scheme: ${s.scheme}`),new TypeError(`Invalid argument: ${n}`);this._sip_uri=`sip:${s.host}${s.port?`:${s.port}`:""};transport=ws`,this._via_transport=s.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(n){this._via_transport=n.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(be.debug("connect()"),this.isConnected()){be.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){be.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),be.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(n){this._onError(n)}}disconnect(){be.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(n){return be.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(be.warn("unable to send message, WebSocket is not open"),!1)}isConnected(){return this._ws&&this._ws.readyState===this._ws.OPEN}isConnecting(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}_onOpen(){be.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:n,code:s,reason:o}){be.debug(`WebSocket ${this._url} closed`),n===!1&&be.debug("WebSocket abrupt disconnection"),this.ondisconnect(!n,s,o)}_onMessage({data:n}){be.debug("received WebSocket message"),this.ondata(n)}_onError(n){be.warn(`WebSocket ${this._url} error: `,n)}};const Er=zr,gu=oe,Tu=He,Eu=Ce(),Su=uu,Cu=Ze(),Au=Ps(),vu=$e(),Ru=mu,Iu=qs("JsSIP"),bu=Pn;Iu("version %s",Er.version);var wu={C:gu,Exceptions:Tu,Utils:Eu,UA:Su,URI:Cu,NameAddrHeader:Au,WebSocketInterface:Ru,Grammar:vu,RTCSession:bu,debug:qs,get name(){return Er.title},get version(){return Er.version}};const Kn=Ji(wu);let L=null,he=null,It=null;const ct=f=>(f==null?void 0:f.replace(/^(https?|wss?):\/\//,"").replace(/\/+$/,""))||null,Se={setConfig(f){L=f},getConfig(){return L},pushSound(){try{It&&clearInterval(It);const f=()=>{try{(!he||he.state==="closed")&&(he=new(window.AudioContext||window.webkitAudioContext)),he.state==="suspended"&&he.resume();const n=he.createOscillator(),s=he.createOscillator(),o=he.createGain();n.type="sine",s.type="sine",n.frequency.setValueAtTime(400,he.currentTime),s.frequency.setValueAtTime(450,he.currentTime);const c=he.createOscillator(),t=he.createGain();c.frequency.value=25,t.gain.value=15,c.connect(t),t.connect(n.frequency),t.connect(s.frequency),n.connect(o),s.connect(o),o.connect(he.destination),o.gain.setValueAtTime(0,he.currentTime),o.gain.linearRampToValueAtTime(.08,he.currentTime+.05),o.gain.setValueAtTime(.08,he.currentTime+1.2),o.gain.linearRampToValueAtTime(0,he.currentTime+1.3),[c,n,s].forEach(d=>{d.start(),d.stop(he.currentTime+1.4)})}catch(n){console.warn("Failed to play synthesized tone:",n)}};f(),It=setInterval(f,3e3)}catch(f){console.warn("AudioContext initialization failed:",f)}},stopSound(){It&&(clearInterval(It),It=null),he&&(he.close().catch(()=>{}),he=null)},toHHMMSS(f){const n=parseInt(f,10),s=Math.floor(n/3600),o=Math.floor(n/60)%60,c=n%60;return[s,o,c].map(t=>t<10?"0"+t:t).filter((t,d)=>t!=="00"||d>0).join(":")},getContactName(f){var n;return f&&((n=L==null?void 0:L.contacts)==null?void 0:n[f])||null},getCpaasBaseUrl(){var n,s;const f=((L==null?void 0:L.cpaas_base_url)||(L==null?void 0:L.cpaasBaseUrl)||((n=L==null?void 0:L.env)==null?void 0:n.CPAAS_BASE_URL)||((s=L==null?void 0:L.pabxConfig)==null?void 0:s.cpaas_base_url)||"https://api-cpaas.omnix.co.id").replace(/\/+$/,"");return!/^https:\/\//.test(f)&&!/^http:\/\/(localhost|127\.0\.0\.1)(:|\/|$)/.test(f)?(console.error("cpaas_base_url must use https. CPaaS API calls are disabled."),null):f},getSipHost(){var f,n,s,o;return ct(L==null?void 0:L.pbx_url)||ct((f=L==null?void 0:L.pabxConfig)==null?void 0:f.pbx_url)||ct((n=L==null?void 0:L.auth)==null?void 0:n.pabx_host)||ct((s=L==null?void 0:L.auth)==null?void 0:s.pbxurl)||ct((o=L==null?void 0:L.auth)==null?void 0:o.host)},getWssHost(){var f;return ct(L==null?void 0:L.sip_url)||ct((f=L==null?void 0:L.pabxConfig)==null?void 0:f.sip_url)||this.getSipHost()},getFingerprint(){var f,n,s;return(L==null?void 0:L["X-CPAAS-Key-Fingerprint"])||(L==null?void 0:L.fingerprint)||(L==null?void 0:L.cpaasKeyFingerprint)||((f=L==null?void 0:L.env)==null?void 0:f.fingerprint)||((n=L==null?void 0:L.env)==null?void 0:n.X_CPAAS_Key_Fingerprint)||((s=L==null?void 0:L.pabxConfig)==null?void 0:s["X-CPAAS-Key-Fingerprint"])},getExtensionUsername(){var f,n;return((f=L==null?void 0:L.auth)==null?void 0:f.user_pbx)||((n=L==null?void 0:L.auth)==null?void 0:n.username)||null},async updateExtensionStatus(f,n="Ready",s="ready"){const o=this.getFingerprint(),c=this.getCpaasBaseUrl();if(!c)return!1;if(!o)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot update extension status."),!1;try{return(await fetch(`${c}/voice/extensions/status`,{method:"POST",headers:{"X-CPAAS-Key-Fingerprint":o,"Content-Type":"application/json"},body:JSON.stringify({extension:f,status:n,reason:s})})).ok}catch(t){return console.error("Failed to update extension status:",t),!1}},async fetchExtensionStatus(f){var o,c;const n=this.getFingerprint(),s=this.getCpaasBaseUrl();if(!s)return null;if(!n)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot fetch extension status."),null;try{const t=await fetch(`${s}/voice/portal/extension?extension=${encodeURIComponent(f)}`,{headers:{"X-CPAAS-Key-Fingerprint":n,"Content-Type":"application/json"}});return t.ok&&((c=(o=await t.json())==null?void 0:o.data)==null?void 0:c[0])||null}catch(t){return console.error("Failed to fetch extension status:",t),null}}},zn={audio:!0,video:!1},Xn={iceServers:[]};let we=null,ee=null,Sr=null,Ne=null,Cr=!1;const Jn={registerStatus:"CONNECTING",agentStatus:"NOT_READY",currentAux:null,callStatus:"Idle",callDuration:"00:00",isMuted:!1,isOnHold:!1,remote:null};let bt={...Jn};const yu=()=>({...bt}),Ie=(f,n,s)=>{s&&Object.assign(bt,s),ts.emitLocal(f,n)},Le=(f,n)=>Ie("register_status",f==="FAILED"?{status:f,reason:n}:f,f==="FAILED"?{registerStatus:f,agentStatus:"NOT_READY",currentAux:null}:{registerStatus:f}),Wt=(f,n=null)=>Ie("agent_status",f,{agentStatus:f,currentAux:f==="AUX"?n:null}),Vt=f=>Ie("call_status",f,{callStatus:f}),Qn=f=>{f.addEventListener("track",n=>{n.track.kind==="audio"&&(Ne||(Ne=document.createElement("audio"),Ne.id="voxnix-remote-audio",Ne.autoplay=!0,document.body.appendChild(Ne)),Ne.srcObject=n.streams[0]||new MediaStream([n.track]),Ne.play().catch(s=>console.error("Error playing media:",s)))})},Nu=f=>n=>{var d,p;if(n.originator!=="remote"||n.type!=="answer")return;const s=(((p=(d=f.connection)==null?void 0:d.localDescription)==null?void 0:p.sdp.match(/^m=/gm))||[]).length,o=(n.sdp.match(/^m=/gm)||[]).length;if(!s||o<=s)return;let c=0;const t=n.sdp.split(/\r?\n/).filter(a=>(a.startsWith("m=")&&c++,c<=s));n.sdp=t.join(`\r
69
+ `).replace(/(\r\n)*$/,`\r
70
+ `)},Ou=f=>{var s,o,c;const n=((o=(s=f.remote_identity)==null?void 0:s.uri)==null?void 0:o.user)||"Unknown";return{number:n,name:((c=f.remote_identity)==null?void 0:c.display_name)||Se.getContactName(n)||"",direction:f.direction}},Zn=f=>{ee=f;const n=Ou(f);Object.assign(bt,{remote:n,isMuted:!1,isOnHold:!1}),f.connection?Qn(f.connection):f.on("peerconnection",o=>Qn(o.peerconnection)),f.on("sdp",Nu(f)),f.on("confirmed",()=>{Se.stopSound(),Vt("InCall"),Ie("sync_call_answered",n);const o=Date.now();Sr=setInterval(()=>{const c=Se.toHHMMSS((Date.now()-o)/1e3);Ie("call_duration",c,{callDuration:c})},1e3)}),f.on("muted",()=>Ie("mute_status",!0,{isMuted:!0})),f.on("unmuted",()=>Ie("mute_status",!1,{isMuted:!1})),f.on("hold",o=>o.originator==="local"&&Ie("hold_status",!0,{isOnHold:!0})),f.on("unhold",o=>o.originator==="local"&&Ie("hold_status",!1,{isOnHold:!1}));const s=o=>c=>{Se.stopSound(),clearInterval(Sr),Ne&&(Ne.srcObject=null),ee=null,Ie("call_duration","00:00",{callDuration:"00:00",isMuted:!1,isOnHold:!1,remote:null}),Vt("Idle");const t={...n,cause:c.cause,originator:c.originator};o?Ie("sync_call_ended",t):n.direction==="incoming"?Ie("sync_call_unanswered",t):c.originator!=="local"&&Ie("call_failed",c.cause||"Call Failed")};f.on("ended",s(!0)),f.on("failed",s(!1))},xu=({session:f,originator:n})=>{var s;if(n==="local")return Zn(f);if(ee)return f.terminate({status_code:486,reason_phrase:"Busy Here"});Zn(f),((s=Se.getConfig())==null?void 0:s.ringtone)!==!1&&Se.pushSound(),Vt("Ringing"),Ie("incoming_call",bt.remote)},Du=f=>{if(f=String(f??"").trim(),!(!we||ee||!f)){if(!/^[0-9A-Za-z+*#._-]+$/.test(f))return Ie("call_failed","Invalid number");Vt("Calling...");try{we.call(`sip:${f}@${Se.getSipHost()}`,{mediaConstraints:zn,pcConfig:Xn})}catch(n){console.error("Dial failed:",n),Vt("Idle"),Ie("call_failed",n.message||"Call Failed")}}},Uu=()=>{Se.stopSound(),(ee==null?void 0:ee.direction)==="incoming"&&!ee.isEstablished()&&ee.answer({mediaConstraints:zn,pcConfig:Xn})},el=()=>{Se.stopSound(),ee&&!ee.isEnded()&&ee.terminate()},$u=el,Pu=(f=!0)=>{ee!=null&&ee.isEstablished()&&(f?ee.mute({audio:!0}):ee.unmute({audio:!0}))},Mu=(f=!0)=>{ee!=null&&ee.isEstablished()&&(f?ee.hold():ee.unhold())},Lu=f=>{if(ee!=null&&ee.isEstablished())try{ee.sendDTMF(String(f))}catch(n){console.error("DTMF failed:",n)}},Hu=3,tl=1e3,Fu=()=>new Promise(f=>{const n=we;if(!n)return f(!1);Cr=!0;const s=d=>{Cr=!1,clearTimeout(t),n.off("registered",o),n.off("registrationFailed",c),f(d)},o=()=>s(!0),c=d=>{console.error("SIP re-register rejected:",d==null?void 0:d.cause),s(!1)},t=setTimeout(()=>s(!0),tl);n.on("registered",o),n.on("registrationFailed",c),n.register()}),sl=async f=>{let n=await Se.fetchExtensionStatus(f);if(!n||Number(n.is_register)!==0)return{ext:n,registered:!0};if(!await Fu())return{ext:n,registered:!1};for(let s=0;s<Hu;s++)if(await new Promise(o=>setTimeout(o,tl)),n=await Se.fetchExtensionStatus(f),n&&Number(n.is_register)===1)return{ext:n,registered:!0};return console.warn("[ExtStatus] is_register still 0 after SIP re-register"),{ext:n,registered:!1}},Ar=async(f,n)=>{const s=Se.getExtensionUsername();if(!s)return!1;const{ext:o,registered:c}=await sl(s);return c?f==="Ready"&&(o==null?void 0:o.extension_status)==="Ready"?!0:Se.updateExtensionStatus(s,f,n):!1},ku=async()=>{const{ext:f,registered:n}=await sl(Se.getExtensionUsername());if(!n)return Le("FAILED","Extension not registered after SIP re-register");const s=f==null?void 0:f.extension_status;if(s==="Ready")return Le("REGISTERED"),Wt("READY");const o=typeof s=="string"&&s.toLowerCase().startsWith("aux");Le("SIP_CONNECTED"),Wt(o?"AUX":"NOT_READY",o?{code:s,label:s}:null)},rl=async()=>{const f=await Ar("Ready","ready");return f&&(Le("REGISTERED"),Wt("READY")),f},qu=async()=>{const f=await Ar("Logout","not_ready");return f&&(Le("SIP_CONNECTED"),Wt("NOT_READY")),f},Gu=async(f="AUX",n=f)=>{const s=await Ar("AUX",f);return s&&Wt("AUX",{code:f,label:n}),s},Bu=async()=>{var f;if(!Cr){if(((f=Se.getConfig())==null?void 0:f.autoReady)===!1)return ku();await rl()||Le("FAILED","Failed to hit extension ready API")}},nl=()=>Math.random().toString(36).slice(2,10),Wu=(f={})=>{var p;ll();const n=f.auth||((p=f.pabxConfig)==null?void 0:p.auth)||{};Se.setConfig({...f,auth:n});const s=n.user_pbx||n.username,o=n.pwd_pbx||n.secret,c=Se.getSipHost(),t=Se.getWssHost(),d=n.port||8089;if(!s||!o||!c)return Le("FAILED","Missing SIP credentials (username, password, host)");try{we=new Kn.UA({sockets:[new Kn.WebSocketInterface(`wss://${t}:${d}`)],uri:`sip:${s}@${c}`,authorization_user:s,password:o,register_expires:600,session_timers:!1,contact_uri:`sip:${nl()}@${nl()}.invalid;transport=tls`}),we.on("registered",Bu),we.on("unregistered",()=>Le("FAILED","SIP Unregistered")),we.on("registrationFailed",a=>Le("FAILED",`SIP registration failed: ${a.cause}`)),we.on("disconnected",()=>{bt.registerStatus!=="FAILED"&&Le("FAILED","WebSocket disconnected, retrying...")}),we.on("newRTCSession",xu),we.start()}catch(a){console.error("JsSIP init error:",a),we=null,Le("FAILED",a.message||"Failed to connect to SIP server")}},ll=()=>{Se.stopSound(),clearInterval(Sr),we&&(we.removeAllListeners(),we.stop(),we=null),ee=null,Ne==null||Ne.remove(),Ne=null,bt={...Jn}},Vu={register_status:"onRegisterStatus",agent_status:"onAgentStatus",call_status:"onCallStatus",call_failed:"onCallFailed",incoming_call:"onIncomingCall",sync_call_answered:"onCallAnswered",sync_call_ended:"onCallEnded",sync_call_unanswered:"onCallUnanswered"};function il(){ll(),ts.listeners={}}const ju={init(f={}){return il(),Object.entries(Vu).forEach(([n,s])=>ts.on(n,o=>{var c;n==="register_status"&&o==="SIP_CONNECTED"||(c=f[s])==null||c.call(f,o)})),Wu(f),{dial:Du,answer:Uu,reject:$u,hangup:el,mute:Pu,hold:Mu,sendDtmf:Lu,setReady:rl,setNotReady:qu,setAux:Gu,getState:yu,on:(n,s)=>ts.on(n,s),destroy:il}}};Tt.OmnixWidget=ju,Object.defineProperty(Tt,Symbol.toStringTag,{value:"Module"})});