""2>3?*A ".@""2@3A*5 ".B""2B3C*) ".D""2D3E'),_('7)*# "7,'),_('.F""2F3G*} ".H""2H3I*q ".J""2J3K*e ".L""2L3M*Y ".N""2N3O*M ".P""2P3Q*A ".R""2R3S*5 ".T""2T3U*) ".V""2V3W'),_('!!.Y""2Y3Z+7$7#+-%7#+#%\'#%$## X$"# X"# X+! (%'),_('!! \\7$,#&7$"+-$7 +#%\'"%$"# X"# X*# " [+@$ \\7$+&$,#&7$""" X+\'%4"6]" %$"# X"# X'),_('7.*# " ['),_('! \\7\'*# "7(,)&7\'*# "7("+A$.8""2839+1%7/+\'%4#6^# %$## X$"# X"# X'),_('!! \\72+&$,#&72""" X+o$ \\! \\7.,#&7."+-$72+#%\'"%$"# X"# X,@&! \\7.,#&7."+-$72+#%\'"%$"# X"# X"+#%\'"%$"# X"# X+! (%'),_('0_""1!3`*# "73'),_('0a""1!3b'),_('0c""1!3d'),_('7!*) "0e""1!3f'),_('! \\7)*\x95 ".F""2F3G*\x89 ".J""2J3K*} ".L""2L3M*q ".Y""2Y3Z*e ".P""2P3Q*Y ".H""2H3I*M ".@""2@3A*A ".g""2g3h*5 ".R""2R3S*) ".N""2N3O+\x9e$,\x9b&7)*\x95 ".F""2F3G*\x89 ".J""2J3K*} ".L""2L3M*q ".Y""2Y3Z*e ".P""2P3Q*Y ".H""2H3I*M ".@""2@3A*A ".g""2g3h*5 ".R""2R3S*) ".N""2N3O""" X+! (%'),_('! \\7)*\x89 ".F""2F3G*} ".L""2L3M*q ".Y""2Y3Z*e ".P""2P3Q*Y ".H""2H3I*M ".@""2@3A*A ".g""2g3h*5 ".R""2R3S*) ".N""2N3O+\x92$,\x8f&7)*\x89 ".F""2F3G*} ".L""2L3M*q ".Y""2Y3Z*e ".P""2P3Q*Y ".H""2H3I*M ".@""2@3A*A ".g""2g3h*5 ".R""2R3S*) ".N""2N3O""" X+! (%'),_('.T""2T3U*\xe3 ".V""2V3W*\xd7 ".i""2i3j*\xcb ".k""2k3l*\xbf ".:""2:3;*\xb3 ".D""2D3E*\xa7 ".2""2233*\x9b ".8""2839*\x8f ".m""2m3n*\x83 "7&*} ".4""2435*q ".o""2o3p*e ".q""2q3r*Y ".6""2637*M ".>""2>3?*A ".s""2s3t*5 ".u""2u3v*) "7\'*# "7('),_('! \\7)*\u012b ".F""2F3G*\u011f ".J""2J3K*\u0113 ".L""2L3M*\u0107 ".Y""2Y3Z*\xfb ".P""2P3Q*\xef ".H""2H3I*\xe3 ".@""2@3A*\xd7 ".g""2g3h*\xcb ".R""2R3S*\xbf ".N""2N3O*\xb3 ".T""2T3U*\xa7 ".V""2V3W*\x9b ".i""2i3j*\x8f ".k""2k3l*\x83 ".8""2839*w ".m""2m3n*k "7&*e ".4""2435*Y ".o""2o3p*M ".q""2q3r*A ".6""2637*5 ".s""2s3t*) ".u""2u3v+\u0134$,\u0131&7)*\u012b ".F""2F3G*\u011f ".J""2J3K*\u0113 ".L""2L3M*\u0107 ".Y""2Y3Z*\xfb ".P""2P3Q*\xef ".H""2H3I*\xe3 ".@""2@3A*\xd7 ".g""2g3h*\xcb ".R""2R3S*\xbf ".N""2N3O*\xb3 ".T""2T3U*\xa7 ".V""2V3W*\x9b ".i""2i3j*\x8f ".k""2k3l*\x83 ".8""2839*w ".m""2m3n*k "7&*e ".4""2435*Y ".o""2o3p*M ".q""2q3r*A ".6""2637*5 ".s""2s3t*) ".u""2u3v""" X+! (%'),_('!7/+A$.P""2P3Q+1%7/+\'%4#6w# %$## X$"# X"# X'),_('!7/+A$.4""2435+1%7/+\'%4#6x# %$## X$"# X"# X'),_('!7/+A$.>""2>3?+1%7/+\'%4#6y# %$## X$"# X"# X'),_('!7/+A$.T""2T3U+1%7/+\'%4#6z# %$## X$"# X"# X'),_('!7/+A$.V""2V3W+1%7/+\'%4#6{# %$## X$"# X"# X'),_('!.k""2k3l+1$7/+\'%4"6|" %$"# X"# X'),_('!7/+7$.i""2i3j+\'%4"6}" %$"# X"# X'),_('!7/+A$.D""2D3E+1%7/+\'%4#6~# %$## X$"# X"# X'),_('!7/+A$.2""2233+1%7/+\'%4#6\x7f# %$## X$"# X"# X'),_('!7/+A$.8""2839+1%7/+\'%4#6\x80# %$## X$"# X"# X'),_('!7/+1$7&+\'%4"6\x81" %$"# X"# X'),_('!7&+1$7/+\'%4"6\x81" %$"# X"# X'),_('!7=+W$ \\7G*) "7K*# "7F,/&7G*) "7K*# "7F"+-%7>+#%\'#%$## X$"# X"# X'),_('0\x82""1!3\x83*A "0\x84""1!3\x85*5 "0\x86""1!3\x87*) "73*# "7.'),_('!!7/+U$7&+K% \\7J*# "7K,)&7J*# "7K"+-%7&+#%\'$%$$# X$## X$"# X"# X+! (%'),_('!7/+`$7&+V%! \\7J*# "7K,)&7J*# "7K"+! (%+2%7&+(%4$6\x88$!!%$$# X$## X$"# X"# X'),_('7.*G ".L""2L3M*; "0\x89""1!3\x8a*/ "0\x86""1!3\x87*# "73'),_('!.m""2m3n+K$0\x8b""1!3\x8c*5 "0\x8d""1!3\x8e*) "0\x8f""1!3\x90+#%\'"%$"# X"# X'),_('!7N+Q$.8""2839+A%7O*# " [+1%7S+\'%4$6\x91$ %$$# X$## X$"# X"# X'),_('!7N+k$.8""2839+[%7O*# " [+K%7S+A%7_+7%7l*# " [+\'%4&6\x92& %$ X$%# X$$# X$## X$"# X"# X'),_('!/\x93""1$3\x94*) "/\x95""1#3\x96+\' 4!6\x97!! %'),_('!7P+b$!.8""2839+-$7R+#%\'"%$"# X"# X*# " [+7%.:""2:3;+\'%4#6\x98# %$## X$"# X"# X'),_(' \\7+*) "7-*# "7Q+2$,/&7+*) "7-*# "7Q""" X'),_('.<""2<3=*q ".>""2>3?*e ".@""2@3A*Y ".B""2B3C*M ".D""2D3E*A ".2""2233*5 ".6""2637*) ".4""2435'),_('! \\7+*_ "7-*Y ".<""2<3=*M ".>""2>3?*A ".@""2@3A*5 ".B""2B3C*) ".D""2D3E,e&7+*_ "7-*Y ".<""2<3=*M ".>""2>3?*A ".@""2@3A*5 ".B""2B3C*) ".D""2D3E"+& 4!6\x99! %'),_('!7T+N$!.8""2839+-$7^+#%\'"%$"# X"# X*# " [+#%\'"%$"# X"# X'),_('!7U*) "7\\*# "7X+& 4!6\x9a! %'),_('! \\!7V+3$.J""2J3K+#%\'"%$"# X"# X,>&!7V+3$.J""2J3K+#%\'"%$"# X"# X"+G$7W+=%.J""2J3K*# " [+\'%4#6\x9b# %$## X$"# X"# X'),_(' \\0\x9c""1!3\x9d+,$,)&0\x9c""1!3\x9d""" X'),_('!0$""1!3%+A$ \\0\x9e""1!3\x9f,)&0\x9e""1!3\x9f"+#%\'"%$"# X"# X'),_('!.o""2o3p+A$7Y+7%.q""2q3r+\'%4#6\xa0# %$## X$"# X"# X'),_('!!7Z+\xbf$.8""2839+\xaf%7Z+\xa5%.8""2839+\x95%7Z+\x8b%.8""2839+{%7Z+q%.8""2839+a%7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\'-%$-# X$,# X$+# X$*# X$)# X$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u0838 "!.\xa1""2\xa13\xa2+\xaf$7Z+\xa5%.8""2839+\x95%7Z+\x8b%.8""2839+{%7Z+q%.8""2839+a%7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\',%$,# X$+# X$*# X$)# X$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u0795 "!.\xa1""2\xa13\xa2+\x95$7Z+\x8b%.8""2839+{%7Z+q%.8""2839+a%7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\'*%$*# X$)# X$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u070c "!.\xa1""2\xa13\xa2+{$7Z+q%.8""2839+a%7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\'(%$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u069d "!.\xa1""2\xa13\xa2+a$7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\'&%$ X$%# X$$# X$## X$"# X"# X*\u0648 "!.\xa1""2\xa13\xa2+G$7Z+=%.8""2839+-%7[+#%\'$%$$# X$## X$"# X"# X*\u060d "!.\xa1""2\xa13\xa2+-$7[+#%\'"%$"# X"# X*\u05ec "!.\xa1""2\xa13\xa2+-$7Z+#%\'"%$"# X"# X*\u05cb "!7Z+\xa5$.\xa1""2\xa13\xa2+\x95%7Z+\x8b%.8""2839+{%7Z+q%.8""2839+a%7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\'+%$+# X$*# X$)# X$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u0538 "!7Z+\xb6$!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\x8b%.\xa1""2\xa13\xa2+{%7Z+q%.8""2839+a%7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\'*%$*# X$)# X$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u0494 "!7Z+\xc7$!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\x9c%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+q%.\xa1""2\xa13\xa2+a%7Z+W%.8""2839+G%7Z+=%.8""2839+-%7[+#%\')%$)# X$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u03df "!7Z+\xd8$!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\xad%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\x82%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+W%.\xa1""2\xa13\xa2+G%7Z+=%.8""2839+-%7[+#%\'(%$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u0319 "!7Z+\xe9$!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\xbe%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\x93%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+h%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+=%.\xa1""2\xa13\xa2+-%7[+#%\'\'%$\'# X$ X$%# X$$# X$## X$"# X"# X*\u0242 "!7Z+\u0114$!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\xe9%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\xbe%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\x93%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+h%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+=%.\xa1""2\xa13\xa2+-%7Z+#%\'(%$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X*\u0140 "!7Z+\u0135$!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\u010a%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\xdf%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\xb4%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+\x89%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+^%!.8""2839+-$7Z+#%\'"%$"# X"# X*# " [+3%.\xa1""2\xa13\xa2+#%\'(%$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X+& 4!6\xa3! %'),_('!7#+S$7#*# " [+C%7#*# " [+3%7#*# " [+#%\'$%$$# X$## X$"# X"# X'),_('!7Z+=$.8""2839+-%7Z+#%\'#%$## X$"# X"# X*# "7\\'),_('!7]+u$.J""2J3K+e%7]+[%.J""2J3K+K%7]+A%.J""2J3K+1%7]+\'%4\'6\xa4\' %$\'# X$ X$%# X$$# X$## X$"# X"# X'),_('!.\xa5""2\xa53\xa6+3$0\xa7""1!3\xa8+#%\'"%$"# X"# X*\xa0 "!.\xa9""2\xa93\xaa+=$0\xab""1!3\xac+-%7!+#%\'#%$## X$"# X"# X*o "!.\xad""2\xad3\xae+7$7!+-%7!+#%\'#%$## X$"# X"# X*D "!0\xaf""1!3\xb0+-$7!+#%\'"%$"# X"# X*# "7!'),_('!!7!*# " [+c$7!*# " [+S%7!*# " [+C%7!*# " [+3%7!*# " [+#%\'%%$%# X$$# X$## X$"# X"# X+\' 4!6\xb1!! %'),_(' \\!.2""2233+-$7`+#%\'"%$"# X"# X,>&!.2""2233+-$7`+#%\'"%$"# X"# X"'),_('7a*A "7b*; "7c*5 "7d*/ "7e*) "7f*# "7g'),_('!/\xb2""1*3\xb3+b$/\xb4""1#3\xb5*G "/\xb6""1#3\xb7*; "/\xb8""1$3\xb9*/ "/\xba""1#3\xbb*# "76+(%4"6\xbc"! %$"# X"# X'),_('!/\xbd""1%3\xbe+J$/\xbf""1%3\xc0*/ "/\xc1""1"3\xc2*# "76+(%4"6\xc3"! %$"# X"# X'),_('!/\xc4""1\'3\xc5+2$7\x8f+(%4"6\xc6"! %$"# X"# X'),_('!/\xc7""1$3\xc8+2$7\xef+(%4"6\xc9"! %$"# X"# X'),_('!/\xca""1&3\xcb+2$7T+(%4"6\xcc"! %$"# X"# X'),_('!/\xcd""1"3\xce+R$!.>""2>3?+-$76+#%\'"%$"# X"# X*# " [+\'%4"6\xcf" %$"# X"# X'),_('!7h+T$!.>""2>3?+-$7i+#%\'"%$"# X"# X*# " [+)%4"6\xd0""! %$"# X"# X'),_('! \\7j+&$,#&7j""" X+! (%'),_('! \\7j+&$,#&7j""" X+! (%'),_('7k*) "7+*# "7-'),_('.o""2o3p*e ".q""2q3r*Y ".4""2435*M ".8""2839*A ".<""2<3=*5 ".@""2@3A*) ".B""2B3C'),_('!.6""2637+u$7m+k% \\!.<""2<3=+-$7m+#%\'"%$"# X"# X,>&!.<""2<3=+-$7m+#%\'"%$"# X"# X"+#%\'#%$## X$"# X"# X'),_('!7n+C$.>""2>3?+3%7o+)%4#6\xd1#"" %$## X$"# X"# X'),_(' \\7p*) "7+*# "7-+2$,/&7p*) "7+*# "7-""" X'),_(' \\7p*) "7+*# "7-,/&7p*) "7+*# "7-"'),_('.o""2o3p*e ".q""2q3r*Y ".4""2435*M ".6""2637*A ".8""2839*5 ".@""2@3A*) ".B""2B3C'),_('7\x90*# "7r'),_("!7\x8f+K$7'+A%7s+7%7'+-%7\x84+#%'%%$%# X$$# X$## X$\"# X\"# X"),_('7M*# "7t'),_('!7\x7f+G$.8""2839+7%7u*# "7x+\'%4#6\xd2# %$## X$"# X"# X'),_('!7v*# "7w+N$!.6""2637+-$7\x83+#%\'"%$"# X"# X*# " [+#%\'"%$"# X"# X'),_('!.\xd3""2\xd33\xd4+=$7\x80+3%7w*# " [+#%\'#%$## X$"# X"# X'),_('!.4""2435+-$7{+#%\'"%$"# X"# X'),_('!7z+5$ \\7y,#&7y"+#%\'"%$"# X"# X'),_('7**) "7+*# "7-'),_('7+*\x8f "7-*\x89 ".2""2233*} ".6""2637*q ".8""2839*e ".:""2:3;*Y ".<""2<3=*M ".>""2>3?*A ".@""2@3A*5 ".B""2B3C*) ".D""2D3E'),_('!7|+k$ \\!.4""2435+-$7|+#%\'"%$"# X"# X,>&!.4""2435+-$7|+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('! \\7~,#&7~"+k$ \\!.2""2233+-$7}+#%\'"%$"# X"# X,>&!.2""2233+-$7}+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_(' \\7~,#&7~"'),_('7+*w "7-*q ".8""2839*e ".:""2:3;*Y ".<""2<3=*M ".>""2>3?*A ".@""2@3A*5 ".B""2B3C*) ".D""2D3E'),_('!7"+\x8d$ \\7"*G "7!*A ".@""2@3A*5 ".F""2F3G*) ".J""2J3K,M&7"*G "7!*A ".@""2@3A*5 ".F""2F3G*) ".J""2J3K"+\'%4"6\xd5" %$"# X"# X'),_('7\x81*# "7\x82'),_('!!7O+3$.:""2:3;+#%\'"%$"# X"# X*# " [+-$7S+#%\'"%$"# X"# X*# " ['),_(' \\7+*\x83 "7-*} ".B""2B3C*q ".D""2D3E*e ".2""2233*Y ".8""2839*M ".:""2:3;*A ".<""2<3=*5 ".>""2>3?*) ".@""2@3A+\x8c$,\x89&7+*\x83 "7-*} ".B""2B3C*q ".D""2D3E*e ".2""2233*Y ".8""2839*M ".:""2:3;*A ".<""2<3=*5 ".>""2>3?*) ".@""2@3A""" X'),_(' \\7y,#&7y"'),_('!/\x95""1#3\xd6+y$.4""2435+i% \\7!+&$,#&7!""" X+P%.J""2J3K+@% \\7!+&$,#&7!""" X+\'%4%6\xd7% %$%# X$$# X$## X$"# X"# X'),_('.\xd8""2\xd83\xd9'),_('.\xda""2\xda3\xdb'),_('.\xdc""2\xdc3\xdd'),_('.\xde""2\xde3\xdf'),_('.\xe0""2\xe03\xe1'),_('.\xe2""2\xe23\xe3'),_('.\xe4""2\xe43\xe5'),_('.\xe6""2\xe63\xe7'),_('.\xe8""2\xe83\xe9'),_('.\xea""2\xea3\xeb'),_('!7\x85*S "7\x86*M "7\x88*G "7\x89*A "7\x8a*; "7\x8b*5 "7\x8c*/ "7\x8d*) "7\x8e*# "76+& 4!6\xec! %'),_("!7\x84+K$7'+A%7\x91+7%7'+-%7\x93+#%'%%$%# X$$# X$## X$\"# X\"# X"),_("!7\x92+' 4!6\xed!! %"),_('!7!+7$7!+-%7!+#%\'#%$## X$"# X"# X'),_('! \\7**A "7+*; "7-*5 "73*/ "74*) "7\'*# "7(,G&7**A "7+*; "7-*5 "73*/ "74*) "7\'*# "7("+& 4!6\xee! %'),_('!7\xb5+_$ \\!7A+-$7\xb5+#%\'"%$"# X"# X,8&!7A+-$7\xb5+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('!79+R$!.:""2:3;+-$79+#%\'"%$"# X"# X*# " [+\'%4"6\xef" %$"# X"# X'),_('!7:*j "!7\x97+_$ \\!7A+-$7\x97+#%\'"%$"# X"# X,8&!7A+-$7\x97+#%\'"%$"# X"# X"+#%\'"%$"# X"# X+& 4!6\xf0! %'),_('!7L*# "7\x98+c$ \\!7B+-$7\x9a+#%\'"%$"# X"# X,8&!7B+-$7\x9a+#%\'"%$"# X"# X"+\'%4"6\xf1" %$"# X"# X'),_('!7\x99*# " [+A$7@+7%7M+-%7?+#%\'$%$$# X$## X$"# X"# X'),_('!!76+_$ \\!7.+-$76+#%\'"%$"# X"# X,8&!7.+-$76+#%\'"%$"# X"# X"+#%\'"%$"# X"# X*# "7H+\' 4!6\xf2!! %'),_('7\x9b*) "7\x9c*# "7\x9f'),_('!/\xf3""1!3\xf4+<$7<+2%7\x9e+(%4#6\xf5#! %$## X$"# X"# X'),_('!/\xf6""1\'3\xf7+<$7<+2%7\x9d+(%4#6\xf8#! %$## X$"# X"# X'),_('! \\7!+&$,#&7!""" X+\' 4!6\xf9!! %'),_('!.\xfa""2\xfa3\xfb+x$!.J""2J3K+S$7!*# " [+C%7!*# " [+3%7!*# " [+#%\'$%$$# X$## X$"# X"# X*# " [+\'%4"6\xfc" %$"# X"# X'),_('!76+N$!7<+-$7\xa0+#%\'"%$"# X"# X*# " [+)%4"6\xfd""! %$"# X"# X'),_('76*) "7T*# "7H'),_('!7\xa2+_$ \\!7B+-$7\xa3+#%\'"%$"# X"# X,8&!7B+-$7\xa3+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('!/\xfe""1&3\xff*G "/\u0100""1\'3\u0101*; "/\u0102""1$3\u0103*/ "/\u0104""1%3\u0105*# "76+& 4!6\u0106! %'),_('7\xa4*# "7\x9f'),_('!/\u0107""1(3\u0108+O$7<+E%/\u0109""1(3\u010a*/ "/\u010b""1(3\u010c*# "76+#%\'#%$## X$"# X"# X'),_('!76+_$ \\!7A+-$76+#%\'"%$"# X"# X,8&!7A+-$76+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('! \\7!+&$,#&7!""" X+\' 4!6\u010d!! %'),_("!7\xa8+& 4!6\u010e! %"),_('!7\xa9+s$7;+i%7\xae+_% \\!7B+-$7\xaf+#%\'"%$"# X"# X,8&!7B+-$7\xaf+#%\'"%$"# X"# X"+#%\'$%$$# X$## X$"# X"# X'),_('7\xaa*# "7\xab'),_('/\u010f""1$3\u0110*S "/\u0111""1%3\u0112*G "/\u0113""1%3\u0114*; "/\u0115""1%3\u0116*/ "/\u0117""1+3\u0118*# "7\xac'),_('/\u0119""1\'3\u011a*/ "/\u011b""1)3\u011c*# "7\xac'),_('76*# "7\xad'),_('!/\u011d""1"3\u011e+-$76+#%\'"%$"# X"# X'),_('7\xac*# "76'),_('!76+7$7<+-%7\xb0+#%\'#%$## X$"# X"# X'),_('76*# "7H'),_('!7\xb2+7$7.+-%7\x8f+#%\'#%$## X$"# X"# X'),_('! \\7!+&$,#&7!""" X+\' 4!6\u011f!! %'),_("!7\x9d+' 4!6\u0120!! %"),_('!7\xb5+d$ \\!7B+-$7\x9f+#%\'"%$"# X"# X,8&!7B+-$7\x9f+#%\'"%$"# X"# X"+(%4"6\u0121"!!%$"# X"# X'),_('!!77+k$ \\!.J""2J3K+-$77+#%\'"%$"# X"# X,>&!.J""2J3K+-$77+#%\'"%$"# X"# X"+#%\'"%$"# X"# X+! (%'),_('!7L*# "7\x98+c$ \\!7B+-$7\xb7+#%\'"%$"# X"# X,8&!7B+-$7\xb7+#%\'"%$"# X"# X"+\'%4"6\u0122" %$"# X"# X'),_('7\xb8*# "7\x9f'),_('!/\u0123""1#3\u0124+<$7<+2%76+(%4#6\u0125#! %$## X$"# X"# X'),_('! \\7!+&$,#&7!""" X+\' 4!6\u0126!! %'),_("!7\x9d+' 4!6\u0127!! %"),_('! \\7\x99,#&7\x99"+\x81$7@+w%7M+m%7?+c% \\!7B+-$7\x9f+#%\'"%$"# X"# X,8&!7B+-$7\x9f+#%\'"%$"# X"# X"+\'%4%6\u0128% %$%# X$$# X$## X$"# X"# X'),_("7\xbd"),_('!/\u0129""1&3\u012a+s$7.+i%7\xc0+_% \\!7A+-$7\xc0+#%\'"%$"# X"# X,8&!7A+-$7\xc0+#%\'"%$"# X"# X"+#%\'$%$$# X$## X$"# X"# X*# "7\xbe'),_('!76+s$7.+i%7\xbf+_% \\!7A+-$7\xbf+#%\'"%$"# X"# X,8&!7A+-$7\xbf+#%\'"%$"# X"# X"+#%\'$%$$# X$## X$"# X"# X'),_('!76+=$7<+3%76*# "7H+#%\'#%$## X$"# X"# X'),_('7\xc1*G "7\xc3*A "7\xc5*; "7\xc7*5 "7\xc8*/ "7\xc9*) "7\xca*# "7\xbf'),_('!/\u012b""1%3\u012c+7$7<+-%7\xc2+#%\'#%$## X$"# X"# X'),_("!7I+' 4!6\u012d!! %"),_('!/\u012e""1&3\u012f+\xa5$7<+\x9b%7D+\x91%7\xc4+\x87% \\! \\7\'+&$,#&7\'""" X+-$7\xc4+#%\'"%$"# X"# X,G&! \\7\'+&$,#&7\'""" X+-$7\xc4+#%\'"%$"# X"# X"+-%7E+#%\'&%$ X$%# X$$# X$## X$"# X"# X'),_('7t*# "7w'),_('!/\u0130""1%3\u0131+7$7<+-%7\xc6+#%\'#%$## X$"# X"# X'),_("!7I+' 4!6\u0132!! %"),_('!/\u0133""1&3\u0134+<$7<+2%7I+(%4#6\u0135#! %$## X$"# X"# X'),_('!/\u0136""1%3\u0137+_$7<+U%!/\u0138""1$3\u0139+& 4!6\u013a! %*4 "!/\u013b""1%3\u013c+& 4!6\u013d! %+#%\'#%$## X$"# X"# X'),_('!/\u013e""1)3\u013f+T$7<+J%/\u0140""1#3\u0141*/ "/\u0142""1(3\u0143*# "76+(%4#6\u0144#! %$## X$"# X"# X'),_('!/\u0145""1#3\u0146+\x9e$7<+\x94%7D+\x8a%!7\xcb+k$ \\!.D""2D3E+-$7\xcb+#%\'"%$"# X"# X,>&!.D""2D3E+-$7\xcb+#%\'"%$"# X"# X"+#%\'"%$"# X"# X+-%7E+#%\'%%$%# X$$# X$## X$"# X"# X'),_('!/\u0147""1(3\u0148*/ "/\u0149""1$3\u014a*# "76+\' 4!6\u014b!! %'),_('!76+_$ \\!7A+-$76+#%\'"%$"# X"# X,8&!7A+-$76+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('!7\xce+K$7.+A%7\xce+7%7.+-%7\x8f+#%\'%%$%# X$$# X$## X$"# X"# X'),_('! \\7!+&$,#&7!""" X+\' 4!6\u014c!! %'),_('!7\xd0+c$ \\!7A+-$7\xd0+#%\'"%$"# X"# X,8&!7A+-$7\xd0+#%\'"%$"# X"# X"+\'%4"6\u014d" %$"# X"# X'),_('!7\x98+c$ \\!7B+-$7\x9f+#%\'"%$"# X"# X,8&!7B+-$7\x9f+#%\'"%$"# X"# X"+\'%4"6\u014e" %$"# X"# X'),_('!7L*T "7\x98*N "!7@*# " [+=$7t+3%7?*# " [+#%\'#%$## X$"# X"# X+c$ \\!7B+-$7\x9f+#%\'"%$"# X"# X,8&!7B+-$7\x9f+#%\'"%$"# X"# X"+\'%4"6\u014f" %$"# X"# X'),_('!7\xd3+c$ \\!7B+-$7\xd4+#%\'"%$"# X"# X,8&!7B+-$7\xd4+#%\'"%$"# X"# X"+\'%4"6\u0150" %$"# X"# X'),_("!7\x95+& 4!6\u0151! %"),_('!/\u0152""1(3\u0153+<$7<+2%76+(%4#6\u0154#! %$## X$"# X"# X*j "!/\u0155""1&3\u0156+<$7<+2%76+(%4#6\u0157#! %$## X$"# X"# X*: "!/\u0158""1*3\u0159+& 4!6\u015a! %*# "7\x9f'),_('!!76+o$ \\!7A+2$76+(%4"6\u015b"! %$"# X"# X,=&!7A+2$76+(%4"6\u015b"! %$"# X"# X"+)%4"6\u015c""! %$"# X"# X*# " [+\' 4!6\u015d!! %'),_('!7\xd7+_$ \\!7A+-$7\xd7+#%\'"%$"# X"# X,8&!7A+-$7\xd7+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('!7\x98+_$ \\!7B+-$7\x9f+#%\'"%$"# X"# X,8&!7B+-$7\x9f+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('! \\7!+&$,#&7!""" X+\' 4!6\u015e!! %'),_('!7\xda+_$ \\!7B+-$7\xdb+#%\'"%$"# X"# X,8&!7B+-$7\xdb+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('!/\u015f""1&3\u0160*; "/\u0161""1\'3\u0162*/ "/\u0163""1*3\u0164*# "76+& 4!6\u0165! %'),_('!/\u0166""1&3\u0167+<$7<+2%7\xdc+(%4#6\u0168#! %$## X$"# X"# X*\x83 "!/\xf6""1\'3\xf7+<$7<+2%7\x9d+(%4#6\u0169#! %$## X$"# X"# X*S "!/\u016a""1+3\u016b+<$7<+2%7\x9d+(%4#6\u016c#! %$## X$"# X"# X*# "7\x9f'),_('/\u016d""1+3\u016e*k "/\u016f""1)3\u0170*_ "/\u0171""1(3\u0172*S "/\u0173""1\'3\u0174*G "/\u0175""1&3\u0176*; "/\u0177""1*3\u0178*/ "/\u0179""1)3\u017a*# "76'),_('71*# " ['),_('!!76+o$ \\!7A+2$76+(%4"6\u015b"! %$"# X"# X,=&!7A+2$76+(%4"6\u015b"! %$"# X"# X"+)%4"6\u015c""! %$"# X"# X*# " [+\' 4!6\u017b!! %'),_('!7L*# "7\x98+c$ \\!7B+-$7\xe0+#%\'"%$"# X"# X,8&!7B+-$7\xe0+#%\'"%$"# X"# X"+\'%4"6\u017c" %$"# X"# X'),_('7\xb8*# "7\x9f'),_('!7\xe2+_$ \\!7A+-$7\xe2+#%\'"%$"# X"# X,8&!7A+-$7\xe2+#%\'"%$"# X"# X"+#%\'"%$"# X"# X'),_('!7\xe9+s$7.+i%7\xec+_% \\!7B+-$7\xe3+#%\'"%$"# X"# X,8&!7B+-$7\xe3+#%\'"%$"# X"# X"+#%\'$%$$# X$## X$"# X"# X'),_('7\xe4*; "7\xe5*5 "7\xe6*/ "7\xe7*) "7\xe8*# "7\x9f'),_('!/\u017d""1#3\u017e+<$7<+2%7\xef+(%4#6\u017f#! %$## X$"# X"# X'),_('!/\u0180""1%3\u0181+<$7<+2%7T+(%4#6\u0182#! %$## X$"# X"# X'),_('!/\u0183""1(3\u0184+B$7<+8%7\\*# "7Y+(%4#6\u0185#! %$## X$"# X"# X'),_('!/\u0186""1&3\u0187+<$7<+2%76+(%4#6\u0188#! %$## X$"# X"# X'),_('!/\u0189""1%3\u018a+T$!7<+5$ \\7!,#&7!"+#%\'"%$"# X"# X*# " [+\'%4"6\u018b" %$"# X"# X'),_('!7\xea+K$7;+A%76+7%7;+-%7\xeb+#%\'%%$%# X$$# X$## X$"# X"# X'),_('!/\x95""1#3\xd6*# "76+\' 4!6\u018c!! %'),_('!/\xb4""1#3\u018d*G "/\xb6""1#3\u018e*; "/\xba""1#3\u018f*/ "/\xb8""1$3\u0190*# "76+\' 4!6\u0191!! %'),_('!7\xed+H$!7C+-$7\xee+#%\'"%$"# X"# X*# " [+#%\'"%$"# X"# X'),_('!7U*) "7\\*# "7X+& 4!6\u0192! %'),_('!!7!*# " [+c$7!*# " [+S%7!*# " [+C%7!*# " [+3%7!*# " [+#%\'%%$%# X$$# X$## X$"# X"# X+\' 4!6\u0193!! %'),_('!!7!+C$7!*# " [+3%7!*# " [+#%\'#%$## X$"# X"# X+\' 4!6\u0194!! %'),_("7\xbd"),_('!7\x9d+d$ \\!7B+-$7\xf2+#%\'"%$"# X"# X,8&!7B+-$7\xf2+#%\'"%$"# X"# X"+(%4"6\u0195"!!%$"# X"# X'),_('7\xf3*# "7\x9f'),_('!.\u0196""2\u01963\u0197+N$7<+D%.\u0198""2\u01983\u0199*) ".\u019a""2\u019a3\u019b+(%4#6\u019c#! %$## X$"# X"# X'),_('!7\x9d+d$ \\!7B+-$7\x9f+#%\'"%$"# X"# X,8&!7B+-$7\x9f+#%\'"%$"# X"# X"+(%4"6\u019d"!!%$"# X"# X'),_('!76+7$70+-%7\xf6+#%\'#%$## X$"# X"# X'),_(' \\72*) "74*# "7.,/&72*) "74*# "7."'),_(' \\7%,#&7%"'),_('!7\xf9+=$.8""2839+-%7\xfa+#%\'#%$## X$"# X"# X'),_('!/\u019e""1%3\u019f*) "/\u01a0""1$3\u01a1+\' 4!6\u01a2!! %'),_('!7\xfb+N$!.8""2839+-$7^+#%\'"%$"# X"# X*# " [+#%\'"%$"# X"# X'),_('!7\\*) "7X*# "7\x82+\' 4!6\u01a3!! %'),_('! \\7\xfd*) "7-*# "7\xfe,/&7\xfd*) "7-*# "7\xfe"+! (%'),_('7"*S "7!*M ".F""2F3G*A ".J""2J3K*5 ".H""2H3I*) ".N""2N3O'),_('.L""2L3M*\x95 ".B""2B3C*\x89 ".<""2<3=*} ".R""2R3S*q ".T""2T3U*e ".V""2V3W*Y ".P""2P3Q*M ".@""2@3A*A ".D""2D3E*5 ".2""2233*) ".>""2>3?'),_('!7\u0100+h$.8""2839+X%7\xfa+N%!.\u01a4""2\u01a43\u01a5+-$7\xeb+#%\'"%$"# X"# X*# " [+#%\'$%$$# X$## X$"# X"# X'),_('!/\u01a6""1%3\u01a7*) "/\u01a8""1$3\u01a9+\' 4!6\u01a2!! %'),_('!7\xeb+Q$/\xb4""1#3\xb5*7 "/\xb6""1#3\xb7*+ " \\7+,#&7+"+\'%4"6\u01aa" %$"# X"# X'),_('!7\u0104+\x8f$.F""2F3G+\x7f%7\u0103+u%.F""2F3G+e%7\u0103+[%.F""2F3G+K%7\u0103+A%.F""2F3G+1%7\u0105+\'%4)6\u01ab) %$)# X$(# X$\'# X$ X$%# X$$# X$## X$"# X"# X'),_('!7#+A$7#+7%7#+-%7#+#%\'$%$$# X$## X$"# X"# X'),_('!7\u0103+-$7\u0103+#%\'"%$"# X"# X'),_('!7\u0103+7$7\u0103+-%7\u0103+#%\'#%$## X$"# X"# X')],u=0,l=0,f=0,h={line:1,column:1,seenCR:!1},p=0,d=[],v=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');a=o[r.startRule]}function m(){return t.substring(l,u)}function g(){return l}function y(e){up&&(p=u,d=[]),d.push(e))}function _(e){var t,n=new Array(e.length);for(t=0;tu?(d=h+3+f[h+1],h+=3):(d=h+3+f[h+1]+f[h+2],h+=3+f[h+1]);break;case 14:m.push(d),p.push(h+4+f[h+2]+f[h+3]),t.substr(u,c[f[h+1]].length)===c[f[h+1]]?(d=h+4+f[h+2],h+=4):(d=h+4+f[h+2]+f[h+3],h+=4+f[h+2]);break;case 15:m.push(d),p.push(h+4+f[h+2]+f[h+3]),t.substr(u,c[f[h+1]].length).toLowerCase()===c[f[h+1]]?(d=h+4+f[h+2],h+=4):(d=h+4+f[h+2]+f[h+3],h+=4+f[h+2]);break;case 16:m.push(d),p.push(h+4+f[h+2]+f[h+3]),c[f[h+1]].test(t.charAt(u))?(d=h+4+f[h+2],h+=4):(d=h+4+f[h+2]+f[h+3],h+=4+f[h+2]);break;case 17:g.push(t.substr(u,f[h+1])),u+=f[h+1],h+=2;break;case 18:g.push(c[f[h+1]]),u+=c[f[h+1]].length,h+=2;break;case 19:g.push(i),0===v&&y(c[f[h+1]]),h+=2;break;case 20:l=g[g.length-1-f[h+1]],h+=2;break;case 21:l=u,h++;break;case 22:for(r=f.slice(h+4,h+4+f[h+3]),o=0;o0))break;d=m.pop(),h=p.pop()}return g[0]}(a))!==i&&u===t.length)return n;throw n!==i&&ue&&(f=0,h={line:1,column:1,seenCR:!1}),function(e,n,r){var i,o;for(i=f;it.description?1:0});t1?r.slice(0,-1).join(", ")+" or "+r[e.length-1]:r[0])+" but "+(t?'"'+function(e){function t(e){return e.charCodeAt(0).toString(16).toUpperCase()}return e.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\x0F]/g,function(e){return"\\x0"+t(e)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(e){return"\\x"+t(e)}).replace(/[\u0180-\u0FFF]/g,function(e){return"\\u0"+t(e)}).replace(/[\u1080-\uFFFF]/g,function(e){return"\\u"+t(e)})}(t)+'"':"end of input")+" found."}(r,a),r,a,i,o.line,o.column)}(null,d,p)}}}()},function(e,t,n){"use strict";var r=n(133);e.exports=function(e){return{parse:function(t,n){var i={startRule:n,SIP:e};try{r.parse(t,i)}catch(e){i.data=-1}return i.data}}}},function(e,t,n){"use strict";e.exports=function(e){var t;return(t=function(e){this.logger=e.getLogger("sipjs.digestauthentication"),this.username=e.configuration.authorizationUser,this.password=e.configuration.password,this.cnonce=null,this.nc=0,this.ncHex="00000000",this.response=null}).prototype.authenticate=function(t,n){if(this.algorithm=n.algorithm,this.realm=n.realm,this.nonce=n.nonce,this.opaque=n.opaque,this.stale=n.stale,this.algorithm){if("MD5"!==this.algorithm)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(n.qop)if(n.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(n.qop.indexOf("auth-int")>-1))return this.logger.warn('challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this.qop="auth-int"}else this.qop=null;return this.method=t.method,this.uri=t.ruri,this.cnonce=e.createRandomToken(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(),!0},t.prototype.calculateResponse=function(){var t,n;t=e.calculateMD5(this.username+":"+this.realm+":"+this.password),"auth"===this.qop?(n=e.calculateMD5(this.method+":"+this.uri),this.response=e.calculateMD5(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+n)):"auth-int"===this.qop?(n=e.calculateMD5(this.method+":"+this.uri+":"+e.calculateMD5(this.body?this.body:"")),this.response=e.calculateMD5(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+n)):null===this.qop&&(n=e.calculateMD5(this.method+":"+this.uri),this.response=e.calculateMD5(t+":"+this.nonce+":"+n))},t.prototype.toString=function(){var 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(", ")},t.prototype.updateNcHex=function(){var e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e},t}},function(e,t,n){"use strict";e.exports=function(e){var t,n=[],r=[],i=[];function o(t,n,r){for(var i,o=e.Utils.buildStatusLine(t),a=n.getHeaders("via"),c=a.length,s=0;s1)return t.getLogger("sip.sanitycheck").warn("More than one Via header field present in the response. Dropping the response"),!1}),r.push(function(t,n){if(e.Utils.str_utf8_length(t.body)e.indexOf("m=")){n=e.match(/m=.*\r\n.*/g);for(var r=0;r=0?(t=e.indexOf(n[r].toString())+n[r].toString().length,"c="!==e.substr(t,2)&&(e=e.substr(0,t)+"\r\nc=IN IP4 0.0.0.0"+e.substr(t))):n[r].toString().search(/c=.*/)<0&&(t=e.indexOf(n[r].toString().match(/.*/))+n[r].toString().match(/.*/).toString().length,e=e.substr(0,t)+"\r\nc=IN IP4 0.0.0.0"+e.substr(t))}return e}},Chrome:{needsExplicitlyInactiveSDP:function(e){var n,r;return t.Firefox.isFirefox()&&-1!==(r=e.indexOf("m=video 0"))?(n=(n=e.substr(r)).replace(/\r\nc=IN IP4.*\r\n$/,"\r\nc=IN IP4 0.0.0.0\r\na=inactive\r\n"),e.substr(0,r)+n):e},getsConfusedAboutGUM:function(e){e.mediaHandler&&e.mediaHandler.close()}}};return t}},function(e,t,n){"use strict";(function(t){e.exports=function(e,n){var r,i={STATUS_INIT:0,STATUS_STARTING:1,STATUS_READY:2,STATUS_USER_CLOSED:3,STATUS_NOT_READY:4,CONFIGURATION_ERROR:1,NETWORK_ERROR:2,ALLOWED_METHODS:["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"],ACCEPTED_BODY_TYPES:["application/sdp","application/dtmf-relay"],MAX_FORWARDS:70,TAG_LENGTH:10};function o(t){if(t instanceof Function)return t.initialize||(t.initialize=function(){return e.Utils.Promise.resolve()}),t}((r=function(r){var o=this;function a(e){return o.emit.bind(o,e)}i.ACCEPTED_BODY_TYPES=i.ACCEPTED_BODY_TYPES.toString(),this.log=new e.LoggerFactory,this.logger=this.getLogger("sip.ua"),this.cache={credentials:{}},this.configuration={},this.dialogs={},this.applicants={},this.data={},this.sessions={},this.subscriptions={},this.transport=null,this.contact=null,this.status=i.STATUS_INIT,this.error=null,this.transactions={nist:{},nict:{},ist:{},ict:{}},this.transportRecoverAttempts=0,this.transportRecoveryTimer=null,Object.defineProperties(this,{transactionsCount:{get:function(){var e,t=["nist","nict","ist","ict"],n=0;for(e in t)n+=Object.keys(this.transactions[t[e]]).length;return n}},nictTransactionsCount:{get:function(){return Object.keys(this.transactions.nict).length}},nistTransactionsCount:{get:function(){return Object.keys(this.transactions.nist).length}},ictTransactionsCount:{get:function(){return Object.keys(this.transactions.ict).length}},istTransactionsCount:{get:function(){return Object.keys(this.transactions.ist).length}}}),void 0===r?r={}:("string"==typeof r||r instanceof String)&&(r={uri:r}),r.log&&(r.log.hasOwnProperty("builtinEnabled")&&(this.log.builtinEnabled=r.log.builtinEnabled),r.log.hasOwnProperty("level")&&(this.log.level=r.log.level),r.log.hasOwnProperty("connector")&&(this.log.connector=r.log.connector));try{this.loadConfig(r)}catch(e){throw this.status=i.STATUS_NOT_READY,this.error=i.CONFIGURATION_ERROR,e}this.registerContext=new e.RegisterContext(this),this.registerContext.on("failed",a("registrationFailed")),this.registerContext.on("registered",a("registered")),this.registerContext.on("unregistered",a("unregistered")),this.configuration.autostart&&this.start(),"function"==typeof n.addEventListener&&(t.chrome&&t.chrome.app&&t.chrome.app.runtime||n.addEventListener("unload",this.stop.bind(this)))}).prototype=Object.create(e.EventEmitter.prototype)).register=function(e){return this.configuration.register=!0,this.registerContext.register(e),this},r.prototype.unregister=function(e){this.configuration.register=!1;var t=this.registerContext;return this.afterConnected(t.unregister.bind(t,e)),this},r.prototype.isRegistered=function(){return this.registerContext.registered},r.prototype.isConnected=function(){return!!this.transport&&this.transport.connected},r.prototype.afterConnected=function(e){this.isConnected()?e():this.once("connected",e)},r.prototype.invite=function(t,n){var r=new e.InviteClientContext(this,t,n);return this.afterConnected(r.invite.bind(r)),r},r.prototype.subscribe=function(t,n,r){var i=new e.Subscription(this,t,n,r);return this.afterConnected(i.subscribe.bind(i)),i},r.prototype.message=function(t,n,r){if(void 0===n)throw new TypeError("Not enough arguments");return(r=Object.create(r||Object.prototype)).contentType||(r.contentType="text/plain"),r.body=n,this.request(e.C.MESSAGE,t,r)},r.prototype.request=function(t,n,r){var i=new e.ClientContext(this,t,n,r);return this.afterConnected(i.send.bind(i)),i},r.prototype.stop=function(){var t,n,r,o=this;if(this.logger.log("user requested closure..."),this.status===i.STATUS_USER_CLOSED)return this.logger.warn("UA already closed"),this;for(t in e.Timers.clearTimeout(this.transportRecoveryTimer),this.logger.log("closing registerContext"),this.registerContext.close(),this.sessions)this.logger.log("closing session "+t),this.sessions[t].terminate();for(n in this.subscriptions)this.logger.log("unsubscribing from subscription "+n),this.subscriptions[n].close();for(r in this.applicants)this.applicants[r].close();return this.status=i.STATUS_USER_CLOSED,0===this.nistTransactionsCount&&0===this.nictTransactionsCount?this.transport&&this.transport.disconnect():this.on("transactionDestroyed",function e(){0===o.nistTransactionsCount&&0===o.nictTransactionsCount&&(o.removeListener("transactionDestroyed",e),o.transport.disconnect())}),this},r.prototype.start=function(){var t;return this.logger.log("user requested startup..."),this.status===i.STATUS_INIT?(t=this.getNextWsServer(),this.status=i.STATUS_STARTING,new e.Transport(this,t)):this.status===i.STATUS_USER_CLOSED?(this.logger.log("resuming"),this.status=i.STATUS_READY,this.transport.connect()):this.status===i.STATUS_STARTING?this.logger.log("UA is in STARTING status, not opening new connection"):this.status===i.STATUS_READY?this.logger.log("UA is in READY status, not resuming"):this.logger.error("Connection is down. Auto-Recovery system is trying to connect"),this},r.prototype.normalizeTarget=function(t){return e.Utils.normalizeTarget(t,this.configuration.hostportParams)},r.prototype.saveCredentials=function(e){return this.cache.credentials[e.realm]=this.cache.credentials[e.realm]||{},this.cache.credentials[e.realm][e.uri]=e,this},r.prototype.getCredentials=function(e){var t,n;return t=e.ruri.host,this.cache.credentials[t]&&this.cache.credentials[t][e.ruri]&&((n=this.cache.credentials[t][e.ruri]).method=e.method),n},r.prototype.getLogger=function(e,t){return this.log.getLogger(e,t)},r.prototype.onTransportClosed=function(t){var n,r,i,o=["nict","ict","nist","ist"];for(t.server.status=e.Transport.C.STATUS_DISCONNECTED,this.logger.log("connection state set to "+e.Transport.C.STATUS_DISCONNECTED),i=o.length,n=0;n0?(t.reply(200,null),u.emit("notify",{request:t})):t.reply(481,"Subscription does not exist");break;default:t.reply(405)}}else t.reply_sl(416)},r.prototype.findSession=function(e){return this.sessions[e.call_id+e.from_tag]||this.sessions[e.call_id+e.to_tag]||null},r.prototype.findDialog=function(e){return this.dialogs[e.call_id+e.from_tag+e.to_tag]||this.dialogs[e.call_id+e.to_tag+e.from_tag]||null},r.prototype.getNextWsServer=function(){var t,n,r,i=[];for(n=this.configuration.wsServers.length,t=0;ti[0].weight?i=[r]:r.weight===i[0].weight&&i.push(r));return i[t=Math.floor(Math.random()*i.length)]},r.prototype.closeSessionsOnTransportError=function(){var e;for(e in this.sessions)this.sessions[e].onTransportError();this.registerContext.onTransportClosed()},r.prototype.recoverTransport=function(t){var n,r,i,o,a;for(o=(t=t||this).transportRecoverAttempts,r=t.configuration.wsServers.length,n=0;nt.configuration.connectionRecoveryMaxInterval&&(this.logger.log("time for next connection attempt exceeds connectionRecoveryMaxInterval, resetting counter"),i=t.configuration.connectionRecoveryMinInterval,o=0),this.logger.log("next connection attempt in "+i+" seconds"),this.transportRecoveryTimer=e.Timers.setTimeout(function(){t.transportRecoverAttempts=o+1,new e.Transport(t,a)},1e3*i)},r.prototype.loadConfig=function(t){var n,i,a,c,s,u={viaHost:e.Utils.createRandomToken(12)+".invalid",uri:new e.URI("sip","anonymous."+e.Utils.createRandomToken(6),"anonymous.invalid",null,null),wsServers:[{scheme:"WSS",sip_uri:"",status:0,weight:0,ws_uri:"wss://edge.sip.onsip.com"}],password:null,registerExpires:600,register:!0,registrarServer:null,wsServerMaxReconnection:3,wsServerReconnectionTimeout:4,connectionRecoveryMinInterval:2,connectionRecoveryMaxInterval:30,keepAliveInterval:0,extraSupported:[],usePreloadedRoute:!1,userAgentString:e.C.USER_AGENT,iceCheckingTimeout:5e3,noAnswerTimeout:60,stunServers:["stun:stun.l.google.com:19302"],turnServers:[],traceSip:!1,hackViaTcp:!1,hackIpInContact:!1,hackWssInTransport:!1,hackAllowUnregisteredOptionTags:!1,hackCleanJitsiSdpImageattr:!1,hackStripTcp:!1,contactTransport:"ws",forceRport:!1,autostart:!0,rel100:e.C.supported.UNSUPPORTED,replaces:e.C.supported.UNSUPPORTED,mediaHandlerFactory:e.WebRTC.MediaHandler.defaultFactory,authenticationFactory:o(function(t){return new e.DigestAuthentication(t)}),allowLegacyNotifications:!1};function l(e,n){var r=e.replace(/([a-z][A-Z])/g,function(e){return e[0]+"_"+e[1].toLowerCase()});if(e!==r){var i=t.hasOwnProperty(e);t.hasOwnProperty(r)&&(n.warn(r+" is deprecated, please use "+e),i&&n.warn(e+" overriding "+r)),t[e]=i?t[e]:t[r]}}for(n in r.configuration_check.mandatory){if(l(n,this.logger),!t.hasOwnProperty(n))throw new e.Exceptions.ConfigurationError(n);if(i=t[n],void 0===(a=r.configuration_check.mandatory[n](i)))throw new e.Exceptions.ConfigurationError(n,i);u[n]=a}e.Utils.optionsOverride(t,"rel100","reliable",!0,this.logger,e.C.supported.UNSUPPORTED);var f=["stunServers","turnServers"];for(n in r.configuration_check.optional)if(l(n,this.logger),t.hasOwnProperty(n)){if((i=t[n])instanceof Array&&0===i.length&&f.indexOf(n)<0)continue;if(null===i||""===i||void 0===i)continue;if("number"==typeof i&&isNaN(i))continue;if(void 0===(a=r.configuration_check.optional[n](i)))throw new e.Exceptions.ConfigurationError(n,i);u[n]=a}if(u.connectionRecoveryMaxInterval"}},e.Utils.optionsOverride(u,"media","mediaConstraints",!0,this.logger),u)r.configuration_skeleton[n].value=u[n];for(n in Object.defineProperties(this.configuration,r.configuration_skeleton),u)r.configuration_skeleton[n].value="";for(n in this.logger.log("configuration parameters after validation:"),u)switch(n){case"uri":case"registrarServer":case"mediaHandlerFactory":this.logger.log("\xb7 "+n+": "+u[n]);break;case"password":this.logger.log("\xb7 "+n+": NOT SHOWN");break;default:this.logger.log("\xb7 "+n+": "+JSON.stringify(u[n]))}},r.configuration_skeleton=function(){var e,t={},n=["sipjsId","hostportParams","uri","wsServers","authorizationUser","connectionRecoveryMaxInterval","connectionRecoveryMinInterval","keepAliveInterval","extraSupported","displayName","hackViaTcp","hackIpInContact","hackWssInTransport","hackAllowUnregisteredOptionTags","hackCleanJitsiSdpImageattr","hackStripTcp","contactTransport","forceRport","iceCheckingTimeout","instanceId","noAnswerTimeout","password","registerExpires","registrarServer","reliable","rel100","replaces","userAgentString","autostart","stunServers","traceSip","turnServers","usePreloadedRoute","wsServerMaxReconnection","wsServerReconnectionTimeout","mediaHandlerFactory","media","mediaConstraints","authenticationFactory","allowLegacyNotifications","via_core_value","viaHost"];for(e in n)t[n[e]]={value:"",writable:!1,configurable:!1};return t.register={value:"",writable:!0,configurable:!1},t}(),r.configuration_check={mandatory:{},optional:{uri:function(t){var n;return/^sip:/i.test(t)||(t=e.C.SIP+":"+t),(n=e.URI.parse(t))&&n.user?n:void 0},wsServers:function(t){var n,r,i;if("string"==typeof t)t=[{ws_uri:t}];else{if(!(t instanceof Array))return;for(r=t.length,n=0;n",t[n].weight||(t[n].weight=0),t[n].status=0,t[n].scheme=i.scheme.toUpperCase()}return t},authorizationUser:function(t){return-1===e.Grammar.parse('"'+t+'"',"quoted_string")?void 0:t},connectionRecoveryMaxInterval:function(t){var n;if(e.Utils.isDecimal(t)&&(n=Number(t))>0)return n},connectionRecoveryMinInterval:function(t){var n;if(e.Utils.isDecimal(t)&&(n=Number(t))>0)return n},displayName:function(t){return-1===e.Grammar.parse('"'+t+'"',"displayName")?void 0:t},hackViaTcp:function(e){if("boolean"==typeof e)return e},hackIpInContact:function(t){return"boolean"==typeof t?t:"string"==typeof t&&-1!==e.Grammar.parse(t,"host")?t:void 0},iceCheckingTimeout:function(t){if(e.Utils.isDecimal(t))return Math.max(500,t)},hackWssInTransport:function(e){if("boolean"==typeof e)return e},hackAllowUnregisteredOptionTags:function(e){if("boolean"==typeof e)return e},hackCleanJitsiSdpImageattr:function(e){if("boolean"==typeof e)return e},hackStripTcp:function(e){if("boolean"==typeof e)return e},contactTransport:function(e){if("string"==typeof e)return e},forceRport:function(e){if("boolean"==typeof e)return e},instanceId:function(t){if("string"==typeof t)return/^uuid:/i.test(t)&&(t=t.substr(5)),-1===e.Grammar.parse(t,"uuid")?void 0:t},keepAliveInterval:function(t){var n;if(e.Utils.isDecimal(t)&&(n=Number(t))>0)return n},extraSupported:function(e){var t,n;if(e instanceof Array){for(n=e.length,t=0;t0)return n},password:function(e){return String(e)},rel100:function(t){return t===e.C.supported.REQUIRED?e.C.supported.REQUIRED:t===e.C.supported.SUPPORTED?e.C.supported.SUPPORTED:e.C.supported.UNSUPPORTED},replaces:function(t){return t===e.C.supported.REQUIRED?e.C.supported.REQUIRED:t===e.C.supported.SUPPORTED?e.C.supported.SUPPORTED:e.C.supported.UNSUPPORTED},register:function(e){if("boolean"==typeof e)return e},registerExpires:function(t){var n;if(e.Utils.isDecimal(t)&&(n=Number(t))>0)return n},registrarServer:function(t){var n;if("string"==typeof t)return/^sip:/i.test(t)||(t=e.C.SIP+":"+t),(n=e.URI.parse(t))?n.user?void 0:n:void 0},stunServers:function(t){var n,r,i;if("string"==typeof t)t=[t];else if(!(t instanceof Array))return;for(r=t.length,n=0;n0)return n},wsServerReconnectionTimeout:function(t){var n;if(e.Utils.isDecimal(t)&&(n=Number(t))>0)return n},autostart:function(e){if("boolean"==typeof e)return e},mediaHandlerFactory:function(t){if(t instanceof Function){var n=function(){var n=t.apply(this,arguments);function r(t){if(n[t].length>1){var r="getDescription"===t;n[t]=e.Utils.promisify(n,t,r)}}return r("getDescription"),r("setDescription"),n};return n.isSupported=t.isSupported,n}},authenticationFactory:o,allowLegacyNotifications:function(e){if("boolean"==typeof e)return e}}},r.C=i,e.UA=r}}).call(this,n(3))},function(e,t,n){"use strict";e.exports=function(e,t){var n=function(t,n){if(!e.WebRTC.isSupported())throw new e.Exceptions.NotSupportedError("Media not supported");this.mediaHint=n||{constraints:{audio:!0,video:!0}},this.acquisitions={}};return n.streamId=function(e){return e.getAudioTracks().concat(e.getVideoTracks()).map(function(e){return e.id}).join("")},n.render=function(n,r){if(!r)return!1;if(Array.isArray(r)&&!r.length)throw new TypeError("elements must not be empty");r=[].concat(r),[].concat(n).forEach(function(n,r,i){var o,a=n[i%n.length];"function"==typeof a&&(a=a()),(t.attachMediaStream||function(e,t){e.srcObject=t})(a,r),(o=a).ensurePlayingIntervalId=e.Timers.setInterval(function(){o.paused&&o.srcObject?o.play():e.Timers.clearInterval(o.ensurePlayingIntervalId)},100)}.bind(null,r))},n.prototype=Object.create(e.EventEmitter.prototype,{acquire:{writable:!0,value:function(t){t=Object.keys(t||{}).length?t:this.mediaHint;var r=function(t,r){return(r=[].concat(r)).forEach(function(e){var r=n.streamId(e);this.acquisitions[r]=!!t},this),e.Utils.Promise.resolve(r)}.bind(this);if(t.stream)return r(!0,t.stream);var i=t.constraints||this.mediaHint&&this.mediaHint.constraints||{audio:!0,video:!0},o=e.Utils.defer();return e.Timers.setTimeout(function(){this.emit("userMediaRequest",i);var t=function(e,t){var n=Array.prototype.slice.call(arguments,2),r=[e].concat(n);return this.emit.apply(this,r),t.apply(null,n)}.bind(this);i.audio||i.video?o.resolve(e.WebRTC.getUserMedia(i).then(t.bind(this,"userMedia",r.bind(null,!1)),t.bind(this,"userMediaFailed",function(e){throw e}))):o.resolve([])}.bind(this),0),o.promise}},release:{writable:!0,value:function(e){(e=[].concat(e)).forEach(function(e){var t=n.streamId(e);!1===this.acquisitions[t]&&e.getTracks().forEach(function(e){e.stop()}),delete this.acquisitions[t]},this)}}}),n}},function(e,t,n){"use strict";e.exports=function(e){var t=function(t,n){n=n||{},this.logger=t.ua.getLogger("sip.invitecontext.mediahandler",t.id),this.session=t,this.localMedia=null,this.ready=!0,this.mediaStreamManager=n.mediaStreamManager||new e.WebRTC.MediaStreamManager(this.logger),this.audioMuted=!1,this.videoMuted=!1,this.local_hold=!1,this.remote_hold=!1;var r=this.prepareIceServers(n.stunServers,n.turnServers);function i(e,t){e.mediaStreamManager.on&&e.mediaStreamManager.on(t,function(){e.emit.apply(e,[t].concat(Array.prototype.slice.call(arguments)))})}this.RTCConstraints=n.RTCConstraints||{},this.initPeerConnection(r),i(this,"userMediaRequest"),i(this,"userMedia"),i(this,"userMediaFailed")};return(t.defaultFactory=function(e,n){return new t(e,n)}).isSupported=function(){return e.WebRTC.isSupported()},t.prototype=Object.create(e.MediaHandler.prototype,{isReady:{writable:!0,value:function(){return this.ready}},close:{writable:!0,value:function(){this.logger.log("closing PeerConnection"),this._remoteStreams=[],this.peerConnection&&"closed"!==this.peerConnection.signalingState&&(this.peerConnection.close(),this.localMedia&&this.mediaStreamManager.release(this.localMedia))}},getDescription:{writable:!0,value:function(t){var n,r=this,i=r.mediaStreamManager.acquire;return i.length>1&&(i=e.Utils.promisify(this.mediaStreamManager,"acquire",!0)),!0===(t=t||{}).dataChannel&&(t.dataChannel={}),this.mediaHint=t,r.localMedia?(r.logger.log("already have local media"),n=e.Utils.Promise.resolve(r.localMedia)):(r.logger.log("acquiring local media"),n=i.call(r.mediaStreamManager,t).then(function(e){return r.logger.log("acquired local media streams"),r.localMedia=e,r.session.connecting(),e},function(e){throw r.logger.error("unable to acquire streams"),r.logger.error(e),r.session.connecting(),e}).then(this.addStreams.bind(this))),n.then(function(){return r.hasOffer("remote")?r.peerConnection.ondatachannel=function(e){r.dataChannel=e.channel,r.emit("dataChannel",r.dataChannel)}:t.dataChannel&&r.peerConnection.createDataChannel&&(r.dataChannel=r.peerConnection.createDataChannel("sipjs",t.dataChannel),r.emit("dataChannel",r.dataChannel)),r.render(),r.createOfferOrAnswer(r.RTCConstraints)}).then(function(t){return t=e.Hacks.Firefox.hasMissingCLineInSDP(t),r.local_hold&&(t=/a=(sendrecv|sendonly|recvonly|inactive)/.test(t)?(t=t.replace(/a=sendrecv\r\n/g,"a=sendonly\r\n")).replace(/a=recvonly\r\n/g,"a=inactive\r\n"):t.replace(/(m=[^\r]*\r\n)/g,"$1a=sendonly\r\n")),{body:t,contentType:"application/sdp"}})}},hasDescription:{writeable:!0,value:function(e){return"application/sdp"===e.getHeader("Content-Type")&&!!e.body}},setDescription:{writable:!0,value:function(t){var n=t.body;this.remote_hold=/a=(sendonly|inactive)/.test(n),n=e.Hacks.Firefox.cannotHandleExtraWhitespace(n),n=e.Hacks.AllBrowsers.maskDtls(n);var r={type:this.hasOffer("local")?"answer":"offer",sdp:n};this.emit("setDescription",r);var i=new e.WebRTC.RTCSessionDescription(r);return e.Utils.promisify(this.peerConnection,"setRemoteDescription")(i)}},getReferMedia:{writable:!0,value:function(){function e(e,t){return t[e]().length>0}function t(t){return this.getLocalStreams().some(e.bind(null,t))&&this.getRemoteStreams().some(e.bind(null,t))}return{constraints:{audio:t.call(this,"getAudioTracks"),video:t.call(this,"getVideoTracks")}}}},updateIceServers:{writeable:!0,value:function(e){var t=this.prepareIceServers(e.stunServers,e.turnServers);this.RTCConstraints=e.RTCConstraints||this.RTCConstraints,this.initPeerConnection(t)}},isMuted:{writable:!0,value:function(){return{audio:this.audioMuted,video:this.videoMuted}}},mute:{writable:!0,value:function(e){if(0!==this.getLocalStreams().length){var t=!1,n=!1;return(e=e||{audio:this.getLocalStreams()[0].getAudioTracks().length>0,video:this.getLocalStreams()[0].getVideoTracks().length>0}).audio&&!this.audioMuted&&(t=!0,this.audioMuted=!0,this.toggleMuteAudio(!0)),e.video&&!this.videoMuted&&(n=!0,this.videoMuted=!0,this.toggleMuteVideo(!0)),t||n?{audio:t,video:n}:void 0}}},unmute:{writable:!0,value:function(e){if(0!==this.getLocalStreams().length){var t=!1,n=!1;return(e=e||{audio:this.getLocalStreams()[0].getAudioTracks().length>0,video:this.getLocalStreams()[0].getVideoTracks().length>0}).audio&&this.audioMuted&&(t=!0,this.audioMuted=!1,this.toggleMuteAudio(!1)),e.video&&this.videoMuted&&(n=!0,this.videoMuted=!1,this.toggleMuteVideo(!1)),t||n?{audio:t,video:n}:void 0}}},hold:{writable:!0,value:function(){this.local_hold=!0,this.toggleMuteAudio(!0),this.toggleMuteVideo(!0)}},unhold:{writable:!0,value:function(){this.local_hold=!1,this.audioMuted||this.toggleMuteAudio(!1),this.videoMuted||this.toggleMuteVideo(!1)}},getLocalStreams:{writable:!0,value:function(){var e=this.peerConnection;return e&&"closed"===e.signalingState?(this.logger.warn("peerConnection is closed, getLocalStreams returning []"),[]):e.getLocalStreams&&e.getLocalStreams()||e.localStreams||[]}},getRemoteStreams:{writable:!0,value:function(){var e=this.peerConnection;return e&&"closed"===e.signalingState?(this.logger.warn("peerConnection is closed, getRemoteStreams returning this._remoteStreams"),this._remoteStreams):e.getRemoteStreams&&e.getRemoteStreams()||e.remoteStreams||[]}},render:{writable:!0,value:function(t){if(!(t=t||this.mediaHint&&this.mediaHint.render))return!1;var n={local:"getLocalStreams",remote:"getRemoteStreams"};Object.keys(n).forEach(function(r){var i=this[n[r]]();e.WebRTC.MediaStreamManager.render(i,t[r])}.bind(this))}},hasOffer:{writable:!0,value:function(e){var t="have-"+e+"-offer";return this.peerConnection.signalingState===t}},prepareIceServers:{writable:!0,value:function(e,t){var n=[],r=this.session.ua.configuration;return e=e||r.stunServers,t=t||r.turnServers,[].concat(e).forEach(function(e){n.push({urls:e})}),[].concat(t).forEach(function(e){n.push({urls:e.urls,username:e.username,credential:e.password})}),n}},initPeerConnection:{writable:!0,value:function(t){var n=this,r=this.session.ua.configuration;this.onIceCompleted=e.Utils.defer(),this.onIceCompleted.promise.then(function(t){n.emit("iceGatheringComplete",t),n.iceCheckingTimer&&(e.Timers.clearTimeout(n.iceCheckingTimer),n.iceCheckingTimer=null)}),this.peerConnection&&this.peerConnection.close(),this.peerConnection=new e.WebRTC.RTCPeerConnection({iceServers:t}),this._remoteStreams=[],this.peerConnection.onaddstream=function(e){n.logger.log("stream added: "+e.stream.id),n._remoteStreams.push(e.stream),n.render(),n.emit("addStream",e)},this.peerConnection.onremovestream=function(e){n.logger.log("stream removed: "+e.stream.id)},this.startIceCheckingTimer=function(){n.iceCheckingTimer||(n.iceCheckingTimer=e.Timers.setTimeout(function(){n.logger.log("RTCIceChecking Timeout Triggered after "+r.iceCheckingTimeout+" milliseconds"),n.onIceCompleted.resolve(this)}.bind(this.peerConnection),r.iceCheckingTimeout))},this.peerConnection.onicecandidate=function(e){n.emit("iceCandidate",e),e.candidate?(n.logger.log("ICE candidate received: "+(null===e.candidate.candidate?null:e.candidate.candidate.trim())),n.startIceCheckingTimer()):n.onIceCompleted.resolve(this)},this.peerConnection.onicegatheringstatechange=function(){n.logger.log("RTCIceGatheringState changed: "+this.iceGatheringState),"gathering"===this.iceGatheringState&&n.emit("iceGathering",this),"complete"===this.iceGatheringState&&n.onIceCompleted.resolve(this)},this.peerConnection.oniceconnectionstatechange=function(){var e;switch("checking"===this.iceConnectionState&&n.startIceCheckingTimer(),this.iceConnectionState){case"new":e="iceConnection";break;case"checking":e="iceConnectionChecking";break;case"connected":e="iceConnectionConnected";break;case"completed":e="iceConnectionCompleted";break;case"failed":e="iceConnectionFailed";break;case"disconnected":e="iceConnectionDisconnected";break;case"closed":e="iceConnectionClosed";break;default:return void n.logger.warn("Unknown iceConnection state:",this.iceConnectionState)}n.emit(e,this)},this.peerConnection.onstatechange=function(){n.logger.log('PeerConnection state changed to "'+this.readyState+'"')}}},createOfferOrAnswer:{writable:!0,value:function(t){var n,r=this,i=r.peerConnection;return r.ready=!1,n=r.hasOffer("remote")?"createAnswer":"createOffer",e.Utils.promisify(i,n,!0)(t).then(e.Utils.promisify(i,"setLocalDescription")).then(function(){var t=e.Utils.defer();return"complete"===i.iceConnectionState||"completed"===i.iceConnectionState?t.resolve():r.onIceCompleted.promise.then(t.resolve),t.promise}).then(function(){var t=i.localDescription.sdp;t=e.Hacks.Chrome.needsExplicitlyInactiveSDP(t),t=e.Hacks.AllBrowsers.unmaskDtls(t);var o={type:"createOffer"===n?"offer":"answer",sdp:t};return r.emit("getDescription",o),r.session.ua.configuration.hackStripTcp&&(o.sdp=o.sdp.replace(/^a=candidate:\d+ \d+ tcp .*?\r\n/gim,"")),r.ready=!0,o.sdp}).catch(function(t){throw r.logger.error(t),r.ready=!0,new e.Exceptions.GetDescriptionError(t)})}},addStreams:{writable:!0,value:function(t){try{(t=[].concat(t)).forEach(function(e){this.peerConnection.addStream(e)},this)}catch(t){return this.logger.error("error adding stream"),this.logger.error(t),e.Utils.Promise.reject(t)}return e.Utils.Promise.resolve()}},toggleMuteHelper:{writable:!0,value:function(e,t){this.getLocalStreams().forEach(function(n){n[e]().forEach(function(e){e.enabled=!t})})}},toggleMuteAudio:{writable:!0,value:function(e){this.toggleMuteHelper("getAudioTracks",e)}},toggleMuteVideo:{writable:!0,value:function(e){this.toggleMuteHelper("getVideoTracks",e)}}}),t}},function(e,t,n){"use strict";e.exports=function(e,t){var r,i;return(r={}).MediaHandler=n(140)(e),r.MediaStreamManager=n(139)(e,t),r.isSupported=function(){return void 0!==i?i:(r.MediaStream=t.MediaStream,r.getUserMedia=t.getUserMedia,r.RTCPeerConnection=t.RTCPeerConnection,r.RTCSessionDescription=t.RTCSessionDescription,r.RTCPeerConnection&&r.RTCSessionDescription?(r.getUserMedia&&(r.getUserMedia=e.Utils.promisify(t,"getUserMedia")),i=!0):i=!1,i)},r}},function(e,t,n){"use strict";e.exports=function(e){e.Subscription=function(t,n,r,i){if(i=Object.create(i||Object.prototype),this.extraHeaders=i.extraHeaders=(i.extraHeaders||[]).slice(),this.id=null,this.state="init",!r)throw new TypeError("Event necessary to create a subscription.");this.event=r,"number"!=typeof i.expires?(t.logger.warn("expires must be a number. Using default of 3600."),this.expires=3600):this.expires=i.expires,i.extraHeaders.push("Event: "+this.event),i.extraHeaders.push("Expires: "+this.expires),i.body&&(this.body=i.body),this.contact=t.contact.toString(),i.extraHeaders.push("Contact: "+this.contact),i.extraHeaders.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),e.Utils.augment(this,e.ClientContext,[t,e.C.SUBSCRIBE,n,i]),this.logger=t.getLogger("sip.subscription"),this.dialog=null,this.timers={N:null,sub_duration:null},this.errorCodes=[404,405,410,416,480,481,482,483,484,485,489,501,604]},e.Subscription.prototype={subscribe:function(){return"active"===this.state?(this.refresh(),this):"notify_wait"===this.state?this:(e.Timers.clearTimeout(this.timers.sub_duration),e.Timers.clearTimeout(this.timers.N),this.timers.N=e.Timers.setTimeout(this.timer_fire.bind(this),e.Timers.TIMER_N),this.send(),this.state="notify_wait",this)},refresh:function(){"terminated"!==this.state&&"pending"!==this.state&&"notify_wait"!==this.state&&this.dialog.sendRequest(this,e.C.SUBSCRIBE,{extraHeaders:this.extraHeaders,body:this.body})},receiveResponse:function(t){var n,r=e.Utils.getReasonPhrase(t.status_code);"notify_wait"===this.state&&t.status_code>=300||"notify_wait"!==this.state&&-1!==this.errorCodes.indexOf(t.status_code)?this.failed(t,null):/^2[0-9]{2}$/.test(t.status_code)&&(n=t.getHeader("Expires"),e.Timers.clearTimeout(this.timers.N),this.createConfirmedDialog(t,"UAC")&&(this.id=this.dialog.id.toString(),this.ua.subscriptions[this.id]=this,this.emit("accepted",t,r)),n&&n<=this.expires?(this.expires=n,this.timers.sub_duration=e.Timers.setTimeout(this.refresh.bind(this),900*n)):n?(this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),this.failed(t,e.C.INVALID_EXPIRES_HEADER)):(this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE"),this.failed(t,e.C.EXPIRES_HEADER_MISSING)))},unsubscribe:function(){var t=[];this.state="terminated",t.push("Event: "+this.event),t.push("Expires: 0"),t.push("Contact: "+this.contact),t.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.receiveResponse=function(){},this.dialog.sendRequest(this,this.method,{extraHeaders:t,body:this.body}),e.Timers.clearTimeout(this.timers.sub_duration),e.Timers.clearTimeout(this.timers.N),this.timers.N=e.Timers.setTimeout(this.timer_fire.bind(this),e.Timers.TIMER_N)},timer_fire:function(){"terminated"===this.state?(this.terminateDialog(),e.Timers.clearTimeout(this.timers.N),e.Timers.clearTimeout(this.timers.sub_duration),delete this.ua.subscriptions[this.id]):"pending"===this.state||"notify_wait"===this.state?this.close():this.refresh()},close:function(){"notify_wait"!==this.state&&"terminated"!==this.state&&this.unsubscribe()},createConfirmedDialog:function(t,n){var r;return this.terminateDialog(),!(r=new e.Dialog(this,t,n)).error&&(this.dialog=r,!0)},terminateDialog:function(){this.dialog&&(delete this.ua.subscriptions[this.id],this.dialog.terminate(),delete this.dialog)},receiveRequest:function(t){var n,r=this;function i(){n.expires&&(e.Timers.clearTimeout(r.timers.sub_duration),n.expires=Math.min(r.expires,Math.max(n.expires,0)),r.timers.sub_duration=e.Timers.setTimeout(r.refresh.bind(r),900*n.expires))}if(this.matchEvent(t))if(n=t.parseHeader("Subscription-State"),t.reply(200,e.C.REASON_200),e.Timers.clearTimeout(this.timers.N),this.emit("notify",{request:t}),"terminated"!==this.state)switch(n.state){case"active":this.state="active",i();break;case"pending":"notify_wait"===this.state&&i(),this.state="pending";break;case"terminated":if(e.Timers.clearTimeout(this.timers.sub_duration),n.reason)switch(this.logger.log("terminating subscription with reason "+n.reason),n.reason){case"deactivated":case"timeout":return void this.subscribe();case"probation":case"giveup":return void(n.params&&n.params["retry-after"]?this.timers.sub_duration=e.Timers.setTimeout(r.subscribe.bind(r),n.params["retry-after"]):this.subscribe())}this.close()}else"terminated"===n.state&&(this.terminateDialog(),e.Timers.clearTimeout(this.timers.N),e.Timers.clearTimeout(this.timers.sub_duration),delete this.ua.subscriptions[this.id]);else t.reply(489)},failed:function(e,t){return this.close(),this.emit("failed",e,t),this},onDialogError:function(t){this.failed(t,e.C.causes.DIALOG_ERROR)},matchEvent:function(e){var t;return e.hasHeader("Event")?e.hasHeader("Subscription-State")?(t=e.parseHeader("event").event,this.event===t||(this.logger.warn("event match failed"),e.reply(481,"Event Match Failed"),!1)):(this.logger.warn("missing Subscription-State header"),!1):(this.logger.warn("missing Event header"),!1)}}}},function(e,t){e.exports=function(e){return{localMinSE:90,hasSmallMinSE:function(e){var t=e.parseHeader("Supported")||[],n=e.parseHeader("Session-Expires")||{};return t.indexOf("timer")>=0&&n.deltaSeconds<90},updateState:function(t,n,r,i){t.sessionTimerState=t.sessionTimerState||{},e.clearTimeout(t.sessionTimerState.timeout);var o="string"==typeof n;o&&(n=r(n,i));var a=n.parseHeader("Session-Expires");if(a){var c=a.deltaSeconds,s=o===("uas"===a.refresher);t.sessionTimerState={interval:c,isRefresher:s};var u=1e3*c,l=this;if(s)t.sessionTimerState.timeout=e.setInterval(function(){t.owner.ua.dialogs[t.id.toString()]?t.sendRequest(l,"UPDATE",{extraHeaders:["Session-Expires: "+c]}):e.clearInterval(t.sessionTimerState.timeout)},u/2);else{var f=Math.min(32e3,u/3);t.sessionTimerState.timeout=e.setTimeout(function(){},u-f)}}else t.sessionTimerState=null},receiveResponse:function(e){},onDialogError:function(e){},onRequestTimeout:function(){},onTransportError:function(){}}}},function(e,t,n){"use strict";e.exports=function(e){var t;return(t=function(n,r,i){var o,a;if(void 0===r)throw new TypeError("Not enough arguments");if(this.logger=n.ua.getLogger("sip.invitecontext.dtmf",n.id),this.owner=n,this.direction=null,o=(i=i||{}).duration||null,a=i.interToneGap||null,"string"==typeof r)r=r.toUpperCase();else{if("number"!=typeof r)throw new TypeError("Invalid tone: "+r);r=r.toString()}if(!r.match(/^[0-9A-D#*]$/))throw new TypeError("Invalid tone: "+r);if(this.tone=r,o&&!e.Utils.isDecimal(o))throw new TypeError("Invalid tone duration: "+o);if(o?ot.C.MAX_DURATION?(this.logger.warn('"duration" value is greater than the maximum allowed, setting it to '+t.C.MAX_DURATION+" milliseconds"),o=t.C.MAX_DURATION):o=Math.abs(o):o=t.C.DEFAULT_DURATION,this.duration=o,a&&!e.Utils.isDecimal(a))throw new TypeError("Invalid interToneGap: "+a);a?a0;)r.push(new a(this,t.shift(),n));if(this.tones)return this.tones=this.tones.concat(r),this;var o=function(){var t,r;if(i.status===s.STATUS_TERMINATED||!i.tones||0===i.tones.length)return i.tones=null,this;(t=i.tones.shift()).on("failed",function(){i.tones=null}),t.send(n),r=t.duration+t.interToneGap,e.Timers.setTimeout(o,r)};return this.tones=r,o(),this},bye:function(t){var n=(t=Object.create(t||Object.prototype)).statusCode;if(this.status===s.STATUS_TERMINATED)return this.logger.error("Error: Attempted to send BYE in a terminated session."),this;if(this.logger.log("terminating Session"),n&&(n<200||n>=700))throw new TypeError("Invalid statusCode: "+n);return t.receiveResponse=function(){},this.sendRequest(e.C.BYE,t).terminated()},refer:function(t,n){var r=((n=n||{}).extraHeaders||[]).slice(),i=t instanceof e.InviteServerContext||t instanceof e.InviteClientContext,o=t;if(void 0===t)throw new TypeError("Not enough arguments");if(this.status!==s.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);if(i)t='"'+t.remoteIdentity.friendlyName+'" <'+t.dialog.remote_target.toString()+"?Replaces="+t.dialog.id.call_id+"%3Bto-tag%3D"+t.dialog.id.remote_tag+"%3Bfrom-tag%3D"+t.dialog.id.local_tag+">";else{try{t=e.Grammar.parse(t,"Refer_To").uri||t}catch(e){this.logger.debug(".refer() cannot parse Refer_To from",t),this.logger.debug("...falling through to normalizeTarget()")}if(!(t=this.ua.normalizeTarget(t)))throw new TypeError("Invalid target: "+o)}return r.push("Contact: "+this.contact),r.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),r.push("Refer-To: "+t),this.sendRequest(e.C.REFER,{extraHeaders:r,body:n.body,receiveResponse:function(e){/^2[0-9]{2}$/.test(e.status_code)&&(i||t.scheme&&t.scheme.match("^sips?$"))&&this.terminate()}.bind(this)}),this},followRefer:function(n){return function(n,r){var i=r.parseHeader("refer-to"),o=i.uri;if(o.scheme.match("^sips?$")){var a=[],c=o.getHeader("Replaces");void 0!==c&&a.push("Replaces: "+decodeURIComponent(c)),o.clearHeaders();var s=this.mediaHandler.getReferMedia,u=s?s.call(this.mediaHandler):this.mediaHint;e.Hacks.Chrome.getsConfusedAboutGUM(this);var l=this.ua.invite(o,{media:u,params:{to_displayName:i.friendlyName},extraHeaders:a});n.call(this,r,l),this.terminate()}else{var f=o.toString();"function"==typeof t.open?t.open(f):this.logger.warn("referred to non-SIP URI but `open` isn't in the environment: "+f)}}.bind(this,n)},sendRequest:function(t,n){n=n||{};var r=this,i=new e.OutgoingRequest(t,this.dialog.remote_target,this.ua,{cseq:n.cseq||(this.dialog.local_seqnum+=1),call_id:this.dialog.id.call_id,from_uri:this.dialog.local_uri,from_tag:this.dialog.id.local_tag,to_uri:this.dialog.remote_uri,to_tag:this.dialog.id.remote_tag,route_set:this.dialog.route_set,statusCode:n.statusCode,reasonPhrase:n.reasonPhrase},n.extraHeaders||[],n.body);return new e.RequestSender({request:i,onRequestTimeout:function(){r.onRequestTimeout()},onTransportError:function(){r.onTransportError()},receiveResponse:n.receiveResponse||function(e){r.receiveNonInviteResponse(e)}},this.ua).send(),this.emit(t.toLowerCase(),i),this},close:function(){var t;if(this.status===s.STATUS_TERMINATED)return this;for(t in this.logger.log("closing INVITE session "+this.id),this.mediaHandler&&this.mediaHandler.close(),this.timers)e.Timers.clearTimeout(this.timers[t]);for(t in this.dialog&&(this.dialog.terminate(),delete this.dialog),this.earlyDialogs)this.earlyDialogs[t].terminate(),delete this.earlyDialogs[t];return this.status=s.STATUS_TERMINATED,delete this.ua.sessions[this.id],this},createDialog:function(t,n,r){var i,o,a=t["UAS"===n?"to_tag":"from_tag"],c=t["UAS"===n?"from_tag":"to_tag"],s=t.call_id+a+c;if(o=this.earlyDialogs[s],r)return!!o||((o=new e.Dialog(this,t,n,e.Dialog.C.STATUS_EARLY)).error?(this.logger.error(o.error),this.failed(t,e.C.causes.INTERNAL_ERROR),!1):(this.earlyDialogs[s]=o,!0));if(o){for(var u in o.update(t,n),this.dialog=o,delete this.earlyDialogs[s],this.earlyDialogs)this.earlyDialogs[u].terminate(),delete this.earlyDialogs[u];return!0}return(i=new e.Dialog(this,t,n)).error?(this.logger.error(i.error),this.failed(t,e.C.causes.INTERNAL_ERROR),!1):(this.to_tag=t.to_tag,this.dialog=i,!0)},isReadyToReinvite:function(){return this.mediaHandler.isReady()&&!this.dialog.uac_pending_reply&&!this.dialog.uas_pending_reply},mute:function(e){var t=this.mediaHandler.mute(e);t&&this.onmute(t)},unmute:function(e){var t=this.mediaHandler.unmute(e);t&&this.onunmute(t)},hold:function(){if(this.status!==s.STATUS_WAITING_FOR_ACK&&this.status!==s.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);this.mediaHandler.hold(),this.isReadyToReinvite()?!0!==this.local_hold&&(this.onhold("local"),this.sendReinvite()):this.pending_actions.isPending("unhold")?this.pending_actions.pop("unhold"):this.pending_actions.isPending("hold")||this.pending_actions.push("hold")},unhold:function(t){if(this.status!==s.STATUS_WAITING_FOR_ACK&&this.status!==s.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);this.mediaHandler.unhold(),this.isReadyToReinvite()?!1!==this.local_hold&&(this.onunhold("local"),this.sendReinvite(t)):this.pending_actions.isPending("hold")?this.pending_actions.pop("hold"):this.pending_actions.isPending("unhold")||this.pending_actions.push("unhold")},isOnHold:function(){return{local:this.local_hold,remote:this.remote_hold}},receiveReinvite:function(t){var n=this;if(!this.mediaHandler.hasDescription(t))return this.logger.warn("invalid Content-Type"),void t.reply(415);this.mediaHandler.setDescription(t).then(this.mediaHandler.getDescription.bind(this.mediaHandler,this.mediaHint)).then(function(e){var r=["Contact: "+n.contact];t.reply(200,null,r,e,function(){n.status=s.STATUS_WAITING_FOR_ACK,n.setInvite2xxTimer(t,e),n.setACKTimer(),n.remote_hold&&!n.mediaHandler.remote_hold?n.onunhold("remote"):!n.remote_hold&&n.mediaHandler.remote_hold&&n.onhold("remote")})}).catch(function(r){var i;r instanceof e.Exceptions.GetDescriptionError?i=500:(n.logger.error(r),i=488),t.reply(i)})},sendReinvite:function(t){var n,r=this,i=((t=t||{}).extraHeaders||[]).slice(),o=t.eventHandlers||{};o.succeeded&&(n=o.succeeded),this.reinviteSucceeded=function(){e.Timers.clearTimeout(r.timers.ackTimer),e.Timers.clearTimeout(r.timers.invite2xxTimer),r.status=s.STATUS_CONFIRMED,n&&n.apply(this,arguments)},o.failed?this.reinviteFailed=o.failed:this.reinviteFailed=function(){},i.push("Contact: "+this.contact),i.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.receiveResponse=this.receiveReinviteResponse,this.mediaHandler.getDescription(r.mediaHint).then(function(t){r.dialog.sendRequest(r,e.C.INVITE,{extraHeaders:i,body:t})},function(){r.isReadyToReinvite()&&r.onReadyToReinvite(),r.reinviteFailed()})},receiveRequest:function(t){switch(t.method){case e.C.BYE:t.reply(200),this.status===s.STATUS_CONFIRMED&&(this.emit("bye",t),this.terminated(t,e.C.causes.BYE));break;case e.C.INVITE:this.status===s.STATUS_CONFIRMED&&(this.logger.log("re-INVITE received"),this.receiveReinvite(t));break;case e.C.INFO:if(this.status===s.STATUS_1XX_RECEIVED||this.status===s.STATUS_WAITING_FOR_PRACK||this.status===s.STATUS_WAITING_FOR_ACK||this.status===s.STATUS_ANSWERED_WAITING_FOR_PRACK||this.status===s.STATUS_EARLY_MEDIA||this.status===s.STATUS_CONFIRMED||this.dialog){if(this.onInfo)return this.onInfo(t);var n,r,i,o=t.getHeader("content-type"),c=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,u=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;o&&(o.match(/^application\/dtmf-relay/i)?(t.body&&2===(n=t.body.split("\r\n",2)).length&&(c.test(n[0])&&(r=n[0].replace(c,"$2")),u.test(n[1])&&(i=parseInt(n[1].replace(u,"$2"),10))),new a(this,r,{duration:i}).init_incoming(t)):t.reply(415,null,["Accept: application/dtmf-relay"]))}break;case e.C.REFER:var l;this.status===s.STATUS_CONFIRMED&&(this.logger.log("REFER received"),this.listeners("refer").length?(t.reply(202,"Accepted"),l="SIP/2.0 100 Trying",this.sendRequest(e.C.NOTIFY,{extraHeaders:["Event: refer","Subscription-State: terminated","Content-Type: message/sipfrag"],body:l,receiveResponse:function(){}}),this.emit("refer",t)):t.reply(603,"Declined"));break;case e.C.NOTIFY:t.reply(200,"OK"),this.emit("notify",t)}},receiveReinviteResponse:function(t){var n=this;if(this.status!==s.STATUS_TERMINATED)switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(this.status=s.STATUS_CONFIRMED,this.sendRequest(e.C.ACK,{cseq:t.cseq}),!this.mediaHandler.hasDescription(t)){this.reinviteFailed();break}this.mediaHandler.setDescription(t).then(function(){n.reinviteSucceeded()},function(){n.reinviteFailed()});break;default:this.reinviteFailed()}},acceptAndTerminate:function(t,n,r){var i=[];return n&&i.push("Reason: "+e.Utils.getReasonHeaderValue(n,r)),(this.dialog||this.createDialog(t,"UAC"))&&(this.sendRequest(e.C.ACK,{cseq:t.cseq}),this.sendRequest(e.C.BYE,{extraHeaders:i})),this},setInvite2xxTimer:function(t,n){var r=this,i=e.Timers.T1;this.timers.invite2xxTimer=e.Timers.setTimeout(function o(){if(r.status===s.STATUS_WAITING_FOR_ACK){r.logger.log("no ACK received, attempting to retransmit OK");var a=["Contact: "+r.contact];t.reply(200,null,a,n),i=Math.min(2*i,e.Timers.T2),r.timers.invite2xxTimer=e.Timers.setTimeout(o,i)}},i)},setACKTimer:function(){var t=this;this.timers.ackTimer=e.Timers.setTimeout(function(){t.status===s.STATUS_WAITING_FOR_ACK&&(t.logger.log("no ACK received for an extended period of time, terminating the call"),e.Timers.clearTimeout(t.timers.invite2xxTimer),t.sendRequest(e.C.BYE),t.terminated(null,e.C.causes.NO_ACK))},e.Timers.TIMER_H)},onReadyToReinvite:function(){var e=this.pending_actions.shift();e&&this[e.name]&&this[e.name]()},onTransportError:function(){this.status!==s.STATUS_CONFIRMED&&this.status!==s.STATUS_TERMINATED&&this.failed(null,e.C.causes.CONNECTION_ERROR)},onRequestTimeout:function(){this.status===s.STATUS_CONFIRMED?this.terminated(null,e.C.causes.REQUEST_TIMEOUT):this.status!==s.STATUS_TERMINATED&&(this.failed(null,e.C.causes.REQUEST_TIMEOUT),this.terminated(null,e.C.causes.REQUEST_TIMEOUT))},onDialogError:function(t){this.status===s.STATUS_CONFIRMED?this.terminated(t,e.C.causes.DIALOG_ERROR):this.status!==s.STATUS_TERMINATED&&(this.failed(t,e.C.causes.DIALOG_ERROR),this.terminated(t,e.C.causes.DIALOG_ERROR))},onhold:function(e){this["local"===e?"local_hold":"remote_hold"]=!0,this.emit("hold",{originator:e})},onunhold:function(e){this["local"===e?"local_hold":"remote_hold"]=!1,this.emit("unhold",{originator:e})},onmute:function(e){this.emit("muted",{audio:e.audio,video:e.video})},onunmute:function(e){this.emit("unmuted",{audio:e.audio,video:e.video})},failed:function(e,t){return this.status===s.STATUS_TERMINATED?this:(this.emit("failed",e||null,t||null),this)},rejected:function(e,t){return this.emit("rejected",e||null,t||null),this},canceled:function(){return this.emit("cancel"),this},accepted:function(t,n){return n=e.Utils.getReasonPhrase(t&&t.status_code,n),this.startTime=new Date,this.replacee&&(this.replacee.emit("replaced",this),this.replacee.terminate()),t&&c.updateState(this.dialog,t,e.Parser.parseMessage,this.ua),this.emit("accepted",t,n),this},terminated:function(e,t){return this.status===s.STATUS_TERMINATED?this:(this.endTime=new Date,this.close(),this.emit("terminated",e||null,t||null),this)},connecting:function(e){return this.emit("connecting",{request:e}),this}},r.desugar=function(e){return t.HTMLMediaElement&&e instanceof t.HTMLMediaElement&&(e={media:{constraints:{audio:!0,video:"VIDEO"===e.tagName},render:{remote:e}}}),e||{}},r.C=s,e.Session=r,(i=function(t,n){var r,i=this,o=n.getHeader("Content-Type"),a=n.parseHeader("Content-Disposition");if(e.Utils.augment(this,e.ServerContext,[t,n]),e.Utils.augment(this,e.Session,[t.configuration.mediaHandlerFactory]),this.mediaHandler=this.mediaHandlerFactory(this,{RTCConstraints:{optional:[{DtlsSrtpKeyAgreement:"true"}]}}),!a&&!this.mediaHandler.hasDescription(n)||a&&"render"===a.type)this.renderbody=n.body,this.rendertype=o;else if(!this.mediaHandler.hasDescription(n)&&a&&"session"===a.type)return void n.reply(415);function u(e,t){n.hasHeader(e)&&n.getHeader(e).toLowerCase().indexOf("100rel")>=0&&(i.rel100=t)}function l(){var t={extraHeaders:["Contact: "+i.contact]};i.rel100!==e.C.supported.REQUIRED&&i.progress(t),i.status=s.STATUS_WAITING_FOR_ANSWER,i.timers.userNoAnswerTimer=e.Timers.setTimeout(function(){n.reply(408),i.failed(n,e.C.causes.NO_ANSWER),i.terminated(n,e.C.causes.NO_ANSWER)},i.ua.configuration.noAnswerTimeout),r&&(i.timers.expiresTimer=e.Timers.setTimeout(function(){i.status===s.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),i.failed(n,e.C.causes.EXPIRES),i.terminated(n,e.C.causes.EXPIRES))},r)),i.emit("invite",n)}c.hasSmallMinSE(n)?n.reply(422,null,["Min-SE: "+c.localMinSE]):(this.status=s.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(),this.receiveNonInviteResponse=function(){},this.logger=t.getLogger("sip.inviteservercontext",this.id),this.ua.sessions[this.id]=this,n.hasHeader("expires")&&(r=1e3*n.getHeader("expires")),u("require",e.C.supported.REQUIRED),u("supported",e.C.supported.SUPPORTED),n.to_tag=e.Utils.newTag(),this.createDialog(n,"UAS",!0)?(this.mediaHandler&&this.mediaHandler.getRemoteStreams&&(this.getRemoteStreams=this.mediaHandler.getRemoteStreams.bind(this.mediaHandler),this.getLocalStreams=this.mediaHandler.getLocalStreams.bind(this.mediaHandler)),!this.mediaHandler.hasDescription(n)||this.renderbody?e.Timers.setTimeout(l,0):(this.hasOffer=!0,this.mediaHandler.setDescription(n).then(l,function(e){i.logger.warn("invalid description"),i.logger.warn(e),n.reply(488)}))):n.reply(500,"Missing Contact header field"))}).prototype={reject:function(t){if(this.status===s.STATUS_TERMINATED)throw new e.Exceptions.InvalidStateError(this.status);return this.logger.log("rejecting RTCSession"),e.ServerContext.prototype.reject.call(this,t),this.terminated()},terminate:function(t){var n,r=((t=t||{}).extraHeaders||[]).slice(),i=t.body,o=this;return this.status===s.STATUS_WAITING_FOR_ACK&&this.request.server_transaction.state!==e.Transactions.C.STATUS_TERMINATED?(n=this.dialog,this.receiveRequest=function(t){t.method===e.C.ACK&&(this.sendRequest(e.C.BYE,{extraHeaders:r,body:i}),n.terminate())},this.request.server_transaction.on("stateChanged",function(){this.state===e.Transactions.C.STATUS_TERMINATED&&this.dialog&&(this.request=new e.OutgoingRequest(e.C.BYE,this.dialog.remote_target,this.ua,{cseq:this.dialog.local_seqnum+=1,call_id:this.dialog.id.call_id,from_uri:this.dialog.local_uri,from_tag:this.dialog.id.local_tag,to_uri:this.dialog.remote_uri,to_tag:this.dialog.id.remote_tag,route_set:this.dialog.route_set},r,i),new e.RequestSender({request:this.request,onRequestTimeout:function(){o.onRequestTimeout()},onTransportError:function(){o.onTransportError()},receiveResponse:function(){}},this.ua).send(),n.terminate())}),this.emit("bye",this.request),this.terminated(),this.dialog=n,this.ua.dialogs[n.id.toString()]=n):this.status===s.STATUS_CONFIRMED?this.bye(t):this.reject(t),this},progress:function(t){var n,r,i=(t=t||{}).statusCode||180,o=t.reasonPhrase,a=(t.extraHeaders||[]).slice(),c=t.stunServers||null,u=t.turnServers||null,l=t.body;if(i<100||i>199)throw new TypeError("Invalid statusCode: "+i);if(this.isCanceled||this.status===s.STATUS_TERMINATED)return this;if(c||u){if(c){if(!(n=e.UA.configuration_check.optional.stunServers(c)))throw new TypeError("Invalid stunServers: "+c);this.stunServers=n}if(u){if(!(n=e.UA.configuration_check.optional.turnServers(u)))throw new TypeError("Invalid turnServers: "+u);this.turnServers=n}this.mediaHandler.updateIceServers({stunServers:this.stunServers,turnServers:this.turnServers})}return 100!==t.statusCode&&(this.rel100===e.C.supported.REQUIRED||this.rel100===e.C.supported.SUPPORTED&&t.rel100||this.rel100===e.C.supported.SUPPORTED&&this.ua.configuration.rel100===e.C.supported.REQUIRED)?function(){i=t.statusCode||183,this.status=s.STATUS_WAITING_FOR_PRACK,a.push("Contact: "+this.contact),a.push("Require: 100rel"),a.push("RSeq: "+Math.floor(1e4*Math.random())),this.mediaHint=t.media,this.mediaHandler.getDescription(t.media).then(function(t){if(!this.isCanceled&&this.status!==s.STATUS_TERMINATED){this.early_sdp=t.body,this[this.hasOffer?"hasAnswer":"hasOffer"]=!0;var n=e.Timers.T1;this.timers.rel1xxTimer=e.Timers.setTimeout(function r(){this.request.reply(i,null,a,t),n*=2,this.timers.rel1xxTimer=e.Timers.setTimeout(r.bind(this),n)}.bind(this),n),this.timers.prackTimer=e.Timers.setTimeout(function(){this.status===s.STATUS_WAITING_FOR_PRACK&&(this.logger.log("no PRACK received, rejecting the call"),e.Timers.clearTimeout(this.timers.rel1xxTimer),this.request.reply(504),this.terminated(null,e.C.causes.NO_PRACK))}.bind(this),64*e.Timers.T1),r=this.request.reply(i,o,a,t),this.emit("progress",r,o)}}.bind(this),function(){this.request.reply(480),this.failed(null,e.C.causes.WEBRTC_ERROR),this.terminated(null,e.C.causes.WEBRTC_ERROR)}.bind(this))}.apply(this):function(){r=this.request.reply(i,o,a,l),this.emit("progress",r,o)}.apply(this),this},accept:function(t){t=Object.create(r.desugar(t)),e.Utils.optionsOverride(t,"media","mediaConstraints",!0,this.logger,this.ua.configuration.media),this.mediaHint=t.media,this.onInfo=t.onInfo;var n,i=this,o=this.request,a=(t.extraHeaders||[]).slice(),c=t.stunServers||null,u=t.turnServers||null,l=function(t){var n;i.mediaHandler.render(),a.push("Contact: "+i.contact),a.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString());var r=o.parseHeader("Supported")||[],c=o.parseHeader("Session-Expires")||{},u=c.deltaSeconds;if(u){var l=c.refresher||"uas";a.push("Session-Expires: "+u+";"+l),("uac"===l||r.indexOf("timer")>=0)&&a.push("Require: timer")}i.hasOffer?i.hasAnswer=!0:i.hasOffer=!0,n=o.reply(200,null,a,t,function(){i.status=s.STATUS_WAITING_FOR_ACK,i.setInvite2xxTimer(o,t),i.setACKTimer()},function(){i.failed(null,e.C.causes.CONNECTION_ERROR),i.terminated(null,e.C.causes.CONNECTION_ERROR)}),i.status!==s.STATUS_TERMINATED&&i.accepted(n,e.Utils.getReasonPhrase(200))};if(this.status===s.STATUS_WAITING_FOR_PRACK)return this.status=s.STATUS_ANSWERED_WAITING_FOR_PRACK,this;if(this.status===s.STATUS_WAITING_FOR_ANSWER)this.status=s.STATUS_ANSWERED;else if(this.status!==s.STATUS_EARLY_MEDIA)throw new e.Exceptions.InvalidStateError(this.status);if((c||u)&&this.status!==s.STATUS_EARLY_MEDIA&&this.status!==s.STATUS_ANSWERED_WAITING_FOR_PRACK){if(c){if(!(n=e.UA.configuration_check.optional.stunServers(c)))throw new TypeError("Invalid stunServers: "+c);this.stunServers=n}if(u){if(!(n=e.UA.configuration_check.optional.turnServers(u)))throw new TypeError("Invalid turnServers: "+u);this.turnServers=n}this.mediaHandler.updateIceServers({stunServers:this.stunServers,turnServers:this.turnServers})}return this.createDialog(o,"UAS")?(e.Timers.clearTimeout(this.timers.userNoAnswerTimer),this.status===s.STATUS_EARLY_MEDIA?l({}):this.mediaHandler.getDescription(i.mediaHint).then(l,function(){i.status!==s.STATUS_TERMINATED&&(i.request.reply(480),i.failed(null,e.C.causes.WEBRTC_ERROR),i.terminated(null,e.C.causes.WEBRTC_ERROR))}),this):(o.reply(500,"Missing Contact header field"),this)},receiveRequest:function(t){function n(){var n;e.Timers.clearTimeout(this.timers.ackTimer),e.Timers.clearTimeout(this.timers.invite2xxTimer),this.status=s.STATUS_CONFIRMED,this.unmute(),n=t.getHeader("Content-Type"),this.mediaHandler.hasDescription(t)||(this.renderbody=t.body,this.rendertype=n),this.emit("confirmed",t)}switch(t.method){case e.C.CANCEL:this.status!==s.STATUS_WAITING_FOR_ANSWER&&this.status!==s.STATUS_WAITING_FOR_PRACK&&this.status!==s.STATUS_ANSWERED_WAITING_FOR_PRACK&&this.status!==s.STATUS_EARLY_MEDIA&&this.status!==s.STATUS_ANSWERED||(this.status=s.STATUS_CANCELED,this.request.reply(487),this.canceled(t),this.rejected(t,e.C.causes.CANCELED),this.failed(t,e.C.causes.CANCELED),this.terminated(t,e.C.causes.CANCELED));break;case e.C.ACK:this.status===s.STATUS_WAITING_FOR_ACK&&(this.hasAnswer?n.apply(this):this.mediaHandler.hasDescription(t)?(this.hasAnswer=!0,this.mediaHandler.setDescription(t).then(n.bind(this),function(n){this.logger.warn(n),this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(t,e.C.causes.BAD_MEDIA_DESCRIPTION)}.bind(this))):this.early_sdp?n.apply(this):(this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(t,e.C.causes.BAD_MEDIA_DESCRIPTION)));break;case e.C.PRACK:this.status===s.STATUS_WAITING_FOR_PRACK||this.status===s.STATUS_ANSWERED_WAITING_FOR_PRACK?this.hasAnswer?(e.Timers.clearTimeout(this.timers.rel1xxTimer),e.Timers.clearTimeout(this.timers.prackTimer),t.reply(200),this.status===s.STATUS_ANSWERED_WAITING_FOR_PRACK&&(this.status=s.STATUS_EARLY_MEDIA,this.accept()),this.status=s.STATUS_EARLY_MEDIA,this.mute()):this.mediaHandler.hasDescription(t)?(this.hasAnswer=!0,this.mediaHandler.setDescription(t).then(function(){e.Timers.clearTimeout(this.timers.rel1xxTimer),e.Timers.clearTimeout(this.timers.prackTimer),t.reply(200),this.status===s.STATUS_ANSWERED_WAITING_FOR_PRACK&&(this.status=s.STATUS_EARLY_MEDIA,this.accept()),this.status=s.STATUS_EARLY_MEDIA,this.mute()}.bind(this),function(n){this.logger.warn(n),this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(t,e.C.causes.BAD_MEDIA_DESCRIPTION)}.bind(this))):(this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(t,e.C.causes.BAD_MEDIA_DESCRIPTION)):this.status===s.STATUS_EARLY_MEDIA&&t.reply(200);break;default:r.prototype.receiveRequest.apply(this,[t])}},onTransportError:function(){this.status!==s.STATUS_CONFIRMED&&this.status!==s.STATUS_TERMINATED&&this.failed(null,e.C.causes.CONNECTION_ERROR)},onRequestTimeout:function(){this.status===s.STATUS_CONFIRMED?this.terminated(null,e.C.causes.REQUEST_TIMEOUT):this.status!==s.STATUS_TERMINATED&&(this.failed(null,e.C.causes.REQUEST_TIMEOUT),this.terminated(null,e.C.causes.REQUEST_TIMEOUT))}},e.InviteServerContext=i,(o=function(t,n,i){(i=Object.create(r.desugar(i))).params=Object.create(i.params||Object.prototype);var o,a=(i.extraHeaders||[]).slice(),c=i.stunServers||null,u=i.turnServers||null,l=i.mediaHandlerFactory||t.configuration.mediaHandlerFactory,f=l.isSupported;if(f&&!f())throw new e.Exceptions.NotSupportedError("Media not supported");if(this.RTCConstraints=i.RTCConstraints||{},this.inviteWithoutSdp=i.inviteWithoutSdp||!1,this.anonymous=i.anonymous||!1,this.renderbody=i.renderbody||null,this.rendertype=i.rendertype||"text/plain",i.params.from_tag=this.from_tag,this.contact=t.contact.toString({anonymous:this.anonymous,outbound:this.anonymous?!t.contact.temp_gruu:!t.contact.pub_gruu}),this.anonymous&&(i.params.from_displayName="Anonymous",i.params.from_uri="sip:anonymous@anonymous.invalid",a.push("P-Preferred-Identity: "+t.configuration.uri.toString()),a.push("Privacy: id")),a.push("Contact: "+this.contact),a.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.inviteWithoutSdp&&this.renderbody&&(a.push("Content-Type: "+this.rendertype),a.push("Content-Disposition: render;handling=optional")),t.configuration.rel100===e.C.supported.REQUIRED&&a.push("Require: 100rel"),t.configuration.replaces===e.C.supported.REQUIRED&&a.push("Require: replaces"),i.extraHeaders=a,e.Utils.augment(this,e.ClientContext,[t,e.C.INVITE,n,i]),e.Utils.augment(this,e.Session,[l]),this.status!==s.STATUS_NULL)throw new e.Exceptions.InvalidStateError(this.status);if(this.from_tag=e.Utils.newTag(),this.isCanceled=!1,this.received_100=!1,this.method=e.C.INVITE,this.receiveNonInviteResponse=this.receiveResponse,this.receiveResponse=this.receiveInviteResponse,this.logger=t.getLogger("sip.inviteclientcontext"),c){if(!(o=e.UA.configuration_check.optional.stunServers(c)))throw new TypeError("Invalid stunServers: "+c);this.stunServers=o}if(u){if(!(o=e.UA.configuration_check.optional.turnServers(u)))throw new TypeError("Invalid turnServers: "+u);this.turnServers=o}t.applicants[this]=this,this.id=this.request.call_id+this.from_tag,this.mediaHandler=this.mediaHandlerFactory(this,{RTCConstraints:this.RTCConstraints,stunServers:this.stunServers,turnServers:this.turnServers}),this.mediaHandler&&this.mediaHandler.getRemoteStreams&&(this.getRemoteStreams=this.mediaHandler.getRemoteStreams.bind(this.mediaHandler),this.getLocalStreams=this.mediaHandler.getLocalStreams.bind(this.mediaHandler)),e.Utils.optionsOverride(i,"media","mediaConstraints",!0,this.logger,this.ua.configuration.media),this.mediaHint=i.media,this.onInfo=i.onInfo}).prototype={invite:function(){var t=this;return this.ua.sessions[this.id]=this,this.inviteWithoutSdp?(this.request.body=t.renderbody,this.status=s.STATUS_INVITE_SENT,this.send()):this.mediaHandler.getDescription(t.mediaHint).then(function(e){t.isCanceled||t.status===s.STATUS_TERMINATED||(t.hasOffer=!0,t.request.body=e,t.status=s.STATUS_INVITE_SENT,t.send())},function(){t.status!==s.STATUS_TERMINATED&&(t.failed(null,e.C.causes.WEBRTC_ERROR),t.terminated(null,e.C.causes.WEBRTC_ERROR))}),this},receiveInviteResponse:function(t){var n,r=this,i=t.call_id+t.from_tag+t.to_tag,o=[],a={};if(this.status!==s.STATUS_TERMINATED&&t.method===e.C.INVITE){if(this.dialog&&t.status_code>=200&&t.status_code<=299){if(i!==this.dialog.id.toString()){if(!this.createDialog(t,"UAC",!0))return;return this.earlyDialogs[i].sendRequest(this,e.C.ACK,{body:e.Utils.generateFakeSDP(t.body)}),this.earlyDialogs[i].sendRequest(this,e.C.BYE),void(this.status!==s.STATUS_CONFIRMED&&(this.failed(t,e.C.causes.WEBRTC_ERROR),this.terminated(t,e.C.causes.WEBRTC_ERROR)))}if(this.status===s.STATUS_CONFIRMED)return void this.sendRequest(e.C.ACK,{cseq:t.cseq});if(!this.hasAnswer)return}if(this.dialog&&t.status_code<200){if(-1!==this.dialog.pracked.indexOf(t.getHeader("rseq"))||this.dialog.pracked[this.dialog.pracked.length-1]>=t.getHeader("rseq")&&this.dialog.pracked.length>0)return;if(!this.earlyDialogs[i]&&!this.createDialog(t,"UAC",!0))return;if(-1!==this.earlyDialogs[i].pracked.indexOf(t.getHeader("rseq"))||this.earlyDialogs[i].pracked[this.earlyDialogs[i].pracked.length-1]>=t.getHeader("rseq")&&this.earlyDialogs[i].pracked.length>0)return;return o.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),this.earlyDialogs[i].pracked.push(t.getHeader("rseq")),void this.earlyDialogs[i].sendRequest(this,e.C.PRACK,{extraHeaders:o,body:e.Utils.generateFakeSDP(t.body)})}if(this.isCanceled)t.status_code>=100&&t.status_code<200?(this.request.cancel(this.cancelReason,o),this.canceled(null)):t.status_code>=200&&t.status_code<299?(this.acceptAndTerminate(t),this.emit("bye",this.request)):t.status_code>=300&&(n=e.C.REASON_PHRASE[t.status_code]||e.C.causes.CANCELED,this.rejected(t,n),this.failed(t,n),this.terminated(t,n));else switch(!0){case/^100$/.test(t.status_code):this.received_100=!0,this.emit("progress",t);break;case/^1[0-9]{2}$/.test(t.status_code):if(!t.to_tag){this.logger.warn("1xx response received without to tag");break}if(t.hasHeader("contact")&&!this.createDialog(t,"UAC",!0))break;if(this.status=s.STATUS_1XX_RECEIVED,t.hasHeader("require")&&-1!==t.getHeader("require").indexOf("100rel")){if(this.dialog||!this.earlyDialogs[i])break;if(-1!==this.earlyDialogs[i].pracked.indexOf(t.getHeader("rseq"))||this.earlyDialogs[i].pracked[this.earlyDialogs[i].pracked.length-1]>=t.getHeader("rseq")&&this.earlyDialogs[i].pracked.length>0)return;if(this.mediaHandler.hasDescription(t))if(this.hasOffer){if(!this.createDialog(t,"UAC"))break;this.hasAnswer=!0,this.dialog.pracked.push(t.getHeader("rseq")),this.mediaHandler.setDescription(t).then(function(){o.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),r.sendRequest(e.C.PRACK,{extraHeaders:o,receiveResponse:function(){}}),r.status=s.STATUS_EARLY_MEDIA,r.mute(),r.emit("progress",t)},function(n){r.logger.warn(n),r.acceptAndTerminate(t,488,"Not Acceptable Here"),r.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION)})}else{var c=this.earlyDialogs[i],u=c.mediaHandler;c.pracked.push(t.getHeader("rseq")),u.setDescription(t).then(u.getDescription.bind(u,r.mediaHint)).then(function(n){o.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),c.sendRequest(r,e.C.PRACK,{extraHeaders:o,body:n}),r.status=s.STATUS_EARLY_MEDIA,r.emit("progress",t)}).catch(function(n){if(n instanceof e.Exceptions.GetDescriptionError){if(c.pracked.push(t.getHeader("rseq")),r.status===s.STATUS_TERMINATED)return;r.failed(null,e.C.causes.WEBRTC_ERROR),r.terminated(null,e.C.causes.WEBRTC_ERROR)}else c.pracked.splice(c.pracked.indexOf(t.getHeader("rseq")),1),r.logger.warn("invalid description"),r.logger.warn(n)})}else o.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),this.earlyDialogs[i].pracked.push(t.getHeader("rseq")),this.earlyDialogs[i].sendRequest(this,e.C.PRACK,{extraHeaders:o}),this.emit("progress",t)}else this.emit("progress",t);break;case/^2[0-9]{2}$/.test(t.status_code):if(this.request.cseq+" "+this.request.method!==t.getHeader("cseq"))break;if(this.status===s.STATUS_EARLY_MEDIA&&this.dialog){this.status=s.STATUS_CONFIRMED,this.unmute(),a={},this.renderbody&&(o.push("Content-Type: "+this.rendertype),a.extraHeaders=o,a.body=this.renderbody),a.cseq=t.cseq,this.sendRequest(e.C.ACK,a),this.accepted(t);break}if(this.dialog)break;if(this.hasOffer)if(this.hasAnswer)this.renderbody&&(o.push("Content-Type: "+r.rendertype),a.extraHeaders=o,a.body=this.renderbody),this.sendRequest(e.C.ACK,a);else{if(!this.mediaHandler.hasDescription(t)){this.acceptAndTerminate(t,400,"Missing session description"),this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION);break}if(!this.createDialog(t,"UAC"))break;this.hasAnswer=!0,this.mediaHandler.setDescription(t).then(function(){var n={};r.status=s.STATUS_CONFIRMED,r.unmute(),r.renderbody&&(o.push("Content-Type: "+r.rendertype),n.extraHeaders=o,n.body=r.renderbody),n.cseq=t.cseq,r.sendRequest(e.C.ACK,n),r.accepted(t)},function(n){r.logger.warn(n),r.acceptAndTerminate(t,488,"Not Acceptable Here"),r.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION)})}else if(this.earlyDialogs[i]&&this.earlyDialogs[i].mediaHandler.localMedia){if(this.hasOffer=!0,this.hasAnswer=!0,this.mediaHandler=this.earlyDialogs[i].mediaHandler,!this.createDialog(t,"UAC"))break;this.status=s.STATUS_CONFIRMED,this.sendRequest(e.C.ACK,{cseq:t.cseq}),this.unmute(),this.accepted(t)}else{if(!this.mediaHandler.hasDescription(t)){this.acceptAndTerminate(t,400,"Missing session description"),this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION);break}if(!this.createDialog(t,"UAC"))break;this.hasOffer=!0,this.mediaHandler.setDescription(t).then(this.mediaHandler.getDescription.bind(this.mediaHandler,this.mediaHint)).then(function(n){r.isCanceled||r.status===s.STATUS_TERMINATED||(r.status=s.STATUS_CONFIRMED,r.hasAnswer=!0,r.unmute(),r.sendRequest(e.C.ACK,{body:n,cseq:t.cseq}),r.accepted(t))}).catch(function(n){n instanceof e.Exceptions.GetDescriptionError?r.logger.warn("there was a problem"):(r.logger.warn("invalid description"),r.logger.warn(n),t.reply(488))})}break;default:n=e.Utils.sipErrorCause(t.status_code),this.rejected(t,n),this.failed(t,n),this.terminated(t,n)}}},cancel:function(t){if((t=t||{}).extraHeaders=(t.extraHeaders||[]).slice(),this.status===s.STATUS_TERMINATED||this.status===s.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);this.logger.log("canceling RTCSession");var n=e.Utils.getCancelReason(t.status_code,t.reason_phrase);return this.status===s.STATUS_NULL||this.status===s.STATUS_INVITE_SENT&&!this.received_100?(this.isCanceled=!0,this.cancelReason=n):this.status!==s.STATUS_INVITE_SENT&&this.status!==s.STATUS_1XX_RECEIVED&&this.status!==s.STATUS_EARLY_MEDIA||this.request.cancel(n,t.extraHeaders),this.canceled()},terminate:function(e){return this.status===s.STATUS_TERMINATED?this:(this.status===s.STATUS_WAITING_FOR_ACK||this.status===s.STATUS_CONFIRMED?this.bye(e):this.cancel(e),this)},receiveRequest:function(t){return t.method,e.C.CANCEL,t.method===e.C.ACK&&this.status===s.STATUS_WAITING_FOR_ACK&&(e.Timers.clearTimeout(this.timers.ackTimer),e.Timers.clearTimeout(this.timers.invite2xxTimer),this.status=s.STATUS_CONFIRMED,this.unmute(),this.accepted()),r.prototype.receiveRequest.apply(this,[t])},onTransportError:function(){this.status!==s.STATUS_CONFIRMED&&this.status!==s.STATUS_TERMINATED&&this.failed(null,e.C.causes.CONNECTION_ERROR)},onRequestTimeout:function(){this.status===s.STATUS_CONFIRMED?this.terminated(null,e.C.causes.REQUEST_TIMEOUT):this.status!==s.STATUS_TERMINATED&&(this.failed(null,e.C.causes.REQUEST_TIMEOUT),this.terminated(null,e.C.causes.REQUEST_TIMEOUT))}},e.InviteClientContext=o}},function(e,t,n){"use strict";e.exports=function(e){var t;((t=function(t,n){this.ua=t,this.logger=t.getLogger("sip.servercontext"),this.request=n,n.method===e.C.INVITE?this.transaction=new e.Transactions.InviteServerTransaction(n,t):this.transaction=new e.Transactions.NonInviteServerTransaction(n,t),n.body&&(this.body=n.body),n.hasHeader("Content-Type")&&(this.contentType=n.getHeader("Content-Type")),this.method=n.method,this.data={},this.localIdentity=n.to,this.remoteIdentity=n.from}).prototype=Object.create(e.EventEmitter.prototype)).progress=function(e){return(e=Object.create(e||Object.prototype)).statusCode||(e.statusCode=180),e.minCode=100,e.maxCode=199,e.events=["progress"],this.reply(e)},t.prototype.accept=function(e){return(e=Object.create(e||Object.prototype)).statusCode||(e.statusCode=200),e.minCode=200,e.maxCode=299,e.events=["accepted"],this.reply(e)},t.prototype.reject=function(e){return(e=Object.create(e||Object.prototype)).statusCode||(e.statusCode=480),e.minCode=300,e.maxCode=699,e.events=["rejected","failed"],this.reply(e)},t.prototype.reply=function(t){var n,r=(t=t||{}).statusCode||100,i=t.minCode||100,o=t.maxCode||699,a=e.Utils.getReasonPhrase(r,t.reasonPhrase),c=t.extraHeaders||[],s=t.body,u=t.events||[];if(ro)throw new TypeError("Invalid statusCode: "+r);return n=this.request.reply(r,a,c,s),u.forEach(function(e){this.emit(e,n,a)},this),this},t.prototype.onRequestTimeout=function(){this.emit("failed",null,e.C.causes.REQUEST_TIMEOUT)},t.prototype.onTransportError=function(){this.emit("failed",null,e.C.causes.CONNECTION_ERROR)},e.ServerContext=t}},function(e,t,n){"use strict";e.exports=function(e){var t;((t=function(t,n,r,i){var o=r;if(void 0===r)throw new TypeError("Not enough arguments");if(this.ua=t,this.logger=t.getLogger("sip.clientcontext"),this.method=n,!(r=t.normalizeTarget(r)))throw new TypeError("Invalid target: "+o);(i=Object.create(i||Object.prototype)).extraHeaders=(i.extraHeaders||[]).slice(),this.request=new e.OutgoingRequest(this.method,r,this.ua,i.params,i.extraHeaders),i.body&&(this.body={},this.body.body=i.body,i.contentType&&(this.body.contentType=i.contentType),this.request.body=this.body),this.localIdentity=this.request.from,this.remoteIdentity=this.request.to,this.data={}}).prototype=Object.create(e.EventEmitter.prototype)).send=function(){return new e.RequestSender(this,this.ua).send(),this},t.prototype.cancel=function(t){(t=t||{}).extraHeaders=(t.extraHeaders||[]).slice();var n=e.Utils.getCancelReason(t.status_code,t.reason_phrase);this.request.cancel(n,t.extraHeaders),this.emit("cancel")},t.prototype.receiveResponse=function(t){var n=e.Utils.getReasonPhrase(t.status_code);switch(!0){case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",t,n);break;case/^2[0-9]{2}$/.test(t.status_code):this.ua.applicants[this]&&delete this.ua.applicants[this],this.emit("accepted",t,n);break;default:this.ua.applicants[this]&&delete this.ua.applicants[this],this.emit("rejected",t,n),this.emit("failed",t,n)}},t.prototype.onRequestTimeout=function(){this.emit("failed",null,e.C.causes.REQUEST_TIMEOUT)},t.prototype.onTransportError=function(){this.emit("failed",null,e.C.causes.CONNECTION_ERROR)},e.ClientContext=t}},function(e,t,n){"use strict";e.exports=function(e){var t=function(e,t){e=e,t=t};return t.prototype=Object.create(e.prototype,{isReady:{value:function(){}},close:{value:function(){}},getDescription:{value:function(e){e=e}},hasDescription:{value:function(e){e=e}},setDescription:{value:function(e){e=e}}}),t}},function(e,t,n){"use strict";e.exports=function(e){var t;(t=function(t){var n={};this.registrar=t.configuration.registrarServer,this.expires=t.configuration.registerExpires,this.contact=t.contact.toString(),this.contact+=";reg-id=1",this.contact+=';+sip.instance=""',this.call_id=e.Utils.createRandomToken(22),this.cseq=80,this.to_uri=t.configuration.uri,n.to_uri=this.to_uri,n.to_displayName=t.configuration.displayName,n.call_id=this.call_id,n.cseq=this.cseq,e.Utils.augment(this,e.ClientContext,[t,"REGISTER",this.registrar,{params:n}]),this.registrationTimer=null,this.registrationExpiredTimer=null,this.registered=!1,this.logger=t.getLogger("sip.registercontext")}).prototype={register:function(t){var n,r=this;this.options=t||{},(n=(this.options.extraHeaders||[]).slice()).push("Contact: "+this.contact+";expires="+this.expires),n.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.closeHeaders=this.options.closeWithHeaders?(this.options.extraHeaders||[]).slice():[],this.receiveResponse=function(t){var n,i,o,a=t.getHeaders("contact").length;if(t.cseq===this.cseq)switch(null!==this.registrationTimer&&(e.Timers.clearTimeout(this.registrationTimer),this.registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",t);break;case/^2[0-9]{2}$/.test(t.status_code):if(this.emit("accepted",t),t.hasHeader("expires")&&(i=t.getHeader("expires")),null!==this.registrationExpiredTimer&&(e.Timers.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),!a){this.logger.warn("no Contact header in response to REGISTER, response ignored");break}for(;a--;){if((n=t.parseHeader("contact",a)).uri.user===this.ua.contact.uri.user){i=n.getParam("expires");break}n=null}if(!n){this.logger.warn("no Contact header pointing to us, response ignored");break}i||(i=this.expires),this.registrationTimer=e.Timers.setTimeout(function(){r.registrationTimer=null,r.register(r.options)},1e3*i-3e3),this.registrationExpiredTimer=e.Timers.setTimeout(function(){r.logger.warn("registration expired"),r.registered&&r.unregistered(null,e.C.causes.EXPIRES)},1e3*i),n.hasParam("temp-gruu")&&(this.ua.contact.temp_gruu=e.URI.parse(n.getParam("temp-gruu").replace(/"/g,""))),n.hasParam("pub-gruu")&&(this.ua.contact.pub_gruu=e.URI.parse(n.getParam("pub-gruu").replace(/"/g,""))),this.registered=!0,this.emit("registered",t||null);break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(this.expires=t.getHeader("min-expires"),this.register(this.options)):(this.logger.warn("423 response received for REGISTER without Min-Expires"),this.registrationFailure(t,e.C.causes.SIP_FAILURE_CODE));break;default:o=e.Utils.sipErrorCause(t.status_code),this.registrationFailure(t,o)}},this.onRequestTimeout=function(){this.registrationFailure(null,e.C.causes.REQUEST_TIMEOUT)},this.onTransportError=function(){this.registrationFailure(null,e.C.causes.CONNECTION_ERROR)},this.cseq++,this.request.cseq=this.cseq,this.request.setHeader("cseq",this.cseq+" REGISTER"),this.request.extraHeaders=n,this.send()},registrationFailure:function(e,t){this.emit("failed",e||null,t||null)},onTransportClosed:function(){this.registered_before=this.registered,null!==this.registrationTimer&&(e.Timers.clearTimeout(this.registrationTimer),this.registrationTimer=null),null!==this.registrationExpiredTimer&&(e.Timers.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),this.registered&&this.unregistered(null,e.C.causes.CONNECTION_ERROR)},onTransportConnected:function(){this.register(this.options)},close:function(){var e={all:!1,extraHeaders:this.closeHeaders};this.registered_before=this.registered,this.unregister(e)},unregister:function(t){var n;t=t||{},this.registered||t.all?(n=(t.extraHeaders||[]).slice(),this.registered=!1,null!==this.registrationTimer&&(e.Timers.clearTimeout(this.registrationTimer),this.registrationTimer=null),t.all?(n.push("Contact: *"),n.push("Expires: 0")):n.push("Contact: "+this.contact+";expires=0"),this.receiveResponse=function(t){var n;switch(!0){case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",t);break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",t),null!==this.registrationExpiredTimer&&(e.Timers.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),this.unregistered(t);break;default:n=e.Utils.sipErrorCause(t.status_code),this.unregistered(t,n)}},this.onRequestTimeout=function(){},this.onTransportError=function(){},this.cseq++,this.request.cseq=this.cseq,this.request.setHeader("cseq",this.cseq+" REGISTER"),this.request.extraHeaders=n,this.send()):this.logger.warn("already unregistered")},unregistered:function(e,t){this.registered=!1,this.emit("unregistered",e||null,t||null)}},e.RegisterContext=t}},function(e,t,n){"use strict";e.exports=function(e){var t;(t=function(t,n){this.logger=n.getLogger("sip.requestsender"),this.ua=n,this.applicant=t,this.method=t.request.method,this.request=t.request,this.credentials=null,this.challenged=!1,this.staled=!1,n.status!==e.UA.C.STATUS_USER_CLOSED||this.method===e.C.BYE&&this.method===e.C.ACK||this.onTransportError()}).prototype={send:function(){switch(this.method){case"INVITE":this.clientTransaction=new e.Transactions.InviteClientTransaction(this,this.request,this.ua.transport);break;case"ACK":this.clientTransaction=new e.Transactions.AckClientTransaction(this,this.request,this.ua.transport);break;default:this.clientTransaction=new e.Transactions.NonInviteClientTransaction(this,this.request,this.ua.transport)}return this.clientTransaction.send(),this.clientTransaction},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(t){var n,r,i,o=t.status_code;if(401===o||407===o){if(401===t.status_code?(r=t.parseHeader("www-authenticate"),i="authorization"):(r=t.parseHeader("proxy-authenticate"),i="proxy-authorization"),!r)return this.logger.warn(t.status_code+" with wrong or missing challenge, cannot authenticate"),void this.applicant.receiveResponse(t);if(!this.challenged||!this.staled&&!0===r.stale){if(this.credentials||(this.credentials=this.ua.configuration.authenticationFactory(this.ua)),!this.credentials.authenticate(this.request,r))return void this.applicant.receiveResponse(t);this.challenged=!0,r.stale&&(this.staled=!0),t.method===e.C.REGISTER?n=this.applicant.cseq+=1:this.request.dialog?n=this.request.dialog.local_seqnum+=1:(n=this.request.cseq+1,this.request.cseq=n),this.request.setHeader("cseq",n+" "+this.method),this.request.setHeader(i,this.credentials.toString()),this.send()}else this.applicant.receiveResponse(t)}else this.applicant.receiveResponse(t)}},e.RequestSender=t}},function(e,t,n){"use strict";e.exports=function(e){var t;return(t=function(e,t,n){this.dialog=e,this.applicant=t,this.request=n,this.reattempt=!1,this.reattemptTimer=null}).prototype={send:function(){var t=this,n=new e.RequestSender(this,this.dialog.owner.ua);n.send(),this.request.method===e.C.INVITE&&n.clientTransaction.state!==e.Transactions.C.STATUS_TERMINATED&&(this.dialog.uac_pending_reply=!0,n.clientTransaction.on("stateChanged",function n(){this.state!==e.Transactions.C.STATUS_ACCEPTED&&this.state!==e.Transactions.C.STATUS_COMPLETED&&this.state!==e.Transactions.C.STATUS_TERMINATED||(this.removeListener("stateChanged",n),t.dialog.uac_pending_reply=!1,!1===t.dialog.uas_pending_reply&&t.dialog.owner.onReadyToReinvite())}))},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(t){var n=this;408===t.status_code||481===t.status_code?this.applicant.onDialogError(t):t.method===e.C.INVITE&&491===t.status_code?this.reattempt?this.applicant.receiveResponse(t):(this.request.cseq.value=this.dialog.local_seqnum+=1,this.reattemptTimer=e.Timers.setTimeout(function(){n.applicant.owner.status!==e.Session.C.STATUS_TERMINATED&&(n.reattempt=!0,n.request_sender.send())},this.getReattemptTimeout())):this.applicant.receiveResponse(t)}},t}},function(e,t,n){"use strict";e.exports=function(e){var t,r=n(151)(e),i={STATUS_EARLY:1,STATUS_CONFIRMED:2};(t=function(t,n,r,o){var a;if(this.uac_pending_reply=!1,this.uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};o=n instanceof e.IncomingResponse?n.status_code<200?i.STATUS_EARLY:i.STATUS_CONFIRMED:o||i.STATUS_CONFIRMED,a=n.parseHeader("contact"),"UAS"===r?(this.id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=o,this.remote_seqnum=n.cseq,this.local_uri=n.parseHeader("to").uri,this.remote_uri=n.parseHeader("from").uri,this.remote_target=a.uri,this.route_set=n.getHeaders("record-route"),this.invite_seqnum=n.cseq,this.local_seqnum=n.cseq):"UAC"===r&&(this.id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=o,this.invite_seqnum=n.cseq,this.local_seqnum=n.cseq,this.local_uri=n.parseHeader("from").uri,this.pracked=[],this.remote_uri=n.parseHeader("to").uri,this.remote_target=a.uri,this.route_set=n.getHeaders("record-route").reverse(),this.state!==i.STATUS_EARLY||t.hasOffer||(this.mediaHandler=t.mediaHandlerFactory(t))),this.logger=t.ua.getLogger("sip.dialog",this.id.toString()),this.owner=t,t.ua.dialogs[this.id.toString()]=this,this.logger.log("new "+r+" dialog created with status "+(this.state===i.STATUS_EARLY?"EARLY":"CONFIRMED")),t.emit("dialog",this)}).prototype={update:function(e,t){this.state=i.STATUS_CONFIRMED,this.logger.log("dialog "+this.id.toString()+" changed to CONFIRMED state"),"UAC"===t&&(this.route_set=e.getHeaders("record-route").reverse())},terminate:function(){this.logger.log("dialog "+this.id.toString()+" deleted"),this.mediaHandler&&this.state!==i.STATUS_CONFIRMED&&this.mediaHandler.peerConnection.close(),delete this.owner.ua.dialogs[this.id.toString()]},createRequest:function(t,n,r){var i,o;return n=(n||[]).slice(),this.local_seqnum||(this.local_seqnum=Math.floor(1e4*Math.random())),i=t===e.C.CANCEL||t===e.C.ACK?this.invite_seqnum:this.local_seqnum+=1,(o=new e.OutgoingRequest(t,this.remote_target,this.owner.ua,{cseq:i,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},n,r)).dialog=this,o},checkInDialogRequest:function(t){var n=this;if(this.remote_seqnum){if(t.cseqthis.remote_seqnum&&(this.remote_seqnum=t.cseq)}else this.remote_seqnum=t.cseq;switch(t.method){case e.C.INVITE:if(!0===this.uac_pending_reply)t.reply(491);else{if(!0===this.uas_pending_reply){var r=1+(10*Math.random()|0);return t.reply(500,null,["Retry-After:"+r]),!1}this.uas_pending_reply=!0,t.server_transaction.on("stateChanged",function t(){this.state!==e.Transactions.C.STATUS_ACCEPTED&&this.state!==e.Transactions.C.STATUS_COMPLETED&&this.state!==e.Transactions.C.STATUS_TERMINATED||(this.removeListener("stateChanged",t),n.uas_pending_reply=!1,!1===n.uac_pending_reply&&n.owner.onReadyToReinvite())})}t.hasHeader("contact")&&t.server_transaction.on("stateChanged",function(){this.state===e.Transactions.C.STATUS_ACCEPTED&&(n.remote_target=t.parseHeader("contact").uri)});break;case e.C.NOTIFY:t.hasHeader("contact")&&t.server_transaction.on("stateChanged",function(){this.state===e.Transactions.C.STATUS_COMPLETED&&(n.remote_target=t.parseHeader("contact").uri)})}return!0},sendRequest:function(e,t,n){var i=((n=n||{}).extraHeaders||[]).slice(),o=null;n.body&&(n.body.body?o=n.body:((o={}).body=n.body,n.contentType&&(o.contentType=n.contentType)));var a=this.createRequest(t,i,o);return new r(this,e,a).send(),a},receiveRequest:function(e){this.checkInDialogRequest(e)&&this.owner.receiveRequest(e)}},t.C=i,e.Dialog=t}},function(e,t,n){"use strict";e.exports=function(e){var t={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"};function n(e,t,n){var r;return r="SIP/2.0/"+(e.ua.configuration.hackViaTcp?"TCP":t.server.scheme),r+=" "+e.ua.configuration.viaHost+";branch="+n,e.ua.configuration.forceRport&&(r+=";rport"),r}var r=function(e,r,i){var o;this.type=t.NON_INVITE_CLIENT,this.transport=i,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=r,this.logger=e.ua.getLogger("sip.transaction.nict",this.id),o=n(e,i,this.id),this.request.setHeader("via",o),this.request_sender.ua.newTransaction(this)};(r.prototype=Object.create(e.EventEmitter.prototype)).stateChanged=function(e){this.state=e,this.emit("stateChanged")},r.prototype.send=function(){this.stateChanged(t.STATUS_TRYING),this.F=e.Timers.setTimeout(this.timer_F.bind(this),e.Timers.TIMER_F),this.transport.send(this.request)||this.onTransportError()},r.prototype.onTransportError=function(){this.logger.log("transport error occurred, deleting non-INVITE client transaction "+this.id),e.Timers.clearTimeout(this.F),e.Timers.clearTimeout(this.K),this.stateChanged(t.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onTransportError()},r.prototype.timer_F=function(){this.logger.log("Timer F expired for non-INVITE client transaction "+this.id),this.stateChanged(t.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onRequestTimeout()},r.prototype.timer_K=function(){this.stateChanged(t.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},r.prototype.receiveResponse=function(n){var r=n.status_code;if(r<200)switch(this.state){case t.STATUS_TRYING:case t.STATUS_PROCEEDING:this.stateChanged(t.STATUS_PROCEEDING),this.request_sender.receiveResponse(n)}else switch(this.state){case t.STATUS_TRYING:case t.STATUS_PROCEEDING:this.stateChanged(t.STATUS_COMPLETED),e.Timers.clearTimeout(this.F),408===r?this.request_sender.onRequestTimeout():this.request_sender.receiveResponse(n),this.K=e.Timers.setTimeout(this.timer_K.bind(this),e.Timers.TIMER_K)}};var i=function(e,r,i){var o,a=this;this.type=t.INVITE_CLIENT,this.transport=i,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=r,this.logger=e.ua.getLogger("sip.transaction.ict",this.id),o=n(e,i,this.id),this.request.setHeader("via",o),this.request_sender.ua.newTransaction(this),this.request.cancel=function(e,t){for(var n=(t=(t||[]).slice()).length,r=null,i=0;i=100&&r<=199)switch(this.state){case t.STATUS_CALLING:this.stateChanged(t.STATUS_PROCEEDING),this.request_sender.receiveResponse(n),this.cancel&&this.transport.send(this.cancel);break;case t.STATUS_PROCEEDING:this.request_sender.receiveResponse(n)}else if(r>=200&&r<=299)switch(this.state){case t.STATUS_CALLING:case t.STATUS_PROCEEDING:this.stateChanged(t.STATUS_ACCEPTED),this.M=e.Timers.setTimeout(this.timer_M.bind(this),e.Timers.TIMER_M),this.request_sender.receiveResponse(n);break;case t.STATUS_ACCEPTED:this.request_sender.receiveResponse(n)}else if(r>=300&&r<=699)switch(this.state){case t.STATUS_CALLING:case t.STATUS_PROCEEDING:this.stateChanged(t.STATUS_COMPLETED),this.sendACK(n),this.request_sender.receiveResponse(n);break;case t.STATUS_COMPLETED:this.sendACK(n)}};var o=function(e,t,r){var i;this.transport=r,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=t,this.logger=e.ua.getLogger("sip.transaction.nict",this.id),i=n(e,r,this.id),this.request.setHeader("via",i)};(o.prototype=Object.create(e.EventEmitter.prototype)).send=function(){this.transport.send(this.request)||this.onTransportError()},o.prototype.onTransportError=function(){this.logger.log("transport error occurred, for an ACK client transaction "+this.id),this.request_sender.onTransportError()};var a=function(e,n){this.type=t.NON_INVITE_SERVER,this.id=e.via_branch,this.request=e,this.transport=e.transport,this.ua=n,this.last_response="",e.server_transaction=this,this.logger=n.getLogger("sip.transaction.nist",this.id),this.state=t.STATUS_TRYING,n.newTransaction(this)};(a.prototype=Object.create(e.EventEmitter.prototype)).stateChanged=function(e){this.state=e,this.emit("stateChanged")},a.prototype.timer_J=function(){this.logger.log("Timer J expired for non-INVITE server transaction "+this.id),this.stateChanged(t.STATUS_TERMINATED),this.ua.destroyTransaction(this)},a.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,this.logger.log("transport error occurred, deleting non-INVITE server transaction "+this.id),e.Timers.clearTimeout(this.J),this.stateChanged(t.STATUS_TERMINATED),this.ua.destroyTransaction(this))},a.prototype.receiveResponse=function(n,r){var i=e.Utils.defer();if(100===n)switch(this.state){case t.STATUS_TRYING:this.stateChanged(t.STATUS_PROCEEDING),this.transport.send(r)||this.onTransportError();break;case t.STATUS_PROCEEDING:this.last_response=r,this.transport.send(r)?i.resolve():(this.onTransportError(),i.reject())}else if(n>=200&&n<=699)switch(this.state){case t.STATUS_TRYING:case t.STATUS_PROCEEDING:this.stateChanged(t.STATUS_COMPLETED),this.last_response=r,this.J=e.Timers.setTimeout(this.timer_J.bind(this),e.Timers.TIMER_J),this.transport.send(r)?i.resolve():(this.onTransportError(),i.reject())}return i.promise};var c=function(e,n){this.type=t.INVITE_SERVER,this.id=e.via_branch,this.request=e,this.transport=e.transport,this.ua=n,this.last_response="",e.server_transaction=this,this.logger=n.getLogger("sip.transaction.ist",this.id),this.state=t.STATUS_PROCEEDING,n.newTransaction(this),this.resendProvisionalTimer=null,e.reply(100)};(c.prototype=Object.create(e.EventEmitter.prototype)).stateChanged=function(e){this.state=e,this.emit("stateChanged")},c.prototype.timer_H=function(){this.logger.log("Timer H expired for INVITE server transaction "+this.id),this.state===t.STATUS_COMPLETED&&this.logger.warn("transactions","ACK for INVITE server transaction was never received, call will be terminated"),this.stateChanged(t.STATUS_TERMINATED),this.ua.destroyTransaction(this)},c.prototype.timer_I=function(){this.stateChanged(t.STATUS_TERMINATED),this.ua.destroyTransaction(this)},c.prototype.timer_L=function(){this.logger.log("Timer L expired for INVITE server transaction "+this.id),this.state===t.STATUS_ACCEPTED&&(this.stateChanged(t.STATUS_TERMINATED),this.ua.destroyTransaction(this))},c.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,this.logger.log("transport error occurred, deleting INVITE server transaction "+this.id),null!==this.resendProvisionalTimer&&(e.Timers.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),e.Timers.clearTimeout(this.L),e.Timers.clearTimeout(this.H),e.Timers.clearTimeout(this.I),this.stateChanged(t.STATUS_TERMINATED),this.ua.destroyTransaction(this))},c.prototype.resend_provisional=function(){this.transport.send(this.last_response)||this.onTransportError()},c.prototype.receiveResponse=function(n,r){var i=this,o=e.Utils.defer();if(n>=100&&n<=199)switch(this.state){case t.STATUS_PROCEEDING:this.transport.send(r)||this.onTransportError(),this.last_response=r}if(n>100&&n<=199&&this.state===t.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=e.Timers.setInterval(i.resend_provisional.bind(i),e.Timers.PROVISIONAL_RESPONSE_INTERVAL));else if(n>=200&&n<=299)switch(this.state){case t.STATUS_PROCEEDING:this.stateChanged(t.STATUS_ACCEPTED),this.last_response=r,this.L=e.Timers.setTimeout(i.timer_L.bind(i),e.Timers.TIMER_L),null!==this.resendProvisionalTimer&&(e.Timers.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case t.STATUS_ACCEPTED:this.transport.send(r)?o.resolve():(this.onTransportError(),o.reject())}else if(n>=300&&n<=699)switch(this.state){case t.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(e.Timers.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(r)?(this.stateChanged(t.STATUS_COMPLETED),this.H=e.Timers.setTimeout(i.timer_H.bind(i),e.Timers.TIMER_H),o.resolve()):(this.onTransportError(),o.reject())}return o.promise},e.Transactions={C:t,checkTransaction:function(n,r){var i;switch(r.method){case e.C.INVITE:if(i=n.transactions.ist[r.via_branch]){switch(i.state){case t.STATUS_PROCEEDING:i.transport.send(i.last_response)}return!0}break;case e.C.ACK:if(!(i=n.transactions.ist[r.via_branch]))return!1;if(i.state===t.STATUS_ACCEPTED)return!1;if(i.state===t.STATUS_COMPLETED)return i.stateChanged(t.STATUS_CONFIRMED),i.I=e.Timers.setTimeout(i.timer_I.bind(i),e.Timers.TIMER_I),!0;break;case e.C.CANCEL:return(i=n.transactions.ist[r.via_branch])?(r.reply_sl(200),i.state!==t.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(i=n.transactions.nist[r.via_branch]){switch(i.state){case t.STATUS_TRYING:break;case t.STATUS_PROCEEDING:case t.STATUS_COMPLETED:i.transport.send(i.last_response)}return!0}}},NonInviteClientTransaction:r,InviteClientTransaction:i,AckClientTransaction:o,NonInviteServerTransaction:a,InviteServerTransaction:c}}},function(e,t,n){"use strict";e.exports=function(e){var t;(t=function(t,n,r){var i;if(!(t&&t instanceof e.URI))throw new TypeError('missing or invalid "uri" parameter');for(i in this.uri=t,this.parameters={},r)this.setParam(i,r[i]);Object.defineProperties(this,{friendlyName:{get:function(){return this.displayName||t.aor}},displayName:{get:function(){return n},set:function(e){n=0===e?"0":e}}})}).prototype={setParam:function(e,t){e&&(this.parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString())},getParam:e.URI.prototype.getParam,hasParam:e.URI.prototype.hasParam,deleteParam:e.URI.prototype.deleteParam,clearParams:e.URI.prototype.clearParams,clone:function(){return new t(this.uri.clone(),this.displayName,JSON.parse(JSON.stringify(this.parameters)))},toString:function(){var e,t;for(t in e=this.displayName||0===this.displayName?'"'+this.displayName+'" ':"",e+="<"+this.uri.toString()+">",this.parameters)e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]);return e}},t.parse=function(t){return-1!==(t=e.Grammar.parse(t,"Name_Addr_Header"))?t:void 0},e.NameAddrHeader=t}},function(e,t,n){"use strict";e.exports=function(e){var t;(t=function(t,n,r,i,o,a){var c,s,u,l;if(!r)throw new TypeError('missing or invalid "host" parameter');for(c in t=t||e.C.SIP,this.parameters={},this.headers={},o)this.setParam(c,o[c]);for(s in a)this.setHeader(s,a[s]);u={scheme:t,user:n,host:r,port:i},l={scheme:t.toLowerCase(),user:n,host:r.toLowerCase(),port:i},Object.defineProperties(this,{_normal:{get:function(){return l}},_raw:{get:function(){return u}},scheme:{get:function(){return l.scheme},set:function(e){u.scheme=e,l.scheme=e.toLowerCase()}},user:{get:function(){return l.user},set:function(e){l.user=u.user=e}},host:{get:function(){return l.host},set:function(e){u.host=e,l.host=e.toLowerCase()}},aor:{get:function(){return l.user+"@"+l.host}},port:{get:function(){return l.port},set:function(e){l.port=u.port=0===e?e:parseInt(e,10)||null}}})}).prototype={setParam:function(e,t){e&&(this.parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString().toLowerCase())},getParam:function(e){if(e)return this.parameters[e.toLowerCase()]},hasParam:function(e){if(e)return!!this.parameters.hasOwnProperty(e.toLowerCase())},deleteParam:function(e){var t;if(e=e.toLowerCase(),this.parameters.hasOwnProperty(e))return t=this.parameters[e],delete this.parameters[e],t},clearParams:function(){this.parameters={}},setHeader:function(t,n){this.headers[e.Utils.headerize(t)]=n instanceof Array?n:[n]},getHeader:function(t){if(t)return this.headers[e.Utils.headerize(t)]},hasHeader:function(t){if(t)return!!this.headers.hasOwnProperty(e.Utils.headerize(t))},deleteHeader:function(t){var n;if(t=e.Utils.headerize(t),this.headers.hasOwnProperty(t))return n=this.headers[t],delete this.headers[t],n},clearHeaders:function(){this.headers={}},clone:function(){return new t(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:function(){return this._toString(this._raw)},toString:function(){return this._toString(this._normal)},_toString:function(t){var n,r,i,o,a=[];for(r in o=t.scheme+":",t.scheme.toLowerCase().match("^sips?$")||(o+="//"),t.user&&(o+=e.Utils.escapeUser(t.user)+"@"),o+=t.host,(t.port||0===t.port)&&(o+=":"+t.port),this.parameters)o+=";"+r,null!==this.parameters[r]&&(o+="="+this.parameters[r]);for(n in this.headers)for(i in this.headers[n])a.push(n+"="+this.headers[n][i]);return a.length>0&&(o+="?"+a.join("&")),o}},t.parse=function(t){return-1!==(t=e.Grammar.parse(t,"SIP_URI"))?t:void 0},e.URI=t}},function(e,t,n){"use strict";e.exports=function(e){var t,n,r,i;function o(t){var n=t.ua.configuration.hackAllowUnregisteredOptionTags,r=[],i={};return t.method===e.C.REGISTER?r.push("path","gruu"):t.method===e.C.INVITE&&(t.ua.contact.pub_gruu||t.ua.contact.temp_gruu)&&r.push("gruu"),t.ua.configuration.rel100===e.C.supported.SUPPORTED&&r.push("100rel"),t.ua.configuration.replaces===e.C.supported.SUPPORTED&&r.push("replaces"),r.push("outbound"),"Supported: "+(r=(r=r.concat(t.ua.configuration.extraSupported)).filter(function(t){var r=e.C.OPTION_TAGS[t],o=!i[t];return i[t]=!0,(r||n)&&o})).join(", ")+"\r\n"}(t=function(t,n,r,i,o,a){var c,s,u,l,f,h;if(i=i||{},!t||!n||!r)return null;this.logger=r.getLogger("sip.sipmessage"),this.ua=r,this.headers={},this.method=t,this.ruri=n,this.body=a,this.extraHeaders=(o||[]).slice(),this.statusCode=i.status_code,this.reasonPhrase=i.reason_phrase,i.route_set?this.setHeader("route",i.route_set):r.configuration.usePreloadedRoute&&this.setHeader("route",r.transport.server.sip_uri),this.setHeader("via",""),this.setHeader("max-forwards",e.UA.C.MAX_FORWARDS),f=i.to_uri||n,c=i.to_displayName||0===i.to_displayName?'"'+i.to_displayName+'" ':"",c+="<"+(f&&f.toRaw?f.toRaw():f)+">",c+=i.to_tag?";tag="+i.to_tag:"",this.to=new e.NameAddrHeader.parse(c),this.setHeader("to",c),h=i.from_uri||r.configuration.uri,s=i.from_displayName||0===i.from_displayName?'"'+i.from_displayName+'" ':r.configuration.displayName?'"'+r.configuration.displayName+'" ':"",s+="<"+(h&&h.toRaw?h.toRaw():h)+">;tag=",s+=i.from_tag||e.Utils.newTag(),this.from=new e.NameAddrHeader.parse(s),this.setHeader("from",s),u=i.call_id||r.configuration.sipjsId+e.Utils.createRandomToken(15),this.call_id=u,this.setHeader("call-id",u),l=i.cseq||Math.floor(1e4*Math.random()),this.cseq=l,this.setHeader("cseq",l+" "+t)}).prototype={setHeader:function(t,n){this.headers[e.Utils.headerize(t)]=n instanceof Array?n:[n]},getHeader:function(t){var n,r,i=this.extraHeaders.length,o=this.headers[e.Utils.headerize(t)];if(o){if(o[0])return o[0]}else for(n=new RegExp("^\\s*"+t+"\\s*:","i"),r=0;r=this.headers[t].length))return i=(r=this.headers[t][n]).raw,r.parsed?r.parsed:-1===(o=e.Grammar.parse(i,t.replace(/-/g,"_")))?(this.headers[t].splice(n,1),void this.logger.warn('error parsing "'+t+'" header field with value "'+i+'"')):(r.parsed=o,o);this.logger.log('not so many "'+t+'" headers present')}else this.logger.log('header "'+t+'" not present')},s:function(e,t){return this.parseHeader(e,t)},setHeader:function(t,n){var r={raw:n};this.headers[e.Utils.headerize(t)]=[r]},toString:function(){return this.data}},((r=function(e){this.logger=e.getLogger("sip.sipmessage"),this.ua=e,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}).prototype=new n).reply=function(t,n,r,i,a,c){var s,u,l,f,h,p=this.getHeader("To"),d=0,v=0;if(h=e.Utils.buildStatusLine(t,n),r=(r||[]).slice(),this.method===e.C.INVITE&&t>100&&t<=200)for(l=(s=this.getHeaders("record-route")).length;d100?p+=";tag="+e.Utils.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(p+=";tag="+this.to_tag),h+="To: "+p+"\r\n",h+="From: "+this.getHeader("From")+"\r\n",h+="Call-ID: "+this.call_id+"\r\n",h+="CSeq: "+this.cseq+" "+this.method+"\r\n",l=r.length,f=0;f100?r+=";tag="+e.Utils.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(r+=";tag="+this.to_tag),i+="To: "+r+"\r\n",i+="From: "+this.getHeader("From")+"\r\n",i+="Call-ID: "+this.call_id+"\r\n",i+="CSeq: "+this.cseq+" "+this.method+"\r\n",i+="User-Agent: "+this.ua.configuration.userAgentString+"\r\n",i+="Content-Length: 0\r\n\r\n",this.transport.send(i)},(i=function(e){this.logger=e.getLogger("sip.sipmessage"),this.headers={},this.status_code=null,this.reason_phrase=null}).prototype=new n,e.OutgoingRequest=t,e.IncomingRequest=r,e.IncomingResponse=i}},function(e,t,n){"use strict";e.exports=function(e){var t;function n(e,t){var n=t,r=0,i=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(i=e.indexOf("\r\n",n)))return i;!e.substring(i+2,i+4).match(/(^\r\n)/)&&e.charAt(i+2).match(/(^\s+)/)?n=i+2:r=i}return r}function r(t,n,r,i){var o,a,c,s,u=n.indexOf(":",r),l=n.substring(r,u).trim(),f=n.substring(u+1,i).trim();switch(l.toLowerCase()){case"via":case"v":t.addHeader("via",f),1===t.getHeaders("via").length?(s=t.parseHeader("Via"))&&(t.via=s,t.via_branch=s.branch):s=0;break;case"from":case"f":t.setHeader("from",f),(s=t.parseHeader("from"))&&(t.from=s,t.from_tag=s.getParam("tag"));break;case"to":case"t":t.setHeader("to",f),(s=t.parseHeader("to"))&&(t.to=s,t.to_tag=s.getParam("tag"));break;case"record-route":if(-1===(s=e.Grammar.parse(f,"Record_Route"))){s=void 0;break}for(c=s.length,a=0;a=0&&n<=3?t=n:n>3?t=3:r.hasOwnProperty(n)?t=r[n]:e.error('invalid "level" parameter value: '+JSON.stringify(n))}},connector:{get:function(){return i},set:function(t){null===t||""===t||void 0===t?i=null:"function"==typeof t?i=t:e.error('invalid "connector" parameter value: '+JSON.stringify(t))}}})};function n(e,t,n){this.logger=e,this.category=t,this.label=n}return t.prototype.print=function(t,n,r,i){if("string"==typeof i){var o=[new Date,n];r&&o.push(r),i=o.concat(i).join(" | ")}t.call(e,i)},Object.keys(r).forEach(function(i){n.prototype[i]=function(e){this.logger[i](this.category,this.label,e)},t.prototype[i]=function(t,n,o){this.level>=r[i]&&(this.builtinEnabled&&this.print(e[i],t,n,o),this.connector&&this.connector(i,t,n,o))}}),t.prototype.getLogger=function(e,t){var r;return t&&3===this.level?new n(this,e,t):this.loggers[e]?this.loggers[e]:(r=new n(this,e),this.loggers[e]=r,r)},t}},function(e,t,n){"use strict";e.exports=function(e,t){var n;n={Promise:t.Promise,defer:function(){var e={};return e.promise=new n.Promise(function(t,n){e.resolve=t,e.reject=n}),e},promisify:function(e,t,r){var i=e[t];return function(t,o,a){return new n.Promise(function(n,o){var a=[t,n,o];r&&(a=[n,o,t]),i.apply(e,a)}).then(o,a)}},augment:function(e,t,n,r){var i,o;for(i in o=t.prototype)(r||void 0===e[i])&&(e[i]=o[i]);t.apply(e,n)},optionsOverride:function(e,t,n,r,i,o){r&&e[n]&&i.warn(n+" is deprecated, please use "+t+" instead"),e[t]&&e[n]&&i.warn(t+" overriding "+n),e[t]=e[t]||e[n]||o},str_utf8_length:function(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length},generateFakeSDP:function(e){if(e){var t=e.indexOf("o="),n=e.indexOf("\r\n",t);return"v=0\r\n"+e.slice(t,n)+"\r\ns=-\r\nt=0 0\r\nc=IN IP4 0.0.0.0"}},isFunction:function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)},isDecimal:function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},createRandomToken:function(e,t){var n,r="";for(t=t||32,n=0;n699)throw new TypeError("Invalid status_code: "+t);if(t)return e.Utils.getReasonHeaderValue(t,n)},buildStatusLine:function(e,t){if(e=e||null,t=t||null,!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);return"SIP/2.0 "+e+" "+(t=n.getReasonPhrase(e,t))+"\r\n"},getRandomTestNetIP:function(){return"192.0.2."+(1,254,Math.floor(254*Math.random()+1))},calculateMD5:function(e){function t(e,t){return e<>>32-t}function n(e,t){var n,r,i,o,a;return i=2147483648&e,o=2147483648&t,a=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(r=1073741824&t)?2147483648^a^i^o:n|r?1073741824&a?3221225472^a^i^o:1073741824^a^i^o:a^i^o}function r(e,r,i,o,a,c,s){return n(t(e=n(e,n(n(r&i|~r&o,a),s)),c),r)}function i(e,r,i,o,a,c,s){return n(t(e=n(e,n(n(r&o|i&~o,a),s)),c),r)}function o(e,r,i,o,a,c,s){return n(t(e=n(e,n(n(r^i^o,a),s)),c),r)}function a(e,r,i,o,a,c,s){return n(t(e=n(e,n(n(i^(r|~o),a),s)),c),r)}function c(e){var t,n="",r="";for(t=0;t<=3;t++)n+=(r="0"+(e>>>8*t&255).toString(16)).substr(r.length-2,2);return n}var s,u,l,f,h,p,d,v,m,g;for(s=function(e){for(var t,n=e.length,r=n+8,i=16*((r-r%64)/64+1),o=Array(i-1),a=0,c=0;c>>29,o}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)),d=1732584193,v=4023233417,m=2562383102,g=271733878,u=0;u0.5.0","grunt-contrib-uglify":"~0.2.0","grunt-peg":"~1.3.1","grunt-trimtrailingspaces":"^0.4.0",pegjs:"^0.8.0","release-tool":"^0.2.2"},engines:{node:">=0.12"},homepage:"http://sipjs.com",keywords:["sip","websocket","webrtc","library","javascript"],license:"MIT",main:"src/index.js",name:"@twilio/sip.js",repository:{type:"git",url:"git+https://github.com/onsip/SIP.js.git"},scripts:{build:"grunt build",repl:"beefy test/repl.js --open",test:"grunt travis --verbose"},title:"SIP.js",version:"0.7.7"}},function(e,t,n){"use strict";e.exports=function(e){var t=n(164),r=Object.defineProperties({},{version:{get:function(){return t.version}},name:{get:function(){return t.title}}});return n(163)(r,e),r.LoggerFactory=n(162)(e.console),r.EventEmitter=n(161)(e.console),r.C=n(160)(r.name,r.version),r.Exceptions=n(159),r.Timers=n(158)(e.timers),r.Transport=e.Transport(r,e.WebSocket),n(157)(r),n(156)(r),n(155)(r),n(154)(r),n(153)(r),n(152)(r),n(150)(r),n(149)(r),r.MediaHandler=n(148)(r.EventEmitter),n(147)(r),n(146)(r),n(145)(r,e),n(142)(r),r.WebRTC=n(141)(r,e),n(138)(r,e),r.Hacks=n(137)(r),n(136)(r),r.DigestAuthentication=n(135)(r.Utils),r.Grammar=n(134)(r),r}},function(e,t,n){"use strict";e.exports=function(e,t){var n;return(n=function(e,t){this.logger=e.getLogger("sip.transport"),this.ua=e,this.ws=null,this.server=t,this.reconnection_attempts=0,this.closed=!1,this.connected=!1,this.reconnectTimer=null,this.lastTransportError={},this.keepAliveInterval=e.configuration.keepAliveInterval,this.keepAliveTimeout=null,this.keepAliveTimer=null,this.ua.transport=this,this.connect()}).prototype={send:function(e){var n=e.toString();return this.ws&&this.ws.readyState===t.OPEN?(!0===this.ua.configuration.traceSip&&this.logger.log("sending WebSocket message:\n\n"+n+"\n"),this.ws.send(n),!0):(this.logger.warn("unable to send message, WebSocket is not open"),!1)},sendKeepAlive:function(){if(!this.keepAliveTimeout)return this.keepAliveTimeout=e.Timers.setTimeout(function(){this.ua.emit("keepAliveTimeout")}.bind(this),1e4),this.send("\r\n\r\n")},startSendingKeepAlives:function(){var t,n;this.keepAliveInterval&&!this.keepAliveTimer&&(this.keepAliveTimer=e.Timers.setTimeout(function(){this.sendKeepAlive(),this.keepAliveTimer=null,this.startSendingKeepAlives()}.bind(this),(n=.8*(t=this.keepAliveInterval),1e3*(Math.random()*(t-n)+n))))},stopSendingKeepAlives:function(){e.Timers.clearTimeout(this.keepAliveTimer),e.Timers.clearTimeout(this.keepAliveTimeout),this.keepAliveTimer=null,this.keepAliveTimeout=null},disconnect:function(){this.ws&&(e.Timers.clearTimeout(this.reconnectTimer),this.stopSendingKeepAlives(),this.closed=!0,this.logger.log("closing WebSocket "+this.server.ws_uri),this.ws.close()),null!==this.reconnectTimer&&(e.Timers.clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ua.emit("disconnected",{transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}))},connect:function(){var e=this;if(this.ws&&(this.ws.readyState===t.OPEN||this.ws.readyState===t.CONNECTING))return this.logger.log("WebSocket "+this.server.ws_uri+" is already connected"),!1;this.ws&&this.ws.close(),this.logger.log("connecting to WebSocket "+this.server.ws_uri),this.ua.onTransportConnecting(this,0===this.reconnection_attempts?1:this.reconnection_attempts);try{this.ws=new t(this.server.ws_uri,"sip")}catch(e){this.logger.warn("error connecting to WebSocket "+this.server.ws_uri+": "+e)}this.ws.binaryType="arraybuffer",this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(t){e.onClose(t)},this.ws.onmessage=function(t){e.onMessage(t)},this.ws.onerror=function(t){e.onError(t)}},onOpen:function(){this.connected=!0,this.logger.log("WebSocket "+this.server.ws_uri+" connected"),null!==this.reconnectTimer&&(e.Timers.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnection_attempts=0,this.closed=!1,this.ua.onTransportConnected(this),this.startSendingKeepAlives()},onClose:function(e){var t=this.connected;this.lastTransportError.code=e.code,this.lastTransportError.reason=e.reason,this.stopSendingKeepAlives(),this.reconnection_attempts>0?(this.logger.log("Reconnection attempt "+this.reconnection_attempts+" failed (code: "+e.code+(e.reason?"| reason: "+e.reason:"")+")"),this.reconnect()):(this.connected=!1,this.logger.log("WebSocket disconnected (code: "+e.code+(e.reason?"| reason: "+e.reason:"")+")"),!1===e.wasClean&&this.logger.warn("WebSocket abrupt disconnection"),!0===t?(this.ua.onTransportClosed(this),this.closed?this.ua.emit("disconnected",{transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}):this.reconnect()):this.ua.onTransportError(this))},onMessage:function(t){var n,r,i=t.data;if("\r\n"===i)return e.Timers.clearTimeout(this.keepAliveTimeout),this.keepAliveTimeout=null,void(!0===this.ua.configuration.traceSip&&this.logger.log("received WebSocket message with CRLF Keep Alive response"));if("string"!=typeof i){try{i=String.fromCharCode.apply(null,new Uint8Array(i))}catch(e){return void this.logger.warn("received WebSocket binary message failed to be converted into string, message discarded")}!0===this.ua.configuration.traceSip&&this.logger.log("received WebSocket binary message:\n\n"+i+"\n")}else!0===this.ua.configuration.traceSip&&this.logger.log("received WebSocket text message:\n\n"+i+"\n");if((n=e.Parser.parseMessage(i,this.ua))&&!(this.ua.status===e.UA.C.STATUS_USER_CLOSED&&n instanceof e.IncomingRequest)&&e.sanityCheck(n,this.ua,this))if(n instanceof e.IncomingRequest)n.transport=this,this.ua.receiveRequest(n);else if(n instanceof e.IncomingResponse)switch(n.method){case e.C.INVITE:(r=this.ua.transactions.ict[n.via_branch])&&r.receiveResponse(n);break;case e.C.ACK:break;default:(r=this.ua.transactions.nict[n.via_branch])&&r.receiveResponse(n)}},onError:function(e){this.logger.warn("WebSocket connection error: "+JSON.stringify(e))},reconnect:function(){var t=this;this.reconnection_attempts+=1,this.reconnection_attempts>this.ua.configuration.wsServerMaxReconnection?(this.logger.warn("maximum reconnection attempts for WebSocket "+this.server.ws_uri),this.ua.onTransportError(this)):1===this.reconnection_attempts?(this.logger.log("Connection to WebSocket "+this.server.ws_uri+" severed, attempting first reconnect"),t.connect()):(this.logger.log("trying to reconnect to WebSocket "+this.server.ws_uri+" (reconnection attempt "+this.reconnection_attempts+")"),this.reconnectTimer=e.Timers.setTimeout(function(){t.connect(),t.reconnectTimer=null},1e3*this.ua.configuration.wsServerReconnectionTimeout))}},n.C={STATUS_READY:0,STATUS_DISCONNECTED:1,STATUS_ERROR:2},n}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n0)return p.emit("reconnecting"),void function(e,t,n,r,i){var o=Date.now()-e._connectTimestamp,a=i.reconnectIntervalMs-o;a>0?setTimeout(function(){h(e,t,n,r,i)},a):h(e,t,n,r,i)}(p,e,n,r,u);p.removeListener("disconnected",t)}),h(f,e,n,r,u),f}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),r(t,[{key:"_publish",value:function(e){e.session=this._session,this._ws.send(JSON.stringify(e))}},{key:"disconnect",value:function(){if(this._ws.readyState===this._WebSocket.CLOSING||this._ws.readyState===this._WebSocket.CLOSED)return!1;try{this._ws.close()}catch(e){}return this.emit("disconnected"),!0}},{key:"publish",value:function(e,t,n){return this._ws.readyState!==this._WebSocket.CLOSING&&this._ws.readyState!==this._WebSocket.CLOSED&&(("string"==typeof this._session?this._publish.bind(this):this._eventQueue.push.bind(this._eventQueue))({group:e,name:t,payload:n,timestamp:Date.now(),type:"event",version:1}),!0)}}]),t}();function h(e,t,n,r,i){e._connectTimestamp=Date.now(),e._reconnectAttemptsLeft--,e._ws=new i.WebSocket(i.gateway);var o=e._ws;o.addEventListener("close",function(t){t.code!==s?e.emit("disconnected",new Error("WebSocket Error "+t.code+": "+t.reason)):e.emit("disconnected")}),o.addEventListener("message",function(t){!function(e,t,n){switch(t.type){case"connected":e._session=t.session,e._reconnectAttemptsLeft=n.maxReconnectAttempts,e._eventQueue.splice(0).forEach(e._publish,e),e.emit("connected");break;case"error":e._ws.close(),e.emit("disconnected",new Error(t.message))}}(e,JSON.parse(t.data),i)}),o.addEventListener("open",function(){var e={type:"connect",token:t,version:1};e.publisher={name:n,sdkVersion:r,userAgent:i.userAgent},o.send(JSON.stringify(e))})}e.exports=f}).call(this,n(3))},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;ne.participant.revision&&(e.participant=t.participant),!e.peer_connections&&t.peer_connections?e.peer_connections=S(t.peer_connections):e.peer_connections&&t.peer_connections&&(e.peer_connections=S(e.peer_connections.concat(t.peer_connections))),e},{type:"update",version:w})),void e._updatesReceived.splice(0).forEach(e.emit.bind(e,"message"));case"disconnected":return t.removeListener("accepted",i),t.removeListener("failed",r),t.removeListener("info",i),t.removeListener("bye",r),e.removeListener("stateChanged",o),void n.stop();case"syncing":default:return}}),n.once("disconnected",r),n.once("keepAliveTimeout",function(){return e.disconnect(new m)})}(y,y._session,l),y}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,l),r(t,[{key:"disconnect",value:function(e){return"disconnected"!==this.state&&(this.preempt("disconnected",null,[e]),this._session.terminate({body:JSON.stringify({type:"disconnect",version:w}),extraHeaders:["Content-Type: application/room-signaling+json"]}),this._eventPublisher.disconnect(),!0)}},{key:"publish",value:function(e){switch(e=Object.assign({type:"update",version:w},e),this.state){case"connected":return function e(t,n,r,o){return o=o||0,new Promise(function(a,c){function s(s){switch(Math.floor(s.status_code/100)){case 2:a();break;case 5:on.description.revision&&(n.description=t.description),!n.ice&&t.ice?n.ice=t.ice:n.ice&&t.ice&&t.ice.revision>n.ice.revision&&(n.ice=t.ice),e.set(n.id,n),e},new Map).values())}function T(e){if(e.body)try{return JSON.parse(e.body)}catch(e){throw new g}return null}function E(e){return function(e){var t=e.headers;if(t&&t["X-Twilio-Error"]){var n=t["X-Twilio-Error"][0].raw.split(" "),r=parseInt(n[0],10),i=n.slice(1).join(" ");return y(r,i)}return null}(e)||function(e){try{var t=T(e);if(t)switch(t.type){case"disconnected":if("completed"===t.status)return new h;break;case"error":return y(t.code,t.message)}return null}catch(e){return e}}(e)}e.exports=x},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n0?i/r*8:0,r>0?o/r*8:0,n.availableOutgoingBitrate,n.currentRoundTripTime)}}]),e}();e.exports=i},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;nthis._subscribedRevision){this._subscribedRevision=e.subscribed.revision,e.subscribed.tracks.forEach(function(e){e.id?(this._subscriptionFailures.delete(e.sid),this._subscribed.set(e.id,e.sid)):e.error&&!this._subscriptionFailures.has(e.sid)&&this._subscriptionFailures.set(e.sid,e.error)},this);var r=new Set(e.subscribed.tracks.filter(function(e){return!!e.id}).map(function(e){return e.id}));this._subscribed.forEach(function(e,n){r.has(n)||t._subscribed.delete(n)})}return(e.participants||[]).forEach(function(e){if(e.sid!==this.localParticipant.sid&&!this._disconnectedParticipantSids.has(e.sid)){var t=this._getOrCreateRemoteParticipant(e);t.update(e),n.add(t)}},this),function(e){var t=new Map(h.flatMap(e.participants,function(e){return Array.from(e.tracks.values()).map(function(e){return[e.sid,e]})}));e._subscriptionFailures.forEach(function(n,r){var i=t.get(r);i&&(e._subscriptionFailures.delete(r),i.subscribeFailed(p(n.code,n.message)))});var n=new Set(Array.from(e._subscribed.keys()));t.forEach(function(t){n.has(t.id)?t.isSubscribed||e._getTrackReceiver(t.id).then(function(e){return t.setTrackTransceiver(e)}):t.setTrackTransceiver(null)})}(this),e.peer_connections&&this._peerConnectionManager.update(e.peer_connections),e.recording&&this.recording.update(e.recording),e.published&&e.published.revision>this._publishedRevision&&(this._publishedRevision=e.published.revision,e.published.tracks.forEach(function(e){e.sid&&this._published.set(e.id,e.sid)},this),this.localParticipant.update(e.published)),e.participant&&this.localParticipant.connect(e.participant.sid,e.participant.identity),!this._dominantSpeakerSignalingPromise&&e.media_signaling&&e.media_signaling.active_speaker&&e.media_signaling.active_speaker.transport&&"data-channel"===e.media_signaling.active_speaker.transport.type&&this._setupDataTransportBackedDominantSpeakerSignaling(e.media_signaling.active_speaker.transport.label),!this._networkQualityMonitorPromise&&e.media_signaling&&e.media_signaling.network_quality&&e.media_signaling.network_quality.transport&&"data-channel"===e.media_signaling.network_quality.transport.type&&this._setupDataTransportBackedNetworkQualityMonitor(e.media_signaling.network_quality.transport.label),this}},{key:"_setupDataTransportBackedDominantSpeakerSignaling",value:function(e){var t=this;this._teardownDominantSpeakerSignaling();var n=this._getTrackReceiver(e).then(function(e){if("data"!==e.kind)throw new Error("Expected a DataTrackReceiver");if(t._dominantSpeakerSignalingPromise===n){var r=new o(e.toDataTransport());t._setDominantSpeakerSignaling(r)}});this._dominantSpeakerSignalingPromise=n}},{key:"_setupDataTransportBackedNetworkQualityMonitor",value:function(e){var t=this;this._teardownNetworkQualityMonitor();var n=this._getTrackReceiver(e).then(function(e){if("data"!==e.kind)throw new Error("Expected a DataTrackReceiver");if(t._networkQualityMonitorPromise===n){var r=new t._NetworkQualitySignaling(e.toDataTransport()),i=new t._NetworkQualityMonitor(t._peerConnectionManager,r);t._setNetworkQualityMonitor(i)}});this._networkQualityMonitorPromise=n}},{key:"_setDominantSpeakerSignaling",value:function(e){var t=this;this._dominantSpeakerSignaling=e,e.on("updated",function(){return t.setDominantSpeaker(e.loudestParticipantSid)})}},{key:"_setNetworkQualityMonitor",value:function(e){var t=this;this._networkQualityMonitor=e,e.on("updated",function(){"failed"!==t.mediaConnectionState&&t.localParticipant.setNetworkQualityLevel(e.level,e.levels)}),e.start()}},{key:"_teardownDominantSpeakerSignaling",value:function(){this._dominantSpeakerSignalingPromise=null,this._dominantSpeakerSignaling=null}},{key:"_teardownNetworkQualityMonitor",value:function(){this._networkQualityMonitorPromise=null,this._networkQualityMonitor&&(this._networkQualityMonitor.stop(),this._networkQualityMonitor=null)}},{key:"getStats",value:function(){var e=this;return this._peerConnectionManager.getStats().then(function(t){return new Map(Array.from(t).map(function(t){var n=r(t,2),i=n[0],o=n[1];return[i,Object.assign({},o,{localAudioTrackStats:g(e,o.localAudioTrackStats),localVideoTrackStats:g(e,o.localVideoTrackStats),remoteAudioTrackStats:y(e,o.remoteAudioTrackStats),remoteVideoTrackStats:y(e,o.remoteVideoTrackStats)})]}))})}},{key:"signalingConnectionState",get:function(){return"syncing"===this._transport.state?"reconnecting":this._transport.state}},{key:"mediaConnectionState",get:function(){return this._peerConnectionManager.iceConnectionState}}]),t}();function m(e,t){return t.reduce(function(t,n){var r=e.get(n.trackId);return r?[Object.assign({},n,{trackSid:r})].concat(t):t},[])}function g(e,t){return m(e._published,t)}function y(e,t){return m(e._subscribed,t)}e.exports=v},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n1?(i.forEach(function(e){t.add(e)}),e):e.set(r,i[0])},new Map)}(function(e,t,n,r){return Array.from(n).reduce(function(n,i){var o=new RegExp("a=fmtp:"+i+" apt=(\\d+)"),a=e.match(o);if(!a)return r.add(i),n;var c=Number.parseInt(a[1]);return t.has(c)?"rtx"===t.get(c)?(r.add(i),n):n.set(i,c):(r.add(i),n)},new Map)}(e,t,r,o),o),s=Array.from(o);return["h264","vp8","vp9"].reduce(function(e,t){var r=n.get(t)||new Set;return Array.from(r).reduce(function(e,t){return a.has(t)?e:e.add(t)},e)},new Set).forEach(function(t){if(s.length){var n=s.shift();e=function(e,t,n){return e.endsWith("\r\n")?e+"a=fmtp:"+t+" apt="+n+"\r\n":e+"\r\na=fmtp:"+t+" apt="+n}(e=c(e,n),n,t)}}),s.forEach(function(t){e=function(e,t){var n=new RegExp("a=rtpmap:"+t+".*\r\n","gm");return e.replace(n,"")}(e=c(e,t),t)}),e}function c(e,t){var n=new RegExp("a=fmtp:"+t+".*\r\n","gm");return e.replace(n,"")}e.exports=function(e){var t,n,i={type:e.type};return"rollback"!==e.type&&(i.sdp=(t=e.sdp,n=o(t),[t.split("\r\nm=")[0]].concat(n.map(a)).join("\r\n"))),new r(i)}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n0,i=l(e.sdp,"application").length>0;return(t=t||r&&!i)?this._offer():Promise.resolve()}},{key:"_offer",value:function(){var e=this,t=Object.assign({},this._offerOptions);return this._shouldRestartIce&&(this._shouldRestartIce=!1,this._isRestartingIce=!0,t.iceRestart=!0),Promise.resolve().then(function(){return e._peerConnection.createOffer(t)}).catch(function(){throw new g}).then(function(t){R||(t=A(t));var n=e._setCodecPreferences(t.sdp,e._preferredAudioCodecs,e._preferredVideoCodecs);return e._shouldOffer=!1,e._negotiationRole||(e._negotiationRole="offerer",e._needsInitialAnswer=!0),e._setLocalDescription({type:"offer",sdp:n})})}},{key:"_setLocalDescription",value:function(e){var t=this,n=e.revision,r=this._preferredVideoCodecs.some(function(e){return"vp8"===e.codec.toLowerCase()&&e.simulcast});return Promise.resolve().then(function(){return e.sdp&&(e={type:e.type,sdp:L&&r?t._setSimulcast(e.sdp,t._trackIdsToAttributes):e.sdp}),"answer"===(e=new t._RTCSessionDescription(e)).type&&(t._lastStableDescriptionRevision=n),t._peerConnection.setLocalDescription(e)}).catch(function(n){throw t._log.warn('Calling setLocalDescription with an RTCSessionDescription of type "'+e.type+'" failed with the error "'+n.message+'".'),e.sdp&&t._log.warn("The SDP was "+e.sdp),new g}).then(function(){"rollback"!==e.type&&(t._localDescription=e,t._localCandidates=[],"offer"===e.type&&t._descriptionRevision++,t._localUfrag=V(e),t.emit("description",t.getState()))})}},{key:"_setRemoteDescription",value:function(e){var t=this;return e.sdp&&(e.sdp=this._setBitrateParameters(e.sdp,R?"TIAS":"AS",this._encodingParameters.maxAudioBitrate,this._encodingParameters.maxVideoBitrate),e.sdp=this._setCodecPreferences(e.sdp,this._preferredAudioCodecs,this._preferredVideoCodecs),R&&(e.sdp=e.sdp.replace(/a=msid:[^ ]+ /g,"a=msid:- "))),e=new this._RTCSessionDescription(e),this._peerConnection.setRemoteDescription(e).then(function(){"answer"===e.type&&t._isRestartingIce&&(t._log.debug("An ICE restart was in-progress and is now completed"),t._isRestartingIce=!1),"unified"===t._sdpFormat&&t._peerConnection.getTransceivers()&&t._peerConnection.getTransceivers().forEach(function(t){(function(e,t){if(!t.stop||t.stopped||!t.mid)return!1;var n=function(e){return e.match(/\r\na=mid:.+$/gm).map(function(e){return e.split(":")[1]}).filter(function(e){return e})}(e);if(t.mid===n[0]||t.mid===n[1])return!1;if("inactive"===t.currentDirection)return!0;var r=function(e,t){var n=l(e).find(function(e){return e.match("a=mid:"+t)});if(!n)return null;var r=n.match(/a=(sendrecv|sendonly|recvonly|inactive)/);return r?r[1]:null}(e,t.mid);return"inactive"===r||"recvonly"===r&&!t.sender.track})(e.sdp,t)&&t.stop()})},function(n){throw t._log.warn('Calling setRemoteDescription with an RTCSessionDescription of type "'+e.type+'" failed with the error "'+n.message+'".'),e.sdp&&t._log.warn("The SDP was "+e.sdp),n})}},{key:"_updateDescription",value:function(e){var t=this;switch(e.type){case"answer":case"pranswer":if(e.revision!==this._descriptionRevision||"have-local-offer"!==this._peerConnection.signalingState)return Promise.resolve();this._descriptionRevision=e.revision;break;case"close":return this._close();case"create-offer":return e.revision<=this._lastStableDescriptionRevision?Promise.resolve():this._needsInitialAnswer?(this._queuedDescription=e,Promise.resolve()):(this._descriptionRevision=e.revision,this._offer());case"offer":return e.revision<=this._lastStableDescriptionRevision||"closed"===this._peerConnection.signalingState?Promise.resolve():"have-local-offer"===this._peerConnection.signalingState?this._needsInitialAnswer?(this._queuedDescription=e,Promise.resolve()):(this._descriptionRevision=e.revision,this._handleGlare(e)):(this._descriptionRevision=e.revision,this._answer(e))}var n=e.revision;return Promise.resolve().then(function(){return"answer"===e.type&&(t._lastStableDescriptionRevision=n),t._setRemoteDescription(e)}).catch(function(){throw new y}).then(function(){return"answer"===e.type&&(t._needsInitialAnswer=!1),t._checkIceBox(e)}).then(function(){return t._queuedDescription&&t._updateDescription(t._queuedDescription)}).then(function(){return t._queuedDescription=null,t._peerConnection.localDescription?t._maybeReoffer(t._peerConnection.localDescription):Promise.resolve()})}},{key:"_updateIce",value:function(e){var t=this._remoteCandidates.update(e);return this._addIceCandidates(t)}},{key:"addDataTrackSender",value:function(e){if(!this._dataChannels.has(e))try{var t={ordered:e.ordered};null!==e.maxPacketLifeTime&&(t.maxPacketLifeTime=e.maxPacketLifeTime),null!==e.maxRetransmits&&(t.maxRetransmits=e.maxRetransmits);var n=this._peerConnection.createDataChannel(e.id,t);e.addDataChannel(n),this._dataChannels.set(e,n)}catch(e){}}},{key:"addMediaTrackSender",value:function(e){if("closed"!==this._peerConnection.signalingState&&!this._rtpSenders.has(e)){var t=void 0;this._localMediaStream?(this._localMediaStream.addTrack(e.track),t=this._peerConnection.addTrack(e.track,this._localMediaStream)):t=this._peerConnection.addTransceiver(e.track).sender,e.addSender(t),this._rtpSenders.set(e,t)}}},{key:"close",value:function(){this._close()&&(this._descriptionRevision++,this._localDescription={type:"close"},this.emit("description",this.getState()))}},{key:"getTrackReceivers",value:function(){return Array.from(this._dataTrackReceivers).concat(Array.from(this._mediaTrackReceivers))}},{key:"getState",value:function(){if(!this._localDescription)return null;var e={type:this._localDescription.type,revision:this._descriptionRevision};return this._localDescription.sdp&&(e.sdp=this._localDescription.sdp),{description:e,id:this.id}}},{key:"offer",value:function(){var e=this;return this._needsInitialAnswer||this._isRestartingIce?(this._shouldOffer=!0,Promise.resolve()):this.bracket("offering",function(t){return e.transition("updating",t),e._offer().then(function(){e.tryTransition("open",t)},function(n){throw e.tryTransition("open",t),n})})}},{key:"removeDataTrackSender",value:function(e){var t=this._dataChannels.get(e);t&&(e.removeDataChannel(t),this._dataChannels.delete(e),t.close())}},{key:"removeMediaTrackSender",value:function(e){if("closed"!==this._peerConnection.signalingState&&this._rtpSenders.has(e)){var t=this._rtpSenders.get(e);this._peerConnection.removeTrack(t),this._localMediaStream&&this._localMediaStream.removeTrack(e.track),e.removeSender(t),this._rtpSenders.delete(e)}}},{key:"setConfiguration",value:function(e){"function"==typeof this._peerConnection.setConfiguration&&this._peerConnection.setConfiguration(F(e))}},{key:"update",value:function(e){var t=this;return this.bracket("updating",function(n){if("closed"===t.state)return Promise.resolve();t.transition("updating",n);var r=[];return e.ice&&r.push(t._updateIce(e.ice)),e.description&&r.push(t._updateDescription(e.description)),Promise.all(r).then(function(){t.tryTransition("open",n)},function(e){throw t.tryTransition("open",n),e})})}},{key:"getStats",value:function(){var e=this;return u(this._peerConnection).then(function(t){return function(e,t){return Object.assign(t,{remoteAudioTrackStats:t.remoteAudioTrackStats.map(function(t){return I(e,t)}),remoteVideoTrackStats:t.remoteVideoTrackStats.map(function(t){return I(e,t)})})}(e,t)})}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}}]),t}();function I(e,t){var n=[].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);tmethod and